From 7f2e96ef4b80221cc1e159452911e3a150292224 Mon Sep 17 00:00:00 2001 From: HindujaB Date: Fri, 15 Jul 2022 15:27:20 +0530 Subject: [PATCH 001/450] Add type-reference support --- .../runtime/internal/TypeChecker.java | 38 ++++++++++++++----- .../runtime/internal/TypeConverter.java | 4 ++ .../runtime/internal/cli/Option.java | 5 ++- .../internal/types/BTypeReferenceType.java | 19 +++++++--- .../runtime/internal/types/BUnionType.java | 15 ++++---- .../runtime/internal/values/ErrorValue.java | 5 ++- .../internal/values/ReadOnlyUtils.java | 8 +++- .../internal/values/TableValueImpl.java | 3 +- .../bir/codegen/JvmInstructionGen.java | 2 +- .../compiler/bir/codegen/JvmSignatures.java | 2 +- .../compiler/bir/codegen/JvmTypeGen.java | 25 ++++++------ .../bir/codegen/methodgen/MainMethodGen.java | 2 - .../bir/codegen/split/JvmAnnotationsGen.java | 2 +- .../bir/codegen/split/JvmCreateTypeGen.java | 2 +- .../codegen/split/types/JvmArrayTypeGen.java | 2 +- .../codegen/split/types/JvmRefTypeGen.java | 4 +- .../langlib/value/CloneWithType.java | 3 ++ .../stamp/MapStampInbuiltFunctionTest.java | 34 +++++++++-------- .../UnionTypeStampInbuiltFunctionTest.java | 12 ++++-- .../org/ballerinalang/test/jvm/TypesTest.java | 3 +- 20 files changed, 123 insertions(+), 67 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java index dea3bb75523b..f7ff4605a4de 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java @@ -25,6 +25,7 @@ import io.ballerina.runtime.api.types.Field; import io.ballerina.runtime.api.types.FunctionType; import io.ballerina.runtime.api.types.MethodType; +import io.ballerina.runtime.api.types.ReferenceType; import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.types.XmlNodeType; import io.ballerina.runtime.api.utils.StringUtils; @@ -804,6 +805,9 @@ private static boolean checkIsRecursiveType(Type sourceType, Type targetType, Li return checkTypeDescType(sourceType, (BTypedescType) targetType, unresolvedTypes); case TypeTags.XML_TAG: return checkIsXMLType(sourceType, targetType, unresolvedTypes); + case TypeTags.TYPE_REFERENCED_TYPE_TAG: + return checkIsRecursiveType(sourceType, ((ReferenceType) targetType).getReferredType(), + unresolvedTypes); default: // other non-recursive types shouldn't reach here return false; @@ -952,12 +956,7 @@ private static boolean checkIsXMLType(Type sourceType, Type targetType, List>> on chained iteration - while (target.constraint.getTag() == TypeTags.XML_TAG) { - target = (BXmlType) target.constraint; - targetConstraint = target.constraint; - } + Type targetConstraint = getRecursiveTargetConstraintType(target); BXmlType source = (BXmlType) sourceType; if (source.constraint.getTag() == TypeTags.NEVER_TAG) { if (targetConstraint.getTag() == TypeTags.UNION_TAG) { @@ -974,6 +973,16 @@ private static boolean checkIsXMLType(Type sourceType, Type targetType, List>> on chained iteration + while (targetConstraint.getTag() == TypeTags.XML_TAG) { + target = (BXmlType) targetConstraint; + targetConstraint = TypeUtils.getReferredType(target.constraint); + } + return targetConstraint; + } + private static List getWideTypeComponents(BRecordType recType) { List types = new ArrayList<>(); for (Field f : recType.getFields().values()) { @@ -1046,6 +1055,9 @@ static BField getTableConstraintField(Type constraintType, String fieldName) { case TypeTags.INTERSECTION_TAG: Type effectiveType = ((BIntersectionType) constraintType).getEffectiveType(); return getTableConstraintField(effectiveType, fieldName); + case TypeTags.TYPE_REFERENCED_TYPE_TAG: + Type referredType = ((BTypeReferenceType) constraintType).getReferredType(); + return getTableConstraintField(referredType, fieldName); case TypeTags.UNION_TAG: BUnionType unionType = (BUnionType) constraintType; List memTypes = unionType.getMemberTypes(); @@ -1130,6 +1142,8 @@ private static boolean checkIsJSONType(Type sourceType, List unresolve } } return true; + case TypeTags.TYPE_REFERENCED_TYPE_TAG: + return checkIsJSONType(((ReferenceType) sourceType).getReferredType(), unresolvedTypes); default: return false; } @@ -2289,6 +2303,9 @@ private static XmlNodeType getXmlNodeType(Type type) { case TypeTags.XML_TEXT_TAG: nodeType = XmlNodeType.TEXT; break; + case TypeTags.TYPE_REFERENCED_TYPE_TAG: + nodeType = getXmlNodeType(((ReferenceType) type).getReferredType()); + break; default: return null; } @@ -2323,7 +2340,7 @@ private static boolean checkIsLikeXMLSequenceType(XmlValue xmlSource, Type targe Set acceptedNodes = new HashSet<>(); BXmlType target = (BXmlType) targetType; - if (target.constraint.getTag() == TypeTags.UNION_TAG) { + if (TypeUtils.getReferredType(target.constraint).getTag() == TypeTags.UNION_TAG) { getXMLNodeOnUnion((BUnionType) target.constraint, acceptedNodes); } else { acceptedNodes.add(getXmlNodeType(((BXmlType) targetType).constraint)); @@ -3330,10 +3347,11 @@ private static boolean isSameBasicTypeWithFillerValue(List memberTypes) { List nonFiniteTypes = new ArrayList<>(); Set combinedValueSpace = new HashSet<>(); for (Type memberType: memberTypes) { - if (memberType.getTag() == TypeTags.FINITE_TYPE_TAG) { - combinedValueSpace.addAll(((BFiniteType) memberType).getValueSpace()); + Type referredType = TypeUtils.getReferredType(memberType); + if (referredType.getTag() == TypeTags.FINITE_TYPE_TAG) { + combinedValueSpace.addAll(((BFiniteType) referredType).getValueSpace()); } else { - nonFiniteTypes.add(memberType); + nonFiniteTypes.add(referredType); } } diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeConverter.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeConverter.java index d8fc821872b5..2abbc47283df 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeConverter.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeConverter.java @@ -23,6 +23,7 @@ import io.ballerina.runtime.api.creators.TypeCreator; import io.ballerina.runtime.api.flags.SymbolFlags; import io.ballerina.runtime.api.types.Field; +import io.ballerina.runtime.api.types.ReferenceType; import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.utils.StringUtils; import io.ballerina.runtime.api.utils.TypeUtils; @@ -555,6 +556,7 @@ private static void addErrorMessage(int errorCountDifference, List error } public static boolean isIntegerSubtypeAndConvertible(Object inputValue, Type targetType) { + targetType = TypeUtils.getReferredType(targetType); Type inputValueType = TypeChecker.getType(inputValue); if (!TypeTags.isIntegerTypeTag(inputValueType.getTag()) && inputValueType.getTag() != TypeTags.BYTE_TAG) { return false; @@ -575,6 +577,8 @@ private static boolean isConvertibleToTableType(Type tableConstrainedType) { return true; case TypeTags.INTERSECTION_TAG: return isConvertibleToTableType(((BIntersectionType) tableConstrainedType).getEffectiveType()); + case TypeTags.TYPE_REFERENCED_TYPE_TAG: + return isConvertibleToTableType(((ReferenceType) tableConstrainedType).getReferredType()); } return false; } diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java index 2f0145a6535b..a39aabb49d17 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java @@ -24,6 +24,7 @@ import io.ballerina.runtime.api.flags.SymbolFlags; import io.ballerina.runtime.api.types.ArrayType; import io.ballerina.runtime.api.types.RecordType; +import io.ballerina.runtime.api.types.ReferenceType; import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.utils.StringUtils; import io.ballerina.runtime.api.utils.TypeUtils; @@ -51,8 +52,8 @@ public class Option { private final int location; public Option(Type recordType, int location) { - this((RecordType) recordType, - ValueCreator.createRecordValue(recordType.getPackage(), recordType.getName()), location); + this((RecordType) ((ReferenceType) recordType).getReferredType(), + ValueCreator.createRecordValue(recordType.getPackage(), recordType.getName()), location); } public Option(RecordType recordType, BMap recordVal) { diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/types/BTypeReferenceType.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/types/BTypeReferenceType.java index 20914c328980..dd196a414877 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/types/BTypeReferenceType.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/types/BTypeReferenceType.java @@ -21,6 +21,7 @@ import io.ballerina.identifier.Utils; import io.ballerina.runtime.api.Module; import io.ballerina.runtime.api.TypeTags; +import io.ballerina.runtime.api.flags.TypeFlags; import io.ballerina.runtime.api.types.IntersectableReferenceType; import io.ballerina.runtime.api.types.IntersectionType; import io.ballerina.runtime.api.types.Type; @@ -34,11 +35,15 @@ */ public class BTypeReferenceType extends BAnnotatableType implements IntersectableReferenceType { + private final int typeFlags; + private final boolean readOnly; private Type referredType; private IntersectionType intersectionType; - public BTypeReferenceType(String typeName, Module pkg) { + public BTypeReferenceType(String typeName, Module pkg, int typeFlags, boolean readOnly) { super(typeName, pkg, Object.class); + this.typeFlags = typeFlags; + this.readOnly = readOnly; } public void setReferredType(Type referredType) { @@ -50,6 +55,10 @@ public Type getReferredType() { return referredType; } + public int getTypeFlags() { + return typeFlags; + } + @Override public boolean equals(Object obj) { if (this == obj) { @@ -84,22 +93,22 @@ public int getTag() { @Override public boolean isNilable() { - return this.referredType.isNilable(); + return TypeFlags.isFlagOn(this.typeFlags, TypeFlags.NILABLE); } @Override public boolean isAnydata() { - return this.referredType.isAnydata(); + return TypeFlags.isFlagOn(this.typeFlags, TypeFlags.ANYDATA); } @Override public boolean isPureType() { - return this.referredType.isPureType(); + return TypeFlags.isFlagOn(this.typeFlags, TypeFlags.PURETYPE); } @Override public boolean isReadOnly() { - return this.referredType.isReadOnly(); + return this.readOnly; } @Override diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/types/BUnionType.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/types/BUnionType.java index f9e1e3c57738..54aba578d16a 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/types/BUnionType.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/types/BUnionType.java @@ -303,11 +303,12 @@ public V getZeroValue() { return null; } - if (memberTypes.get(0).getTag() == TypeTags.FINITE_TYPE_TAG) { + Type firstMemberType = TypeUtils.getReferredType(memberTypes.get(0)); + if (firstMemberType.getTag() == TypeTags.FINITE_TYPE_TAG) { return TypeChecker.getType( - ((BFiniteType) memberTypes.get(0)).getValueSpace().iterator().next()).getZeroValue(); + ((BFiniteType) firstMemberType).getValueSpace().iterator().next()).getZeroValue(); } else { - return memberTypes.get(0).getZeroValue(); + return firstMemberType.getZeroValue(); } } @@ -316,12 +317,12 @@ public V getEmptyValue() { if (isNilable() || memberTypes.stream().anyMatch(Type::isNilable)) { return null; } - - if (memberTypes.get(0).getTag() == TypeTags.FINITE_TYPE_TAG) { + Type firstMemberType = TypeUtils.getReferredType(memberTypes.get(0)); + if (firstMemberType.getTag() == TypeTags.FINITE_TYPE_TAG) { return TypeChecker.getType( - ((BFiniteType) memberTypes.get(0)).getValueSpace().iterator().next()).getEmptyValue(); + ((BFiniteType) firstMemberType).getValueSpace().iterator().next()).getEmptyValue(); } else { - return memberTypes.get(0).getEmptyValue(); + return firstMemberType.getEmptyValue(); } } diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ErrorValue.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ErrorValue.java index 64662ded4e25..2aebb9b908c6 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ErrorValue.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ErrorValue.java @@ -22,6 +22,7 @@ import io.ballerina.runtime.api.PredefinedTypes; import io.ballerina.runtime.api.TypeTags; import io.ballerina.runtime.api.constants.TypeConstants; +import io.ballerina.runtime.api.types.ReferenceType; import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.types.TypeId; import io.ballerina.runtime.api.utils.StringUtils; @@ -90,7 +91,7 @@ public ErrorValue(BString message, Object details) { public ErrorValue(Type type, BString message, BError cause, Object details) { super(message); - this.type = type; + this.type = ((ReferenceType) type).getReferredType(); this.message = message; this.cause = cause; this.details = details; @@ -100,7 +101,7 @@ public ErrorValue(Type type, BString message, BError cause, Object details) { public ErrorValue(Type type, BString message, BError cause, Object details, String typeIdName, Module typeIdPkg) { super(message); - this.type = type; + this.type = ((ReferenceType) type).getReferredType(); this.message = message; this.cause = cause; this.details = details; diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ReadOnlyUtils.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ReadOnlyUtils.java index 9a3bae23ca76..fd57bd606615 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ReadOnlyUtils.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ReadOnlyUtils.java @@ -27,6 +27,7 @@ import io.ballerina.runtime.api.types.Field; import io.ballerina.runtime.api.types.IntersectableReferenceType; import io.ballerina.runtime.api.types.IntersectionType; +import io.ballerina.runtime.api.types.ReferenceType; import io.ballerina.runtime.api.types.SelectivelyImmutableReferenceType; import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.internal.TypeChecker; @@ -120,6 +121,10 @@ private static Type getAvailableImmutableType(Type type) { return type; } + if (type.getTag() == TypeTags.TYPE_REFERENCED_TYPE_TAG) { + return getAvailableImmutableType(((ReferenceType) type).getReferredType()); + } + if (type.getTag() == TypeTags.INTERSECTION_TAG && type.isReadOnly()) { return ((BIntersectionType) type).getEffectiveType(); } @@ -274,7 +279,8 @@ private static BIntersectionType setImmutableIntersectionType(Type type, Set keyTypes = new ArrayList<>(); - Type constraintType = type.getConstrainedType(); + Type constraintType = ((ReferenceType) type.getConstrainedType()).getReferredType(); if (constraintType.getTag() == TypeTags.RECORD_TYPE_TAG) { BRecordType recordType = (BRecordType) constraintType; Arrays.stream(fieldNames) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java index a10d553ece2f..85da2284e23a 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java @@ -1985,7 +1985,7 @@ private void generateNewTypedescCreate(BType btype, List closureVars } this.mv.visitTypeInsn(NEW, className); this.mv.visitInsn(DUP); - jvmTypeGen.loadLocalType(this.mv, btype); + jvmTypeGen.loadType(this.mv, btype); mv.visitIntInsn(BIPUSH, closureVars.size()); mv.visitTypeInsn(ANEWARRAY, MAP_VALUE); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java index 33187c3c328f..1504bb8fb25a 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java @@ -303,7 +303,7 @@ public class JvmSignatures { public static final String INIT_WITH_BOOLEAN = "(L" + TYPE + ";Z)V"; public static final String INIT_WITH_STRING = "(L" + STRING_VALUE + ";)V"; public static final String INITIAL_METHOD_DESC = "(L" + STRAND_CLASS + ";"; - public static final String INIT_TYPE_REF = "(L" + STRING_VALUE + ";L" + MODULE + ";)V"; + public static final String INIT_TYPE_REF = "(L" + STRING_VALUE + ";L" + MODULE + ";IZ)V"; public static final String INSTANTIATE = "(L" + STRAND_CLASS + ";[L" + B_INITIAL_VALUE_ENTRY + ";)L" + OBJECT + ";"; public static final String INT_VALUE_OF_METHOD = "(I)L" + INT_VALUE + ";"; public static final String INTI_VARIABLE_KEY = diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeGen.java index f6705136d9eb..156a13e2265f 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeGen.java @@ -466,7 +466,10 @@ public void loadType(MethodVisitor mv, BType bType) { loadParameterizedType(mv, (BParameterizedType) bType); return; case TypeTags.TYPEREFDESC: - loadType(mv, JvmCodeGenUtil.getReferredType(bType)); + String typeOwner = JvmCodeGenUtil.getModuleLevelClassName(bType.tsymbol.pkgID, + JvmConstants.TYPEREF_TYPE_CONSTANT_CLASS_NAME); + mv.visitFieldInsn(GETSTATIC, typeOwner, + JvmCodeGenUtil.getRefTypeConstantName((BTypeReferenceType) bType), GET_TYPE_REF_TYPE_IMPL); return; default: return; @@ -1092,14 +1095,14 @@ private void loadValueType(MethodVisitor mv, BType valueType) { } } - public void loadLocalType(MethodVisitor mv, BType type) { - if (type.tag == TypeTags.TYPEREFDESC) { - String typeOwner = JvmCodeGenUtil.getModuleLevelClassName(type.tsymbol.pkgID, - JvmConstants.TYPEREF_TYPE_CONSTANT_CLASS_NAME); - mv.visitFieldInsn(GETSTATIC, typeOwner, - JvmCodeGenUtil.getRefTypeConstantName((BTypeReferenceType) type), GET_TYPE_REF_TYPE_IMPL); - } else { - loadType(mv, JvmCodeGenUtil.getReferredType(type)); - } - } +// public void loadLocalType(MethodVisitor mv, BType type) { +// if (type.tag == TypeTags.TYPEREFDESC) { +// String typeOwner = JvmCodeGenUtil.getModuleLevelClassName(type.tsymbol.pkgID, +// JvmConstants.TYPEREF_TYPE_CONSTANT_CLASS_NAME); +// mv.visitFieldInsn(GETSTATIC, typeOwner, +// JvmCodeGenUtil.getRefTypeConstantName((BTypeReferenceType) type), GET_TYPE_REF_TYPE_IMPL); +// } else { +// loadType(mv, type); +// } +// } } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/MainMethodGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/MainMethodGen.java index 566091fb2757..0b152aceca63 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/MainMethodGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/MainMethodGen.java @@ -77,7 +77,6 @@ import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.OPTION; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.PANIC_FIELD; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.PATH; -import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.RECORD_TYPE; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.RUNTIME_UTILS; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.SCHEDULER; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.SCHEDULER_START_METHOD; @@ -350,7 +349,6 @@ private void createOption(MethodVisitor mv, BIRNode.BIRFunctionParameter param, mv.visitTypeInsn(NEW , OPTION); mv.visitInsn(DUP); jvmTypeGen.loadType(mv, param.type); - mv.visitTypeInsn(CHECKCAST , RECORD_TYPE); mv.visitIntInsn(BIPUSH, location); mv.visitMethodInsn(INVOKESPECIAL , OPTION , JVM_INIT_METHOD, INIT_OPTION, false); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmAnnotationsGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmAnnotationsGen.java index 8e570aef2fba..3cff7856c45c 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmAnnotationsGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmAnnotationsGen.java @@ -128,7 +128,7 @@ private void loadAnnotations(MethodVisitor mv, String pkgName, BIRNode.BIRTypeDe mv.visitFieldInsn(GETSTATIC, pkgClassName, ANNOTATION_MAP_NAME, JvmSignatures.GET_MAP_VALUE); BType refType = typeDef.referenceType == null || typeDef.type.tag == TypeTags.RECORD ? typeDef.type : typeDef.referenceType; - jvmTypeGen.loadLocalType(mv, refType); + jvmTypeGen.loadType(mv, refType); mv.visitMethodInsn(INVOKESTATIC, ANNOTATION_UTILS, "processAnnotations", JvmSignatures.PROCESS_ANNOTATIONS, false); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmCreateTypeGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmCreateTypeGen.java index d3046cba468e..6172965193ad 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmCreateTypeGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmCreateTypeGen.java @@ -653,7 +653,7 @@ private void createField(MethodVisitor mv, BField field) { mv.visitInsn(DUP); // Load the field type - jvmTypeGen.loadLocalType(mv, field.symbol.type); + jvmTypeGen.loadType(mv, field.symbol.type); // Load field name mv.visitLdcInsn(decodeIdentifier(field.name.value)); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/types/JvmArrayTypeGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/types/JvmArrayTypeGen.java index eca665e4f147..9f081e4360a1 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/types/JvmArrayTypeGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/types/JvmArrayTypeGen.java @@ -54,7 +54,7 @@ public JvmArrayTypeGen(JvmTypeGen jvmTypeGen) { public void populateArray(MethodVisitor mv, BArrayType bType) { mv.visitTypeInsn(CHECKCAST, ARRAY_TYPE_IMPL); - jvmTypeGen.loadLocalType(mv, bType.eType); + jvmTypeGen.loadType(mv, bType.eType); loadDimension(mv, bType.eType, 1); jvmTypeGen.loadReadonlyFlag(mv, bType.eType); mv.visitMethodInsn(INVOKEVIRTUAL, ARRAY_TYPE_IMPL, "setElementType", SET_ARRAY_ELEMENT, false); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/types/JvmRefTypeGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/types/JvmRefTypeGen.java index a47ce51defe0..928316d37a26 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/types/JvmRefTypeGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/types/JvmRefTypeGen.java @@ -63,12 +63,14 @@ public void createTypeRefType(MethodVisitor mv, BTypeReferenceType typeRefType) mv.visitLdcInsn(Utils.decodeIdentifier(typeRefType.tsymbol.name.value)); String varName = jvmConstantsGen.getModuleConstantVar(typeRefType.tsymbol.pkgID); mv.visitFieldInsn(GETSTATIC, jvmConstantsGen.getModuleConstantClass(), varName, GET_MODULE); + mv.visitLdcInsn(jvmTypeGen.typeFlag(typeRefType.referredType)); + jvmTypeGen.loadReadonlyFlag(mv, typeRefType.referredType); mv.visitMethodInsn(INVOKESPECIAL, TYPE_REF_TYPE_IMPL, JVM_INIT_METHOD, INIT_TYPE_REF, false); } public void populateTypeRef(MethodVisitor mv, BTypeReferenceType referenceType) { mv.visitTypeInsn(CHECKCAST, TYPE_REF_TYPE_IMPL); - jvmTypeGen.loadLocalType(mv, referenceType.referredType); + jvmTypeGen.loadType(mv, referenceType.referredType); mv.visitMethodInsn(INVOKEVIRTUAL, TYPE_REF_TYPE_IMPL, "setReferredType", TYPE_PARAMETER, false); } } diff --git a/langlib/lang.value/src/main/java/org/ballerinalang/langlib/value/CloneWithType.java b/langlib/lang.value/src/main/java/org/ballerinalang/langlib/value/CloneWithType.java index 35e85a901c6a..717552d674f8 100644 --- a/langlib/lang.value/src/main/java/org/ballerinalang/langlib/value/CloneWithType.java +++ b/langlib/lang.value/src/main/java/org/ballerinalang/langlib/value/CloneWithType.java @@ -27,6 +27,7 @@ import io.ballerina.runtime.api.types.IntersectionType; import io.ballerina.runtime.api.types.MapType; import io.ballerina.runtime.api.types.RecordType; +import io.ballerina.runtime.api.types.ReferenceType; import io.ballerina.runtime.api.types.TableType; import io.ballerina.runtime.api.types.TupleType; import io.ballerina.runtime.api.types.Type; @@ -215,6 +216,8 @@ private static Object convertMap(BMap map, Type targetType, List Date: Tue, 19 Jul 2022 12:30:37 +0530 Subject: [PATCH 002/450] Fix integration tests --- .../internal/configurable/ConfigResolver.java | 94 ++++++++----------- .../providers/toml/ConfigValueCreator.java | 5 +- .../providers/toml/TomlProvider.java | 13 ++- .../configurable/providers/toml/Utils.java | 16 +++- .../internal/values/ReadOnlyUtils.java | 6 +- .../config/negative/ConfigNegativeTest.java | 8 +- .../negative/TomlProviderNegativeTest.java | 12 +-- .../{InvalidMapType.toml => InvalidType.toml} | 0 8 files changed, 75 insertions(+), 79 deletions(-) rename bvm/ballerina-runtime/src/test/resources/config_files/negative/{InvalidMapType.toml => InvalidType.toml} (100%) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/configurable/ConfigResolver.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/configurable/ConfigResolver.java index 4df39f45afb1..c2e828eb1681 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/configurable/ConfigResolver.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/configurable/ConfigResolver.java @@ -22,6 +22,7 @@ import io.ballerina.runtime.api.Module; import io.ballerina.runtime.api.TypeTags; import io.ballerina.runtime.api.types.IntersectionType; +import io.ballerina.runtime.api.types.ReferenceType; import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.internal.configurable.exceptions.ConfigException; import io.ballerina.runtime.internal.diagnostics.RuntimeDiagnosticLog; @@ -90,77 +91,58 @@ public Map resolveConfigs() { } private Optional getConfigValue(Module module, VariableKey key) { - Type type = key.type; + Function> function = getValueFunction(module, key, key.type); + if (function != null) { + return getConfigValue(key, function); + } + return Optional.empty(); + } + + private Function> getValueFunction(Module module, VariableKey key, Type type) { switch (type.getTag()) { case TypeTags.INT_TAG: - return getConfigValue(key, configProvider -> configProvider - .getAsIntAndMark(module, key)); + return configProvider -> configProvider.getAsIntAndMark(module, key); case TypeTags.BYTE_TAG: - return getConfigValue(key, configProvider -> configProvider - .getAsByteAndMark(module, key)); + return configProvider -> configProvider.getAsByteAndMark(module, key); case TypeTags.BOOLEAN_TAG: - return getConfigValue(key, configProvider -> configProvider - .getAsBooleanAndMark(module, key)); + return configProvider -> configProvider.getAsBooleanAndMark(module, key); case TypeTags.FLOAT_TAG: - return getConfigValue(key, configProvider -> configProvider - .getAsFloatAndMark(module, key)); + return configProvider -> configProvider.getAsFloatAndMark(module, key); case TypeTags.DECIMAL_TAG: - return getConfigValue(key, configProvider -> configProvider - .getAsDecimalAndMark(module, key)); + return configProvider -> configProvider.getAsDecimalAndMark(module, key); case TypeTags.STRING_TAG: - return getConfigValue(key, configProvider -> configProvider - .getAsStringAndMark(module, key)); + return configProvider -> configProvider.getAsStringAndMark(module, key); case TypeTags.RECORD_TYPE_TAG: - return getConfigValue(key, configProvider -> configProvider - .getAsRecordAndMark(module, key)); + return configProvider -> configProvider.getAsRecordAndMark(module, key); + case TypeTags.XML_TAG: + case TypeTags.XML_ELEMENT_TAG: + case TypeTags.XML_COMMENT_TAG: + case TypeTags.XML_PI_TAG: case TypeTags.XML_TEXT_TAG: - return getConfigValue(key, configProvider -> configProvider - .getAsXmlAndMark(module, key)); + return configProvider -> configProvider.getAsXmlAndMark(module, key); case TypeTags.FINITE_TYPE_TAG: - return getConfigValue(key, configProvider -> configProvider - .getAsFiniteAndMark(module, key)); + return configProvider -> configProvider.getAsFiniteAndMark(module, key); + case TypeTags.ARRAY_TAG: + return configProvider -> configProvider.getAsArrayAndMark(module, key); + case TypeTags.MAP_TAG: + return configProvider -> configProvider.getAsMapAndMark(module, key); + case TypeTags.TABLE_TAG: + return configProvider -> configProvider.getAsTableAndMark(module, key); + case TypeTags.ANYDATA_TAG: + case TypeTags.UNION_TAG: + return configProvider -> configProvider.getAsUnionAndMark(module, key); + case TypeTags.TUPLE_TAG: + return configProvider -> configProvider.getAsTupleAndMark(module, key); + case TypeTags.TYPE_REFERENCED_TYPE_TAG: + return getValueFunction(module, key, ((ReferenceType) type).getReferredType()); case TypeTags.INTERSECTION_TAG: Type effectiveType = ((IntersectionType) type).getEffectiveType(); - switch (effectiveType.getTag()) { - case TypeTags.ARRAY_TAG: - return getConfigValue(key, configProvider -> configProvider - .getAsArrayAndMark(module, key)); - case TypeTags.RECORD_TYPE_TAG: - return getConfigValue(key, configProvider -> configProvider - .getAsRecordAndMark(module, key)); - case TypeTags.MAP_TAG: - return getConfigValue(key, configProvider -> configProvider - .getAsMapAndMark(module, key)); - case TypeTags.TABLE_TAG: - return getConfigValue(key, configProvider -> configProvider - .getAsTableAndMark(module, key)); - case TypeTags.XML_TAG: - case TypeTags.XML_ELEMENT_TAG: - case TypeTags.XML_COMMENT_TAG: - case TypeTags.XML_PI_TAG: - case TypeTags.XML_TEXT_TAG: - return getConfigValue(key, configProvider -> configProvider - .getAsXmlAndMark(module, key)); - case TypeTags.ANYDATA_TAG: - case TypeTags.UNION_TAG: - return getConfigValue(key, configProvider -> configProvider - .getAsUnionAndMark(module, key)); - case TypeTags.FINITE_TYPE_TAG: - return getConfigValue(key, configProvider -> configProvider - .getAsFiniteAndMark(module, key)); - case TypeTags.TUPLE_TAG: - return getConfigValue(key, configProvider -> configProvider - .getAsTupleAndMark(module, key)); - default: - diagnosticLog.error(CONFIG_TYPE_NOT_SUPPORTED, key.location, key.variable, - Utils.decodeIdentifier(effectiveType.toString())); - } - break; + return getValueFunction(module, key, effectiveType); default: diagnosticLog.error(CONFIG_TYPE_NOT_SUPPORTED, key.location, key.variable, - Utils.decodeIdentifier(type.toString())); + Utils.decodeIdentifier(type.toString())); } - return Optional.empty(); + return null; } private Optional getConfigValue(VariableKey key, Function> getConfigFunc) { diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/configurable/providers/toml/ConfigValueCreator.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/configurable/providers/toml/ConfigValueCreator.java index f2253a1b2364..787d60b55a6f 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/configurable/providers/toml/ConfigValueCreator.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/configurable/providers/toml/ConfigValueCreator.java @@ -26,6 +26,7 @@ import io.ballerina.runtime.api.types.IntersectionType; import io.ballerina.runtime.api.types.MapType; import io.ballerina.runtime.api.types.RecordType; +import io.ballerina.runtime.api.types.ReferenceType; import io.ballerina.runtime.api.types.TableType; import io.ballerina.runtime.api.types.TupleType; import io.ballerina.runtime.api.types.Type; @@ -112,6 +113,8 @@ private Object createStructuredValue(TomlNode tomlValue, Type type) { return createBalValue(type, ((TomlKeyValueNode) tomlValue).value()); case TypeTags.TUPLE_TAG: return createTupleValue(tomlValue, (TupleType) type); + case TypeTags.TYPE_REFERENCED_TYPE_TAG: + return createValue(tomlValue, ((ReferenceType) type).getReferredType()); default: Type effectiveType = ((IntersectionType) type).getEffectiveType(); if (effectiveType.getTag() == TypeTags.RECORD_TYPE_TAG) { @@ -372,7 +375,7 @@ private Object createUnionValue(TomlNode tomlValue, BUnionType unionType) { convertibleTypes.add(type); } } - Type type = convertibleTypes.get(0); + Type type = getEffectiveType(convertibleTypes.get(0)); if (isSimpleType(type.getTag()) || type.getTag() == TypeTags.FINITE_TYPE_TAG || isXMLType(type)) { return balValue; } diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/configurable/providers/toml/TomlProvider.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/configurable/providers/toml/TomlProvider.java index a8f9d7c567b9..99b418768088 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/configurable/providers/toml/TomlProvider.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/configurable/providers/toml/TomlProvider.java @@ -27,6 +27,7 @@ import io.ballerina.runtime.api.types.IntersectionType; import io.ballerina.runtime.api.types.MapType; import io.ballerina.runtime.api.types.RecordType; +import io.ballerina.runtime.api.types.ReferenceType; import io.ballerina.runtime.api.types.TableType; import io.ballerina.runtime.api.types.TupleType; import io.ballerina.runtime.api.types.Type; @@ -69,6 +70,7 @@ import static io.ballerina.identifier.Utils.decodeIdentifier; import static io.ballerina.runtime.internal.ValueUtils.createReadOnlyXmlValue; import static io.ballerina.runtime.internal.configurable.providers.toml.Utils.checkEffectiveTomlType; +import static io.ballerina.runtime.internal.configurable.providers.toml.Utils.getEffectiveType; import static io.ballerina.runtime.internal.configurable.providers.toml.Utils.getLineRange; import static io.ballerina.runtime.internal.configurable.providers.toml.Utils.getModuleKey; import static io.ballerina.runtime.internal.configurable.providers.toml.Utils.getTomlTypeString; @@ -337,6 +339,9 @@ private void validateStructuredValue(TomlNode tomlValue, String variableName, Ty case TypeTags.UNION_TAG: validateUnionValue(tomlValue, variableName, (BUnionType) type); break; + case TypeTags.TYPE_REFERENCED_TYPE_TAG: + validateValue(tomlValue, variableName, ((ReferenceType) type).getReferredType()); + break; default: invalidTomlLines.add(tomlValue.location().lineRange()); throw new ConfigException(CONFIG_TYPE_NOT_SUPPORTED, variableName, type.toString()); @@ -381,7 +386,7 @@ public Optional getAsFiniteAndMark(Module module, VariableKey key) if (key.type.getTag() == TypeTags.INTERSECTION_TAG) { type = (BFiniteType) ((IntersectionType) key.type).getEffectiveType(); } else { - type = (BFiniteType) key.type; + type = (BFiniteType) TypeUtils.getReferredType(key.type); } return getTomlConfigValue(validateAndGetFiniteValue(tomlValue, key.variable, type), key); } @@ -457,7 +462,7 @@ private TomlNode getBasicTomlValue(Module module, VariableKey key) { for (TomlTableNode moduleNode : moduleTomlNodes) { if (moduleNode.entries().containsKey(variableName)) { TomlNode tomlValue = moduleNode.entries().get(variableName); - return getTomlNode(tomlValue, variableName, key.type); + return getTomlNode(tomlValue, variableName, TypeUtils.getReferredType(key.type)); } } return null; @@ -643,7 +648,7 @@ private void validateUnionValue(TomlNode tomlValue, String variableName, BUnionT if (convertibleTypes.isEmpty()) { throwTypeIncompatibleError(tomlValue, variableName, unionType); } - Type type = convertibleTypes.get(0); + Type type = getEffectiveType(convertibleTypes.get(0)); if (isSimpleType(type.getTag()) || isXMLType(type)) { return; } @@ -951,6 +956,6 @@ private List getModuleTomlNodes(Module module, VariableKey key) { } private Optional getTomlConfigValue(Object value, VariableKey key) { - return Optional.of(new TomlConfigValue(value, key.type)); + return Optional.of(new TomlConfigValue(value, TypeUtils.getReferredType(key.type))); } } diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/configurable/providers/toml/Utils.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/configurable/providers/toml/Utils.java index 50af92e5649a..d1c119ad39ce 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/configurable/providers/toml/Utils.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/configurable/providers/toml/Utils.java @@ -30,6 +30,7 @@ import io.ballerina.runtime.api.types.IntersectableReferenceType; import io.ballerina.runtime.api.types.IntersectionType; import io.ballerina.runtime.api.types.RecordType; +import io.ballerina.runtime.api.types.ReferenceType; import io.ballerina.runtime.api.types.TableType; import io.ballerina.runtime.api.types.TupleType; import io.ballerina.runtime.api.types.Type; @@ -389,9 +390,10 @@ private static void throwMemberAmbiguityError(Type type, Set invalidT private static boolean containsType(BUnionType unionType, int tag) { for (Type type : unionType.getMemberTypes()) { - int typeTag = getEffectiveType(type).getTag(); + Type effectiveType = getEffectiveType(type); + int typeTag = effectiveType.getTag(); if (typeTag == TypeTags.FINITE_TYPE_TAG) { - for (Object obj : ((FiniteType) type).getValueSpace()) { + for (Object obj : ((FiniteType) effectiveType).getValueSpace()) { if (TypeChecker.getType(obj).getTag() == tag) { return true; } @@ -433,10 +435,14 @@ static boolean isXMLType(Type type) { } static Type getEffectiveType(Type type) { - if (type.getTag() == TypeTags.INTERSECTION_TAG) { - return ((IntersectionType) type).getEffectiveType(); + switch (type.getTag()) { + case TypeTags.INTERSECTION_TAG: + return ((IntersectionType) type).getEffectiveType(); + case TypeTags.TYPE_REFERENCED_TYPE_TAG: + return getEffectiveType(((ReferenceType) type).getReferredType()); + default: + return type; } - return type; } private static boolean isMappingType(int typeTag) { diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ReadOnlyUtils.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ReadOnlyUtils.java index fd57bd606615..a6ce8e161b95 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ReadOnlyUtils.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ReadOnlyUtils.java @@ -30,6 +30,7 @@ import io.ballerina.runtime.api.types.ReferenceType; import io.ballerina.runtime.api.types.SelectivelyImmutableReferenceType; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.internal.TypeChecker; import io.ballerina.runtime.internal.types.BArrayType; import io.ballerina.runtime.internal.types.BField; @@ -357,8 +358,9 @@ private static BIntersectionType createAndSetImmutableIntersectionType(Module pk */ public static Type getMutableType(BIntersectionType intersectionType) { for (Type type : intersectionType.getConstituentTypes()) { - if (intersectionType.getEffectiveType().getTag() == type.getTag()) { - return type; + Type referredType = TypeUtils.getReferredType(type); + if (intersectionType.getEffectiveType().getTag() == referredType.getTag()) { + return referredType; } } throw new IllegalStateException("Unsupported intersection type found: " + intersectionType); diff --git a/bvm/ballerina-runtime/src/test/java/io/ballerina/runtime/test/config/negative/ConfigNegativeTest.java b/bvm/ballerina-runtime/src/test/java/io/ballerina/runtime/test/config/negative/ConfigNegativeTest.java index 73e1ad4c45d6..d385af4c0c26 100644 --- a/bvm/ballerina-runtime/src/test/java/io/ballerina/runtime/test/config/negative/ConfigNegativeTest.java +++ b/bvm/ballerina-runtime/src/test/java/io/ballerina/runtime/test/config/negative/ConfigNegativeTest.java @@ -160,10 +160,10 @@ public Object[][] configErrorCases() { "error: [MatchedTypeValues.toml:(3:1,3:14)] unused configuration value 'org.mod1" + ".intVar'"}}, // not supported both toml type and cli type - {new String[]{"-Corg.mod1.myMap=4"}, "MatchedTypeValues.toml", - new VariableKey[]{new VariableKey(MODULE, "myMap", PredefinedTypes.TYPE_MAP, null, true)}, 6 - , 0, new String[]{"error: configurable variable 'myMap' with type 'map' is not supported", - "error: [org.mod1.myMap=4] unused command line argument"}}, + {new String[]{"-Corg.mod1.myVar=4"}, "MatchedTypeValues.toml", + new VariableKey[]{new VariableKey(MODULE, "myVar", PredefinedTypes.TYPE_ANY, null, true)}, 6 + , 0, new String[]{"error: configurable variable 'myVar' with type 'any' is not supported", + "error: [org.mod1.myVar=4] unused command line argument"}}, // not supported cli union type {new String[]{"-Corg.mod1.myUnion=5"}, null, new VariableKey[]{ new VariableKey(MODULE, "myUnion", incompatibleUnionType, null, true)}, 1, 0, diff --git a/bvm/ballerina-runtime/src/test/java/io/ballerina/runtime/test/config/negative/TomlProviderNegativeTest.java b/bvm/ballerina-runtime/src/test/java/io/ballerina/runtime/test/config/negative/TomlProviderNegativeTest.java index 0378fc30e403..d11cd04630b7 100644 --- a/bvm/ballerina-runtime/src/test/java/io/ballerina/runtime/test/config/negative/TomlProviderNegativeTest.java +++ b/bvm/ballerina-runtime/src/test/java/io/ballerina/runtime/test/config/negative/TomlProviderNegativeTest.java @@ -244,13 +244,11 @@ public Object[][] getRecordNegativeTests() { } @Test() - public void testInvalidMapType() { - MapType mapType = TypeCreator.createMapType(PredefinedTypes.TYPE_INT, true); - VariableKey mapInt = new VariableKey(ROOT_MODULE, "mapVar", mapType, true); - Map configVarMap = Map.ofEntries(Map.entry(ROOT_MODULE, new VariableKey[]{mapInt})); - String errorMsg = "configurable variable 'mapVar' with type 'map & readonly' is not " + - "supported"; - validateTomlProviderErrors("InvalidMapType", errorMsg, configVarMap, 4, 0); + public void testInvalidType() { + VariableKey anyVar = new VariableKey(ROOT_MODULE, "anyVar", PredefinedTypes.TYPE_ANY, true); + Map configVarMap = Map.ofEntries(Map.entry(ROOT_MODULE, new VariableKey[]{anyVar})); + String errorMsg = "configurable variable 'anyVar' with type 'any' is not supported"; + validateTomlProviderErrors("InvalidType", errorMsg, configVarMap, 4, 0); } @Test() diff --git a/bvm/ballerina-runtime/src/test/resources/config_files/negative/InvalidMapType.toml b/bvm/ballerina-runtime/src/test/resources/config_files/negative/InvalidType.toml similarity index 100% rename from bvm/ballerina-runtime/src/test/resources/config_files/negative/InvalidMapType.toml rename to bvm/ballerina-runtime/src/test/resources/config_files/negative/InvalidType.toml From 7996b26e0e0520768694c142c27a00ad71d58175 Mon Sep 17 00:00:00 2001 From: HindujaB Date: Tue, 19 Jul 2022 21:25:10 +0530 Subject: [PATCH 003/450] Fix testerina tests --- .../org/ballerinalang/test/runtime/BTestRunner.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/BTestRunner.java b/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/BTestRunner.java index 3ade2877f53e..6b1ff532300b 100644 --- a/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/BTestRunner.java +++ b/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/BTestRunner.java @@ -464,7 +464,7 @@ private void executeBeforeFunction(Test test, TestSuite suite, ClassLoader class */ private List getKeyValues(BMap dataMap) { List keyValues = new ArrayList<>(); - if (((BMapType) dataMap.getType()).getConstrainedType() instanceof TupleType) { + if (TypeUtils.getReferredType(((BMapType) dataMap.getType()).getConstrainedType()) instanceof TupleType) { for (BString key : (BString[]) dataMap.getKeys()) { keyValues.add(key.getValue()); } @@ -757,7 +757,7 @@ private boolean isTestDependsOnFailedFunctions(List failedOrSkippedTests */ private List extractArguments(BArray bArray) { List argsList = new ArrayList<>(); - if (bArray.getElementType() instanceof ArrayType) { + if (TypeUtils.getReferredType(bArray.getElementType()) instanceof ArrayType) { // Ok we have an array of an array for (int i = 0; i < bArray.size(); i++) { // Iterate array elements and set parameters @@ -778,7 +778,7 @@ private List extractArguments(BArray bArray) { */ private List extractArguments(BMap dataMap) { List argsList = new ArrayList<>(); - if (((BMapType) dataMap.getType()).getConstrainedType() instanceof TupleType) { + if (TypeUtils.getReferredType(((BMapType) dataMap.getType()).getConstrainedType()) instanceof TupleType) { for (BString keyValue : (BString[]) dataMap.getKeys()) { setTestFunctionParams(argsList, dataMap.getArrayValue(keyValue)); } @@ -795,7 +795,7 @@ private List extractArguments(BMap dataMap) { private static Class[] extractArgumentTypes(BArray bArray) { List> typeList = new ArrayList<>(); typeList.add(Strand.class); - if (bArray.getElementType() instanceof ArrayType) { + if (TypeUtils.getReferredType(bArray.getElementType()) instanceof ArrayType) { // Iterate elements of first entry in array of array // to get the class types setTestFunctionSignature(typeList, (BArray) bArray.get(0)); @@ -817,7 +817,7 @@ private static Class[] extractArgumentTypes(BArray bArray) { private static Class[] extractArgumentTypes(BMap dataMap) { List> typeList = new ArrayList<>(); typeList.add(Strand.class); - if (((BMapType) dataMap.getType()).getConstrainedType() instanceof TupleType) { + if (TypeUtils.getReferredType(((BMapType) dataMap.getType()).getConstrainedType()) instanceof TupleType) { setTestFunctionSignature(typeList, dataMap.getArrayValue( (BString) dataMap.getKeys()[0])); } From b577cb10d4f66e5a3cea28b0d1cca5653cd7a1ec Mon Sep 17 00:00:00 2001 From: HindujaB Date: Thu, 28 Jul 2022 18:05:10 +0530 Subject: [PATCH 004/450] Add API tests --- .../runtime/api/utils/TypeUtils.java | 34 +-- .../internal/types/BTypeReferenceType.java | 6 + .../runtime/internal/types/BTypedescType.java | 3 - .../compiler/bir/codegen/JvmTypeGen.java | 4 +- .../jvm/runtime/api/tests/TypeReference.java | 238 ++++++++++++++++++ .../api/types/modules/typeref/typeAPIs.bal | 145 +++++++++++ .../api/types/modules/typeref/typeref.bal | 1 + 7 files changed, 411 insertions(+), 20 deletions(-) create mode 100644 tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java create mode 100644 tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/TypeUtils.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/TypeUtils.java index 307c42af5529..1f58f0627520 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/TypeUtils.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/TypeUtils.java @@ -55,23 +55,27 @@ private TypeUtils() { } public static boolean isValueType(Type type) { - if (type == TYPE_INT || type == TYPE_BYTE || - type == TYPE_FLOAT || - type == TYPE_DECIMAL || type == TYPE_STRING || - type == TYPE_BOOLEAN) { - return true; - } - - if (type != null && type.getTag() == TypeTags.FINITE_TYPE_TAG) { - // All the types in value space should be value types. - for (Object value : ((BFiniteType) type).valueSpace) { - if (!isValueType(TypeChecker.getType(value))) { - return false; + switch (type.getTag()) { + case TypeTags.INT_TAG: + case TypeTags.BYTE_TAG: + case TypeTags.FLOAT_TAG: + case TypeTags.DECIMAL_TAG: + case TypeTags.BOOLEAN_TAG: + case TypeTags.STRING_TAG: + return true; + case TypeTags.FINITE_TYPE_TAG: + for (Object value : ((BFiniteType) type).valueSpace) { + if (!isValueType(TypeChecker.getType(value))) { + return false; + } } - } - return true; + return true; + case TypeTags.TYPE_REFERENCED_TYPE_TAG: + return isValueType(((ReferenceType) type).getReferredType()); + default: + return false; + } - return false; } public static Type getTypeFromName(String typeName) { diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/types/BTypeReferenceType.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/types/BTypeReferenceType.java index dd196a414877..f43cd540dc0e 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/types/BTypeReferenceType.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/types/BTypeReferenceType.java @@ -26,6 +26,7 @@ import io.ballerina.runtime.api.types.IntersectionType; import io.ballerina.runtime.api.types.Type; +import java.util.Objects; import java.util.Optional; /** @@ -71,6 +72,11 @@ public boolean equals(Object obj) { return false; } + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), referredType); + } + @Override public String getAnnotationKey() { return Utils.decodeIdentifier(this.typeName); diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/types/BTypedescType.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/types/BTypedescType.java index ba12a3f8479d..18874690225c 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/types/BTypedescType.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/types/BTypedescType.java @@ -71,9 +71,6 @@ public boolean equals(Object obj) { } public Type getConstraint() { - if (constraint.getTag() == TypeTags.TYPE_REFERENCED_TYPE_TAG) { - return ((BTypeReferenceType) constraint).getReferredType(); - } return constraint; } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeGen.java index b6b42fc4160d..156a13e2265f 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeGen.java @@ -941,7 +941,7 @@ private void loadFunctionParameters(MethodVisitor mv, BInvokableType invokableTy mv.visitLdcInsn(paramSymbol.name.value); mv.visitLdcInsn(paramSymbol.isDefaultable); mv.visitMethodInsn(INVOKESTATIC, BOOLEAN_VALUE, VALUE_OF_METHOD, BOOLEAN_VALUE_OF_METHOD, false); - loadLocalType(mv, paramSymbol.type); + loadType(mv, paramSymbol.type); mv.visitMethodInsn(INVOKESPECIAL, FUNCTION_PARAMETER, JVM_INIT_METHOD, INIT_FUCNTION_PARAM, false); mv.visitInsn(AASTORE); } @@ -961,7 +961,7 @@ private void loadFunctionPointerParameters(MethodVisitor mv, BInvokableType invo mv.visitLdcInsn(""); mv.visitLdcInsn(false); mv.visitMethodInsn(INVOKESTATIC, BOOLEAN_VALUE, VALUE_OF_METHOD, BOOLEAN_VALUE_OF_METHOD, false); - loadLocalType(mv, paramTypes.get(i)); + loadType(mv, paramTypes.get(i)); mv.visitMethodInsn(INVOKESPECIAL, FUNCTION_PARAMETER, JVM_INIT_METHOD, INIT_FUCNTION_PARAM, false); mv.visitInsn(AASTORE); } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java new file mode 100644 index 000000000000..6355a573b3d7 --- /dev/null +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java @@ -0,0 +1,238 @@ +/* + * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.ballerinalang.nativeimpl.jvm.runtime.api.tests; + +import io.ballerina.runtime.api.TypeTags; +import io.ballerina.runtime.api.creators.ErrorCreator; +import io.ballerina.runtime.api.types.ObjectType; +import io.ballerina.runtime.api.types.Parameter; +import io.ballerina.runtime.api.types.ReferenceType; +import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.types.UnionType; +import io.ballerina.runtime.api.utils.StringUtils; +import io.ballerina.runtime.api.utils.TypeUtils; +import io.ballerina.runtime.api.values.BError; +import io.ballerina.runtime.api.values.BTypedesc; +import io.ballerina.runtime.internal.types.BArrayType; +import io.ballerina.runtime.internal.types.BErrorType; +import io.ballerina.runtime.internal.types.BFunctionType; +import io.ballerina.runtime.internal.types.BIntersectionType; +import io.ballerina.runtime.internal.types.BMapType; +import io.ballerina.runtime.internal.types.BParameterizedType; +import io.ballerina.runtime.internal.types.BRecordType; +import io.ballerina.runtime.internal.types.BStreamType; +import io.ballerina.runtime.internal.types.BTableType; +import io.ballerina.runtime.internal.types.BTupleType; +import io.ballerina.runtime.internal.types.BTypedescType; +import io.ballerina.runtime.internal.types.BUnionType; +import io.ballerina.runtime.internal.values.ObjectValue; + +import java.util.List; + +/** + * This class contains a set of utility methods required for runtime api + * @{@link io.ballerina.runtime.internal.types.BTypeReferenceType} testing. + * + * @since 2.3.0 + */ +public class TypeReference { + + public static Boolean validateGetDetailType(BTypedesc typedesc) { + BErrorType errorType = (BErrorType) ((ReferenceType) typedesc.getDescribingType()).getReferredType(); + Type detailType = errorType.getDetailType(); + if (detailType.getTag() == TypeTags.TYPE_REFERENCED_TYPE_TAG) { + return true; + } + throw ErrorCreator.createError(StringUtils.fromString("error detail type provided a non type reference type.")); + } + + public static Boolean validateFunctionType(BTypedesc typedesc) { + BFunctionType functionType = (BFunctionType) ((ReferenceType) typedesc.getDescribingType()).getReferredType(); + BError error = ErrorCreator.createError( + StringUtils.fromString("function type API provided a non type reference type.")); + + for (Type type : functionType.getParameterTypes()) { + if (type.getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + } + + for (Parameter parameter : functionType.getParameters()) { + if (parameter.type.getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + } + + if (functionType.getReturnType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + + if (functionType.getReturnParameterType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + + Type restType = functionType.getRestType(); + if (((BArrayType) restType).getElementType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + return true; + } + + public static Boolean validateIntersectionType(BTypedesc typedesc) { + BIntersectionType + intersectionType = (BIntersectionType) ((ReferenceType) typedesc.getDescribingType()).getReferredType(); + BError error = ErrorCreator.createError( + StringUtils.fromString("intersection type API provided a non type reference type.")); + + if (intersectionType.getEffectiveType().getTag() != TypeTags.RECORD_TYPE_TAG) { + throw error; + } + + List constituentTypes = intersectionType.getConstituentTypes(); + if (constituentTypes.get(0).getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + return true; + } + + public static Boolean validateMapType(BTypedesc typedesc) { + BMapType mapType = (BMapType) ((ReferenceType) typedesc.getDescribingType()).getReferredType(); + BError error = ErrorCreator.createError(StringUtils.fromString("map type API provided a non type reference " + + "type.")); + + if (mapType.getConstrainedType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + return true; + } + + public static Boolean validateRecordType(BTypedesc typedesc) { + BRecordType recordType = + (BRecordType) (TypeUtils.getReferredType(typedesc.getDescribingType())); + BError error = ErrorCreator.createError(StringUtils.fromString("record type API provided a non type reference" + + " type.")); + if (recordType.getRestFieldType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + return true; + } + + public static Boolean validateStreamType(BTypedesc typedesc) { + BStreamType streamType = (BStreamType) ((ReferenceType) typedesc.getDescribingType()).getReferredType(); + BError error = ErrorCreator.createError(StringUtils.fromString("stream type API provided a non type reference" + + " type.")); + if (streamType.getConstrainedType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + + if (streamType.getCompletionType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + return true; + } + + public static Boolean validateTableType(BTypedesc typedesc) { + BTableType tableType = (BTableType) ((ReferenceType) typedesc.getDescribingType()).getReferredType(); + BError error = ErrorCreator.createError(StringUtils.fromString("table type API provided a non type reference" + + " type.")); + if (tableType.getConstrainedType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + return true; + } + + public static Boolean validateTupleType(BTypedesc typedesc) { + BTupleType tupleType = (BTupleType) ((ReferenceType) typedesc.getDescribingType()).getReferredType(); + BError error = ErrorCreator.createError(StringUtils.fromString("table type API provided a non type reference" + + " type.")); + for (Type type : tupleType.getTupleTypes()) { + if (type.getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + } + + if (tupleType.getRestType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + + return true; + } + + public static Boolean validateTypedescType(BTypedesc typedesc) { + BTypedescType typedescType = (BTypedescType) ((ReferenceType) typedesc.getDescribingType()).getReferredType(); + BError error = ErrorCreator.createError(StringUtils.fromString("typdesc type API provided a non type " + + "reference type.")); + if (typedescType.getConstraint().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + return true; + } + + public static Boolean validateUnionType(BTypedesc typedesc) { + BUnionType unionType = (BUnionType) ((ReferenceType) typedesc.getDescribingType()).getReferredType(); + BError error = ErrorCreator.createError(StringUtils.fromString("union type API provided a non type " + + "reference type.")); + + for (Type type : unionType.getMemberTypes()) { + if (type.getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + } + + for (Type type : unionType.getOriginalMemberTypes()) { + if (type.getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + } + + return true; + } + + public static Boolean validateParameterizedType(ObjectValue objectValue) { + BError error = ErrorCreator.createError(StringUtils.fromString("parameterized type API provided a non type " + + "reference type.")); + ObjectType objectType = objectValue.getType(); + BFunctionType functionType = (BFunctionType) objectType.getMethods()[0].getType(); + BParameterizedType parameterizedType = + (BParameterizedType) ((UnionType) functionType.getReturnType()).getMemberTypes().get(0); + if (parameterizedType.getParamValueType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + parameterizedType = + (BParameterizedType) ((UnionType) functionType.getReturnType()).getOriginalMemberTypes().get(0); + if (parameterizedType.getParamValueType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + return true; + } + + public static Boolean validateTypeUtilsAPI(BTypedesc typedesc) { + Type type = typedesc.getDescribingType(); + BError error = ErrorCreator.createError(StringUtils.fromString("TypeUtils API provided a non type " + + "reference type.")); + if (!TypeUtils.isValueType(type)) { + throw error; + } + return true; + } + + public static Object getInt(ObjectValue objectValue, BTypedesc td) { + return true; + } +} diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal new file mode 100644 index 000000000000..31fc7479fad2 --- /dev/null +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal @@ -0,0 +1,145 @@ +// Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +// +// WSO2 Inc. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +import ballerina/jballerina.java; +import ballerina/test; + +type ErrorRec record {| + int id; + string msg; + PositiveInt...; +|}; + +type Detail ErrorRec; + +type DetailedError error; + +type FunctionType function (PositiveInt a, PositiveInt... args) returns PositiveInt; + +type IntersectionType Detail & readonly; + +type MapType map; + +type RecordType ErrorRec; + +type StreamType stream; + +type TableType table; + +type TupleType [PositiveInt, Detail, PositiveIntRef...]; + +type TypedescType typedesc; + +type UnionType PositiveInt|Detail|PositiveIntRef; + +public class Test { + int i = 1; + + public function get(typedesc td) returns td|error = @java:Method { + 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference", + name: "getInt", + paramTypes: ["io.ballerina.runtime.api.values.BTypedesc"] + } external; +} + +function validateRuntimeAPIs() { + boolean result = validateGetDetailType(DetailedError); + test:assertTrue(result); + + result = validateFunctionType(FunctionType); + test:assertTrue(result); + + result = validateIntersectionType(IntersectionType); + test:assertTrue(result); + + result = validateMapType(MapType); + test:assertTrue(result); + + result = validateRecordType(RecordType); + test:assertTrue(result); + + result = validateStreamType(StreamType); + test:assertTrue(result); + + result = validateTableType(TableType); + test:assertTrue(result); + + result = validateTupleType(TupleType); + test:assertTrue(result); + + result = validateTypedescType(TypedescType); + test:assertTrue(result); + + result = validateUnionType(UnionType); + test:assertTrue(result); + + Test testVal = new (); + result = validateParameterizedType(testVal); + test:assertTrue(result); + + result = validateTypeUtilsAPI(PositiveInt); + test:assertTrue(result); +} + +public function validateGetDetailType(any value) returns boolean = @java:Method { + 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" +} external; + +public function validateFunctionType(any value) returns boolean = @java:Method { + 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" +} external; + +public function validateIntersectionType(any value) returns boolean = @java:Method { + 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" +} external; + +public function validateMapType(any value) returns boolean = @java:Method { + 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" +} external; + +public function validateRecordType(any value) returns boolean = @java:Method { + 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" +} external; + +public function validateStreamType(any value) returns boolean = @java:Method { + 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" +} external; + +public function validateTableType(any value) returns boolean = @java:Method { + 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" +} external; + +public function validateTupleType(any value) returns boolean = @java:Method { + 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" +} external; + +public function validateTypedescType(any value) returns boolean = @java:Method { + 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" +} external; + +public function validateUnionType(any value) returns boolean = @java:Method { + 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" +} external; + +public function validateParameterizedType(any value) returns boolean = @java:Method { + 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" +} external; + +public function validateTypeUtilsAPI(any value) returns boolean = @java:Method { + 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" +} external; + + diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeref.bal b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeref.bal index 9171180f356f..82e796b08b5e 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeref.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeref.bal @@ -84,6 +84,7 @@ public function validateTypeRef() { testRuntimeTypeRef(); validateArray(); validateFunctionParameters(); + validateRuntimeAPIs(); } function validateFunctionParameters() { From 31818e67212bcea2c7ba660c96b6a6125f5cafc1 Mon Sep 17 00:00:00 2001 From: HindujaB Date: Thu, 28 Jul 2022 18:08:47 +0530 Subject: [PATCH 005/450] Remove `loadLocalType` method --- .../ballerinalang/compiler/bir/codegen/JvmTypeGen.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeGen.java index 156a13e2265f..d4bed0bec5a3 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeGen.java @@ -1095,14 +1095,4 @@ private void loadValueType(MethodVisitor mv, BType valueType) { } } -// public void loadLocalType(MethodVisitor mv, BType type) { -// if (type.tag == TypeTags.TYPEREFDESC) { -// String typeOwner = JvmCodeGenUtil.getModuleLevelClassName(type.tsymbol.pkgID, -// JvmConstants.TYPEREF_TYPE_CONSTANT_CLASS_NAME); -// mv.visitFieldInsn(GETSTATIC, typeOwner, -// JvmCodeGenUtil.getRefTypeConstantName((BTypeReferenceType) type), GET_TYPE_REF_TYPE_IMPL); -// } else { -// loadType(mv, type); -// } -// } } From 301cbc3207b26f6cd718ac47f0fae35438b0c079 Mon Sep 17 00:00:00 2001 From: HindujaB Date: Thu, 28 Jul 2022 18:47:32 +0530 Subject: [PATCH 006/450] Fix checkstyle error --- .../nativeimpl/jvm/runtime/api/tests/TypeReference.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java index 6355a573b3d7..cc5160bfb30a 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java @@ -46,8 +46,7 @@ import java.util.List; /** - * This class contains a set of utility methods required for runtime api - * @{@link io.ballerina.runtime.internal.types.BTypeReferenceType} testing. + * Utility methods used for runtime api @{@link io.ballerina.runtime.internal.types.BTypeReferenceType} testing. * * @since 2.3.0 */ From 5585a7837dbcaf71265cf1e43e9f53e921dc67c1 Mon Sep 17 00:00:00 2001 From: HindujaB Date: Sat, 30 Jul 2022 10:45:27 +0530 Subject: [PATCH 007/450] Add BValue tests --- .../internal/values/AbstractArrayValue.java | 3 +- .../langlib/internal/Construct.java | 6 +- .../jvm/runtime/api/tests/TypeReference.java | 55 ++++++++++++++- .../jvm/tests/VariableReturnType.java | 2 +- .../api/types/modules/typeref/typeAPIs.bal | 70 +++++++++++++++++-- 5 files changed, 122 insertions(+), 14 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/AbstractArrayValue.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/AbstractArrayValue.java index 5f476a922cab..25b2a257ffa1 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/AbstractArrayValue.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/AbstractArrayValue.java @@ -20,7 +20,6 @@ import io.ballerina.runtime.api.TypeTags; import io.ballerina.runtime.api.creators.ErrorCreator; import io.ballerina.runtime.api.types.Type; -import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.internal.IteratorUtils; import io.ballerina.runtime.internal.JsonGenerator; import io.ballerina.runtime.internal.types.BTupleType; @@ -165,7 +164,7 @@ public long getLength() { protected void initializeIteratorNextReturnType() { Type type; if (getType().getTag() == TypeTags.ARRAY_TAG) { - type = TypeUtils.getReferredType(getElementType()); + type = getElementType(); } else { BTupleType tupleType = (BTupleType) getType(); LinkedHashSet types = new LinkedHashSet<>(tupleType.getTupleTypes()); diff --git a/langlib/lang.__internal/src/main/java/org/ballerinalang/langlib/internal/Construct.java b/langlib/lang.__internal/src/main/java/org/ballerinalang/langlib/internal/Construct.java index c6388fbe4c12..940af0b39ba0 100644 --- a/langlib/lang.__internal/src/main/java/org/ballerinalang/langlib/internal/Construct.java +++ b/langlib/lang.__internal/src/main/java/org/ballerinalang/langlib/internal/Construct.java @@ -20,7 +20,6 @@ import io.ballerina.runtime.api.creators.TypeCreator; import io.ballerina.runtime.api.creators.ValueCreator; -import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BObject; import io.ballerina.runtime.api.values.BStream; import io.ballerina.runtime.api.values.BTypedesc; @@ -33,8 +32,7 @@ public class Construct { public static BStream construct(BTypedesc constraintTd, BTypedesc completionTd, BObject iteratorObj) { - return ValueCreator.createStreamValue( - TypeCreator.createStreamType(TypeUtils.getReferredType(constraintTd.getDescribingType()), - TypeUtils.getReferredType(completionTd.getDescribingType())), iteratorObj); + return ValueCreator.createStreamValue(TypeCreator.createStreamType(constraintTd.getDescribingType(), + completionTd.getDescribingType()), iteratorObj); } } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java index cc5160bfb30a..84781cddbf06 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java @@ -27,7 +27,11 @@ import io.ballerina.runtime.api.types.UnionType; import io.ballerina.runtime.api.utils.StringUtils; import io.ballerina.runtime.api.utils.TypeUtils; +import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BError; +import io.ballerina.runtime.api.values.BFunctionPointer; +import io.ballerina.runtime.api.values.BMap; +import io.ballerina.runtime.api.values.BStream; import io.ballerina.runtime.api.values.BTypedesc; import io.ballerina.runtime.internal.types.BArrayType; import io.ballerina.runtime.internal.types.BErrorType; @@ -42,6 +46,7 @@ import io.ballerina.runtime.internal.types.BTypedescType; import io.ballerina.runtime.internal.types.BUnionType; import io.ballerina.runtime.internal.values.ObjectValue; +import io.ballerina.runtime.internal.values.TableValue; import java.util.List; @@ -146,13 +151,16 @@ public static Boolean validateStreamType(BTypedesc typedesc) { return true; } - public static Boolean validateTableType(BTypedesc typedesc) { + public static Boolean validateTableType(BTypedesc typedesc, TableValue tableValue) { BTableType tableType = (BTableType) ((ReferenceType) typedesc.getDescribingType()).getReferredType(); BError error = ErrorCreator.createError(StringUtils.fromString("table type API provided a non type reference" + " type.")); if (tableType.getConstrainedType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { throw error; } + if (tableValue.getKeyType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } return true; } @@ -234,4 +242,49 @@ public static Boolean validateTypeUtilsAPI(BTypedesc typedesc) { public static Object getInt(ObjectValue objectValue, BTypedesc td) { return true; } + + public static Boolean validateBStream(BStream value) { + BError error = ErrorCreator.createError(StringUtils.fromString("BStream getType API provided a non type " + + "reference type.")); + if (value.getConstraintType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + if (value.getCompletionType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + return true; + } + + public static Boolean validateBArray(BArray value1, BArray value2) { + BError error = ErrorCreator.createError(StringUtils.fromString("BArray getType API provided a non type " + + "reference type.")); + if (value1.getType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG || + value2.getType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + if (value1.getElementType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + return true; + } + + public static Boolean validateBMap(BMap value1, BMap value2) { + BError error = ErrorCreator.createError(StringUtils.fromString("BMap getType API provided a non type " + + "reference type.")); + if (value1.getType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG || + value2.getType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + return true; + } + + public static Boolean validateBFunctionPointer(BFunctionPointer value) { + BError error = ErrorCreator.createError(StringUtils.fromString("Function Pointer getType API provided a non " + + "type reference type.")); + if (value.getType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + return true; + } + } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/tests/VariableReturnType.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/tests/VariableReturnType.java index 8ce9f8adbaf5..dfed621b7d57 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/tests/VariableReturnType.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/tests/VariableReturnType.java @@ -150,7 +150,7 @@ public static MapValue query(BString query, BTypedesc typedesc) { public static BStream getStreamOfRecords(ObjectValue objectValue, BStream strm, BTypedesc typedesc) { RecordType streamConstraint = (RecordType) typedesc.getDescribingType(); - assert streamConstraint == strm.getConstraintType(); + assert streamConstraint == TypeUtils.getReferredType(strm.getConstraintType()); return strm; } diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal index 31fc7479fad2..8484f7fbd36a 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal @@ -18,7 +18,7 @@ import ballerina/jballerina.java; import ballerina/test; type ErrorRec record {| - int id; + readonly PositiveInt id; string msg; PositiveInt...; |}; @@ -35,9 +35,11 @@ type MapType map; type RecordType ErrorRec; -type StreamType stream; +type ErrorOrNil DetailedError?; -type TableType table; +type StreamType stream; + +type TableType table key (id); type TupleType [PositiveInt, Detail, PositiveIntRef...]; @@ -45,6 +47,14 @@ type TypedescType typedesc; type UnionType PositiveInt|Detail|PositiveIntRef; +type BArray PositiveInt[]; + +type BTuple [PositiveInt, Detail]; + +type BFunctionPointer function (int a) returns int; + +type BMap map; + public class Test { int i = 1; @@ -55,6 +65,15 @@ public class Test { } external; } +class PositiveNumberGenerator { + PositiveInt i = 0; + + public isolated function next() returns record {|PositiveInt value;|}|ErrorOrNil { + self.i += 2; + return {value: self.i}; + } +} + function validateRuntimeAPIs() { boolean result = validateGetDetailType(DetailedError); test:assertTrue(result); @@ -74,7 +93,8 @@ function validateRuntimeAPIs() { result = validateStreamType(StreamType); test:assertTrue(result); - result = validateTableType(TableType); + TableType tab = table []; + result = validateTableType(TableType, tab); test:assertTrue(result); result = validateTupleType(TupleType); @@ -91,7 +111,30 @@ function validateRuntimeAPIs() { test:assertTrue(result); result = validateTypeUtilsAPI(PositiveInt); - test:assertTrue(result); + + PositiveNumberGenerator gen = new (); + StreamType s = new (gen); + result = validateBStream(s); + + // BArray arr = [1, 2, 3]; + // BTuple tup = [1, {id: 101, msg: "message", "priority": 2}]; + + // result = validateBArray(arr, tup); + // test:assertTrue(result); + + // BMap m = {a: 1, b: 2, c: 3}; + // RecordType r = {id: 11, msg: "message", "intVal": 22}; + // result = validateBMap(m, r); + // test:assertTrue(result); + + // BFunctionPointer fp = testFunc; + // result = validateBFunctionPointer(fp); + // test:assertTrue(result); + +} + +function testFunc(int a) returns int { + return a + 5; } public function validateGetDetailType(any value) returns boolean = @java:Method { @@ -118,7 +161,7 @@ public function validateStreamType(any value) returns boolean = @java:Method { 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" } external; -public function validateTableType(any value) returns boolean = @java:Method { +public function validateTableType(any value1, any value2) returns boolean = @java:Method { 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" } external; @@ -142,4 +185,19 @@ public function validateTypeUtilsAPI(any value) returns boolean = @java:Method { 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" } external; +public function validateBStream(any value) returns boolean = @java:Method { + 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" +} external; + +public function validateBArray(any value1, any value2) returns boolean = @java:Method { + 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" +} external; + +public function validateBMap(any value1, any value2) returns boolean = @java:Method { + 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" +} external; + +public function validateBFunctionPointer(any value) returns boolean = @java:Method { + 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" +} external; From 4c3f7f17ace8371008695652793c26361a4e4560 Mon Sep 17 00:00:00 2001 From: HindujaB Date: Tue, 2 Aug 2022 12:33:43 +0530 Subject: [PATCH 008/450] Fix BMap and BError `getType()` --- .../io/ballerina/runtime/api/Runtime.java | 2 +- .../runtime/api/utils/StringUtils.java | 4 +- .../ballerina/runtime/api/values/BObject.java | 4 +- .../ballerina/runtime/internal/JsonUtils.java | 2 +- .../runtime/internal/TypeChecker.java | 3 ++ .../internal/values/AbstractObjectValue.java | 3 +- .../runtime/internal/values/ErrorValue.java | 9 ++-- .../runtime/internal/values/MapValueImpl.java | 31 +++++++----- .../internal/values/ReadOnlyUtils.java | 2 +- .../internal/values/TypedescValueImpl.java | 2 +- .../runtime/observability/ObserveUtils.java | 2 +- .../org/ballerinalang/langlib/java/Cast.java | 2 +- .../langlib/error/StackTrace.java | 2 +- .../langlib/map/util/MapLibUtils.java | 3 ++ .../natives/mock/GenericMockObjectValue.java | 3 +- .../testerina/natives/mock/ObjectMock.java | 27 ++++++----- .../jvm/runtime/api/tests/Async.java | 12 ++--- .../jvm/runtime/api/tests/Errors.java | 3 +- .../jvm/runtime/api/tests/TypeReference.java | 48 ++++++++++++------- .../jvm/runtime/api/tests/Values.java | 8 ++-- .../jvm/servicetests/ServiceValue.java | 2 +- .../test/object/ObjectInitializerTest.java | 13 ++--- .../api/types/modules/typeref/typeAPIs.bal | 40 ++++++++++------ 23 files changed, 136 insertions(+), 91 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/Runtime.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/Runtime.java index 619a1d8c7e2f..2da573b177be 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/Runtime.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/Runtime.java @@ -162,7 +162,7 @@ public BFuture invokeMethodAsync(BObject object, String methodName, String stran Type returnType, Object... args) { try { validateArgs(object, methodName); - ObjectType objectType = object.getType(); + ObjectType objectType = (ObjectType) object.getType(); boolean isIsolated = objectType.isIsolated() && objectType.isIsolated(methodName); Function func = o -> object.call((Strand) (((Object[]) o)[0]), methodName, args); if (isIsolated) { diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/StringUtils.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/StringUtils.java index 51d1a02703dd..f07240acf34d 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/StringUtils.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/StringUtils.java @@ -202,7 +202,7 @@ public static String getStringValue(Object value, BLink parent) { if (type.getTag() == TypeTags.OBJECT_TYPE_TAG) { BObject objectValue = (BObject) value; - ObjectType objectType = objectValue.getType(); + ObjectType objectType = (ObjectType) objectValue.getType(); for (MethodType func : objectType.getMethods()) { if (func.getName().equals(TO_STRING) && func.getParameters().length == 0 && func.getType().getReturnType().getTag() == TypeTags.STRING_TAG) { @@ -273,7 +273,7 @@ public static String getExpressionStringValue(Object value, BLink parent) { if (type.getTag() == TypeTags.OBJECT_TYPE_TAG) { AbstractObjectValue objectValue = (AbstractObjectValue) value; - ObjectType objectType = objectValue.getType(); + ObjectType objectType = (ObjectType) objectValue.getType(); for (MethodType func : objectType.getMethods()) { if (func.getName().equals(TO_STRING) && func.getParameters().length == 0 && func.getType().getReturnType().getTag() == TypeTags.STRING_TAG) { diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/values/BObject.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/values/BObject.java index 3c81d65411d1..49763301feb2 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/values/BObject.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/values/BObject.java @@ -17,7 +17,7 @@ */ package io.ballerina.runtime.api.values; -import io.ballerina.runtime.api.types.ObjectType; +import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.internal.scheduling.Strand; import io.ballerina.runtime.internal.values.RefValue; @@ -36,7 +36,7 @@ public interface BObject extends RefValue { BFuture start(Strand strand, String funcName, Object... args); - ObjectType getType(); + Type getType(); Object get(BString fieldName); diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/JsonUtils.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/JsonUtils.java index 9d16c8ab75fb..bc9a5923db90 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/JsonUtils.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/JsonUtils.java @@ -250,7 +250,7 @@ public static boolean isJSONObject(Object json) { return false; } - Type type = ((RefValue) json).getType(); + Type type = TypeUtils.getReferredType(((RefValue) json).getType()); int typeTag = type.getTag(); return typeTag == TypeTags.MAP_TAG || typeTag == TypeTags.RECORD_TYPE_TAG; } diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java index f7ff4605a4de..4207696a11c0 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java @@ -2116,6 +2116,9 @@ private static boolean checkIsNeverTypeOrStructureTypeWithARequiredNeverMember(T case TypeTags.TYPE_REFERENCED_TYPE_TAG: return checkIsNeverTypeOrStructureTypeWithARequiredNeverMember( ((BTypeReferenceType) type).getReferredType(), visitedTypeSet); + case TypeTags.INTERSECTION_TAG: + return checkIsNeverTypeOrStructureTypeWithARequiredNeverMember( + ((BIntersectionType) type).getEffectiveType(), visitedTypeSet); default: return false; } diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/AbstractObjectValue.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/AbstractObjectValue.java index 9eca206e78a2..296016aa90a9 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/AbstractObjectValue.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/AbstractObjectValue.java @@ -20,7 +20,6 @@ import io.ballerina.runtime.api.creators.ErrorCreator; import io.ballerina.runtime.api.flags.SymbolFlags; import io.ballerina.runtime.api.types.Field; -import io.ballerina.runtime.api.types.ObjectType; import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.types.TypeId; import io.ballerina.runtime.api.utils.StringUtils; @@ -146,7 +145,7 @@ public BArray getArrayValue(BString fieldName) { } @Override - public ObjectType getType() { + public Type getType() { return type; } diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ErrorValue.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ErrorValue.java index 2aebb9b908c6..0097033c1d69 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ErrorValue.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ErrorValue.java @@ -22,10 +22,10 @@ import io.ballerina.runtime.api.PredefinedTypes; import io.ballerina.runtime.api.TypeTags; import io.ballerina.runtime.api.constants.TypeConstants; -import io.ballerina.runtime.api.types.ReferenceType; import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.types.TypeId; import io.ballerina.runtime.api.utils.StringUtils; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BError; import io.ballerina.runtime.api.values.BLink; import io.ballerina.runtime.api.values.BString; @@ -91,7 +91,7 @@ public ErrorValue(BString message, Object details) { public ErrorValue(Type type, BString message, BError cause, Object details) { super(message); - this.type = ((ReferenceType) type).getReferredType(); + this.type = type; this.message = message; this.cause = cause; this.details = details; @@ -101,13 +101,13 @@ public ErrorValue(Type type, BString message, BError cause, Object details) { public ErrorValue(Type type, BString message, BError cause, Object details, String typeIdName, Module typeIdPkg) { super(message); - this.type = ((ReferenceType) type).getReferredType(); + this.type = type; this.message = message; this.cause = cause; this.details = details; BTypeIdSet typeIdSet = new BTypeIdSet(); typeIdSet.add(typeIdPkg, typeIdName, true); - ((BErrorType) type).setTypeIdSet(typeIdSet); + ((BErrorType) TypeUtils.getReferredType(type)).setTypeIdSet(typeIdSet); this.typedesc = new TypedescValueImpl(type); } @@ -189,6 +189,7 @@ private String getCauseToBalString(BLink parent) { } private String getModuleNameToBalString() { + Type type = TypeUtils.getReferredType(this.type); if (((BErrorType) type).typeIdSet == null) { return ""; } diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/MapValueImpl.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/MapValueImpl.java index 10d72a28434e..23e0aaf7cd7d 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/MapValueImpl.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/MapValueImpl.java @@ -94,6 +94,7 @@ public class MapValueImpl extends LinkedHashMap implements RefValue, private static final long serialVersionUID = 1L; private BTypedesc typedesc; private Type type; + private Type referredType; private final Map nativeData = new HashMap<>(); private Type iteratorNextReturnType; @@ -106,13 +107,15 @@ public MapValueImpl(TypedescValue typedesc) { public MapValueImpl(Type type) { super(); - this.type = getReferredType(type); + this.type = type; + this.referredType = getReferredType(type); this.typedesc = getTypedescValue(type, this); } public MapValueImpl(Type type, BMapInitialValueEntry[] initialValues) { super(); - this.type = getReferredType(type); + this.type = type; + this.referredType = getReferredType(type); populateInitialValues(initialValues); if (!type.isReadOnly()) { this.typedesc = new TypedescValueImpl(type); @@ -122,6 +125,7 @@ public MapValueImpl(Type type, BMapInitialValueEntry[] initialValues) { public MapValueImpl() { super(); type = PredefinedTypes.TYPE_MAP; + this.referredType = this.type; this.typedesc = getTypedescValue(type, this); } @@ -191,8 +195,8 @@ public V fillAndGet(Object key) { Type expectedType = null; // The type should be a record or map for filling read. - if (this.type.getTag() == TypeTags.RECORD_TYPE_TAG) { - BRecordType recordType = (BRecordType) this.type; + if (this.referredType.getTag() == TypeTags.RECORD_TYPE_TAG) { + BRecordType recordType = (BRecordType) this.referredType; Map fields = recordType.getFields(); if (fields.containsKey(key.toString())) { expectedType = ((BField) fields.get(key.toString())).getFieldType(); @@ -205,7 +209,7 @@ public V fillAndGet(Object key) { expectedType = recordType.restFieldType; } } else { - expectedType = ((BMapType) this.type).getConstrainedType(); + expectedType = ((BMapType) this.referredType).getConstrainedType(); } if (!TypeChecker.hasFillerValue(expectedType)) { @@ -298,11 +302,11 @@ protected void populateInitialValues(BMapInitialValueEntry[] initialValues) { } public void populateInitialValue(K key, V value) { - if (type.getTag() == TypeTags.MAP_TAG) { - MapUtils.handleInherentTypeViolatingMapUpdate(value, (BMapType) type); + if (referredType.getTag() == TypeTags.MAP_TAG) { + MapUtils.handleInherentTypeViolatingMapUpdate(value, (BMapType) referredType); } else { BString fieldName = (BString) key; - MapUtils.handleInherentTypeViolatingRecordUpdate(this, fieldName, value, (BRecordType) type, true); + MapUtils.handleInherentTypeViolatingRecordUpdate(this, fieldName, value, (BRecordType) referredType, true); } putValue(key, value); @@ -353,6 +357,10 @@ public boolean equals(Object o) { return false; } + if (mapValue.referredType.getTag() != this.referredType.getTag()) { + return false; + } + if (this.entrySet().size() != mapValue.entrySet().size()) { return false; } @@ -522,6 +530,7 @@ public void freezeDirect() { } this.type = ReadOnlyUtils.setImmutableTypeAndGetEffectiveType(this.type); + this.referredType = ReadOnlyUtils.setImmutableTypeAndGetEffectiveType(this.referredType); this.values().forEach(val -> { if (val instanceof RefValue) { @@ -618,11 +627,11 @@ public Map getNativeDataMap() { private void initializeIteratorNextReturnType() { Type type; - if (this.type.getTag() == PredefinedTypes.TYPE_MAP.getTag()) { - BMapType mapType = (BMapType) this.type; + if (this.referredType.getTag() == PredefinedTypes.TYPE_MAP.getTag()) { + BMapType mapType = (BMapType) this.referredType; type = mapType.getConstrainedType(); } else { - BRecordType recordType = (BRecordType) this.type; + BRecordType recordType = (BRecordType) this.referredType; LinkedHashSet types = recordType.getFields().values().stream().map(Field::getFieldType) .collect(Collectors.toCollection(LinkedHashSet::new)); if (recordType.restFieldType != null) { diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ReadOnlyUtils.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ReadOnlyUtils.java index a6ce8e161b95..6f18eda381de 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ReadOnlyUtils.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ReadOnlyUtils.java @@ -281,7 +281,7 @@ private static BIntersectionType setImmutableIntersectionType(Type type, Set(PredefinedTypes.TYPE_ERROR_DETAIL)); } else { - for (MethodType attachedFunction : objectValue.getType().getMethods()) { + for (MethodType attachedFunction : objectValueType.getMethods()) { BError error = validateFunctionSignatures(attachedFunction, ((ObjectType) bTypedesc.getDescribingType()).getMethods()); if (error != null) { throw error; } } - for (Map.Entry field : objectValue.getType().getFields().entrySet()) { + for (Map.Entry field : objectValueType.getFields().entrySet()) { BError error = validateField(field, ((ObjectType) bTypedesc.getDescribingType()).getFields()); if (error != null) { @@ -125,7 +126,7 @@ public static BError validatePreparedObj(BObject caseObj) { public static BError validateFunctionName(String functionName, BObject mockObject) { GenericMockObjectValue genericMock = (GenericMockObjectValue) mockObject; - if (!validateFunctionName(functionName, genericMock.getType().getMethods())) { + if (!validateFunctionName(functionName, ((ObjectType) genericMock.getType()).getMethods())) { String detail = "invalid function name '" + functionName + " ' provided"; throw ErrorCreator.createError( MockConstants.TEST_PACKAGE_ID, @@ -146,7 +147,7 @@ public static BError validateFunctionName(String functionName, BObject mockObjec */ public static BError validateFieldName(String fieldName, BObject mockObject) { GenericMockObjectValue genericMock = (GenericMockObjectValue) mockObject; - if (!validateFieldName(fieldName, genericMock.getType().getFields())) { + if (!validateFieldName(fieldName, ((ObjectType) genericMock.getType()).getFields())) { String detail = "invalid field name '" + fieldName + "' provided"; throw ErrorCreator.createError( MockConstants.TEST_PACKAGE_ID, @@ -170,7 +171,7 @@ public static BError validateArguments(BObject caseObj) { String functionName = caseObj.getStringValue(StringUtils.fromString("functionName")).toString(); BArray argsList = caseObj.getArrayValue(StringUtils.fromString("args")); - for (MethodType attachedFunction : genericMock.getType().getMethods()) { + for (MethodType attachedFunction : ((ObjectType) genericMock.getType()).getMethods()) { if (attachedFunction.getName().equals(functionName)) { // validate the number of arguments provided @@ -247,10 +248,11 @@ public static BError thenReturn(BObject caseObj) { } functionName = null; } + ObjectType objectType = (ObjectType) genericMock.getType(); if (functionName != null) { // register return value for member function BArray args = caseObj.getArrayValue(StringUtils.fromString("args")); - if (!validateReturnValue(functionName, returnVal, genericMock.getType().getMethods())) { + if (!validateReturnValue(functionName, returnVal, objectType.getMethods())) { String detail = "return value provided does not match the return type of function '" + functionName + "()'"; return ErrorCreator.createError( @@ -266,8 +268,7 @@ public static BError thenReturn(BObject caseObj) { // register return value for member field String fieldName = caseObj.getStringValue(StringUtils.fromString("fieldName")).toString(); - if (!validateFieldValue(returnVal, - genericMock.getType().getFields().get(fieldName).getFieldType())) { + if (!validateFieldValue(returnVal, objectType.getFields().get(fieldName).getFieldType())) { String detail = "return value provided does not match the type of '" + fieldName + "'"; return ErrorCreator.createError( MockConstants.TEST_PACKAGE_ID, @@ -299,7 +300,7 @@ public static BError thenReturnSequence(BObject caseObj) { break; } if (!validateReturnValue(functionName, returnVals.getValues()[i], - genericMock.getType().getMethods())) { + ((ObjectType) genericMock.getType()).getMethods())) { String detail = "return value provided at position '" + i + "' does not match the return type of function '" + functionName + "()'"; return ErrorCreator.createError( diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Async.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Async.java index fbbf1d16b6dd..eba593fdffcf 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Async.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Async.java @@ -76,7 +76,7 @@ public static long isolatedGetA(Environment env, BObject obj) { } public static boolean isolatedClassIsIsolated(BObject obj) { - return obj.getType().isIsolated(); + return ((ObjectType) obj.getType()).isIsolated(); } public static boolean isolatedClassIsIsolatedFunction(BObject obj) { @@ -84,7 +84,7 @@ public static boolean isolatedClassIsIsolatedFunction(BObject obj) { } public static boolean isIsolatedFunctionWithName(BObject obj, BString method) { - ObjectType objectType = obj.getType(); + ObjectType objectType = (ObjectType) obj.getType(); return objectType.isIsolated() && objectType.isIsolated(method.getValue()); } @@ -104,7 +104,7 @@ public static long getNonIsolatedResourceB(Environment env, BObject obj) { } public static boolean nonIsolatedClassIsIsolated(BObject obj) { - return obj.getType().isIsolated(); + return ((ObjectType) obj.getType()).isIsolated(); } public static boolean nonIsolatedClassIsIsolatedFunction(BObject obj) { @@ -117,7 +117,7 @@ public static long isolatedServiceGetA(Environment env, BObject obj) { } public static boolean isolatedServiceIsIsolated(BObject obj) { - return obj.getType().isIsolated(); + return ((ObjectType) obj.getType()).isIsolated(); } public static boolean isolatedServiceIsIsolatedFunction(BObject obj) { @@ -130,7 +130,7 @@ public static long nonIsolatedServiceGetA(Environment env, BObject obj) { } public static boolean nonIsolatedServiceIsIsolated(BObject obj) { - return obj.getType().isIsolated(); + return ((ObjectType) obj.getType()).isIsolated(); } public static boolean nonIsolatedServiceIsIsolatedFunction(BObject obj) { @@ -238,7 +238,7 @@ private static boolean isResourceMethodIsolated(BObject obj) { } private static boolean isRemoteMethodIsolated(BObject obj) { - MethodType[] methods = obj.getType().getMethods(); + MethodType[] methods = ((ObjectType) obj.getType()).getMethods(); for (MethodType method : methods) { if (method.getName().equals("getA")) { return method.isIsolated(); diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Errors.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Errors.java index 27cb7d41d93a..c1b0ea299c3c 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Errors.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Errors.java @@ -27,6 +27,7 @@ import io.ballerina.runtime.api.types.ErrorType; import io.ballerina.runtime.api.types.TypeId; import io.ballerina.runtime.api.utils.StringUtils; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BError; import io.ballerina.runtime.api.values.BMap; @@ -55,7 +56,7 @@ public static BError getError(BString errorName) { } public static BArray getTypeIds(BError error) { - List typeIds = ((ErrorType) error.getType()).getTypeIdSet().getIds(); + List typeIds = ((ErrorType) TypeUtils.getReferredType(error.getType())).getTypeIdSet().getIds(); int size = typeIds.size(); BArray arrayValue = ValueCreator.createArrayValue(TypeCreator.createArrayType(PredefinedTypes.TYPE_STRING, size), size); diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java index 84781cddbf06..ca846190cd73 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java @@ -31,6 +31,7 @@ import io.ballerina.runtime.api.values.BError; import io.ballerina.runtime.api.values.BFunctionPointer; import io.ballerina.runtime.api.values.BMap; +import io.ballerina.runtime.api.values.BObject; import io.ballerina.runtime.api.values.BStream; import io.ballerina.runtime.api.values.BTypedesc; import io.ballerina.runtime.internal.types.BArrayType; @@ -137,9 +138,9 @@ public static Boolean validateRecordType(BTypedesc typedesc) { return true; } - public static Boolean validateStreamType(BTypedesc typedesc) { - BStreamType streamType = (BStreamType) ((ReferenceType) typedesc.getDescribingType()).getReferredType(); - BError error = ErrorCreator.createError(StringUtils.fromString("stream type API provided a non type reference" + + public static Boolean validateStreamType(BTypedesc value1, BStream value2) { + BStreamType streamType = (BStreamType) ((ReferenceType) value1.getDescribingType()).getReferredType(); + BError error = ErrorCreator.createError(StringUtils.fromString("stream API provided a non type reference" + " type.")); if (streamType.getConstrainedType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { throw error; @@ -148,6 +149,12 @@ public static Boolean validateStreamType(BTypedesc typedesc) { if (streamType.getCompletionType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { throw error; } + if (value2.getConstraintType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + if (value2.getCompletionType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } return true; } @@ -161,6 +168,9 @@ public static Boolean validateTableType(BTypedesc typedesc, TableValue tableValu if (tableValue.getKeyType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { throw error; } +// if (tableValue.getType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { +// throw error; +// } return true; } @@ -214,7 +224,7 @@ public static Boolean validateUnionType(BTypedesc typedesc) { public static Boolean validateParameterizedType(ObjectValue objectValue) { BError error = ErrorCreator.createError(StringUtils.fromString("parameterized type API provided a non type " + "reference type.")); - ObjectType objectType = objectValue.getType(); + ObjectType objectType = (ObjectType) objectValue.getType(); BFunctionType functionType = (BFunctionType) objectType.getMethods()[0].getType(); BParameterizedType parameterizedType = (BParameterizedType) ((UnionType) functionType.getReturnType()).getMemberTypes().get(0); @@ -243,18 +253,6 @@ public static Object getInt(ObjectValue objectValue, BTypedesc td) { return true; } - public static Boolean validateBStream(BStream value) { - BError error = ErrorCreator.createError(StringUtils.fromString("BStream getType API provided a non type " + - "reference type.")); - if (value.getConstraintType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { - throw error; - } - if (value.getCompletionType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { - throw error; - } - return true; - } - public static Boolean validateBArray(BArray value1, BArray value2) { BError error = ErrorCreator.createError(StringUtils.fromString("BArray getType API provided a non type " + "reference type.")); @@ -278,6 +276,15 @@ public static Boolean validateBMap(BMap value1, BMap value2) { return true; } + public static Boolean validateBError(BError value) { + BError error = ErrorCreator.createError(StringUtils.fromString("BError getType API provided a non type " + + "reference type.")); + if (value.getType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + return true; + } + public static Boolean validateBFunctionPointer(BFunctionPointer value) { BError error = ErrorCreator.createError(StringUtils.fromString("Function Pointer getType API provided a non " + "type reference type.")); @@ -287,4 +294,13 @@ public static Boolean validateBFunctionPointer(BFunctionPointer value) { return true; } + public static Boolean validateBObject(BObject value) { + BError error = ErrorCreator.createError(StringUtils.fromString("BObject getType API provided a non type " + + "reference type.")); + if (value.getType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + return true; + } + } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Values.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Values.java index 03f8935592b6..4d5aa4fbf08b 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Values.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Values.java @@ -128,7 +128,7 @@ public static BObject getObject(BString objectName) { } public static BArray getParameters(BObject object, BString methodName) { - ObjectType objectType = object.getType(); + ObjectType objectType = (ObjectType) object.getType(); Optional funcType = Arrays.stream(objectType.getMethods()) .filter(r -> r.getName().equals(methodName.getValue())).findAny(); TupleType tupleType = TypeCreator.createTupleType(List.of(PredefinedTypes.TYPE_STRING, @@ -153,7 +153,7 @@ public static BArray getParameters(BObject object, BString methodName) { } public static BString getFunctionString(BObject object, BString methodName) { - ObjectType objectType = object.getType(); + ObjectType objectType = (ObjectType) object.getType(); Optional funcType = Arrays.stream(objectType.getMethods()) .filter(r -> r.getName().equals(methodName.getValue())).findAny(); if (funcType.isPresent()) { @@ -193,7 +193,7 @@ public static BArray getConstituentTypes(BArray array) { } public static BArray getTypeIds(BObject bObject) { - List typeIds = bObject.getType().getTypeIdSet().getIds(); + List typeIds = ((ObjectType) bObject.getType()).getTypeIdSet().getIds(); int size = typeIds.size(); BArray arrayValue = ValueCreator.createArrayValue(TypeCreator.createArrayType(PredefinedTypes.TYPE_STRING, size), size); @@ -395,7 +395,7 @@ private static BError validateFunctionType(FunctionType functionType) { } public static Object validateFunctionParameterFromObject(BObject object) { - ObjectType type = object.getType(); + ObjectType type = (ObjectType) object.getType(); for (MethodType methodType : type.getMethods()) { if (methodType.getName() == "testFunction") { return validateFunctionType(methodType.getType()); diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/servicetests/ServiceValue.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/servicetests/ServiceValue.java index 6a6b376aba3b..c3673082e4fb 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/servicetests/ServiceValue.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/servicetests/ServiceValue.java @@ -76,7 +76,7 @@ public static BFuture callMethodWithParams(Environment env, BObject l, BString n } public static BArray getParamNames(BObject o, BString methodName) { - ObjectType type = o.getType(); + ObjectType type = (ObjectType) o.getType(); if (!(type instanceof ServiceType)) { return null; } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/object/ObjectInitializerTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/object/ObjectInitializerTest.java index 53e7f71e92d6..b52b1d286c80 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/object/ObjectInitializerTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/object/ObjectInitializerTest.java @@ -19,6 +19,7 @@ import io.ballerina.runtime.api.TypeTags; import io.ballerina.runtime.api.utils.StringUtils; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BError; import io.ballerina.runtime.api.values.BObject; @@ -120,12 +121,12 @@ public void testInitializerWithRestArgs() { public void testCustomErrorReturn() { BArray returns = (BArray) BRunUtil.invoke(compileResult, "testCustomErrorReturn"); - Assert.assertEquals(getType(returns.get(0)).getTag(), TypeTags.ERROR_TAG); + Assert.assertEquals(TypeUtils.getReferredType(getType(returns.get(0))).getTag(), TypeTags.ERROR_TAG); Assert.assertEquals(getType(returns.get(0)).getName(), "Err"); Assert.assertEquals(((BError) returns.get(0)).getMessage(), "Failed to create object"); Assert.assertEquals(((BError) returns.get(0)).getDetails().toString(), "{\"id\":100}"); - Assert.assertEquals(getType(returns.get(1)).getTag(), TypeTags.ERROR_TAG); + Assert.assertEquals(TypeUtils.getReferredType(getType(returns.get(1))).getTag(), TypeTags.ERROR_TAG); Assert.assertEquals(getType(returns.get(1)).getName(), "Err"); Assert.assertEquals(((BError) returns.get(1)).getMessage(), "Failed to create object"); Assert.assertEquals(((BError) returns.get(1)).getDetails().toString(), "{\"id\":100}"); @@ -141,11 +142,11 @@ public void testReturnedValWithTypeGuard() { public void testMultipleErrorReturn() { BArray returns = (BArray) BRunUtil.invoke(compileResult, "testMultipleErrorReturn"); - Assert.assertEquals(getType(returns.get(0)).getTag(), TypeTags.ERROR_TAG); + Assert.assertEquals(TypeUtils.getReferredType(getType(returns.get(0))).getTag(), TypeTags.ERROR_TAG); Assert.assertEquals(((BError) returns.get(0)).getMessage(), "Foo Error"); Assert.assertEquals(((BError) returns.get(0)).getDetails().toString(), "{\"f\":\"foo\"}"); - Assert.assertEquals(getType(returns.get(1)).getTag(), TypeTags.ERROR_TAG); + Assert.assertEquals(TypeUtils.getReferredType(getType(returns.get(1))).getTag(), TypeTags.ERROR_TAG); Assert.assertEquals(((BError) returns.get(1)).getMessage(), "Bar Error"); Assert.assertEquals(((BError) returns.get(1)).getDetails().toString(), "{\"b\":\"bar\"}"); } @@ -163,11 +164,11 @@ public void testCheckPanicInObjectInitArg() { @Test(description = "Test checkpanic expression in object init expr's argument") public void testCheckPanicObjectInit() { Object returns = BRunUtil.invoke(compileResult, "testCheckPanicObjectInit", new Object[]{(true)}); - Assert.assertEquals(getType(returns).getTag(), TypeTags.ERROR_TAG); + Assert.assertEquals(TypeUtils.getReferredType(getType(returns)).getTag(), TypeTags.ERROR_TAG); Assert.assertEquals(returns.toString(), "error FooErr (\"Foo Error\",f=\"foo\")"); returns = BRunUtil.invoke(compileResult, "testCheckPanicObjectInit", new Object[]{(false)}); - Assert.assertEquals(getType(returns).getTag(), TypeTags.ERROR_TAG); + Assert.assertEquals(TypeUtils.getReferredType(getType(returns)).getTag(), TypeTags.ERROR_TAG); Assert.assertEquals(returns.toString(), "error BarErr (\"Bar Error\",b=\"bar\")"); } diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal index 8484f7fbd36a..b8a6e0979fe1 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal @@ -39,7 +39,7 @@ type ErrorOrNil DetailedError?; type StreamType stream; -type TableType table key (id); +type TableType table key(id); type TupleType [PositiveInt, Detail, PositiveIntRef...]; @@ -74,6 +74,8 @@ class PositiveNumberGenerator { } } +type BObject Test; + function validateRuntimeAPIs() { boolean result = validateGetDetailType(DetailedError); test:assertTrue(result); @@ -90,7 +92,9 @@ function validateRuntimeAPIs() { result = validateRecordType(RecordType); test:assertTrue(result); - result = validateStreamType(StreamType); + PositiveNumberGenerator gen = new (); + StreamType s = new (gen); + result = validateStreamType(StreamType, s); test:assertTrue(result); TableType tab = table []; @@ -112,25 +116,27 @@ function validateRuntimeAPIs() { result = validateTypeUtilsAPI(PositiveInt); - PositiveNumberGenerator gen = new (); - StreamType s = new (gen); - result = validateBStream(s); - // BArray arr = [1, 2, 3]; // BTuple tup = [1, {id: 101, msg: "message", "priority": 2}]; - // result = validateBArray(arr, tup); // test:assertTrue(result); - // BMap m = {a: 1, b: 2, c: 3}; - // RecordType r = {id: 11, msg: "message", "intVal": 22}; - // result = validateBMap(m, r); + BMap m = {a: 1, b: 2, c: 3}; + RecordType r = {id: 11, msg: "message", "intVal": 22}; + result = validateBMap(m, r); + test:assertTrue(result); + + DetailedError err = error("This is error", id = 101, msg = "error message"); + result = validateBError(err); + test:assertTrue(result); + + // BObject obj = new (); + // result = validateBObject(obj); // test:assertTrue(result); // BFunctionPointer fp = testFunc; // result = validateBFunctionPointer(fp); // test:assertTrue(result); - } function testFunc(int a) returns int { @@ -157,7 +163,7 @@ public function validateRecordType(any value) returns boolean = @java:Method { 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" } external; -public function validateStreamType(any value) returns boolean = @java:Method { +public function validateStreamType(any value1, any value2) returns boolean = @java:Method { 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" } external; @@ -185,15 +191,19 @@ public function validateTypeUtilsAPI(any value) returns boolean = @java:Method { 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" } external; -public function validateBStream(any value) returns boolean = @java:Method { +public function validateBArray(any value1, any value2) returns boolean = @java:Method { 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" } external; -public function validateBArray(any value1, any value2) returns boolean = @java:Method { +public function validateBMap(any value1, any value2) returns boolean = @java:Method { 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" } external; -public function validateBMap(any value1, any value2) returns boolean = @java:Method { +public function validateBError(any|error value) returns boolean = @java:Method { + 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" +} external; + +public function validateBObject(any value) returns boolean = @java:Method { 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" } external; From 14d409425a7656a6afeb4d332ea881e418c8db03 Mon Sep 17 00:00:00 2001 From: HindujaB Date: Fri, 9 Sep 2022 10:26:27 +0530 Subject: [PATCH 009/450] Fix ConfigResolver class --- .../runtime/internal/configurable/ConfigResolver.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/configurable/ConfigResolver.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/configurable/ConfigResolver.java index 749dde6809e0..63ef3a6cc594 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/configurable/ConfigResolver.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/configurable/ConfigResolver.java @@ -132,18 +132,12 @@ private Function> getValueFunction(Module module, Va return configProvider -> configProvider.getAsTableAndMark(module, key); case TypeTags.ANYDATA_TAG: case TypeTags.UNION_TAG: -<<<<<<< HEAD + case TypeTags.JSON_TAG: return configProvider -> configProvider.getAsUnionAndMark(module, key); case TypeTags.TUPLE_TAG: return configProvider -> configProvider.getAsTupleAndMark(module, key); case TypeTags.TYPE_REFERENCED_TYPE_TAG: return getValueFunction(module, key, ((ReferenceType) type).getReferredType()); -======= - case TypeTags.JSON_TAG: - return configProvider -> configProvider.getAsUnionAndMark(module, key); - case TypeTags.TUPLE_TAG: - return configProvider -> configProvider.getAsTupleAndMark(module, key); ->>>>>>> e1b9318d0f9fbc395826c61840df51be26ac0899 case TypeTags.INTERSECTION_TAG: Type effectiveType = ((IntersectionType) type).getEffectiveType(); return getValueFunction(module, key, effectiveType); From 38c628d7091b6c931746696206a5e69c6f46f28b Mon Sep 17 00:00:00 2001 From: HindujaB Date: Fri, 9 Sep 2022 11:38:14 +0530 Subject: [PATCH 010/450] Fix CCE in Desugar --- .../org/wso2/ballerinalang/compiler/desugar/Desugar.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java index f89cbd745541..4b161e4ab60a 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java @@ -6797,13 +6797,14 @@ private BLangInvocation desugarStreamTypeInit(BLangTypeInit typeInitExpr) { BInvokableSymbol symbol = (BInvokableSymbol) symTable.langInternalModuleSymbol.scope .lookup(Names.CONSTRUCT_STREAM).symbol; - BType constraintType = ((BStreamType) typeInitExpr.getBType()).constraint; + BType bType = typeInitExpr.getBType(); + BType constraintType = ((BStreamType) Types.getReferredType(bType)).constraint; BType constraintTdType = new BTypedescType(constraintType, symTable.typeDesc.tsymbol); BLangTypedescExpr constraintTdExpr = new BLangTypedescExpr(); constraintTdExpr.resolvedType = constraintType; constraintTdExpr.setBType(constraintTdType); - BType completionType = ((BStreamType) typeInitExpr.getBType()).completionType; + BType completionType = ((BStreamType) Types.getReferredType(bType)).completionType; BType completionTdType = new BTypedescType(completionType, symTable.typeDesc.tsymbol); BLangTypedescExpr completionTdExpr = new BLangTypedescExpr(); completionTdExpr.resolvedType = completionType; From fc21ebbbe86769e5a3f0261aebe7bf20e1de187b Mon Sep 17 00:00:00 2001 From: HindujaB Date: Tue, 13 Sep 2022 17:27:45 +0530 Subject: [PATCH 011/450] Fix Array and Tuple values with type reference --- .../runtime/internal/TypeChecker.java | 18 ++++++- .../internal/ValueComparisonUtils.java | 5 +- .../internal/values/AbstractArrayValue.java | 7 +-- .../internal/values/ArrayValueImpl.java | 50 +++++++++++-------- .../internal/values/TupleValueImpl.java | 33 +++++++----- .../bir/codegen/JvmInstructionGen.java | 7 +-- .../compiler/bir/codegen/JvmSignatures.java | 10 ++-- .../compiler/bir/codegen/JvmValueGen.java | 9 ++-- .../langlib/value/CloneWithType.java | 28 ++++++----- .../api/types/modules/typeref/typeAPIs.bal | 8 +-- 10 files changed, 105 insertions(+), 70 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java index bdf898e8ec3b..0bbbc06d720a 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java @@ -2947,8 +2947,17 @@ private static boolean isEqual(Object lhsValue, Object rhsValue, List return false; } - int lhsValTypeTag = getType(lhsValue).getTag(); - int rhsValTypeTag = getType(rhsValue).getTag(); + return checkValueEquals(lhsValue, rhsValue, checkedValues, getType(lhsValue), getType(rhsValue)); + } + + private static boolean checkValueEquals(Object lhsValue, Object rhsValue, List checkedValues, + Type lhsValType, Type rhsValType) { + int lhsValTypeTag = lhsValType.getTag(); + int rhsValTypeTag = rhsValType.getTag(); + if (rhsValTypeTag == TypeTags.TYPE_REFERENCED_TYPE_TAG) { + rhsValType = ((BTypeReferenceType) rhsValType).getReferredType(); + rhsValTypeTag = rhsValType.getTag(); + } switch (lhsValTypeTag) { case TypeTags.STRING_TAG: @@ -3008,6 +3017,11 @@ private static boolean isEqual(Object lhsValue, Object rhsValue, List case TypeTags.TABLE_TAG: return rhsValTypeTag == TypeTags.TABLE_TAG && isEqual((TableValueImpl) lhsValue, (TableValueImpl) rhsValue, checkedValues); + case TypeTags.TYPE_REFERENCED_TYPE_TAG: + return checkValueEquals(lhsValue, rhsValue, checkedValues, + ((BTypeReferenceType) lhsValType).getReferredType(), rhsValType); + default: + return false; } return false; } diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/ValueComparisonUtils.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/ValueComparisonUtils.java index f1eee55f3c3a..cc915edb2039 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/ValueComparisonUtils.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/ValueComparisonUtils.java @@ -19,6 +19,7 @@ package io.ballerina.runtime.internal; import io.ballerina.runtime.api.TypeTags; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BError; import io.ballerina.runtime.internal.values.DecimalValue; @@ -179,8 +180,8 @@ private static int compareFloatValues(double lhsValue, double rhsValue) { * 0 left hand side value = right hand side value */ public static int compareValues(Object lhsValue, Object rhsValue, String direction) { - int lhsTypeTag = TypeChecker.getType(lhsValue).getTag(); - int rhsTypeTag = TypeChecker.getType(rhsValue).getTag(); + int lhsTypeTag = TypeUtils.getReferredType(TypeChecker.getType(lhsValue)).getTag(); + int rhsTypeTag = TypeUtils.getReferredType(TypeChecker.getType(rhsValue)).getTag(); boolean inRelationalExpr = false; if (direction.isEmpty()) { inRelationalExpr = true; diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/AbstractArrayValue.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/AbstractArrayValue.java index 25b2a257ffa1..ed5ef3fe4fe2 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/AbstractArrayValue.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/AbstractArrayValue.java @@ -20,6 +20,7 @@ import io.ballerina.runtime.api.TypeTags; import io.ballerina.runtime.api.creators.ErrorCreator; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.internal.IteratorUtils; import io.ballerina.runtime.internal.JsonGenerator; import io.ballerina.runtime.internal.types.BTupleType; @@ -162,11 +163,11 @@ public long getLength() { } protected void initializeIteratorNextReturnType() { - Type type; - if (getType().getTag() == TypeTags.ARRAY_TAG) { + Type type = TypeUtils.getReferredType(getType()); + if (type.getTag() == TypeTags.ARRAY_TAG) { type = getElementType(); } else { - BTupleType tupleType = (BTupleType) getType(); + BTupleType tupleType = (BTupleType) type; LinkedHashSet types = new LinkedHashSet<>(tupleType.getTupleTypes()); if (tupleType.getRestType() != null) { types.add(tupleType.getRestType()); diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ArrayValueImpl.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ArrayValueImpl.java index 0aac8971439c..3f9ca83da526 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ArrayValueImpl.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ArrayValueImpl.java @@ -71,6 +71,7 @@ public class ArrayValueImpl extends AbstractArrayValue { private Type elementReferredType; + protected Type type; protected ArrayType arrayType; protected Type elementType; private TypedescValue elementTypedescValue = null; @@ -86,41 +87,41 @@ public class ArrayValueImpl extends AbstractArrayValue { public ArrayValueImpl(Object[] values, ArrayType type) { this.refValues = values; - this.arrayType = type; + this.type = this.arrayType = type; this.size = values.length; if (type.getTag() == TypeTags.ARRAY_TAG) { this.elementType = type.getElementType(); this.elementReferredType = TypeUtils.getReferredType(this.elementType); } - this.typedesc = getTypedescValue(arrayType, this); + this.typedesc = getTypedescValue(type, this); } public ArrayValueImpl(long[] values, boolean readonly) { this.intValues = values; this.size = values.length; setArrayType(PredefinedTypes.TYPE_INT, readonly); - this.typedesc = getTypedescValue(arrayType, this); + this.typedesc = getTypedescValue(type, this); } public ArrayValueImpl(boolean[] values, boolean readonly) { this.booleanValues = values; this.size = values.length; setArrayType(PredefinedTypes.TYPE_BOOLEAN, readonly); - this.typedesc = getTypedescValue(arrayType, this); + this.typedesc = getTypedescValue(type, this); } public ArrayValueImpl(byte[] values, boolean readonly) { this.byteValues = values; this.size = values.length; setArrayType(PredefinedTypes.TYPE_BYTE, readonly); - this.typedesc = getTypedescValue(arrayType, this); + this.typedesc = getTypedescValue(type, this); } public ArrayValueImpl(double[] values, boolean readonly) { this.floatValues = values; this.size = values.length; setArrayType(PredefinedTypes.TYPE_FLOAT, readonly); - this.typedesc = getTypedescValue(arrayType, this); + this.typedesc = getTypedescValue(type, this); } public ArrayValueImpl(String[] values, boolean readonly) { @@ -130,25 +131,25 @@ public ArrayValueImpl(String[] values, boolean readonly) { bStringValues[i] = StringUtils.fromString(values[i]); } setArrayType(PredefinedTypes.TYPE_STRING, readonly); - this.typedesc = getTypedescValue(arrayType, this); + this.typedesc = getTypedescValue(type, this); } public ArrayValueImpl(BString[] values, boolean readonly) { this.bStringValues = values; this.size = values.length; setArrayType(PredefinedTypes.TYPE_STRING, readonly); - this.typedesc = getTypedescValue(arrayType, this); + this.typedesc = getTypedescValue(type, this); } public ArrayValueImpl(ArrayType type) { - this.arrayType = type; + this.type = this.arrayType = type; this.elementType = type.getElementType(); this.elementReferredType = TypeUtils.getReferredType(this.elementType); initArrayValues(); if (type.getState() == ArrayState.CLOSED) { this.size = maxSize = type.getSize(); } - this.typedesc = getTypedescValue(arrayType, this); + this.typedesc = getTypedescValue(type, this); } private void initArrayValues() { @@ -248,24 +249,30 @@ public Object reverse() { } public ArrayValueImpl(ArrayType type, long size) { - this.arrayType = type; + this.type = this.arrayType = type; this.elementType = type.getElementType(); this.elementReferredType = TypeUtils.getReferredType(this.elementType); initArrayValues(); if (size != -1) { this.size = this.maxSize = (int) size; } - this.typedesc = getTypedescValue(arrayType, this); + this.typedesc = getTypedescValue(type, this); + } + + // Used when the array value is created from a type reference type + public ArrayValueImpl(Type type, long size, BListInitialValueEntry[] initialValues) { + this(type, size, initialValues, null); } public ArrayValueImpl(ArrayType type, long size, BListInitialValueEntry[] initialValues) { this(type, size, initialValues, null); } - public ArrayValueImpl(ArrayType type, long size, BListInitialValueEntry[] initialValues, + public ArrayValueImpl(Type type, long size, BListInitialValueEntry[] initialValues, TypedescValue typedescValue) { - this.arrayType = type; - this.elementType = type.getElementType(); + this.type = type; + this.arrayType = (ArrayType) TypeUtils.getReferredType(type); + this.elementType = arrayType.getElementType(); this.elementReferredType = TypeUtils.getReferredType(this.elementType); this.elementTypedescValue = typedescValue; initArrayValues(); @@ -286,7 +293,7 @@ public ArrayValueImpl(ArrayType type, long size, BListInitialValueEntry[] initia } } - this.typedesc = getTypedescValue(arrayType, this); + this.typedesc = getTypedescValue(type, this); } // ----------------------- get methods ---------------------------------------------------- @@ -761,7 +768,7 @@ public String expressionStringValue(BLink parent) { @Override public Type getType() { - return this.arrayType; + return this.type; } @Override @@ -975,7 +982,10 @@ public void freezeDirect() { return; } - this.arrayType = (ArrayType) ReadOnlyUtils.setImmutableTypeAndGetEffectiveType(this.arrayType); +// this.arrayType = (ArrayType) ReadOnlyUtils.setImmutableTypeAndGetEffectiveType(this.arrayType); + this.type = ReadOnlyUtils.setImmutableTypeAndGetEffectiveType(this.type); + this.arrayType = (ArrayType) TypeUtils.getReferredType(type); + if (this.elementType == null || this.elementReferredType.getTag() > TypeTags.BOOLEAN_TAG) { for (int i = 0; i < this.size; i++) { Object value = this.getRefValue(i); @@ -1210,7 +1220,7 @@ private void fillRead(long index, int currentArraySize) { } private void setArrayType(Type elementType, boolean readonly) { - this.arrayType = new BArrayType(elementType, -1, readonly, 6); + this.type = this.arrayType = new BArrayType(elementType, -1, readonly, 6); this.elementType = elementType; this.elementReferredType = TypeUtils.getReferredType(this.elementType); } @@ -1293,7 +1303,7 @@ private int getCurrentArrayLength() { @Override public int hashCode() { - int result = Objects.hash(arrayType, elementType); + int result = Objects.hash(type, elementType); result = 31 * result + Arrays.hashCode(refValues); result = 31 * result + Arrays.hashCode(intValues); result = 31 * result + Arrays.hashCode(booleanValues); diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TupleValueImpl.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TupleValueImpl.java index 645c3e06bd46..4aba36372d68 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TupleValueImpl.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TupleValueImpl.java @@ -22,6 +22,7 @@ import io.ballerina.runtime.api.types.TupleType; import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.utils.StringUtils; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BIterator; import io.ballerina.runtime.api.values.BLink; @@ -66,6 +67,7 @@ public class TupleValueImpl extends AbstractArrayValue { protected TupleType tupleType; + protected Type type; Object[] refValues; private int minSize; private boolean hasRestElement; // cached value for ease of access @@ -85,20 +87,20 @@ public boolean equals(Object o) { TupleValueImpl that = (TupleValueImpl) o; return minSize == that.minSize && hasRestElement == that.hasRestElement && - tupleType.equals(that.tupleType) && + type.equals(that.type) && Arrays.equals(refValues, that.refValues); } @Override public int hashCode() { - int result = Objects.hash(tupleType, minSize, hasRestElement); + int result = Objects.hash(type, tupleType, minSize, hasRestElement); result = 31 * result + Arrays.hashCode(refValues); return result; } public TupleValueImpl(Object[] values, TupleType type) { this.refValues = values; - this.tupleType = type; + this.type = this.tupleType = type; this.hasRestElement = this.tupleType.getRestType() != null; List memTypes = type.getTupleTypes(); @@ -112,11 +114,11 @@ public TupleValueImpl(Object[] values, TupleType type) { } this.minSize = memTypes.size(); this.size = refValues.length; - this.typedesc = getTypedescValue(tupleType, this); + this.typedesc = getTypedescValue(type, this); } public TupleValueImpl(TupleType type) { - this.tupleType = type; + this.type = this.tupleType = type; List memTypes = this.tupleType.getTupleTypes(); int memTypeCount = memTypes.size(); @@ -138,16 +140,22 @@ public TupleValueImpl(TupleType type) { } this.refValues[i] = memType.getZeroValue(); } - this.typedesc = getTypedescValue(tupleType, this); + this.typedesc = getTypedescValue(type, this); } + public TupleValueImpl(Type type, long size, BListInitialValueEntry[] initialValues) { + this((TupleType) TypeUtils.getReferredType(type), size, initialValues); + this.type = type; + } + + public TupleValueImpl(TupleType type, long size, BListInitialValueEntry[] initialValues) { - this.tupleType = type; + this.type = this.tupleType = type; List memTypes = this.tupleType.getTupleTypes(); int memCount = memTypes.size(); - if (type.getRestType() != null) { + if (tupleType.getRestType() != null) { int valueCount = 0; for (BListInitialValueEntry listEntry : initialValues) { if (listEntry instanceof ListInitialValueEntry.ExpressionEntry) { @@ -186,7 +194,7 @@ public TupleValueImpl(TupleType type, long size, BListInitialValueEntry[] initia } if (index >= memCount) { - this.typedesc = getTypedescValue(tupleType, this); + this.typedesc = getTypedescValue(type, this); return; } @@ -198,7 +206,7 @@ public TupleValueImpl(TupleType type, long size, BListInitialValueEntry[] initia this.refValues[i] = memType.getZeroValue(); } - this.typedesc = getTypedescValue(tupleType, this); + this.typedesc = getTypedescValue(type, this); } @Override @@ -467,7 +475,7 @@ public String expressionStringValue(BLink parent) { @Override public Type getType() { - return this.tupleType; + return this.type; } @Override @@ -583,7 +591,8 @@ public void freezeDirect() { return; } - this.tupleType = (TupleType) ReadOnlyUtils.setImmutableTypeAndGetEffectiveType(this.tupleType); + this.type = ReadOnlyUtils.setImmutableTypeAndGetEffectiveType(this.type); + this.tupleType = (TupleType) TypeUtils.getReferredType(type); for (int i = 0; i < this.size; i++) { Object value = this.get(i); if (value instanceof RefValue) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java index 1376bf5f1510..be57a3a19e95 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java @@ -41,7 +41,6 @@ import org.wso2.ballerinalang.compiler.bir.model.VarKind; import org.wso2.ballerinalang.compiler.semantics.analyzer.Types; import org.wso2.ballerinalang.compiler.semantics.model.SymbolTable; -import org.wso2.ballerinalang.compiler.semantics.model.symbols.BTypeSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.SchedulerPolicy; import org.wso2.ballerinalang.compiler.semantics.model.types.BArrayType; import org.wso2.ballerinalang.compiler.semantics.model.types.BIntersectionType; @@ -1474,7 +1473,7 @@ void generateArrayNewIns(BIRNonTerminator.NewArray inst) { if (instType.tag == TypeTags.ARRAY) { this.mv.visitTypeInsn(NEW, ARRAY_VALUE_IMPL); this.mv.visitInsn(DUP); - jvmTypeGen.loadType(this.mv, instType); + jvmTypeGen.loadType(this.mv, inst.type); this.loadVar(inst.sizeOp.variableDcl); loadListInitialValues(inst); BType elementType = JvmCodeGenUtil.getReferredType(((BArrayType) instType).eType); @@ -1490,7 +1489,7 @@ void generateArrayNewIns(BIRNonTerminator.NewArray inst) { } else { this.mv.visitTypeInsn(NEW, TUPLE_VALUE_IMPL); this.mv.visitInsn(DUP); - jvmTypeGen.loadType(this.mv, instType); + jvmTypeGen.loadType(this.mv, inst.type); this.loadVar(inst.sizeOp.variableDcl); loadListInitialValues(inst); this.mv.visitMethodInsn(INVOKESPECIAL, TUPLE_VALUE_IMPL, JVM_INIT_METHOD, INIT_TUPLE, false); @@ -1502,8 +1501,6 @@ private void visitNewRecordArray(BType type) { BType elementType = JvmCodeGenUtil.getReferredType(type); elementType = elementType.tag == TypeTags.INTERSECTION ? ((BIntersectionType) elementType).effectiveType : elementType; - BTypeSymbol tsymbol = elementType.tag == TypeTags.RECORD ? elementType.tsymbol : - ((BIntersectionType) elementType).effectiveType.tsymbol; String typeOwner = JvmCodeGenUtil.getPackageName(type.tsymbol.pkgID) + MODULE_INIT_CLASS_NAME; String typedescFieldName = jvmTypeGen.getTypedescFieldName(toNameString(elementType)); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java index d49b8c0868cc..549435d426bf 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java @@ -20,7 +20,6 @@ import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.ANYDATA_TYPE; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.ANY_TYPE; -import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.ARRAY_TYPE; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.ARRAY_TYPE_IMPL; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.ARRAY_VALUE; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.BAL_ENV; @@ -99,7 +98,6 @@ import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TABLE_VALUE; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TABLE_VALUE_IMPL; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.THROWABLE; -import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TUPLE_TYPE; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TUPLE_TYPE_IMPL; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TYPE; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TYPEDESC_VALUE; @@ -255,10 +253,10 @@ public class JvmSignatures { public static final String HANDLE_WAIT_MULTIPLE = "(L" + MAP + ";L" + MAP_VALUE + ";)V"; public static final String HANDLE_WORKER_ERROR = "(L" + REF_VALUE + ";L" + STRAND_CLASS + ";[L" + CHANNEL_DETAILS + ";)V"; - public static final String INIT_ARRAY = "(L" + ARRAY_TYPE + ";J[L" + B_LIST_INITIAL_VALUE_ENTRY + ";)V"; + public static final String INIT_ARRAY = "(L" + TYPE + ";J[L" + B_LIST_INITIAL_VALUE_ENTRY + ";)V"; public static final String INIT_ARRAY_TYPE_IMPL = "(L" + TYPE + ";IZI)V"; - public static final String INIT_ARRAY_WITH_INITIAL_VALUES = - "(L" + ARRAY_TYPE + ";J[L" + B_LIST_INITIAL_VALUE_ENTRY + ";L" + TYPEDESC_VALUE + ";)V"; + public static final String INIT_ARRAY_WITH_INITIAL_VALUES = "(L" + TYPE + ";J[L" + B_LIST_INITIAL_VALUE_ENTRY + + ";L" + TYPEDESC_VALUE + ";)V"; public static final String INIT_BAL_ENV = "(L" + STRAND_CLASS + ";L" + MODULE + ";)V"; public static final String INIT_CHANNEL_DETAILS = "(L" + STRING_VALUE + ";ZZ)V"; public static final String INIT_CLI_SPEC = "(L" + OPTION + ";[L" + OPERAND + ";[L" + STRING_VALUE + ";)V"; @@ -296,7 +294,7 @@ public class JvmSignatures { public static final String INIT_TABLE_TYPE_WITH_FIELD_NAME_LIST = "(L" + TYPE + ";[L" + STRING_VALUE + ";Z)V"; public static final String INIT_TABLE_VALUE_IMPL = "(L" + TABLE_TYPE + ";L" + ARRAY_VALUE + ";L" + ARRAY_VALUE + ";)V"; - public static final String INIT_TUPLE = "(L" + TUPLE_TYPE + ";J[L" + B_LIST_INITIAL_VALUE_ENTRY + ";)V"; + public static final String INIT_TUPLE = "(L" + TYPE + ";J[L" + B_LIST_INITIAL_VALUE_ENTRY + ";)V"; public static final String INIT_TUPLE_TYPE_IMPL = "(L" + STRING_VALUE + ";L" + MODULE + ";IZZ)V"; public static final String INIT_TYPEDESC = "(L" + TYPEDESC_VALUE + ";)V"; public static final String INIT_UNION_TYPE_IMPL = "(L" + STRING_VALUE + ";L" + MODULE + ";IZJ)V"; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmValueGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmValueGen.java index 0a320f72f00c..f8f8657e9e41 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmValueGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmValueGen.java @@ -214,11 +214,14 @@ public static boolean isOptionalRecordField(BField field) { void generateValueClasses(Map jarEntries, JvmConstantsGen jvmConstantsGen) { String packageName = JvmCodeGenUtil.getPackageName(module.packageID); module.typeDefs.forEach(optionalTypeDef -> { - BType bType = JvmCodeGenUtil.getReferredType(optionalTypeDef.type); + if (optionalTypeDef.type.tag == TypeTags.TYPEREFDESC) { + return; + } + BType bType = optionalTypeDef.type; String className = getTypeValueClassName(packageName, optionalTypeDef.internalName.value); AsyncDataCollector asyncDataCollector = new AsyncDataCollector(className); - if (bType.tag == TypeTags.OBJECT && Symbols.isFlagOn(bType.tsymbol.flags, Flags.CLASS)) { - BObjectType objectType = (BObjectType) bType; + if (optionalTypeDef.type.tag == TypeTags.OBJECT && Symbols.isFlagOn(optionalTypeDef.type.tsymbol.flags, Flags.CLASS)) { + BObjectType objectType = (BObjectType) optionalTypeDef.type; byte[] bytes = this.createObjectValueClass(objectType, className, optionalTypeDef, jvmConstantsGen , asyncDataCollector); jarEntries.put(className + ".class", bytes); diff --git a/langlib/lang.value/src/main/java/org/ballerinalang/langlib/value/CloneWithType.java b/langlib/lang.value/src/main/java/org/ballerinalang/langlib/value/CloneWithType.java index 1d2c5b672303..4f30476e0b8d 100644 --- a/langlib/lang.value/src/main/java/org/ballerinalang/langlib/value/CloneWithType.java +++ b/langlib/lang.value/src/main/java/org/ballerinalang/langlib/value/CloneWithType.java @@ -153,34 +153,36 @@ private static Object convert(BRefValue value, Type targetType, List unresolvedValues, BTypedesc t) { + switch (sourceType.getTag()) { case TypeTags.MAP_TAG: case TypeTags.RECORD_TYPE_TAG: - newValue = convertMap((BMap) value, targetType, unresolvedValues, t); - break; + return convertMap((BMap) value, targetType, unresolvedValues, t); case TypeTags.ARRAY_TAG: case TypeTags.TUPLE_TAG: - newValue = convertArray((BArray) value, targetType, unresolvedValues, t); - break; + return convertArray((BArray) value, targetType, unresolvedValues, t); case TypeTags.TABLE_TAG: - newValue = convertTable((BTable) value, targetType, unresolvedValues, t); - break; + return convertTable((BTable) value, targetType, unresolvedValues, t); case TypeTags.XML_TAG: case TypeTags.XML_ELEMENT_TAG: case TypeTags.XML_COMMENT_TAG: case TypeTags.XML_PI_TAG: case TypeTags.XML_TEXT_TAG: case TypeTags.ERROR_TAG: - newValue = value.copy(new HashMap<>()); - break; + return value.copy(new HashMap<>()); + case TypeTags.TYPE_REFERENCED_TYPE_TAG: + return getConvertedObject(value, ((ReferenceType) sourceType).getReferredType(), targetType, + unresolvedValues, t); default: // should never reach here throw createConversionError(value, targetType); } - - unresolvedValues.remove(typeValuePair); - return newValue; } private static Object convertMap(BMap map, Type targetType, List unresolvedValues, diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal index b8a6e0979fe1..6c48d033c556 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal @@ -116,10 +116,10 @@ function validateRuntimeAPIs() { result = validateTypeUtilsAPI(PositiveInt); - // BArray arr = [1, 2, 3]; - // BTuple tup = [1, {id: 101, msg: "message", "priority": 2}]; - // result = validateBArray(arr, tup); - // test:assertTrue(result); + BArray arr = [1, 2, 3]; + BTuple tup = [1, {id: 101, msg: "message", "priority": 2}]; + result = validateBArray(arr, tup); + test:assertTrue(result); BMap m = {a: 1, b: 2, c: 3}; RecordType r = {id: 11, msg: "message", "intVal": 22}; From 5b09f13143a2fce57e517ee24d0acc759c1e66f5 Mon Sep 17 00:00:00 2001 From: HindujaB Date: Tue, 13 Sep 2022 23:30:12 +0530 Subject: [PATCH 012/450] Fix checkStyle error --- .../org/wso2/ballerinalang/compiler/bir/BIRGen.java | 11 ++++++----- .../compiler/bir/codegen/JvmValueGen.java | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java index abfb6ff6c599..9d2263e3a40a 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java @@ -2410,11 +2410,12 @@ private void generateListConstructorExpr(BLangListConstructorExpr listConstructo long size = -1L; List exprs = listConstructorExpr.exprs; - BType listConstructorExprType = Types.getReferredType(listConstructorExpr.getBType()); - if (listConstructorExprType.tag == TypeTags.ARRAY && - ((BArrayType) listConstructorExprType).state != BArrayState.OPEN) { - size = ((BArrayType) listConstructorExprType).size; - } else if (listConstructorExprType.tag == TypeTags.TUPLE) { + BType listConstructorExprType = listConstructorExpr.getBType(); + BType referredType = Types.getReferredType(listConstructorExprType); + if (referredType.tag == TypeTags.ARRAY && + ((BArrayType) referredType).state != BArrayState.OPEN) { + size = ((BArrayType) referredType).size; + } else if (referredType.tag == TypeTags.TUPLE) { size = exprs.size(); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmValueGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmValueGen.java index f8f8657e9e41..171be0aa0b0a 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmValueGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmValueGen.java @@ -220,7 +220,8 @@ void generateValueClasses(Map jarEntries, JvmConstantsGen jvmCon BType bType = optionalTypeDef.type; String className = getTypeValueClassName(packageName, optionalTypeDef.internalName.value); AsyncDataCollector asyncDataCollector = new AsyncDataCollector(className); - if (optionalTypeDef.type.tag == TypeTags.OBJECT && Symbols.isFlagOn(optionalTypeDef.type.tsymbol.flags, Flags.CLASS)) { + if (optionalTypeDef.type.tag == TypeTags.OBJECT && + Symbols.isFlagOn(optionalTypeDef.type.tsymbol.flags, Flags.CLASS)) { BObjectType objectType = (BObjectType) optionalTypeDef.type; byte[] bytes = this.createObjectValueClass(objectType, className, optionalTypeDef, jvmConstantsGen , asyncDataCollector); From d74994566075e60af412b58912a763ae27363a6b Mon Sep 17 00:00:00 2001 From: HindujaB Date: Wed, 14 Sep 2022 10:51:45 +0530 Subject: [PATCH 013/450] Fix function pointers type-reference --- .../compiler/bir/codegen/JvmInstructionGen.java | 2 ++ .../wso2/ballerinalang/compiler/desugar/Desugar.java | 5 +++++ .../runtime/api/types/modules/typeref/typeAPIs.bal | 10 +++++++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java index be57a3a19e95..6b456171fc2d 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java @@ -1732,6 +1732,8 @@ void generateFPLoadIns(BIRNonTerminator.FPLoad inst) { JvmCodeGenUtil.visitInvokeDynamic(mv, asyncDataCollector.getEnclosingClass(), lambdaName, inst.closureMaps.size()); + type = inst.lhsOp.variableDcl.type.tag == TypeTags.TYPEREFDESC ? inst.lhsOp.variableDcl.type : type; + jvmTypeGen.loadType(this.mv, type); if (inst.strandName != null) { mv.visitLdcInsn(inst.strandName); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java index 4b161e4ab60a..11b2b35a5617 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java @@ -9150,6 +9150,11 @@ BLangExpression addConversionExprIfRequired(BLangExpression expr, BType lhsType) } BType rhsType = expr.getBType(); + + if (lhsType.tag == TypeTags.TYPEREFDESC && rhsType.tag != TypeTags.TYPEREFDESC) { + return addConversionExprIfRequired(expr, Types.getReferredType(lhsType)); + } + if (types.isSameType(rhsType, lhsType)) { return expr; } diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal index 6c48d033c556..a36dc6c80dc3 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal @@ -134,9 +134,13 @@ function validateRuntimeAPIs() { // result = validateBObject(obj); // test:assertTrue(result); - // BFunctionPointer fp = testFunc; - // result = validateBFunctionPointer(fp); - // test:assertTrue(result); + BFunctionPointer fp = testFunc; + result = validateBFunctionPointer(fp); + test:assertTrue(result); + + fp = (i) => 5 * i; + result = validateBFunctionPointer(fp); + test:assertTrue(result); } function testFunc(int a) returns int { From 0818a78bdc36e1c32a5648420b9a89dc81499722 Mon Sep 17 00:00:00 2001 From: prakanth <50439067+prakanth97@users.noreply.github.com> Date: Fri, 16 Sep 2022 00:43:13 +0530 Subject: [PATCH 014/450] Recover type reference information for object --- .../wso2/ballerinalang/compiler/bir/BIRGen.java | 8 ++++---- .../ballerinalang/compiler/desugar/Desugar.java | 6 +++--- .../compiler/semantics/analyzer/TypeChecker.java | 15 ++++++++------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java index 1df503a04cfd..0d133f26c4ed 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java @@ -2547,12 +2547,12 @@ private void generateMappingAccess(BLangIndexBasedAccess astIndexBasedAccessExpr private BTypeSymbol getObjectTypeSymbol(BType objType) { BType type = Types.getReferredType(objType); if (type.tag == TypeTags.UNION) { - return ((BUnionType) type).getMemberTypes().stream() - .filter(t -> t.tag == TypeTags.OBJECT) + return Types.getReferredType(((BUnionType) type).getMemberTypes().stream() + .filter(t -> Types.getReferredType(t).tag == TypeTags.OBJECT) .findFirst() - .orElse(symTable.noType).tsymbol; + .orElse(symTable.noType)).tsymbol; } - return type.tsymbol; + return Types.getReferredType(type).tsymbol; } private BIROperand generateStringLiteral(String value) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java index f5fb9d631b8b..b4fbdce2a366 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java @@ -6732,7 +6732,7 @@ private BLangStatementExpression desugarObjectTypeInit(BLangTypeInit typeInitExp blockStmt.addStatement(objVarDef); BLangInvocation typeInitInvocation = typeInitExpr.initInvocation; typeInitInvocation.exprSymbol = objVarDef.var.symbol; - typeInitInvocation.symbol = ((BObjectTypeSymbol) objType.tsymbol).generatedInitializerFunc.symbol; + typeInitInvocation.symbol = ((BObjectTypeSymbol) Types.getReferredType(objType).tsymbol).generatedInitializerFunc.symbol; typeInitInvocation.objectInitMethod = true; @@ -6841,10 +6841,10 @@ private BLangSimpleVariableDef createVarDef(String name, BType type, BLangExpres private BType getObjectType(BType bType) { BType type = Types.getReferredType(bType); if (type.tag == TypeTags.OBJECT) { - return type; + return bType; } else if (type.tag == TypeTags.UNION) { return ((BUnionType) type).getMemberTypes().stream() - .filter(t -> t.tag == TypeTags.OBJECT) + .filter(t -> Types.getReferredType(t).tag == TypeTags.OBJECT) .findFirst() .orElse(symTable.noType); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java index 7972f8cac9c0..efee983f9755 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java @@ -4226,15 +4226,16 @@ private BType checkObjectCompatibility(BType actualType, BLangTypeInit cIExpr, A BType matchedType = getMatchingType(matchingMembers, cIExpr, actualType, data); cIExpr.initInvocation.setBType(symTable.nilType); - if (matchedType.tag == TypeTags.OBJECT) { - if (((BObjectTypeSymbol) matchedType.tsymbol).initializerFunc != null) { - cIExpr.initInvocation.symbol = ((BObjectTypeSymbol) matchedType.tsymbol).initializerFunc.symbol; + BType referredMatchedType = Types.getReferredType(matchedType); + if (referredMatchedType.tag == TypeTags.OBJECT) { + if (((BObjectTypeSymbol) referredMatchedType.tsymbol).initializerFunc != null) { + cIExpr.initInvocation.symbol = ((BObjectTypeSymbol) referredMatchedType.tsymbol).initializerFunc.symbol; checkInvocationParam(cIExpr.initInvocation, data); cIExpr.initInvocation.setBType(((BInvokableSymbol) cIExpr.initInvocation.symbol).retType); actualType = matchedType; break; } else { - if (!isValidInitInvocation(cIExpr, (BObjectType) matchedType, data)) { + if (!isValidInitInvocation(cIExpr, (BObjectType) referredMatchedType, data)) { return symTable.semanticError; } } @@ -4359,12 +4360,12 @@ private List findMembersWithMatchingInitFunc(BLangTypeInit cIExpr, BUnion } if (containsSingleObject) { - return Collections.singletonList(memberType); + return Collections.singletonList(type); } BAttachedFunction initializerFunc = ((BObjectTypeSymbol) memberType.tsymbol).initializerFunc; if (isArgsMatchesFunction(cIExpr.argsExpr, initializerFunc, data)) { - matchingLhsMemberTypes.add(memberType); + matchingLhsMemberTypes.add(type); } } return matchingLhsMemberTypes; @@ -4379,7 +4380,7 @@ private BType getMatchingType(List matchingLhsMembers, BLangTypeInit cIEx return symTable.semanticError; } else if (matchingLhsMembers.size() == 1) { // We have a correct match. - return matchingLhsMembers.get(0).tsymbol.type; + return matchingLhsMembers.get(0); } else { // Multiple matches found. dlog.error(cIExpr.pos, DiagnosticErrorCode.AMBIGUOUS_TYPES, lhsUnion); From 6ca1027f21db7fe9bc36889c858e9883382826c8 Mon Sep 17 00:00:00 2001 From: prakanth <50439067+prakanth97@users.noreply.github.com> Date: Mon, 19 Sep 2022 12:35:02 +0530 Subject: [PATCH 015/450] Recover type reference information for table --- .../java/org/wso2/ballerinalang/compiler/bir/BIRGen.java | 5 +++-- .../compiler/semantics/analyzer/TypeChecker.java | 9 ++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java index 0d133f26c4ed..63deabfcb821 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java @@ -2178,7 +2178,7 @@ public void visit(BLangTableConstructorExpr tableConstructorExpr) { keySpecifierLiteral.pos = tableConstructorExpr.pos; keySpecifierLiteral.setBType(symTable.stringArrayType); keySpecifierLiteral.exprs = new ArrayList<>(); - BTableType type = (BTableType) tableConstructorExpr.getBType(); + BTableType type = (BTableType) Types.getReferredType(tableConstructorExpr.getBType()); if (!type.fieldNameList.isEmpty()) { type.fieldNameList.forEach(col -> { @@ -2195,7 +2195,8 @@ public void visit(BLangTableConstructorExpr tableConstructorExpr) { BLangArrayLiteral dataLiteral = new BLangArrayLiteral(); dataLiteral.pos = tableConstructorExpr.pos; - dataLiteral.setBType(new BArrayType(((BTableType) tableConstructorExpr.getBType()).constraint)); + dataLiteral.setBType( + new BArrayType(((BTableType) Types.getReferredType(tableConstructorExpr.getBType())).constraint)); dataLiteral.exprs = new ArrayList<>(tableConstructorExpr.recordLiteralList); dataLiteral.accept(this); BIROperand dataOp = this.env.targetOperand; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java index efee983f9755..ff46425f9d93 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java @@ -1132,7 +1132,14 @@ public void visit(BLangTableConstructorExpr tableConstructorExpr, AnalyzerData d if (!expectedTableType.fieldNameList.isEmpty() && tableType.fieldNameList.isEmpty()) { tableType.fieldNameList = expectedTableType.fieldNameList; } - data.resultType = tableType; + + if (((BTableType) applicableExpType).keyTypeConstraint != symTable.neverType && + tableType.constraint.equals(((BTableType) applicableExpType).constraint) && + tableType.fieldNameList.equals(((BTableType) applicableExpType).fieldNameList)) { + data.resultType = expType; + } else { + data.resultType = tableType; + } } else if (applicableExpType.tag == TypeTags.UNION) { boolean prevNonErrorLoggingCheck = data.commonAnalyzerData.nonErrorLoggingCheck; From 0cdfc547dd9cea52b741b039f237716a5b37e135 Mon Sep 17 00:00:00 2001 From: prakanth <50439067+prakanth97@users.noreply.github.com> Date: Mon, 19 Sep 2022 14:06:02 +0530 Subject: [PATCH 016/450] Fix style check --- .../java/org/wso2/ballerinalang/compiler/desugar/Desugar.java | 3 ++- .../ballerinalang/compiler/semantics/analyzer/TypeChecker.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java index b4fbdce2a366..d29ae28a3248 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java @@ -6732,7 +6732,8 @@ private BLangStatementExpression desugarObjectTypeInit(BLangTypeInit typeInitExp blockStmt.addStatement(objVarDef); BLangInvocation typeInitInvocation = typeInitExpr.initInvocation; typeInitInvocation.exprSymbol = objVarDef.var.symbol; - typeInitInvocation.symbol = ((BObjectTypeSymbol) Types.getReferredType(objType).tsymbol).generatedInitializerFunc.symbol; + typeInitInvocation.symbol = + ((BObjectTypeSymbol) Types.getReferredType(objType).tsymbol).generatedInitializerFunc.symbol; typeInitInvocation.objectInitMethod = true; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java index ff46425f9d93..dac846df6545 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java @@ -4236,7 +4236,8 @@ private BType checkObjectCompatibility(BType actualType, BLangTypeInit cIExpr, A BType referredMatchedType = Types.getReferredType(matchedType); if (referredMatchedType.tag == TypeTags.OBJECT) { if (((BObjectTypeSymbol) referredMatchedType.tsymbol).initializerFunc != null) { - cIExpr.initInvocation.symbol = ((BObjectTypeSymbol) referredMatchedType.tsymbol).initializerFunc.symbol; + cIExpr.initInvocation.symbol = + ((BObjectTypeSymbol) referredMatchedType.tsymbol).initializerFunc.symbol; checkInvocationParam(cIExpr.initInvocation, data); cIExpr.initInvocation.setBType(((BInvokableSymbol) cIExpr.initInvocation.symbol).retType); actualType = matchedType; From b8be3ba1ac10facc697fde7aa1ed7e22ebd02854 Mon Sep 17 00:00:00 2001 From: HindujaB Date: Wed, 21 Sep 2022 14:14:56 +0530 Subject: [PATCH 017/450] Add typeref support for table value --- .../runtime/api/utils/JsonUtils.java | 15 ++++- .../runtime/internal/TypeChecker.java | 6 +- .../internal/values/ArrayValueImpl.java | 4 +- .../internal/values/TableValueImpl.java | 57 +++++++++++-------- .../compiler/bir/codegen/JvmSignatures.java | 3 +- .../ballerinalang/langlib/table/Filter.java | 3 +- .../org/ballerinalang/langlib/table/Map.java | 3 +- .../ballerinalang/langlib/table/ToArray.java | 3 +- .../jvm/runtime/api/tests/TypeReference.java | 6 +- 9 files changed, 62 insertions(+), 38 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/JsonUtils.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/JsonUtils.java index d1a9091bad7f..0c8e4c1660e6 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/JsonUtils.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/JsonUtils.java @@ -24,6 +24,7 @@ import io.ballerina.runtime.api.types.ArrayType; import io.ballerina.runtime.api.types.JsonType; import io.ballerina.runtime.api.types.MapType; +import io.ballerina.runtime.api.types.ReferenceType; import io.ballerina.runtime.api.types.StructureType; import io.ballerina.runtime.api.types.TableType; import io.ballerina.runtime.api.types.Type; @@ -292,8 +293,14 @@ public static Object convertToJson(Object value, List unresolvedV throw createCyclicValueReferenceError(value); } unresolvedValues.add(typeValuePair); - Object newValue; + Object newValue = getJsonObject(value, unresolvedValues, jsonType, sourceType); + unresolvedValues.remove(typeValuePair); + return newValue; + } + private static Object getJsonObject(Object value, List unresolvedValues, Type jsonType, + Type sourceType) { + Object newValue; switch (sourceType.getTag()) { case TypeTags.XML_TAG: case TypeTags.XML_ELEMENT_TAG: @@ -308,7 +315,7 @@ public static Object convertToJson(Object value, List unresolvedV break; case TypeTags.TABLE_TAG: BTable bTable = (BTable) value; - Type constrainedType = ((TableType) bTable.getType()).getConstrainedType(); + Type constrainedType = ((TableType) sourceType).getConstrainedType(); if (constrainedType.getTag() == TypeTags.MAP_TAG) { newValue = convertMapConstrainedTableToJson((BTable) value, unresolvedValues); } else { @@ -323,11 +330,13 @@ public static Object convertToJson(Object value, List unresolvedV case TypeTags.MAP_TAG: newValue = convertMapToJson((BMap) value, unresolvedValues); break; + case TypeTags.TYPE_REFERENCED_TYPE_TAG: + newValue = getJsonObject(value, unresolvedValues, jsonType, ((ReferenceType) sourceType).getReferredType()); + break; case TypeTags.ERROR_TAG: default: throw createConversionError(value, jsonType); } - unresolvedValues.remove(typeValuePair); return newValue; } diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java index 7eab711b90be..9c92c5690bd1 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java @@ -3113,8 +3113,10 @@ private static boolean isEqual(TableValueImpl lhsTable, TableValueImpl rhsTable, return false; } - boolean isLhsKeyedTable = ((BTableType) lhsTable.getType()).getFieldNames().length > 0; - boolean isRhsKeyedTable = ((BTableType) rhsTable.getType()).getFieldNames().length > 0; + boolean isLhsKeyedTable = + ((BTableType) TypeUtils.getReferredType(lhsTable.getType())).getFieldNames().length > 0; + boolean isRhsKeyedTable = + ((BTableType) TypeUtils.getReferredType(rhsTable.getType())).getFieldNames().length > 0; Object[] lhsTableValues = lhsTable.values().toArray(); Object[] rhsTableValues = rhsTable.values().toArray(); diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ArrayValueImpl.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ArrayValueImpl.java index 347748c1e046..4a5f11a9df71 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ArrayValueImpl.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ArrayValueImpl.java @@ -255,8 +255,8 @@ public ArrayValueImpl(Type type, long size, BListInitialValueEntry[] initialValu this(type, size, initialValues, null); } - public ArrayValueImpl(ArrayType type, BListInitialValueEntry[] initialValues) { - this(type, type.getSize(), initialValues, null); + public ArrayValueImpl(Type type, BListInitialValueEntry[] initialValues) { + this(type, ((ArrayType) TypeUtils.getReferredType(type)).getSize(), initialValues, null); } public ArrayValueImpl(ArrayType type, long size, BListInitialValueEntry[] initialValues) { diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TableValueImpl.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TableValueImpl.java index 9431e516912e..5545a3364d20 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TableValueImpl.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TableValueImpl.java @@ -25,6 +25,7 @@ import io.ballerina.runtime.api.types.TableType; import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.utils.StringUtils; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BIterator; import io.ballerina.runtime.api.values.BLink; @@ -82,7 +83,8 @@ */ public class TableValueImpl implements TableValue { - private TableType type; + private Type type; + private TableType tableType; private Type iteratorNextReturnType; private ConcurrentHashMap>> entries; private LinkedHashMap> values; @@ -102,39 +104,44 @@ public class TableValueImpl implements TableValue { private final Map nativeData = new HashMap<>(); private BTypedesc typedesc; - public TableValueImpl(TableType type) { - this.type = type; + public TableValueImpl(TableType tableType) { + this.type = this.tableType = tableType; this.entries = new ConcurrentHashMap<>(); this.keys = new LinkedHashMap<>(); this.values = new LinkedHashMap<>(); this.keyToIndexMap = new LinkedHashMap<>(); this.indexToKeyMap = new LinkedHashMap<>(); - this.fieldNames = type.getFieldNames(); + this.fieldNames = tableType.getFieldNames(); this.keyValues = new LinkedHashMap<>(); - if (type.getFieldNames().length > 0) { + if (tableType.getFieldNames().length > 0) { this.valueHolder = new KeyHashValueHolder(); } else { this.valueHolder = new ValueHolder(); } - this.typedesc = getTypedescValue(type, this); + this.typedesc = getTypedescValue(tableType, this); + } + + public TableValueImpl(Type type, ArrayValue data, ArrayValue fieldNames) { + this((TableType) TypeUtils.getReferredType(type), data, fieldNames); + this.type = type; } - public TableValueImpl(TableType type, ArrayValue data, ArrayValue fieldNames) { - this(type); + public TableValueImpl(TableType tableType, ArrayValue data, ArrayValue fieldNames) { + this(tableType); if (this.fieldNames == null) { this.fieldNames = fieldNames.getStringArray(); } addData(data); - if (type.isReadOnly()) { + if (tableType.isReadOnly()) { this.typedesc = createSingletonTypedesc(this); } } // TODO: Might be unnecessary after fixing issue lang/#36721 - public TableValueImpl(TableType type, ArrayValue fieldNames) { - this(type); + public TableValueImpl(TableType tableType, ArrayValue fieldNames) { + this(tableType); this.fieldNames = fieldNames.getStringArray(); if (this.fieldNames.length > 0) { @@ -167,7 +174,9 @@ public Object copy(Map refs) { return refs.get(this); } - TableValueImpl clone = new TableValueImpl<>(type); + TableValueImpl clone = new TableValueImpl<>(tableType); + clone.type = type; + if (fieldNames != null) { clone.fieldNames = fieldNames; } @@ -195,7 +204,7 @@ public Object frozenCopy(Map refs) { protected void handleFrozenTableValue() { synchronized (this) { try { - if (this.type.isReadOnly()) { + if (this.tableType.isReadOnly()) { ReadOnlyUtils.handleInvalidUpdate(TABLE_LANG_LIB); } } catch (BLangFreezeException e) { @@ -313,7 +322,7 @@ public V fillAndGet(Object key) { return this.get(key); } - Type expectedType = (this.type).getConstrainedType(); + Type expectedType = (this.tableType).getConstrainedType(); if (!TypeChecker.hasFillerValue(expectedType)) { // Panic if the field does not have a filler value. @@ -363,7 +372,9 @@ public void freezeDirect() { return; } - this.type = (BTableType) ReadOnlyUtils.setImmutableTypeAndGetEffectiveType(this.type); + this.tableType = (BTableType) ReadOnlyUtils.setImmutableTypeAndGetEffectiveType(this.tableType); + this.type = ReadOnlyUtils.setImmutableTypeAndGetEffectiveType(this.type); + //we know that values are always RefValues this.values().forEach(val -> ((RefValue) val).freezeDirect()); this.typedesc = createSingletonTypedesc(this); @@ -405,7 +416,7 @@ private String createStringValueDataEntry(Iterator>> itr private String createExpressionStringValueDataEntry(Iterator>> itr, BLink parent) { StringJoiner sj = new StringJoiner(","); StringJoiner keyJoiner = new StringJoiner(","); - String[] keysList = type.getFieldNames(); + String[] keysList = tableType.getFieldNames(); for (int i = 0; i < keysList.length; i++) { keyJoiner.add(keysList[i]); } @@ -460,7 +471,7 @@ public Type getType() { public Type getIteratorNextReturnType() { if (iteratorNextReturnType == null) { - iteratorNextReturnType = IteratorUtils.createIteratorNextReturnType(type.getConstrainedType()); + iteratorNextReturnType = IteratorUtils.createIteratorNextReturnType(tableType.getConstrainedType()); } return iteratorNextReturnType; @@ -518,7 +529,7 @@ public V putData(K key, V data) { } public V putData(V data) { - checkInherentTypeViolation((MapValue) data, type); + checkInherentTypeViolation((MapValue) data, tableType); ArrayList newData = new ArrayList<>(); newData.add(data); @@ -564,7 +575,7 @@ public KeyHashValueHolder() { public void addData(V data) { MapValue dataMap = (MapValue) data; - checkInherentTypeViolation(dataMap, type); + checkInherentTypeViolation(dataMap, tableType); K key = this.keyWrapper.wrapKey(dataMap); if (containsKey((K) key)) { @@ -639,7 +650,7 @@ private V putData(K key, V value, List data, Map.Entry entry, Long hash public V putData(V data) { MapValue dataMap = (MapValue) data; - checkInherentTypeViolation(dataMap, type); + checkInherentTypeViolation(dataMap, tableType); K key = this.keyWrapper.wrapKey(dataMap); ArrayList newData = new ArrayList<>(); @@ -703,7 +714,7 @@ private class DefaultKeyWrapper { public DefaultKeyWrapper() { if (fieldNames.length == 1) { - keyType = getTableConstraintField(type.getConstrainedType(), fieldNames[0]); + keyType = getTableConstraintField(tableType.getConstrainedType(), fieldNames[0]); if (keyType != null && keyType.getTag() == TypeTags.INT_TAG) { nextKeySupported = true; } @@ -720,7 +731,7 @@ private class MultiKeyWrapper extends DefaultKeyWrapper { public MultiKeyWrapper() { super(); List keyTypes = new ArrayList<>(); - Type constraintType = ((ReferenceType) type.getConstrainedType()).getReferredType(); + Type constraintType = ((ReferenceType) tableType.getConstrainedType()).getReferredType(); if (constraintType.getTag() == TypeTags.RECORD_TYPE_TAG) { BRecordType recordType = (BRecordType) constraintType; Arrays.stream(fieldNames) @@ -779,7 +790,7 @@ public boolean equals(Object o) { TableValueImpl tableValue = (TableValueImpl) o; - if (tableValue.type.getTag() != this.type.getTag()) { + if (tableValue.tableType.getTag() != this.tableType.getTag()) { return false; } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java index 7d853ca398ce..d6d69ee4865b 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java @@ -94,7 +94,6 @@ import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.STRING_BUILDER; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.STRING_TYPE; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.STRING_VALUE; -import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TABLE_TYPE; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TABLE_VALUE; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TABLE_VALUE_IMPL; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.THROWABLE; @@ -292,7 +291,7 @@ public class JvmSignatures { public static final String INIT_STREAM_TYPE_IMPL = "(L" + TYPE + ";L" + TYPE + ";)V"; public static final String INIT_TABLE_TYPE_IMPL = "(L" + TYPE + ";L" + TYPE + ";Z)V"; public static final String INIT_TABLE_TYPE_WITH_FIELD_NAME_LIST = "(L" + TYPE + ";[L" + STRING_VALUE + ";Z)V"; - public static final String INIT_TABLE_VALUE_IMPL = "(L" + TABLE_TYPE + ";L" + ARRAY_VALUE + ";L" + ARRAY_VALUE + + public static final String INIT_TABLE_VALUE_IMPL = "(L" + TYPE + ";L" + ARRAY_VALUE + ";L" + ARRAY_VALUE + ";)V"; public static final String INIT_TUPLE = "(L" + TYPE + ";[L" + B_LIST_INITIAL_VALUE_ENTRY + ";)V"; public static final String INIT_TUPLE_TYPE_IMPL = "(L" + STRING_VALUE + ";L" + MODULE + ";IZZ)V"; diff --git a/langlib/lang.table/src/main/java/org/ballerinalang/langlib/table/Filter.java b/langlib/lang.table/src/main/java/org/ballerinalang/langlib/table/Filter.java index 940337fd92f9..9ab2e4de7d77 100644 --- a/langlib/lang.table/src/main/java/org/ballerinalang/langlib/table/Filter.java +++ b/langlib/lang.table/src/main/java/org/ballerinalang/langlib/table/Filter.java @@ -22,6 +22,7 @@ import io.ballerina.runtime.api.creators.TypeCreator; import io.ballerina.runtime.api.creators.ValueCreator; import io.ballerina.runtime.api.types.TableType; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BFunctionPointer; import io.ballerina.runtime.api.values.BTable; import io.ballerina.runtime.internal.scheduling.AsyncUtils; @@ -51,7 +52,7 @@ public class Filter { TABLE_VERSION, "filter"); public static BTable filter(BTable tbl, BFunctionPointer func) { - TableType tableType = (TableType) tbl.getType(); + TableType tableType = (TableType) TypeUtils.getReferredType(tbl.getType()); BTable newTable = ValueCreator.createTableValue(TypeCreator.createTableType(tableType.getConstrainedType(), tableType.getFieldNames(), false)); diff --git a/langlib/lang.table/src/main/java/org/ballerinalang/langlib/table/Map.java b/langlib/lang.table/src/main/java/org/ballerinalang/langlib/table/Map.java index e5bba5c1e26c..a18ff9444ab2 100644 --- a/langlib/lang.table/src/main/java/org/ballerinalang/langlib/table/Map.java +++ b/langlib/lang.table/src/main/java/org/ballerinalang/langlib/table/Map.java @@ -25,6 +25,7 @@ import io.ballerina.runtime.api.types.FunctionType; import io.ballerina.runtime.api.types.TableType; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BFunctionPointer; import io.ballerina.runtime.api.values.BTable; import io.ballerina.runtime.internal.scheduling.AsyncUtils; @@ -49,7 +50,7 @@ public class Map { public static BTable map(BTable tbl, BFunctionPointer func) { Type newConstraintType = ((FunctionType) func.getType()).getReturnType(); - TableType tblType = (TableType) tbl.getType(); + TableType tblType = (TableType) TypeUtils.getReferredType(tbl.getType()); TableType newTableType = TypeCreator.createTableType(newConstraintType, PredefinedTypes.TYPE_NEVER, tblType.isReadOnly()); diff --git a/langlib/lang.table/src/main/java/org/ballerinalang/langlib/table/ToArray.java b/langlib/lang.table/src/main/java/org/ballerinalang/langlib/table/ToArray.java index 4f8a1c4f8319..2ccb19eecc7c 100644 --- a/langlib/lang.table/src/main/java/org/ballerinalang/langlib/table/ToArray.java +++ b/langlib/lang.table/src/main/java/org/ballerinalang/langlib/table/ToArray.java @@ -22,6 +22,7 @@ import io.ballerina.runtime.api.creators.ValueCreator; import io.ballerina.runtime.api.types.TableType; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BTable; @@ -42,7 +43,7 @@ public class ToArray { public static BArray toArray(BTable tbl) { - Type constrainedType = ((TableType) tbl.getType()).getConstrainedType(); + Type constrainedType = ((TableType) TypeUtils.getReferredType(tbl.getType())).getConstrainedType(); Collection values = tbl.values(); //Basic constrain types not applicable for table type diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java index ca846190cd73..23697972b0a1 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java @@ -168,9 +168,9 @@ public static Boolean validateTableType(BTypedesc typedesc, TableValue tableValu if (tableValue.getKeyType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { throw error; } -// if (tableValue.getType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { -// throw error; -// } + if (tableValue.getType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } return true; } From 7b6ebdd15b97c56c09227e5bdd4c6244a1907657 Mon Sep 17 00:00:00 2001 From: HindujaB Date: Wed, 21 Sep 2022 18:12:56 +0530 Subject: [PATCH 018/450] Add typeref support for object value --- .../runtime/api/utils/JsonUtils.java | 3 +- .../internal/values/AbstractObjectValue.java | 30 ++++++++-------- .../ballerinalang/compiler/bir/BIRGen.java | 34 ++++++++----------- .../bir/codegen/JvmInstructionGen.java | 6 ++-- .../compiler/bir/codegen/JvmSignatures.java | 2 +- .../compiler/bir/model/BIRNonTerminator.java | 7 ++-- .../api/types/modules/typeref/typeAPIs.bal | 6 ++-- 7 files changed, 43 insertions(+), 45 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/JsonUtils.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/JsonUtils.java index 0c8e4c1660e6..e8c4c7f59c9a 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/JsonUtils.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/JsonUtils.java @@ -331,7 +331,8 @@ private static Object getJsonObject(Object value, List unresolved newValue = convertMapToJson((BMap) value, unresolvedValues); break; case TypeTags.TYPE_REFERENCED_TYPE_TAG: - newValue = getJsonObject(value, unresolvedValues, jsonType, ((ReferenceType) sourceType).getReferredType()); + newValue = getJsonObject(value, unresolvedValues, jsonType, + ((ReferenceType) sourceType).getReferredType()); break; case TypeTags.ERROR_TAG: default: diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/AbstractObjectValue.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/AbstractObjectValue.java index 296016aa90a9..b9318104a645 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/AbstractObjectValue.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/AbstractObjectValue.java @@ -23,6 +23,7 @@ import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.types.TypeId; import io.ballerina.runtime.api.utils.StringUtils; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BLink; import io.ballerina.runtime.api.values.BMap; @@ -56,13 +57,15 @@ * @since 0.995.0 */ public abstract class AbstractObjectValue implements ObjectValue { - private BTypedesc typedesc; - private BObjectType type; + private final BTypedesc typedesc; + private final BObjectType objectType; + private final Type type; private final HashMap nativeData = new HashMap<>(); - public AbstractObjectValue(BObjectType type) { + public AbstractObjectValue(Type type) { this.type = type; + this.objectType = (BObjectType) TypeUtils.getReferredType(type); this.typedesc = new TypedescValueImpl(type); } @@ -98,7 +101,7 @@ public BString getStringValue(BString fieldName) { @Override public String stringValue(BLink parent) { - return "object " + type.toString(); + return "object " + objectType.toString(); } @Override @@ -108,11 +111,11 @@ public String informalStringValue(BLink parent) { @Override public String expressionStringValue(BLink parent) { - if (type.typeIdSet == null) { + if (objectType.typeIdSet == null) { return "object " + this.hashCode(); } StringJoiner sj = new StringJoiner("&"); - List typeIds = type.typeIdSet.getIds(); + List typeIds = objectType.typeIdSet.getIds(); for (TypeId typeId : typeIds) { String pkg = typeId.getPkg().toString(); if (DOT.equals(pkg)) { @@ -121,7 +124,7 @@ public String expressionStringValue(BLink parent) { sj.add("{" + pkg + "}" + typeId.getName()); } } - return "object " + sj.toString() + " " + this.hashCode(); + return "object " + sj + " " + this.hashCode(); } @Override @@ -156,7 +159,6 @@ public Object copy(Map refs) { @Override public void freezeDirect() { - return; } @Override @@ -167,7 +169,7 @@ public Object frozenCopy(Map refs) { @Override public String toString() { StringJoiner sj = new StringJoiner(", ", "{", "}"); - for (Map.Entry field : this.type.getFields().entrySet()) { + for (Map.Entry field : this.objectType.getFields().entrySet()) { if (!SymbolFlags.isFlagOn(field.getValue().getFlags(), SymbolFlags.PUBLIC)) { continue; } @@ -187,32 +189,32 @@ private String getStringValue(Object value) { if (value == null) { return null; } else if (value instanceof String) { - return "\"" + value.toString() + "\""; + return "\"" + value + "\""; } else { return value.toString(); } } protected void checkFieldUpdate(String fieldName, Object value) { - if (type.isReadOnly()) { + if (objectType.isReadOnly()) { throw ErrorCreator.createError( getModulePrefixedReason(OBJECT_LANG_LIB, INHERENT_TYPE_VIOLATION_ERROR_IDENTIFIER), BLangExceptionHelper.getErrorDetails(RuntimeErrors.INVALID_READONLY_VALUE_UPDATE)); } - Field field = type.getFields().get(fieldName); + Field field = objectType.getFields().get(fieldName); if (SymbolFlags.isFlagOn(field.getFlags(), SymbolFlags.FINAL)) { throw ErrorCreator.createError( getModulePrefixedReason(OBJECT_LANG_LIB, INVALID_UPDATE_ERROR_IDENTIFIER), BLangExceptionHelper.getErrorDetails(RuntimeErrors.OBJECT_INVALID_FINAL_FIELD_UPDATE, - fieldName, type)); + fieldName, objectType)); } checkFieldUpdateType(fieldName, value); } private void checkFieldUpdateType(String fieldName, Object value) { - Type fieldType = type.getFields().get(fieldName).getFieldType(); + Type fieldType = objectType.getFields().get(fieldName).getFieldType(); if (TypeChecker.checkIsType(value, fieldType)) { return; } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java index 63deabfcb821..e442ed4a3e55 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java @@ -1613,27 +1613,21 @@ private List mapToVarDcls(TreeMap enclMapSymbol @Override public void visit(BLangTypeInit connectorInitExpr) { - BIRVariableDcl tempVarDcl = new BIRVariableDcl(connectorInitExpr.getBType(), this.env.nextLocalVarId(names), - VarScope.FUNCTION, VarKind.TEMP); + BType exprType = connectorInitExpr.getBType(); + BIRVariableDcl tempVarDcl = new BIRVariableDcl(exprType, this.env.nextLocalVarId(names), VarScope.FUNCTION, + VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand toVarRef = new BIROperand(tempVarDcl); - - BTypeSymbol objectTypeSymbol = getObjectTypeSymbol(connectorInitExpr.getBType()); + BType objectType = getEffectiveObjectType(exprType); + BTypeSymbol objectTypeSymbol = Types.getReferredType(objectType).tsymbol; BIRNonTerminator.NewInstance instruction; if (isInSamePackage(objectTypeSymbol, env.enclPkg.packageID)) { BIRTypeDefinition def = typeDefs.get(objectTypeSymbol); - instruction = new BIRNonTerminator.NewInstance(connectorInitExpr.pos, def, toVarRef); + instruction = new BIRNonTerminator.NewInstance(connectorInitExpr.pos, def, toVarRef, objectType); } else { - BType connectorInitExprType = Types.getReferredType(connectorInitExpr.getBType()); - BType objectType = connectorInitExprType.tag != TypeTags.UNION ? connectorInitExprType : - ((BUnionType) connectorInitExprType).getMemberTypes().stream() - .filter(bType -> bType.tag != TypeTags.ERROR) - .findFirst() - .get(); - - String objectName = objectType.tsymbol.name.value; - instruction = new BIRNonTerminator.NewInstance(connectorInitExpr.pos, objectTypeSymbol.pkgID, - objectName, toVarRef); + String objectName = objectTypeSymbol.name.value; + instruction = new BIRNonTerminator.NewInstance(connectorInitExpr.pos, objectTypeSymbol.pkgID, objectName, + toVarRef, objectType); } setScopeAndEmit(instruction); this.env.targetOperand = toVarRef; @@ -2545,15 +2539,15 @@ private void generateMappingAccess(BLangIndexBasedAccess astIndexBasedAccessExpr this.varAssignment = variableStore; } - private BTypeSymbol getObjectTypeSymbol(BType objType) { + private BType getEffectiveObjectType(BType objType) { BType type = Types.getReferredType(objType); if (type.tag == TypeTags.UNION) { - return Types.getReferredType(((BUnionType) type).getMemberTypes().stream() - .filter(t -> Types.getReferredType(t).tag == TypeTags.OBJECT) + return ((BUnionType) type).getMemberTypes().stream() + .filter(t -> Types.getReferredType(t).tag != TypeTags.ERROR) .findFirst() - .orElse(symTable.noType)).tsymbol; + .orElse(symTable.noType); } - return Types.getReferredType(type).tsymbol; + return objType; } private BIROperand generateStringLiteral(String value) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java index b6ddbf36af17..4e27a5b5075d 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java @@ -1676,11 +1676,9 @@ void generateObjectNewIns(BIRNonTerminator.NewInstance objectNewIns, int strandI this.mv.visitTypeInsn(NEW, className); this.mv.visitInsn(DUP); - jvmTypeGen.loadType(mv, type); + jvmTypeGen.loadType(mv, objectNewIns.expectedType); reloadObjectCtorAnnots(type, strandIndex); - this.mv.visitTypeInsn(CHECKCAST, OBJECT_TYPE_IMPL); - this.mv.visitMethodInsn(INVOKESPECIAL, className, JVM_INIT_METHOD, OBJECT_TYPE_IMPL_INIT, - false); + this.mv.visitMethodInsn(INVOKESPECIAL, className, JVM_INIT_METHOD, OBJECT_TYPE_IMPL_INIT, false); this.storeToVar(objectNewIns.lhsOp.variableDcl); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java index d6d69ee4865b..506e349679df 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java @@ -344,7 +344,7 @@ public class JvmSignatures { public static final String MODULE_START = "(L" + STRAND_CLASS + ";)L" + OBJECT + ";"; public static final String OBJECT_SET = "(L" + STRING_VALUE + ";L" + B_STRING_VALUE + ";L" + OBJECT + ";)V"; public static final String OBJECT_TYPE_DUPLICATE = "()L" + OBJECT_TYPE_IMPL + ";"; - public static final String OBJECT_TYPE_IMPL_INIT = "(L" + OBJECT_TYPE_IMPL + ";)V"; + public static final String OBJECT_TYPE_IMPL_INIT = "(L" + TYPE + ";)V"; public static final String PANIC_IF_UNLOCK = "(L" + STRING_VALUE + ";L" + STRAND_CLASS + ";)V"; public static final String PASS_BSTRING_RETURN_OBJECT = "(L" + B_STRING_VALUE + ";)L" + OBJECT + ";"; public static final String PASS_OBJECT_RETURN_OBJECT = "(L" + OBJECT + ";)L" + OBJECT + ";"; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/model/BIRNonTerminator.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/model/BIRNonTerminator.java index 112857bf1604..0fa86a612c21 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/model/BIRNonTerminator.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/model/BIRNonTerminator.java @@ -245,24 +245,27 @@ public static class NewInstance extends BIRNonTerminator { public final PackageID externalPackageId; public BIRTypeDefinition def; public final String objectName; + public final BType expectedType; - public NewInstance(Location pos, BIRTypeDefinition def, BIROperand lhsOp) { + public NewInstance(Location pos, BIRTypeDefinition def, BIROperand lhsOp, BType expectedType) { super(pos, InstructionKind.NEW_INSTANCE); this.lhsOp = lhsOp; this.def = def; this.objectName = null; this.externalPackageId = null; this.isExternalDef = false; + this.expectedType = expectedType; } public NewInstance(Location pos, PackageID externalPackageId, String objectName, - BIROperand lhsOp) { + BIROperand lhsOp, BType expectedType) { super(pos, InstructionKind.NEW_INSTANCE); this.objectName = objectName; this.lhsOp = lhsOp; this.def = null; this.externalPackageId = externalPackageId; this.isExternalDef = true; + this.expectedType = expectedType; } @Override diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal index a36dc6c80dc3..43525272f846 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal @@ -130,9 +130,9 @@ function validateRuntimeAPIs() { result = validateBError(err); test:assertTrue(result); - // BObject obj = new (); - // result = validateBObject(obj); - // test:assertTrue(result); + BObject obj = new (); + result = validateBObject(obj); + test:assertTrue(result); BFunctionPointer fp = testFunc; result = validateBFunctionPointer(fp); From 81cda25b026654a1d835f8e00e216ac30eec7c0e Mon Sep 17 00:00:00 2001 From: HindujaB Date: Thu, 22 Sep 2022 12:28:45 +0530 Subject: [PATCH 019/450] Fix testerina integration tests --- .../providers/toml/ConfigValueCreator.java | 2 +- .../ballerinalang/test/runtime/BTestRunner.java | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/configurable/providers/toml/ConfigValueCreator.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/configurable/providers/toml/ConfigValueCreator.java index 0091671afd6d..18e71942d191 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/configurable/providers/toml/ConfigValueCreator.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/configurable/providers/toml/ConfigValueCreator.java @@ -381,7 +381,7 @@ private Object createUnionValue(TomlNode tomlValue, BUnionType unionType) { break; } } - Type type = getEffectiveType(convertibleType; + Type type = getEffectiveType(convertibleType); if (isSimpleType(type.getTag()) || type.getTag() == TypeTags.FINITE_TYPE_TAG || isXMLType(type)) { return balValue; } diff --git a/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/BTestRunner.java b/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/BTestRunner.java index 2299ffe5eca9..8f9fb915b95b 100644 --- a/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/BTestRunner.java +++ b/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/BTestRunner.java @@ -469,7 +469,8 @@ private void executeBeforeFunction(Test test, TestSuite suite, ClassLoader class */ private List getKeyValues(BMap dataMap) { List keyValues = new ArrayList<>(); - if (TypeUtils.getReferredType(((BMapType) dataMap.getType()).getConstrainedType()) instanceof TupleType) { + if (TypeUtils.getReferredType( + ((BMapType) TypeUtils.getReferredType(dataMap.getType())).getConstrainedType()) instanceof TupleType) { for (BString key : (BString[]) dataMap.getKeys()) { keyValues.add(key.getValue()); } @@ -844,7 +845,8 @@ private List extractArguments(BArray bArray) { */ private List extractArguments(BMap dataMap) { List argsList = new ArrayList<>(); - if (TypeUtils.getReferredType(((BMapType) dataMap.getType()).getConstrainedType()) instanceof TupleType) { + if (TypeUtils.getReferredType( + ((BMapType) TypeUtils.getReferredType(dataMap.getType())).getConstrainedType()) instanceof TupleType) { for (BString keyValue : (BString[]) dataMap.getKeys()) { setTestFunctionParams(argsList, dataMap.getArrayValue(keyValue)); } @@ -883,7 +885,8 @@ private static Class[] extractArgumentTypes(BArray bArray) { private static Class[] extractArgumentTypes(BMap dataMap) { List> typeList = new ArrayList<>(); typeList.add(Strand.class); - if (TypeUtils.getReferredType(((BMapType) dataMap.getType()).getConstrainedType()) instanceof TupleType) { + if (TypeUtils.getReferredType( + ((BMapType) TypeUtils.getReferredType(dataMap.getType())).getConstrainedType()) instanceof TupleType) { setTestFunctionSignature(typeList, dataMap.getArrayValue( (BString) dataMap.getKeys()[0])); } @@ -893,8 +896,9 @@ private static Class[] extractArgumentTypes(BMap dataMap) { } private static void setTestFunctionSignature(List> typeList, BArray bArray) { - if (bArray.getType() instanceof BTupleType) { - List types = ((BTupleType) bArray.getType()).getTupleTypes(); + Type arrayType = TypeUtils.getReferredType(bArray.getType()); + if (arrayType instanceof BTupleType) { + List types = ((BTupleType) arrayType).getTupleTypes(); for (Type type : types) { Class classMapping = getArgTypeToClassMapping(TypeUtils.getReferredType(type)); typeList.add(classMapping); @@ -915,7 +919,7 @@ private static void setTestFunctionParams(List valueList, BArray bArra List params = new ArrayList<>(); // Add a place holder to Strand params.add(new Object()); - if (bArray.getType() instanceof BTupleType) { + if (TypeUtils.getReferredType(bArray.getType()) instanceof BTupleType) { for (int i = 0; i < bArray.size(); i++) { // Add the param type. params.add(bArray.getRefValue(i)); From bbd048eb959f1e34478045d6325f6e5b670ffc2b Mon Sep 17 00:00:00 2001 From: HindujaB Date: Fri, 23 Sep 2022 08:12:45 +0530 Subject: [PATCH 020/450] Fix langlib `getType()` usages --- .../org/ballerinalang/langlib/java/Cast.java | 3 +- .../langlib/internal/GetElementType.java | 3 + .../langlib/internal/GetFilterFunc.java | 3 +- .../langlib/internal/GetMapFunc.java | 3 +- .../langlib/internal/GetReturnType.java | 3 +- .../langlib/internal/SetNarrowType.java | 3 +- .../langlib/array/Enumerate.java | 3 +- .../ballerinalang/langlib/array/Filter.java | 3 +- .../org/ballerinalang/langlib/array/Map.java | 5 +- .../org/ballerinalang/langlib/array/Pop.java | 3 +- .../org/ballerinalang/langlib/array/Push.java | 3 +- .../ballerinalang/langlib/array/Remove.java | 3 +- .../ballerinalang/langlib/array/Reverse.java | 3 +- .../ballerinalang/langlib/array/Shift.java | 3 +- .../ballerinalang/langlib/array/Slice.java | 3 +- .../org/ballerinalang/langlib/array/Sort.java | 3 +- .../ballerinalang/langlib/array/ToBase16.java | 3 +- .../ballerinalang/langlib/array/ToBase64.java | 3 +- .../ballerinalang/langlib/array/Unshift.java | 3 +- .../langlib/array/utils/ArrayUtils.java | 5 +- .../ballerinalang/langlib/function/Call.java | 3 +- .../org/ballerinalang/langlib/map/Filter.java | 3 +- .../org/ballerinalang/langlib/map/Map.java | 4 +- .../org/ballerinalang/langlib/map/Remove.java | 3 +- .../ballerinalang/langlib/map/RemoveAll.java | 3 +- .../langlib/map/RemoveIfHasKey.java | 3 +- .../ballerinalang/langlib/map/ToArray.java | 3 +- .../langlib/map/util/MapLibUtils.java | 5 +- .../langlib/query/CreateImmutableType.java | 14 ++-- .../org/ballerinalang/langlib/table/Map.java | 2 +- .../org/ballerinalang/langlib/table/Next.java | 3 +- .../jvm/runtime/api/tests/TypeReference.java | 15 ++++ .../api/types/modules/typeref/typeAPIs.bal | 69 +++++++++++++++++++ .../api/types/modules/typeref/typeref.bal | 1 + .../tests/assertions-error-messages.bal | 3 +- 35 files changed, 161 insertions(+), 37 deletions(-) diff --git a/langlib/jballerina.java/src/main/java/org/ballerinalang/langlib/java/Cast.java b/langlib/jballerina.java/src/main/java/org/ballerinalang/langlib/java/Cast.java index eefe65263e60..9e9ea196584b 100644 --- a/langlib/jballerina.java/src/main/java/org/ballerinalang/langlib/java/Cast.java +++ b/langlib/jballerina.java/src/main/java/org/ballerinalang/langlib/java/Cast.java @@ -22,6 +22,7 @@ import io.ballerina.runtime.api.types.ObjectType; import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.utils.StringUtils; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BHandle; import io.ballerina.runtime.api.values.BMap; import io.ballerina.runtime.api.values.BObject; @@ -47,7 +48,7 @@ public class Cast { public static Object cast(BObject value, BTypedesc castType) { BHandle handleObj; - ObjectType objType = (ObjectType) value.getType(); + ObjectType objType = (ObjectType) TypeUtils.getReferredType(value.getType()); String valueObjName = objType.getName(); handleObj = (BHandle) value.get(StringUtils.fromString(jObjField)); Object jObj = handleObj.getValue(); diff --git a/langlib/lang.__internal/src/main/java/org/ballerinalang/langlib/internal/GetElementType.java b/langlib/lang.__internal/src/main/java/org/ballerinalang/langlib/internal/GetElementType.java index f149b4e7d56d..07302ab03e7e 100644 --- a/langlib/lang.__internal/src/main/java/org/ballerinalang/langlib/internal/GetElementType.java +++ b/langlib/lang.__internal/src/main/java/org/ballerinalang/langlib/internal/GetElementType.java @@ -23,6 +23,7 @@ import io.ballerina.runtime.api.creators.ValueCreator; import io.ballerina.runtime.api.types.ArrayType; import io.ballerina.runtime.api.types.FiniteType; +import io.ballerina.runtime.api.types.ReferenceType; import io.ballerina.runtime.api.types.StreamType; import io.ballerina.runtime.api.types.TupleType; import io.ballerina.runtime.api.types.Type; @@ -55,6 +56,8 @@ private static BTypedesc getElementTypeDescValue(Type type) { // this is reached only for immutable values return getElementTypeDescValue( ((BValue) (((FiniteType) type).getValueSpace().iterator().next())).getType()); + case TypeTags.TYPE_REFERENCED_TYPE_TAG: + return getElementTypeDescValue(((ReferenceType)type).getReferredType()); default: return ValueCreator.createTypedescValue(((StreamType) type).getConstrainedType()); } diff --git a/langlib/lang.__internal/src/main/java/org/ballerinalang/langlib/internal/GetFilterFunc.java b/langlib/lang.__internal/src/main/java/org/ballerinalang/langlib/internal/GetFilterFunc.java index 323ae59d8dcb..b2f2bc6e5cab 100644 --- a/langlib/lang.__internal/src/main/java/org/ballerinalang/langlib/internal/GetFilterFunc.java +++ b/langlib/lang.__internal/src/main/java/org/ballerinalang/langlib/internal/GetFilterFunc.java @@ -21,6 +21,7 @@ import io.ballerina.runtime.api.PredefinedTypes; import io.ballerina.runtime.api.creators.TypeCreator; import io.ballerina.runtime.api.types.FunctionType; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BFunctionPointer; import java.util.List; @@ -34,7 +35,7 @@ public class GetFilterFunc { public static BFunctionPointer getFilterFunc(Object obj) { BFunctionPointer bFunctionPointer = (BFunctionPointer) obj; - FunctionType functionType = (FunctionType) bFunctionPointer.getType(); + FunctionType functionType = (FunctionType) TypeUtils.getReferredType(bFunctionPointer.getType()); functionType.getParameters()[0].type = TypeCreator.createUnionType(List.of(PredefinedTypes.TYPE_ANY, PredefinedTypes.TYPE_ERROR), 0); return bFunctionPointer; diff --git a/langlib/lang.__internal/src/main/java/org/ballerinalang/langlib/internal/GetMapFunc.java b/langlib/lang.__internal/src/main/java/org/ballerinalang/langlib/internal/GetMapFunc.java index 1c2b245d5d16..3d6e459d7c29 100644 --- a/langlib/lang.__internal/src/main/java/org/ballerinalang/langlib/internal/GetMapFunc.java +++ b/langlib/lang.__internal/src/main/java/org/ballerinalang/langlib/internal/GetMapFunc.java @@ -21,6 +21,7 @@ import io.ballerina.runtime.api.PredefinedTypes; import io.ballerina.runtime.api.creators.TypeCreator; import io.ballerina.runtime.api.types.FunctionType; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BFunctionPointer; import java.util.List; @@ -34,7 +35,7 @@ public class GetMapFunc { public static BFunctionPointer getMapFunc(Object obj) { BFunctionPointer functionPointer = (BFunctionPointer) obj; - FunctionType functionType = (FunctionType) functionPointer.getType(); + FunctionType functionType = (FunctionType) TypeUtils.getReferredType(functionPointer.getType()); functionType.getParameters()[0].type = TypeCreator.createUnionType(List.of(PredefinedTypes.TYPE_ANY, PredefinedTypes.TYPE_ERROR), 0); return functionPointer; diff --git a/langlib/lang.__internal/src/main/java/org/ballerinalang/langlib/internal/GetReturnType.java b/langlib/lang.__internal/src/main/java/org/ballerinalang/langlib/internal/GetReturnType.java index c5b17e66cd7c..af4efc9c0fa5 100644 --- a/langlib/lang.__internal/src/main/java/org/ballerinalang/langlib/internal/GetReturnType.java +++ b/langlib/lang.__internal/src/main/java/org/ballerinalang/langlib/internal/GetReturnType.java @@ -20,6 +20,7 @@ import io.ballerina.runtime.api.creators.ValueCreator; import io.ballerina.runtime.api.types.FunctionType; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BFunctionPointer; import io.ballerina.runtime.api.values.BTypedesc; @@ -32,7 +33,7 @@ public class GetReturnType { public static BTypedesc getReturnType(Object obj) { BFunctionPointer bFunctionPointer = (BFunctionPointer) obj; - FunctionType functionType = (FunctionType) bFunctionPointer.getType(); + FunctionType functionType = (FunctionType) TypeUtils.getReferredType(bFunctionPointer.getType()); return ValueCreator.createTypedescValue(functionType.getReturnType()); } } diff --git a/langlib/lang.__internal/src/main/java/org/ballerinalang/langlib/internal/SetNarrowType.java b/langlib/lang.__internal/src/main/java/org/ballerinalang/langlib/internal/SetNarrowType.java index 1ffcb13e19eb..087ccd0acc4c 100644 --- a/langlib/lang.__internal/src/main/java/org/ballerinalang/langlib/internal/SetNarrowType.java +++ b/langlib/lang.__internal/src/main/java/org/ballerinalang/langlib/internal/SetNarrowType.java @@ -23,6 +23,7 @@ import io.ballerina.runtime.api.flags.SymbolFlags; import io.ballerina.runtime.api.types.RecordType; import io.ballerina.runtime.api.utils.StringUtils; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BMap; import io.ballerina.runtime.api.values.BString; import io.ballerina.runtime.api.values.BTypedesc; @@ -37,7 +38,7 @@ public class SetNarrowType { public static BMap setNarrowType(BTypedesc td, BMap value) { - RecordType recordType = (RecordType) value.getType(); + RecordType recordType = (RecordType) TypeUtils.getReferredType(value.getType()); RecordType newRecordType = TypeCreator.createRecordType("narrowType", recordType.getPackage(), recordType.getTypeFlags(), recordType.isSealed(), recordType.getTypeFlags()); diff --git a/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Enumerate.java b/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Enumerate.java index 999e05ad7542..61627e6725b8 100644 --- a/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Enumerate.java +++ b/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Enumerate.java @@ -26,6 +26,7 @@ import io.ballerina.runtime.api.types.TupleType; import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.types.UnionType; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import org.ballerinalang.langlib.array.utils.GetFunction; @@ -47,7 +48,7 @@ public class Enumerate { public static BArray enumerate(BArray arr) { - Type arrType = arr.getType(); + Type arrType = TypeUtils.getReferredType(arr.getType()); int size = arr.size(); TupleType elemType; GetFunction getFn; diff --git a/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Filter.java b/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Filter.java index 67bd47e19a76..3553d09c4c14 100644 --- a/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Filter.java +++ b/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Filter.java @@ -23,6 +23,7 @@ import io.ballerina.runtime.api.creators.TypeCreator; import io.ballerina.runtime.api.creators.ValueCreator; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BFunctionPointer; import io.ballerina.runtime.internal.scheduling.AsyncUtils; @@ -49,7 +50,7 @@ public class Filter { public static BArray filter(BArray arr, BFunctionPointer func) { BArray newArr; - Type arrType = arr.getType(); + Type arrType = TypeUtils.getReferredType(arr.getType()); switch (arrType.getTag()) { case TypeTags.ARRAY_TAG: newArr = ValueCreator.createArrayValue(TypeCreator.createArrayType(arr.getElementType())); diff --git a/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Map.java b/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Map.java index f4a1de19b15c..5490e798a4aa 100644 --- a/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Map.java +++ b/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Map.java @@ -25,6 +25,7 @@ import io.ballerina.runtime.api.types.ArrayType; import io.ballerina.runtime.api.types.FunctionType; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BFunctionPointer; import io.ballerina.runtime.internal.scheduling.AsyncUtils; @@ -56,13 +57,13 @@ public class Map { ARRAY_VERSION, "map"); public static BArray map(BArray arr, BFunctionPointer func) { - Type elemType = ((FunctionType) func.getType()).getReturnType(); + Type elemType = ((FunctionType) TypeUtils.getReferredType(func.getType())).getReturnType(); Type retArrType = TypeCreator.createArrayType(elemType); BArray retArr = ValueCreator.createArrayValue((ArrayType) retArrType); int size = arr.size(); GetFunction getFn; - Type arrType = arr.getType(); + Type arrType = TypeUtils.getReferredType(arr.getType()); switch (arrType.getTag()) { case TypeTags.ARRAY_TAG: getFn = BArray::get; diff --git a/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Pop.java b/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Pop.java index 30d2eb56122a..9cf218622328 100644 --- a/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Pop.java +++ b/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Pop.java @@ -18,6 +18,7 @@ package org.ballerinalang.langlib.array; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import static org.ballerinalang.langlib.array.utils.ArrayUtils.checkIsArrayOnlyOperation; @@ -38,7 +39,7 @@ public class Pop { private static final String FUNCTION_SIGNATURE = "pop()"; public static Object pop(BArray arr) { - checkIsArrayOnlyOperation(arr.getType(), FUNCTION_SIGNATURE); + checkIsArrayOnlyOperation(TypeUtils.getReferredType(arr.getType()), FUNCTION_SIGNATURE); return arr.shift(arr.size() - 1); } } diff --git a/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Push.java b/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Push.java index 020f4b2937f1..6f4428d87b0b 100644 --- a/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Push.java +++ b/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Push.java @@ -20,6 +20,7 @@ import io.ballerina.runtime.api.TypeTags; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import static org.ballerinalang.langlib.array.utils.ArrayUtils.createOpNotSupportedError; @@ -40,7 +41,7 @@ public class Push { private static final String FUNCTION_SIGNATURE = "push()"; public static void push(BArray arr, Object... vals) { - Type arrType = arr.getType(); + Type arrType = TypeUtils.getReferredType(arr.getType()); int nVals = vals.length; switch (arrType.getTag()) { case TypeTags.ARRAY_TAG: diff --git a/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Remove.java b/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Remove.java index 682fc830a37a..e8b9ee6516ac 100644 --- a/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Remove.java +++ b/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Remove.java @@ -18,6 +18,7 @@ package org.ballerinalang.langlib.array; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import static org.ballerinalang.langlib.array.utils.ArrayUtils.checkIsArrayOnlyOperation; @@ -36,7 +37,7 @@ public class Remove { public static Object remove(BArray arr, long i) { - checkIsArrayOnlyOperation(arr.getType(), "remove()"); + checkIsArrayOnlyOperation(TypeUtils.getReferredType(arr.getType()), "remove()"); return arr.shift(i); } } diff --git a/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Reverse.java b/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Reverse.java index 63d64c044acc..a27bc650c18f 100644 --- a/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Reverse.java +++ b/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Reverse.java @@ -22,6 +22,7 @@ import io.ballerina.runtime.api.creators.TypeCreator; import io.ballerina.runtime.api.creators.ValueCreator; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import org.ballerinalang.langlib.array.utils.ArrayUtils; @@ -35,7 +36,7 @@ public class Reverse { public static BArray reverse(BArray arr) { - Type arrType = arr.getType(); + Type arrType = TypeUtils.getReferredType(arr.getType()); BArray reversedArr; switch (arrType.getTag()) { case TypeTags.ARRAY_TAG: diff --git a/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Shift.java b/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Shift.java index 2a4e6610a75c..7e6eee2ad9b1 100644 --- a/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Shift.java +++ b/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Shift.java @@ -18,6 +18,7 @@ package org.ballerinalang.langlib.array; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import static org.ballerinalang.langlib.array.utils.ArrayUtils.checkIsArrayOnlyOperation; @@ -36,7 +37,7 @@ public class Shift { public static Object shift(BArray arr) { - checkIsArrayOnlyOperation(arr.getType(), "shift()"); + checkIsArrayOnlyOperation(TypeUtils.getReferredType(arr.getType()), "shift()"); return arr.shift(0); } } diff --git a/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Slice.java b/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Slice.java index c92de1af0fea..7b603b34515e 100644 --- a/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Slice.java +++ b/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Slice.java @@ -25,6 +25,7 @@ import io.ballerina.runtime.api.types.TupleType; import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.types.UnionType; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.internal.util.exceptions.BLangExceptionHelper; import io.ballerina.runtime.internal.util.exceptions.RuntimeErrors; @@ -60,7 +61,7 @@ public static BArray slice(BArray arr, long startIndex, long endIndex) { .getRuntimeException(RuntimeErrors.ARRAY_INDEX_OUT_OF_RANGE, sliceSize, size); } - Type arrType = arr.getType(); + Type arrType = TypeUtils.getReferredType(arr.getType()); BArray slicedArr; switch (arrType.getTag()) { diff --git a/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Sort.java b/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Sort.java index c946029e23d4..a1fcd2b2cd58 100644 --- a/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Sort.java +++ b/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Sort.java @@ -21,6 +21,7 @@ import io.ballerina.runtime.api.creators.ErrorCreator; import io.ballerina.runtime.api.creators.TypeCreator; import io.ballerina.runtime.api.creators.ValueCreator; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BError; import io.ballerina.runtime.api.values.BFunctionPointer; @@ -41,7 +42,7 @@ public class Sort { public static BArray sort(BArray arr, Object direction, Object func) { - checkIsArrayOnlyOperation(arr.getType(), "sort()"); + checkIsArrayOnlyOperation(TypeUtils.getReferredType(arr.getType()), "sort()"); BFunctionPointer function = (BFunctionPointer) func; Object[][] sortArr = new Object[arr.size()][2]; diff --git a/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/ToBase16.java b/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/ToBase16.java index 181b80ec3534..74fc62b29523 100644 --- a/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/ToBase16.java +++ b/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/ToBase16.java @@ -23,6 +23,7 @@ import io.ballerina.runtime.api.types.ArrayType; import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.utils.StringUtils; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BString; @@ -41,7 +42,7 @@ public class ToBase16 { private static final BString NOT_SUPPORTED_ERROR_DETAIL = StringUtils.fromString("toBase16() is only supported " + "on 'byte[]'"); public static BString toBase16(BArray arr) { - Type arrType = arr.getType(); + Type arrType = TypeUtils.getReferredType(arr.getType()); if (arrType.getTag() != TypeTags.ARRAY_TAG || ((ArrayType) arrType).getElementType().getTag() != TypeTags.BYTE_TAG) { throw ErrorCreator.createError(getModulePrefixedReason(ARRAY_LANG_LIB, diff --git a/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/ToBase64.java b/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/ToBase64.java index 0492aac695df..d363326a460a 100644 --- a/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/ToBase64.java +++ b/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/ToBase64.java @@ -23,6 +23,7 @@ import io.ballerina.runtime.api.types.ArrayType; import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.utils.StringUtils; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BString; @@ -43,7 +44,7 @@ public class ToBase64 { .fromString("toBase64() is only supported on 'byte[]'"); public static BString toBase64(BArray arr) { - Type arrType = arr.getType(); + Type arrType = TypeUtils.getReferredType(arr.getType()); if (arrType.getTag() != TypeTags.ARRAY_TAG || ((ArrayType) arrType).getElementType().getTag() != TypeTags.BYTE_TAG) { throw ErrorCreator.createError(getModulePrefixedReason(ARRAY_LANG_LIB, diff --git a/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Unshift.java b/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Unshift.java index c89f596723ab..3761b02f66d1 100644 --- a/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Unshift.java +++ b/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/Unshift.java @@ -18,6 +18,7 @@ package org.ballerinalang.langlib.array; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import static org.ballerinalang.langlib.array.utils.ArrayUtils.checkIsArrayOnlyOperation; @@ -30,7 +31,7 @@ public class Unshift { public static void unshift(BArray arr, Object... vals) { - checkIsArrayOnlyOperation(arr.getType(), "unshift()"); + checkIsArrayOnlyOperation(TypeUtils.getReferredType(arr.getType()), "unshift()"); arr.unshift(vals); } } diff --git a/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/utils/ArrayUtils.java b/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/utils/ArrayUtils.java index bd5fcf5362e2..55a0ae2579d6 100644 --- a/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/utils/ArrayUtils.java +++ b/langlib/lang.array/src/main/java/org/ballerinalang/langlib/array/utils/ArrayUtils.java @@ -26,6 +26,7 @@ import io.ballerina.runtime.api.types.TupleType; import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.types.UnionType; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BError; import io.ballerina.runtime.internal.util.exceptions.BLangExceptionHelper; @@ -74,6 +75,8 @@ public static GetFunction getElementAccessFunction(Type arrType, String funcName return BArray::get; case TypeTags.TUPLE_TAG: return BArray::getRefValue; + case TypeTags.TYPE_REFERENCED_TYPE_TAG: + return getElementAccessFunction(TypeUtils.getReferredType(arrType), funcName); default: throw createOpNotSupportedError(arrType, funcName); } @@ -92,7 +95,7 @@ public static BError createOpNotSupportedError(Type type, String op) { } public static BArray createEmptyArrayFromTuple(BArray arr) { - Type arrType = arr.getType(); + Type arrType = TypeUtils.getReferredType(arr.getType()); TupleType tupleType = (TupleType) arrType; List memTypes = new ArrayList<>(); List tupleTypes = tupleType.getTupleTypes(); diff --git a/langlib/lang.function/src/main/java/org/ballerinalang/langlib/function/Call.java b/langlib/lang.function/src/main/java/org/ballerinalang/langlib/function/Call.java index 4a553748a592..6a3bb61bbfbb 100644 --- a/langlib/lang.function/src/main/java/org/ballerinalang/langlib/function/Call.java +++ b/langlib/lang.function/src/main/java/org/ballerinalang/langlib/function/Call.java @@ -22,6 +22,7 @@ import io.ballerina.runtime.api.creators.ErrorCreator; import io.ballerina.runtime.api.types.Parameter; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BFunctionPointer; import io.ballerina.runtime.internal.TypeChecker; import io.ballerina.runtime.internal.scheduling.Scheduler; @@ -52,7 +53,7 @@ public class Call { "1.0.0", "call"); public static Object call(BFunctionPointer func, Object... args) { - BFunctionType functionType = (BFunctionType) func.getType(); + BFunctionType functionType = (BFunctionType) TypeUtils.getReferredType(func.getType()); List paramTypes = new LinkedList<>(); List argTypes = new LinkedList<>(); List argsList = new java.util.ArrayList<>(List.of(Scheduler.getStrand())); diff --git a/langlib/lang.map/src/main/java/org/ballerinalang/langlib/map/Filter.java b/langlib/lang.map/src/main/java/org/ballerinalang/langlib/map/Filter.java index 25ccdd66ef57..b36c5795bda6 100644 --- a/langlib/lang.map/src/main/java/org/ballerinalang/langlib/map/Filter.java +++ b/langlib/lang.map/src/main/java/org/ballerinalang/langlib/map/Filter.java @@ -25,6 +25,7 @@ import io.ballerina.runtime.api.types.MapType; import io.ballerina.runtime.api.types.RecordType; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BFunctionPointer; import io.ballerina.runtime.api.values.BMap; import io.ballerina.runtime.api.values.BString; @@ -51,7 +52,7 @@ public class Filter { MAP_VERSION, "filter"); public static BMap filter(BMap m, BFunctionPointer func) { - Type mapType = m.getType(); + Type mapType = TypeUtils.getReferredType(m.getType()); Type constraint; switch (mapType.getTag()) { case TypeTags.MAP_TAG: diff --git a/langlib/lang.map/src/main/java/org/ballerinalang/langlib/map/Map.java b/langlib/lang.map/src/main/java/org/ballerinalang/langlib/map/Map.java index 1e4d788b79b7..d149efea8ce1 100644 --- a/langlib/lang.map/src/main/java/org/ballerinalang/langlib/map/Map.java +++ b/langlib/lang.map/src/main/java/org/ballerinalang/langlib/map/Map.java @@ -23,6 +23,7 @@ import io.ballerina.runtime.api.creators.ValueCreator; import io.ballerina.runtime.api.types.FunctionType; import io.ballerina.runtime.api.types.MapType; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BFunctionPointer; import io.ballerina.runtime.api.values.BMap; import io.ballerina.runtime.api.values.BString; @@ -53,7 +54,8 @@ public class Map { MAP_VERSION, "map"); public static BMap map(BMap m, BFunctionPointer func) { - MapType newMapType = TypeCreator.createMapType(((FunctionType) func.getType()).getReturnType()); + MapType newMapType = + TypeCreator.createMapType(((FunctionType) TypeUtils.getReferredType(func.getType())).getReturnType()); BMap newMap = ValueCreator.createMapValue(newMapType); int size = m.size(); AtomicInteger index = new AtomicInteger(-1); diff --git a/langlib/lang.map/src/main/java/org/ballerinalang/langlib/map/Remove.java b/langlib/lang.map/src/main/java/org/ballerinalang/langlib/map/Remove.java index 2f398f39c674..dc3fa08df19a 100644 --- a/langlib/lang.map/src/main/java/org/ballerinalang/langlib/map/Remove.java +++ b/langlib/lang.map/src/main/java/org/ballerinalang/langlib/map/Remove.java @@ -21,6 +21,7 @@ import io.ballerina.runtime.api.creators.ErrorCreator; import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.utils.StringUtils; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BMap; import io.ballerina.runtime.api.values.BString; import io.ballerina.runtime.internal.util.exceptions.BLangExceptionHelper; @@ -38,7 +39,7 @@ public class Remove { public static Object remove(BMap m, BString k) { - Type type = m.getType(); + Type type = TypeUtils.getReferredType(m.getType()); checkIsMapOnlyOperation(type, REMOVE); validateRequiredFieldForRecord(m, k.getValue()); diff --git a/langlib/lang.map/src/main/java/org/ballerinalang/langlib/map/RemoveAll.java b/langlib/lang.map/src/main/java/org/ballerinalang/langlib/map/RemoveAll.java index 33f57b6aa27d..847a767e136b 100644 --- a/langlib/lang.map/src/main/java/org/ballerinalang/langlib/map/RemoveAll.java +++ b/langlib/lang.map/src/main/java/org/ballerinalang/langlib/map/RemoveAll.java @@ -20,6 +20,7 @@ import io.ballerina.runtime.api.creators.ErrorCreator; import io.ballerina.runtime.api.utils.StringUtils; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BMap; import static io.ballerina.runtime.internal.MapUtils.checkIsMapOnlyOperation; @@ -33,7 +34,7 @@ public class RemoveAll { public static void removeAll(BMap m) { - checkIsMapOnlyOperation(m.getType(), "removeAll()"); + checkIsMapOnlyOperation(TypeUtils.getReferredType(m.getType()), "removeAll()"); validateRecord(m); try { m.clear(); diff --git a/langlib/lang.map/src/main/java/org/ballerinalang/langlib/map/RemoveIfHasKey.java b/langlib/lang.map/src/main/java/org/ballerinalang/langlib/map/RemoveIfHasKey.java index c07030ef10b0..4717509a3551 100644 --- a/langlib/lang.map/src/main/java/org/ballerinalang/langlib/map/RemoveIfHasKey.java +++ b/langlib/lang.map/src/main/java/org/ballerinalang/langlib/map/RemoveIfHasKey.java @@ -20,6 +20,7 @@ import io.ballerina.runtime.api.creators.ErrorCreator; import io.ballerina.runtime.api.utils.StringUtils; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BMap; import io.ballerina.runtime.api.values.BString; @@ -37,7 +38,7 @@ public class RemoveIfHasKey { public static Object removeIfHasKey(BMap m, BString k) { String op = "removeIfHasKey()"; - checkIsMapOnlyOperation(m.getType(), op); + checkIsMapOnlyOperation(TypeUtils.getReferredType(m.getType()), op); validateRequiredFieldForRecord(m, k.getValue()); try { return m.remove(k); diff --git a/langlib/lang.map/src/main/java/org/ballerinalang/langlib/map/ToArray.java b/langlib/lang.map/src/main/java/org/ballerinalang/langlib/map/ToArray.java index 87ac9139685a..7113576e4863 100644 --- a/langlib/lang.map/src/main/java/org/ballerinalang/langlib/map/ToArray.java +++ b/langlib/lang.map/src/main/java/org/ballerinalang/langlib/map/ToArray.java @@ -24,6 +24,7 @@ import io.ballerina.runtime.api.types.MapType; import io.ballerina.runtime.api.types.RecordType; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BMap; import io.ballerina.runtime.api.values.BString; @@ -48,7 +49,7 @@ public class ToArray { public static BArray toArray(BMap m) { - Type mapType = m.getType(); + Type mapType = TypeUtils.getReferredType(m.getType()); Type arrElemType; switch (mapType.getTag()) { case TypeTags.MAP_TAG: diff --git a/langlib/lang.map/src/main/java/org/ballerinalang/langlib/map/util/MapLibUtils.java b/langlib/lang.map/src/main/java/org/ballerinalang/langlib/map/util/MapLibUtils.java index 8498dccef459..c53239f7e564 100644 --- a/langlib/lang.map/src/main/java/org/ballerinalang/langlib/map/util/MapLibUtils.java +++ b/langlib/lang.map/src/main/java/org/ballerinalang/langlib/map/util/MapLibUtils.java @@ -27,6 +27,7 @@ import io.ballerina.runtime.api.types.RecordType; import io.ballerina.runtime.api.types.ReferenceType; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BError; import io.ballerina.runtime.api.values.BMap; import io.ballerina.runtime.internal.util.exceptions.BLangExceptionHelper; @@ -78,7 +79,7 @@ public static Type getCommonTypeForRecordField(RecordType recordType) { } public static void validateRecord(BMap m) { - Type type = m.getType(); + Type type = TypeUtils.getReferredType(m.getType()); if (type.getTag() != TypeTags.RECORD_TYPE_TAG) { return; } @@ -104,7 +105,7 @@ private static BError createOpNotSupportedErrorForRecord(Type type, String field } public static void validateRequiredFieldForRecord(BMap m, String k) { - Type type = m.getType(); + Type type = TypeUtils.getReferredType(m.getType()); if (type.getTag() == TypeTags.RECORD_TYPE_TAG && isRequiredField((RecordType) type, k)) { throw createOpNotSupportedErrorForRecord(type, k); } diff --git a/langlib/lang.query/src/main/java/org/ballerinalang/langlib/query/CreateImmutableType.java b/langlib/lang.query/src/main/java/org/ballerinalang/langlib/query/CreateImmutableType.java index 728d218554b4..03511cbd3518 100644 --- a/langlib/lang.query/src/main/java/org/ballerinalang/langlib/query/CreateImmutableType.java +++ b/langlib/lang.query/src/main/java/org/ballerinalang/langlib/query/CreateImmutableType.java @@ -2,6 +2,8 @@ import io.ballerina.runtime.api.types.ArrayType; import io.ballerina.runtime.api.types.TableType; +import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BRefValue; import io.ballerina.runtime.api.values.BTable; @@ -22,18 +24,20 @@ public static void createImmutableValue(BRefValue value) { } public static BTable createImmutableTable(BTable tbl, BArray arr) { - TableType type = (TableType) tbl.getType(); + Type type = tbl.getType(); + TableType tableType = (TableType) TypeUtils.getReferredType(type); BTable immutableTable = new TableValueImpl(type, - new ArrayValueImpl(arr.getValues(), (ArrayType) arr.getType()), - new ArrayValueImpl(((TableType) tbl.getType()).getFieldNames(), true)); + new ArrayValueImpl(arr.getValues(), (ArrayType) TypeUtils.getReferredType(arr.getType())), + new ArrayValueImpl(tableType.getFieldNames(), true)); immutableTable.freezeDirect(); return immutableTable; } public static BTable createTableWithKeySpecifier(BTable immutableTable, BTypedesc tableType) { - TableType type = (TableType) tableType.getDescribingType(); + TableType type = (TableType) TypeUtils.getReferredType(tableType.getDescribingType()); BTable tbl = new TableValueImpl(type, - new ArrayValueImpl(((TableType) immutableTable.getType()).getFieldNames(), false)); + new ArrayValueImpl(((TableType) TypeUtils.getReferredType(immutableTable.getType())).getFieldNames(), + false)); return tbl; } } diff --git a/langlib/lang.table/src/main/java/org/ballerinalang/langlib/table/Map.java b/langlib/lang.table/src/main/java/org/ballerinalang/langlib/table/Map.java index a18ff9444ab2..3c03a6132f57 100644 --- a/langlib/lang.table/src/main/java/org/ballerinalang/langlib/table/Map.java +++ b/langlib/lang.table/src/main/java/org/ballerinalang/langlib/table/Map.java @@ -49,7 +49,7 @@ public class Map { TABLE_VERSION, "map"); public static BTable map(BTable tbl, BFunctionPointer func) { - Type newConstraintType = ((FunctionType) func.getType()).getReturnType(); + Type newConstraintType = ((FunctionType) TypeUtils.getReferredType(func.getType())).getReturnType(); TableType tblType = (TableType) TypeUtils.getReferredType(tbl.getType()); TableType newTableType = TypeCreator.createTableType(newConstraintType, PredefinedTypes.TYPE_NEVER, tblType.isReadOnly()); diff --git a/langlib/lang.table/src/main/java/org/ballerinalang/langlib/table/Next.java b/langlib/lang.table/src/main/java/org/ballerinalang/langlib/table/Next.java index 1ea305a59a49..6df58828a57d 100644 --- a/langlib/lang.table/src/main/java/org/ballerinalang/langlib/table/Next.java +++ b/langlib/lang.table/src/main/java/org/ballerinalang/langlib/table/Next.java @@ -23,6 +23,7 @@ import io.ballerina.runtime.api.types.ArrayType; import io.ballerina.runtime.api.types.RecordType; import io.ballerina.runtime.api.utils.StringUtils; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BIterator; import io.ballerina.runtime.api.values.BObject; @@ -90,7 +91,7 @@ private static void handleMutation(BTable table, BArray keys, } } - BArray currentKeyArray = ValueCreator.createArrayValue((ArrayType) keys.getType()); + BArray currentKeyArray = ValueCreator.createArrayValue((ArrayType) TypeUtils.getReferredType(keys.getType())); for (int i = 0; i < currentKeys.size(); i++) { Object key = currentKeys.get(i); currentKeyArray.add(i, key); diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java index 23697972b0a1..b8dae9de08dc 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java @@ -34,6 +34,7 @@ import io.ballerina.runtime.api.values.BObject; import io.ballerina.runtime.api.values.BStream; import io.ballerina.runtime.api.values.BTypedesc; +import io.ballerina.runtime.internal.TypeChecker; import io.ballerina.runtime.internal.types.BArrayType; import io.ballerina.runtime.internal.types.BErrorType; import io.ballerina.runtime.internal.types.BFunctionType; @@ -303,4 +304,18 @@ public static Boolean validateBObject(BObject value) { return true; } + public static boolean validateUnionTypeNarrowing(Object value, BTypedesc typedesc) { + Type describingType = typedesc.getDescribingType(); + BError error = ErrorCreator.createError(StringUtils.fromString("RefValue getType API provided a wrong type " + + "reference type.")); + Type type = TypeChecker.getType(value); + if (type.getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + if (type.getTag() != describingType.getTag() || !type.toString().equals(describingType.toString())) { + throw error; + } + return true; + } + } diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal index 43525272f846..76f385386d00 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal @@ -76,6 +76,36 @@ class PositiveNumberGenerator { type BObject Test; +public class TestWithInit { + int i = 1; + + function init() { + self.i = 5; + } +} + +public class TestWithInitReturnError { + int i = 1; + + function init() returns error? { + self.i = 5; + } +} + +public class TestWithInitReturnTypeRefError { + int i = 1; + + function init() returns DetailedError? { + self.i = 5; + } +} + +type BObjectWithInit TestWithInit; + +type BObjectWithInitReturnError TestWithInitReturnError; + +type BObjectWithInitReturnTypeRefError TestWithInitReturnTypeRefError; + function validateRuntimeAPIs() { boolean result = validateGetDetailType(DetailedError); test:assertTrue(result); @@ -134,6 +164,18 @@ function validateRuntimeAPIs() { result = validateBObject(obj); test:assertTrue(result); + BObjectWithInit obj2 = new (); + result = validateBObject(obj2); + test:assertTrue(result); + + BObjectWithInitReturnError obj3 = checkpanic new (); + result = validateBObject(obj3); + test:assertTrue(result); + + BObjectWithInitReturnTypeRefError obj4 = checkpanic new (); + result = validateBObject(obj4); + test:assertTrue(result); + BFunctionPointer fp = testFunc; result = validateBFunctionPointer(fp); test:assertTrue(result); @@ -147,6 +189,30 @@ function testFunc(int a) returns int { return a + 5; } +type UnionValues BArray|BTuple|BMap|TableType|BObject; + +function validateValueWithUnion() { + UnionValues value = [2, 4, 6, 8]; + boolean result = validateUnionTypeNarrowing(value, BArray); + test:assertTrue(result); + + value = [1, {id: 100, msg: "hello", "priority": 5}]; + result = validateUnionTypeNarrowing(value, BTuple); + test:assertTrue(result); + + value = {"a": 1, "b": 2, "c": 3}; + result = validateUnionTypeNarrowing(value, BMap); + test:assertTrue(result); + + value = table [{id: 200, msg: "error message", "priority": 1}]; + result = validateUnionTypeNarrowing(value, TableType); + test:assertTrue(result); + + value = new (); + result = validateUnionTypeNarrowing(value, BObject); + test:assertTrue(result); +} + public function validateGetDetailType(any value) returns boolean = @java:Method { 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" } external; @@ -215,3 +281,6 @@ public function validateBFunctionPointer(any value) returns boolean = @java:Meth 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" } external; +public function validateUnionTypeNarrowing(any|error value, typedesc td) returns boolean = @java:Method { + 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" +} external; diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeref.bal b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeref.bal index 82e796b08b5e..47b054fdc6d2 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeref.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeref.bal @@ -85,6 +85,7 @@ public function validateTypeRef() { validateArray(); validateFunctionParameters(); validateRuntimeAPIs(); + validateValueWithUnion(); } function validateFunctionParameters() { diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/assertions-error-messages/tests/assertions-error-messages.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/assertions-error-messages/tests/assertions-error-messages.bal index 19f06b5c7483..2950f5461f99 100644 --- a/tests/testerina-integration-test/src/test/resources/project-based-tests/assertions-error-messages/tests/assertions-error-messages.bal +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/assertions-error-messages/tests/assertions-error-messages.bal @@ -94,7 +94,8 @@ function testAssertTableAndString() { test:assertEquals(result.message().toString(), "Assertion Failed!\n \n" + "expected: 'table [{id: 1, name: \"John\", salary: 300.50}," + "{id: 2, name: \"Bella\", salary: 500.\n50}]'" + - "\nactual\t: '[{\"id\":1,\"name\":\"John\",\"salary\":300.5},{\"id\":2,\"name\":\"Bella\",\"salary\":500.5}]'"); + "\nactual\t: '[{\"id\":1,\"name\":\"John\",\"salary\":300.5},{\"id\":2,\"name\":\"Bella\"," + + "\"salary\":500.5}]'"); } @test:Config {} From a0d36f82d9a465e7da9a0c94c84ff3b03763309a Mon Sep 17 00:00:00 2001 From: HindujaB Date: Fri, 23 Sep 2022 11:30:40 +0530 Subject: [PATCH 021/450] Fix `TypeChecker.getType()` and `TypeUtils.getType()` usages --- .../java/io/ballerina/runtime/api/Runtime.java | 3 ++- .../ballerina/runtime/api/utils/JsonUtils.java | 3 ++- .../runtime/api/utils/StringUtils.java | 10 +++++----- .../ballerina/runtime/api/utils/TypeUtils.java | 4 +--- .../runtime/internal/JsonGenerator.java | 3 ++- .../runtime/internal/JsonInternalUtils.java | 14 +++++++------- .../ballerina/runtime/internal/JsonParser.java | 3 ++- .../runtime/internal/TableJsonDataSource.java | 5 +++-- .../configurable/providers/toml/Utils.java | 5 +++-- .../runtime/observability/ObserveUtils.java | 3 ++- .../langlib/internal/GetElementType.java | 2 +- .../ballerinalang/langlib/test/AssertError.java | 3 ++- .../langlib/test/AssertNotError.java | 3 ++- .../langlib/value/CloneWithType.java | 2 +- .../ballerinalang/langlib/value/EnsureType.java | 2 +- .../langlib/value/FromJsonWithType.java | 2 +- .../ballerinalang/langlib/xml/SetChildren.java | 3 ++- .../testerina/natives/io/Sprintf.java | 3 ++- .../natives/mock/GenericMockObjectValue.java | 3 ++- .../testerina/natives/mock/ObjectMock.java | 17 ++++++++++------- .../benchmark/nativeimpl/Utils.java | 2 +- 21 files changed, 54 insertions(+), 41 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/Runtime.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/Runtime.java index 2da573b177be..2981422fff76 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/Runtime.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/Runtime.java @@ -23,6 +23,7 @@ import io.ballerina.runtime.api.types.ObjectType; import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.utils.StringUtils; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BError; import io.ballerina.runtime.api.values.BFunctionPointer; import io.ballerina.runtime.api.values.BFuture; @@ -162,7 +163,7 @@ public BFuture invokeMethodAsync(BObject object, String methodName, String stran Type returnType, Object... args) { try { validateArgs(object, methodName); - ObjectType objectType = (ObjectType) object.getType(); + ObjectType objectType = (ObjectType) TypeUtils.getReferredType(object.getType()); boolean isIsolated = objectType.isIsolated() && objectType.isIsolated(methodName); Function func = o -> object.call((Strand) (((Object[]) o)[0]), methodName, args); if (isIsolated) { diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/JsonUtils.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/JsonUtils.java index e8c4c7f59c9a..0a4f472f45fb 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/JsonUtils.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/JsonUtils.java @@ -285,7 +285,8 @@ public static Object convertToJson(Object value, List unresolvedV return null; } Type sourceType = TypeChecker.getType(value); - if (sourceType.getTag() <= TypeTags.BOOLEAN_TAG && TypeChecker.checkIsType(value, jsonType)) { + if (TypeUtils.getReferredType(sourceType).getTag() <= TypeTags.BOOLEAN_TAG && TypeChecker.checkIsType(value, + jsonType)) { return value; } TypeValuePair typeValuePair = new TypeValuePair(value, jsonType); diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/StringUtils.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/StringUtils.java index b40799cee8fd..ec3341aa08f4 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/StringUtils.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/StringUtils.java @@ -170,7 +170,7 @@ public static String getStringValue(Object value, BLink parent) { return ""; } - Type type = TypeChecker.getType(value); + Type type = TypeUtils.getReferredType(TypeChecker.getType(value)); if (type.getTag() == TypeTags.STRING_TAG) { return ((BString) value).getValue(); @@ -202,7 +202,7 @@ public static String getStringValue(Object value, BLink parent) { if (type.getTag() == TypeTags.OBJECT_TYPE_TAG) { BObject objectValue = (BObject) value; - ObjectType objectType = (ObjectType) objectValue.getType(); + ObjectType objectType = (ObjectType) TypeUtils.getReferredType(objectValue.getType()); for (MethodType func : objectType.getMethods()) { if (func.getName().equals(TO_STRING) && func.getParameters().length == 0 && func.getType().getReturnType().getTag() == TypeTags.STRING_TAG) { @@ -227,7 +227,7 @@ public static String getExpressionStringValue(Object value, BLink parent) { return "()"; } - Type type = TypeChecker.getType(value); + Type type = TypeUtils.getReferredType(TypeChecker.getType(value)); if (type.getTag() == TypeTags.STRING_TAG) { return "\"" + ((BString) value).getValue() + "\""; @@ -273,7 +273,7 @@ public static String getExpressionStringValue(Object value, BLink parent) { if (type.getTag() == TypeTags.OBJECT_TYPE_TAG) { AbstractObjectValue objectValue = (AbstractObjectValue) value; - ObjectType objectType = (ObjectType) objectValue.getType(); + ObjectType objectType = (ObjectType) TypeUtils.getReferredType(objectValue.getType()); for (MethodType func : objectType.getMethods()) { if (func.getName().equals(TO_STRING) && func.getParameters().length == 0 && func.getType().getReturnType().getTag() == TypeTags.STRING_TAG) { @@ -351,7 +351,7 @@ public static Object parseExpressionStringValue(String value, BLink parent) thro public static String getJsonString(Object value) { Object jsonValue = JsonUtils.convertToJson(value, new ArrayList<>()); - Type type = TypeChecker.getType(jsonValue); + Type type = TypeUtils.getReferredType(TypeChecker.getType(jsonValue)); switch (type.getTag()) { case TypeTags.NULL_TAG: return "null"; diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/TypeUtils.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/TypeUtils.java index 1f58f0627520..9ad74e33464f 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/TypeUtils.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/TypeUtils.java @@ -55,7 +55,7 @@ private TypeUtils() { } public static boolean isValueType(Type type) { - switch (type.getTag()) { + switch (TypeUtils.getReferredType(type).getTag()) { case TypeTags.INT_TAG: case TypeTags.BYTE_TAG: case TypeTags.FLOAT_TAG: @@ -70,8 +70,6 @@ public static boolean isValueType(Type type) { } } return true; - case TypeTags.TYPE_REFERENCED_TYPE_TAG: - return isValueType(((ReferenceType) type).getReferredType()); default: return false; diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/JsonGenerator.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/JsonGenerator.java index 917700736001..10ac9febaeb7 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/JsonGenerator.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/JsonGenerator.java @@ -18,6 +18,7 @@ package io.ballerina.runtime.internal; import io.ballerina.runtime.api.TypeTags; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BString; import io.ballerina.runtime.internal.values.ArrayValue; import io.ballerina.runtime.internal.values.DecimalValue; @@ -279,7 +280,7 @@ public void serialize(Object json) throws IOException { return; } - switch (TypeChecker.getType(json).getTag()) { + switch (TypeUtils.getReferredType(TypeChecker.getType(json)).getTag()) { case TypeTags.ARRAY_TAG: if (json instanceof StreamingJsonValue) { ((StreamingJsonValue) json).serialize(this); diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/JsonInternalUtils.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/JsonInternalUtils.java index 2e701b481974..4422e1dcdf65 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/JsonInternalUtils.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/JsonInternalUtils.java @@ -398,7 +398,7 @@ public static Object convertUnionTypeToJSON(Object source, JsonType targetType) return null; } - Type type = TypeChecker.getType(source); + Type type = TypeUtils.getReferredType(TypeChecker.getType(source)); switch (type.getTag()) { case TypeTags.INT_TAG: case TypeTags.FLOAT_TAG: @@ -438,8 +438,8 @@ public static BError getErrorIfUnmergeable(Object j1, Object j2, List json, BString key, Object return; } - Type type = TypeChecker.getType(value); + Type type = TypeUtils.getReferredType(TypeChecker.getType(value)); switch (type.getTag()) { case TypeTags.INT_TAG: case TypeTags.FLOAT_TAG: diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/JsonParser.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/JsonParser.java index a3789eb302eb..e539d91b1ad0 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/JsonParser.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/JsonParser.java @@ -23,6 +23,7 @@ import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.utils.JsonUtils; import io.ballerina.runtime.api.utils.StringUtils; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BError; import io.ballerina.runtime.api.values.BString; import io.ballerina.runtime.internal.types.BArrayType; @@ -310,7 +311,7 @@ private State finalizeObject() { } Object parentNode = this.nodesStack.pop(); - if (TypeChecker.getType(parentNode).getTag() == TypeTags.MAP_TAG) { + if (TypeUtils.getReferredType(TypeChecker.getType(parentNode)).getTag() == TypeTags.MAP_TAG) { ((MapValueImpl) parentNode).put(StringUtils.fromString(fieldNames.pop()), currentJsonNode); currentJsonNode = parentNode; diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TableJsonDataSource.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TableJsonDataSource.java index 399b9dd3389b..d7c6057a2488 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TableJsonDataSource.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TableJsonDataSource.java @@ -21,6 +21,7 @@ import io.ballerina.runtime.api.TypeTags; import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.utils.StringUtils; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BIterator; import io.ballerina.runtime.api.values.BMap; @@ -104,7 +105,7 @@ private static class DefaultJSONObjectGenerator implements JSONObjectGenerator { public Object transform(BMap record) { MapValue objNode = new MapValueImpl<>(new BMapType(PredefinedTypes.TYPE_JSON)); for (Map.Entry entry : record.entrySet()) { - Type type = TypeChecker.getType(entry.getValue()); + Type type = TypeUtils.getReferredType(TypeChecker.getType(entry.getValue())); BString keyName = StringUtils.fromString(entry.getKey().toString()); constructJsonData(record, objNode, keyName, type); } @@ -151,7 +152,7 @@ private static void constructJsonData(BMap record, MapValue jsonData = new MapValueImpl<>(new BMapType(PredefinedTypes.TYPE_JSON)); for (Map.Entry entry : record.getMapValue(key).entrySet()) { - Type internalType = TypeChecker.getType(entry.getValue()); + Type internalType = TypeUtils.getReferredType(TypeChecker.getType(entry.getValue())); BString internalKeyName = StringUtils.fromString(entry.getKey().toString()); constructJsonData(record.getMapValue(key), jsonData, internalKeyName, internalType); } diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/configurable/providers/toml/Utils.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/configurable/providers/toml/Utils.java index 5570874ddbba..0911fb91b6b8 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/configurable/providers/toml/Utils.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/configurable/providers/toml/Utils.java @@ -35,6 +35,7 @@ import io.ballerina.runtime.api.types.TupleType; import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.utils.StringUtils; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BMapInitialValueEntry; import io.ballerina.runtime.internal.TypeChecker; import io.ballerina.runtime.internal.configurable.exceptions.ConfigException; @@ -354,7 +355,7 @@ private static Object validateAndGetFiniteDoubleValue(TomlDoubleValueNodeNode to private static boolean checkDoubleValue(BFiniteType type, int tag, double doubleValue) { for (Object value : type.getValueSpace()) { - if (TypeChecker.getType(value).getTag() == tag) { + if (TypeUtils.getReferredType(TypeChecker.getType(value)).getTag() == tag) { if (tag == TypeTags.DECIMAL_TAG) { return doubleValue == ((DecimalValue) value).floatValue(); } else { @@ -393,7 +394,7 @@ private static boolean containsType(BUnionType unionType, int tag) { int typeTag = effectiveType.getTag(); if (typeTag == TypeTags.FINITE_TYPE_TAG) { for (Object obj : ((FiniteType) effectiveType).getValueSpace()) { - if (TypeChecker.getType(obj).getTag() == tag) { + if (TypeUtils.getReferredType(TypeChecker.getType(obj)).getTag() == tag) { return true; } } diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/observability/ObserveUtils.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/observability/ObserveUtils.java index fab7a40dd25e..d86c08983b35 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/observability/ObserveUtils.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/observability/ObserveUtils.java @@ -22,6 +22,7 @@ import io.ballerina.runtime.api.PredefinedTypes; import io.ballerina.runtime.api.types.ObjectType; import io.ballerina.runtime.api.utils.StringUtils; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BObject; import io.ballerina.runtime.api.values.BString; import io.ballerina.runtime.internal.configurable.ConfigMap; @@ -378,7 +379,7 @@ public static void startCallableObservation(Environment env, BString module, BSt } // Else normal function if (typeDef != null) { - ObjectType type = (ObjectType) typeDef.getType(); + ObjectType type = (ObjectType) TypeUtils.getReferredType(typeDef.getType()); Module typeModule = type.getPackage(); String objectName = typeModule.getOrg() + "/" + typeModule.getName() + "/" + type.getName(); diff --git a/langlib/lang.__internal/src/main/java/org/ballerinalang/langlib/internal/GetElementType.java b/langlib/lang.__internal/src/main/java/org/ballerinalang/langlib/internal/GetElementType.java index 07302ab03e7e..7d38e661a726 100644 --- a/langlib/lang.__internal/src/main/java/org/ballerinalang/langlib/internal/GetElementType.java +++ b/langlib/lang.__internal/src/main/java/org/ballerinalang/langlib/internal/GetElementType.java @@ -57,7 +57,7 @@ private static BTypedesc getElementTypeDescValue(Type type) { return getElementTypeDescValue( ((BValue) (((FiniteType) type).getValueSpace().iterator().next())).getType()); case TypeTags.TYPE_REFERENCED_TYPE_TAG: - return getElementTypeDescValue(((ReferenceType)type).getReferredType()); + return getElementTypeDescValue(((ReferenceType) type).getReferredType()); default: return ValueCreator.createTypedescValue(((StreamType) type).getConstrainedType()); } diff --git a/langlib/lang.test/src/main/java/org/ballerinalang/langlib/test/AssertError.java b/langlib/lang.test/src/main/java/org/ballerinalang/langlib/test/AssertError.java index 1750041d38fc..d9bfd955a2f7 100644 --- a/langlib/lang.test/src/main/java/org/ballerinalang/langlib/test/AssertError.java +++ b/langlib/lang.test/src/main/java/org/ballerinalang/langlib/test/AssertError.java @@ -21,6 +21,7 @@ import io.ballerina.runtime.api.TypeTags; import io.ballerina.runtime.api.creators.ErrorCreator; import io.ballerina.runtime.api.utils.StringUtils; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.internal.TypeChecker; /** @@ -30,7 +31,7 @@ */ public class AssertError { public static void assertError(Object value) { - if (TypeChecker.getType(value).getTag() != TypeTags.ERROR_TAG) { + if (TypeUtils.getReferredType(TypeChecker.getType(value)).getTag() != TypeTags.ERROR_TAG) { throw ErrorCreator.createError(StringUtils.fromString("{ballerina/lang.test}AssertionError"), StringUtils.fromString("expected an error type")); } diff --git a/langlib/lang.test/src/main/java/org/ballerinalang/langlib/test/AssertNotError.java b/langlib/lang.test/src/main/java/org/ballerinalang/langlib/test/AssertNotError.java index 8f70ba533d44..02c2be88ae98 100644 --- a/langlib/lang.test/src/main/java/org/ballerinalang/langlib/test/AssertNotError.java +++ b/langlib/lang.test/src/main/java/org/ballerinalang/langlib/test/AssertNotError.java @@ -21,6 +21,7 @@ import io.ballerina.runtime.api.TypeTags; import io.ballerina.runtime.api.creators.ErrorCreator; import io.ballerina.runtime.api.utils.StringUtils; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.internal.TypeChecker; /** @@ -30,7 +31,7 @@ */ public class AssertNotError { public static void assertNotError(Object value) { - if (TypeChecker.getType(value).getTag() == TypeTags.ERROR_TAG) { + if (TypeUtils.getReferredType(TypeChecker.getType(value)).getTag() == TypeTags.ERROR_TAG) { throw ErrorCreator.createError(StringUtils.fromString("{ballerina/lang.test}AssertionError"), StringUtils.fromString("expected a non-error type")); } diff --git a/langlib/lang.value/src/main/java/org/ballerinalang/langlib/value/CloneWithType.java b/langlib/lang.value/src/main/java/org/ballerinalang/langlib/value/CloneWithType.java index 00ca327e4bb9..d9cb0f9bc5ad 100644 --- a/langlib/lang.value/src/main/java/org/ballerinalang/langlib/value/CloneWithType.java +++ b/langlib/lang.value/src/main/java/org/ballerinalang/langlib/value/CloneWithType.java @@ -108,7 +108,7 @@ private static Object convert(Object value, Type targetType, List } // handle primitive values - if (sourceType.getTag() <= TypeTags.BOOLEAN_TAG) { + if (TypeUtils.getReferredType(sourceType).getTag() <= TypeTags.BOOLEAN_TAG) { if (TypeChecker.checkIsType(value, convertibleType)) { return value; } else { diff --git a/langlib/lang.value/src/main/java/org/ballerinalang/langlib/value/EnsureType.java b/langlib/lang.value/src/main/java/org/ballerinalang/langlib/value/EnsureType.java index 8c00080bb274..924a2a9a13c4 100644 --- a/langlib/lang.value/src/main/java/org/ballerinalang/langlib/value/EnsureType.java +++ b/langlib/lang.value/src/main/java/org/ballerinalang/langlib/value/EnsureType.java @@ -31,7 +31,7 @@ */ public class EnsureType { public static Object ensureType(Object value, BTypedesc type) { - if (TypeChecker.getType(value).getTag() == TypeTags.ERROR_TAG) { + if (TypeUtils.getReferredType(TypeChecker.getType(value)).getTag() == TypeTags.ERROR_TAG) { return value; } return convert(TypeUtils.getReferredType(type.getDescribingType()), value); diff --git a/langlib/lang.value/src/main/java/org/ballerinalang/langlib/value/FromJsonWithType.java b/langlib/lang.value/src/main/java/org/ballerinalang/langlib/value/FromJsonWithType.java index 89c6fb1d9862..e5bc5fb44736 100644 --- a/langlib/lang.value/src/main/java/org/ballerinalang/langlib/value/FromJsonWithType.java +++ b/langlib/lang.value/src/main/java/org/ballerinalang/langlib/value/FromJsonWithType.java @@ -96,7 +96,7 @@ private static Object convert(Object value, Type targetType, List BLangExceptionHelper.getErrorDetails(RuntimeErrors.CANNOT_CONVERT_NIL, targetType)); } - Type sourceType = TypeChecker.getType(value); + Type sourceType = TypeUtils.getReferredType(TypeChecker.getType(value)); if (unresolvedValues.contains(typeValuePair)) { throw new BallerinaException(VALUE_LANG_LIB_CYCLIC_VALUE_REFERENCE_ERROR.getValue(), diff --git a/langlib/lang.xml/src/main/java/org/ballerinalang/langlib/xml/SetChildren.java b/langlib/lang.xml/src/main/java/org/ballerinalang/langlib/xml/SetChildren.java index e4d1f7c10337..c5a4d0540d0f 100644 --- a/langlib/lang.xml/src/main/java/org/ballerinalang/langlib/xml/SetChildren.java +++ b/langlib/lang.xml/src/main/java/org/ballerinalang/langlib/xml/SetChildren.java @@ -23,6 +23,7 @@ import io.ballerina.runtime.api.creators.TypeCreator; import io.ballerina.runtime.api.flags.TypeFlags; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BString; import io.ballerina.runtime.api.values.BXml; import io.ballerina.runtime.internal.TypeChecker; @@ -53,7 +54,7 @@ public static void setChildren(BXml xml, Object children) { throw BLangExceptionHelper.getRuntimeException(RuntimeErrors.XML_FUNC_TYPE_ERROR, "setChildren", "element"); } - Type childrenType = TypeChecker.getType(children); + Type childrenType = TypeUtils.getReferredType(TypeChecker.getType(children)); if (childrenType.getTag() == TypeTags.STRING_TAG) { BXml xmlText = XmlFactory.createXMLText((BString) children); children = xmlText; diff --git a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/natives/io/Sprintf.java b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/natives/io/Sprintf.java index 2ef696d490fb..a976dfea228e 100644 --- a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/natives/io/Sprintf.java +++ b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/natives/io/Sprintf.java @@ -22,6 +22,7 @@ import io.ballerina.runtime.api.types.ArrayType; import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.utils.StringUtils; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BString; import io.ballerina.runtime.internal.TypeChecker; @@ -116,7 +117,7 @@ public static BString sprintf(BString format, Object... args) { private static void formatHexString(StringBuilder result, int k, StringBuilder padding, char x, Object... args) { final Object argsValues = args[k]; - final Type type = TypeChecker.getType(argsValues); + final Type type = TypeUtils.getReferredType(TypeChecker.getType(argsValues)); if (TypeTags.ARRAY_TAG == type.getTag() && TypeTags.BYTE_TAG == ((ArrayType) type).getElementType().getTag()) { BArray byteArray = ((BArray) argsValues); for (int i = 0; i < byteArray.size(); i++) { diff --git a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/natives/mock/GenericMockObjectValue.java b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/natives/mock/GenericMockObjectValue.java index 54fc5eb26038..44b41001735d 100644 --- a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/natives/mock/GenericMockObjectValue.java +++ b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/natives/mock/GenericMockObjectValue.java @@ -233,7 +233,8 @@ private Object[] removeUnnecessaryArgs(Object[] args) { List newArgs = new ArrayList<>(); int i = 0; while (i < args.length) { - if (args[i] != null && (TypeUtils.getType(args[i]).getTag() != TypeTags.TYPEDESC_TAG)) { + if (args[i] != null && + (TypeUtils.getReferredType(TypeUtils.getType(args[i])).getTag() != TypeTags.TYPEDESC_TAG)) { newArgs.add(args[i]); } i += 2; diff --git a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/natives/mock/ObjectMock.java b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/natives/mock/ObjectMock.java index fb09f671701e..656b5b9cb06f 100644 --- a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/natives/mock/ObjectMock.java +++ b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/natives/mock/ObjectMock.java @@ -60,7 +60,7 @@ private ObjectMock() { * @return mock object of provided type */ public static BObject mock(BTypedesc bTypedesc, BObject objectValue) { - ObjectType objectValueType = (ObjectType) objectValue.getType(); + ObjectType objectValueType = (ObjectType) TypeUtils.getReferredType(objectValue.getType()); if (!objectValueType.getName().contains(MockConstants.DEFAULT_MOCK_OBJ_ANON)) { // handle user-defined mock object if (objectValueType.getMethods().length == 0 && @@ -126,7 +126,8 @@ public static BError validatePreparedObj(BObject caseObj) { public static BError validateFunctionName(String functionName, BObject mockObject) { GenericMockObjectValue genericMock = (GenericMockObjectValue) mockObject; - if (!validateFunctionName(functionName, ((ObjectType) genericMock.getType()).getMethods())) { + if (!validateFunctionName(functionName, + ((ObjectType) TypeUtils.getReferredType(genericMock.getType())).getMethods())) { String detail = "invalid function name '" + functionName + " ' provided"; throw ErrorCreator.createError( MockConstants.TEST_PACKAGE_ID, @@ -147,7 +148,8 @@ public static BError validateFunctionName(String functionName, BObject mockObjec */ public static BError validateFieldName(String fieldName, BObject mockObject) { GenericMockObjectValue genericMock = (GenericMockObjectValue) mockObject; - if (!validateFieldName(fieldName, ((ObjectType) genericMock.getType()).getFields())) { + if (!validateFieldName(fieldName, + ((ObjectType) TypeUtils.getReferredType(genericMock.getType())).getFields())) { String detail = "invalid field name '" + fieldName + "' provided"; throw ErrorCreator.createError( MockConstants.TEST_PACKAGE_ID, @@ -171,7 +173,8 @@ public static BError validateArguments(BObject caseObj) { String functionName = caseObj.getStringValue(StringUtils.fromString("functionName")).toString(); BArray argsList = caseObj.getArrayValue(StringUtils.fromString("args")); - for (MethodType attachedFunction : ((ObjectType) genericMock.getType()).getMethods()) { + for (MethodType attachedFunction : + ((ObjectType) TypeUtils.getReferredType(genericMock.getType())).getMethods()) { if (attachedFunction.getName().equals(functionName)) { // validate the number of arguments provided @@ -248,7 +251,7 @@ public static BError thenReturn(BObject caseObj) { } functionName = null; } - ObjectType objectType = (ObjectType) genericMock.getType(); + ObjectType objectType = (ObjectType) TypeUtils.getReferredType(genericMock.getType()); if (functionName != null) { // register return value for member function BArray args = caseObj.getArrayValue(StringUtils.fromString("args")); @@ -300,7 +303,7 @@ public static BError thenReturnSequence(BObject caseObj) { break; } if (!validateReturnValue(functionName, returnVals.getValues()[i], - ((ObjectType) genericMock.getType()).getMethods())) { + ((ObjectType) TypeUtils.getReferredType(genericMock.getType())).getMethods())) { String detail = "return value provided at position '" + i + "' does not match the return type of function '" + functionName + "()'"; return ErrorCreator.createError( @@ -375,7 +378,7 @@ private static boolean validateUnionValue(Object returnVal, UnionType functionRe * @return whether the return value is valid */ private static boolean validateStreamValue(Object returnVal, StreamType streamType) { - Type sourceType = getType(returnVal); + Type sourceType = TypeUtils.getReferredType(getType(returnVal)); if (sourceType.getTag() == TypeTags.STREAM_TAG) { Type targetConstrainedType = streamType.getConstrainedType(); Type targetCompletionType = streamType.getCompletionType(); diff --git a/tests/jballerina-benchmark-test/src/main/java/org/ballerinalang/benchmark/nativeimpl/Utils.java b/tests/jballerina-benchmark-test/src/main/java/org/ballerinalang/benchmark/nativeimpl/Utils.java index e2302655863b..84f3fa7c57c8 100644 --- a/tests/jballerina-benchmark-test/src/main/java/org/ballerinalang/benchmark/nativeimpl/Utils.java +++ b/tests/jballerina-benchmark-test/src/main/java/org/ballerinalang/benchmark/nativeimpl/Utils.java @@ -147,7 +147,7 @@ public static BString sprintf(BString format, Object... args) { private static void formatHexString(StringBuilder result, int k, StringBuilder padding, char x, Object... args) { final Object argsValues = args[k]; - final Type type = TypeUtils.getType(argsValues); + final Type type = TypeUtils.getReferredType(TypeUtils.getType(argsValues)); if (TypeTags.ARRAY_TAG == type.getTag() && TypeTags.BYTE_TAG == ((ArrayType) type).getElementType().getTag()) { BArray byteArray = ((BArray) argsValues); for (int i = 0; i < byteArray.size(); i++) { From c6ca4f448ca64d1c4bffaed33a70c66831a0d690 Mon Sep 17 00:00:00 2001 From: HindujaB Date: Fri, 23 Sep 2022 17:20:27 +0530 Subject: [PATCH 022/450] Address review suggestions --- .../main/java/io/ballerina/runtime/api/utils/TypeUtils.java | 5 +++-- .../io/ballerina/runtime/internal/values/ArrayValueImpl.java | 1 - .../compiler/bir/codegen/JvmInstructionGen.java | 1 + .../nativeimpl/jvm/runtime/api/tests/TypeReference.java | 4 ++-- .../test-src/runtime/api/types/modules/typeref/typeAPIs.bal | 4 ++-- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/TypeUtils.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/TypeUtils.java index 9ad74e33464f..08fe7d823abb 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/TypeUtils.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/TypeUtils.java @@ -55,7 +55,8 @@ private TypeUtils() { } public static boolean isValueType(Type type) { - switch (TypeUtils.getReferredType(type).getTag()) { + Type referredType = TypeUtils.getReferredType(type); + switch (referredType.getTag()) { case TypeTags.INT_TAG: case TypeTags.BYTE_TAG: case TypeTags.FLOAT_TAG: @@ -64,7 +65,7 @@ public static boolean isValueType(Type type) { case TypeTags.STRING_TAG: return true; case TypeTags.FINITE_TYPE_TAG: - for (Object value : ((BFiniteType) type).valueSpace) { + for (Object value : ((BFiniteType) referredType).valueSpace) { if (!isValueType(TypeChecker.getType(value))) { return false; } diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ArrayValueImpl.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ArrayValueImpl.java index 4a5f11a9df71..11dd179ed53f 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ArrayValueImpl.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/ArrayValueImpl.java @@ -980,7 +980,6 @@ public void freezeDirect() { return; } -// this.arrayType = (ArrayType) ReadOnlyUtils.setImmutableTypeAndGetEffectiveType(this.arrayType); this.type = ReadOnlyUtils.setImmutableTypeAndGetEffectiveType(this.type); this.arrayType = (ArrayType) TypeUtils.getReferredType(type); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java index 4e27a5b5075d..322f9e9b675a 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java @@ -1729,6 +1729,7 @@ void generateFPLoadIns(BIRNonTerminator.FPLoad inst) { JvmCodeGenUtil.visitInvokeDynamic(mv, asyncDataCollector.getEnclosingClass(), lambdaName, inst.closureMaps.size()); + // Need to remove once we fix #37875 type = inst.lhsOp.variableDcl.type.tag == TypeTags.TYPEREFDESC ? inst.lhsOp.variableDcl.type : type; jvmTypeGen.loadType(this.mv, type); diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java index b8dae9de08dc..b1440d44a126 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java @@ -1,7 +1,7 @@ /* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. * - * WSO2 Inc. licenses this file to you under the Apache License, + * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. * You may obtain a copy of the License at diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal index 76f385386d00..ea78a6907246 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal @@ -1,6 +1,6 @@ -// Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +// Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com) All Rights Reserved. // -// WSO2 Inc. licenses this file to you under the Apache License, +// WSO2 LLC. licenses this file to you under the Apache License, // Version 2.0 (the "License"); you may not use this file except // in compliance with the License. // You may obtain a copy of the License at From 5c4966c1e0191446a1a0e217084d582493bf41c3 Mon Sep 17 00:00:00 2001 From: HindujaB Date: Fri, 23 Sep 2022 17:55:21 +0530 Subject: [PATCH 023/450] Fix shell test --- .../main/java/io/ballerina/runtime/internal/TypeChecker.java | 2 +- .../io/ballerina/runtime/internal/scheduling/AsyncUtils.java | 4 +++- .../resources/testcases/getResult/functional.programming.json | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java index 7fb4ceecd8e5..d35efa90b5e1 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java @@ -137,7 +137,7 @@ public class TypeChecker { public static Object checkCast(Object sourceVal, Type targetType) { List errors = new ArrayList<>(); - Type sourceType = getType(sourceVal); + Type sourceType = TypeUtils.getReferredType(getType(sourceVal)); if (checkIsType(errors, sourceVal, sourceType, targetType)) { return sourceVal; } diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/scheduling/AsyncUtils.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/scheduling/AsyncUtils.java index 3051251c93a2..9f80bbbd958d 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/scheduling/AsyncUtils.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/scheduling/AsyncUtils.java @@ -19,6 +19,7 @@ package io.ballerina.runtime.internal.scheduling; import io.ballerina.runtime.api.async.StrandMetadata; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BError; import io.ballerina.runtime.api.values.BFunctionPointer; import io.ballerina.runtime.internal.types.BFunctionType; @@ -84,7 +85,8 @@ public static FutureValue invokeFunctionPointerAsync(BFunctionPointer func blockStrand(parent); final FutureValue future = scheduler.createFuture(parent, null, null, - ((BFunctionType) func.getType()).retType, name, metadata); + ((BFunctionType) TypeUtils.getReferredType(func.getType())).retType, name, + metadata); future.callback = callback; callback.setFuture(future); callback.setStrand(parent); diff --git a/misc/ls-extensions/modules/bal-shell-service/src/test/resources/testcases/getResult/functional.programming.json b/misc/ls-extensions/modules/bal-shell-service/src/test/resources/testcases/getResult/functional.programming.json index ba9053506774..b09f41f282c9 100644 --- a/misc/ls-extensions/modules/bal-shell-service/src/test/resources/testcases/getResult/functional.programming.json +++ b/misc/ls-extensions/modules/bal-shell-service/src/test/resources/testcases/getResult/functional.programming.json @@ -39,9 +39,9 @@ "source": "f", "result": { "shellValue": { - "value": "function isolated function (int) returns (boolean)", + "value": "function IntFilter", "mimeType":"plain/text", - "type":"isolated function (int) returns (boolean)" + "type":"IntFilter" }, "errors":[], "diagnostics":[], From 271fc9d9fb065d25580e8a784dc52b5af9789c27 Mon Sep 17 00:00:00 2001 From: Nipuna Ranasinghe Date: Wed, 28 Sep 2022 13:20:59 +0530 Subject: [PATCH 024/450] Incorporate runtime TypeReferenceType changes to the debugger --- .../debugadapter/variable/VariableUtils.java | 2 + .../debugadapter/variable/types/BTable.java | 41 +++++++++++++------ 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/variable/VariableUtils.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/variable/VariableUtils.java index 23ef6f0a7f6f..2b8921cac828 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/variable/VariableUtils.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/variable/VariableUtils.java @@ -52,6 +52,8 @@ public class VariableUtils { // Used to trim redundant beginning and ending double quotes from a string, if presents. private static final String ADDITIONAL_QUOTES_REMOVE_REGEX = "^\"|\"$"; static final String INTERNAL_VALUE_PREFIX = "io.ballerina.runtime.internal.values."; + public static final String INTERNAL_TYPE_PREFIX = "io.ballerina.runtime.internal.types."; + public static final String INTERNAL_TYPE_REF_TYPE = "BTypeReferenceType"; /** * Returns the corresponding ballerina variable type of a given ballerina backend jvm variable instance. diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/variable/types/BTable.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/variable/types/BTable.java index 88a28cc4551f..87172eee4eef 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/variable/types/BTable.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/variable/types/BTable.java @@ -36,6 +36,8 @@ import static org.ballerinalang.debugadapter.variable.VariableUtils.FIELD_TYPE; import static org.ballerinalang.debugadapter.variable.VariableUtils.FIELD_TYPENAME; +import static org.ballerinalang.debugadapter.variable.VariableUtils.INTERNAL_TYPE_PREFIX; +import static org.ballerinalang.debugadapter.variable.VariableUtils.INTERNAL_TYPE_REF_TYPE; import static org.ballerinalang.debugadapter.variable.VariableUtils.UNKNOWN_VALUE; import static org.ballerinalang.debugadapter.variable.VariableUtils.getFieldValue; import static org.ballerinalang.debugadapter.variable.VariableUtils.getStringFrom; @@ -49,6 +51,7 @@ public class BTable extends IndexedCompoundVariable { private final Map tableValues = new LinkedHashMap<>(); private static final String FIELD_CONSTRAINT = "constraint"; + private static final String FIELD_REFERRED_TYPE = "referredType"; private static final String METHOD_SIZE = "size"; private static final String METHOD_GET_ITERATOR = "getIterator"; private static final String METHOD_HAS_NEXT = "hasNext"; @@ -96,20 +99,34 @@ public int getChildrenCount() { /** * Retrieves the constraint type of the table variable, in string format. */ - private String getConstrainedTypeName() throws DebugVariableException { - Optional type = getFieldValue(jvmValue, FIELD_TYPE); - if (type.isEmpty()) { - return UNKNOWN_VALUE; - } - Optional constraint = getFieldValue(type.get(), FIELD_CONSTRAINT); - if (constraint.isEmpty()) { - return UNKNOWN_VALUE; - } - Optional constraintTypeName = getFieldValue(constraint.get(), FIELD_TYPENAME); - if (constraintTypeName.isEmpty()) { + private String getConstrainedTypeName() { + try { + Optional type = getFieldValue(jvmValue, FIELD_TYPE); + if (type.isPresent() && isTypeReferenceType(type.get())) { + type = getFieldValue(type.get(), FIELD_REFERRED_TYPE); + } + if (type.isEmpty()) { + return UNKNOWN_VALUE; + } + + Optional constraint = getFieldValue(type.get(), FIELD_CONSTRAINT); + if (constraint.isEmpty()) { + return UNKNOWN_VALUE; + } + + Optional constraintTypeName = getFieldValue(constraint.get(), FIELD_TYPENAME); + if (constraintTypeName.isEmpty()) { + return UNKNOWN_VALUE; + } + + return getStringFrom(constraintTypeName.get()); + } catch (DebugVariableException e) { return UNKNOWN_VALUE; } - return getStringFrom(constraintTypeName.get()); + } + + private boolean isTypeReferenceType(Value runtimeType) { + return runtimeType.type().name().equals(INTERNAL_TYPE_PREFIX + INTERNAL_TYPE_REF_TYPE); } private int getTableSize() { From 8008402d4a2f4c6b93a8ed8a5923b6c64a3b7399 Mon Sep 17 00:00:00 2001 From: HindujaB Date: Wed, 28 Sep 2022 16:19:47 +0530 Subject: [PATCH 025/450] Address review suggestions --- .../java/io/ballerina/runtime/internal/TypeChecker.java | 4 +--- .../ballerina/runtime/internal/scheduling/AsyncUtils.java | 3 +-- .../nativeimpl/jvm/runtime/api/tests/TypeReference.java | 6 ++---- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java index d35efa90b5e1..e8f5288b5033 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java @@ -3012,18 +3012,16 @@ private static boolean checkValueEquals(Object lhsValue, Object rhsValue, List func blockStrand(parent); final FutureValue future = scheduler.createFuture(parent, null, null, - ((BFunctionType) TypeUtils.getReferredType(func.getType())).retType, name, - metadata); + ((BFunctionType) TypeUtils.getReferredType(func.getType())).retType, name, metadata); future.callback = callback; callback.setFuture(future); callback.setStrand(parent); diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java index b1440d44a126..4cc56460c99b 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java @@ -1,6 +1,5 @@ /* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * + * Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com) All Rights Reserved. * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. @@ -55,7 +54,7 @@ /** * Utility methods used for runtime api @{@link io.ballerina.runtime.internal.types.BTypeReferenceType} testing. * - * @since 2.3.0 + * @since 2201.3.0 */ public class TypeReference { @@ -146,7 +145,6 @@ public static Boolean validateStreamType(BTypedesc value1, BStream value2) { if (streamType.getConstrainedType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { throw error; } - if (streamType.getCompletionType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { throw error; } From f9a135663ddf2fc56e8e681044790b826e85e5b3 Mon Sep 17 00:00:00 2001 From: HindujaB Date: Thu, 29 Sep 2022 08:44:06 +0530 Subject: [PATCH 026/450] Fix checkStyle error --- .../io/ballerina/runtime/internal/values/MapValueImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/MapValueImpl.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/MapValueImpl.java index 7234078aadeb..9c2b8d02e85d 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/MapValueImpl.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/MapValueImpl.java @@ -307,7 +307,8 @@ public void populateInitialValue(K key, V value) { putValue(key, value); } else { BString fieldName = (BString) key; - if (MapUtils.handleInherentTypeViolatingRecordUpdate(this, fieldName, value, (BRecordType) referredType, true)) { + if (MapUtils.handleInherentTypeViolatingRecordUpdate(this, fieldName, value, (BRecordType) referredType, + true)) { putValue(key, value); } } From 9a22145c0dd6989912401948fe47f94af48bd382 Mon Sep 17 00:00:00 2001 From: gabilang Date: Sat, 1 Oct 2022 13:33:30 +0530 Subject: [PATCH 027/450] Reuse on-fail node without creating new blocks each time --- .../ballerinalang/compiler/bir/BIRGen.java | 85 +++++++++++-------- .../ballerinalang/compiler/bir/BIRGenEnv.java | 5 ++ .../compiler/desugar/Desugar.java | 28 ++++-- 3 files changed, 77 insertions(+), 41 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java index 7df4c1962d77..4011fbf3562c 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java @@ -213,6 +213,7 @@ import java.util.Map; import java.util.Set; import java.util.TreeMap; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; import javax.xml.XMLConstants; @@ -1013,51 +1014,67 @@ public void visit(BLangFail failNode) { numLocks--; } - // Create a basic block for the on fail clause. - BIRBasicBlock onFailBB = new BIRBasicBlock(this.env.nextBBId(names)); - addToTrapStack(onFailBB); - this.env.enclBasicBlocks.add(onFailBB); + BIRBasicBlock onFailBB = this.env.onFailStartBlockByFailNode.get(failNode); + if (onFailBB == null) { + // Create a basic block for the on fail clause. + onFailBB = new BIRBasicBlock(this.env.nextBBId(names)); + addToTrapStack(onFailBB); + this.env.enclBasicBlocks.add(onFailBB); - // Insert a GOTO instruction as the terminal instruction into current basic block. - this.env.enclBB.terminator = new BIRTerminator.GOTO(null, onFailBB, this.currentScope); + // Insert a GOTO instruction as the terminal instruction into current basic block. + this.env.enclBB.terminator = new BIRTerminator.GOTO(null, onFailBB, this.currentScope); - // Visit condition expression - this.env.enclBB = onFailBB; - failNode.exprStmt.accept(this); - if (this.env.enclBB.terminator == null) { - this.env.enclBB.terminator = new BIRTerminator.GOTO(null, this.env.enclOnFailEndBB, - this.currentScope); - } + // Visit condition expression + this.env.enclBB = onFailBB; + failNode.exprStmt.accept(this); + if (this.env.enclBB.terminator == null) { + this.env.enclBB.terminator = new BIRTerminator.GOTO(null, this.env.enclOnFailEndBB, + this.currentScope); + } - // Statements after fail expression are unreachable, hence ignored - BIRBasicBlock ignoreBlock = new BIRBasicBlock(this.env.nextBBId(names)); - addToTrapStack(ignoreBlock); - ignoreBlock.terminator = new BIRTerminator.GOTO(null, this.env.enclOnFailEndBB, this.currentScope); - this.env.enclBasicBlocks.add(ignoreBlock); - this.env.enclBB = ignoreBlock; + // Statements after fail expression are unreachable, hence ignored + BIRBasicBlock ignoreBlock = new BIRBasicBlock(this.env.nextBBId(names)); + addToTrapStack(ignoreBlock); + ignoreBlock.terminator = new BIRTerminator.GOTO(null, this.env.enclOnFailEndBB, this.currentScope); + this.env.enclBasicBlocks.add(ignoreBlock); + this.env.enclBB = ignoreBlock; + + this.env.onFailStartBlockByFailNode.put(failNode, onFailBB); + return; + } + this.env.enclBB.terminator = new BIRTerminator.GOTO(null, onFailBB, this.currentScope); + this.env.enclBB = onFailBB; } @Override public void visit(BLangSimpleVariableDef astVarDefStmt) { - VarKind kind; + BIRVariableDcl birVarDcl; + AtomicBoolean isExistingVarDef = new AtomicBoolean(true); if (astVarDefStmt.var.symbol.origin == SymbolOrigin.VIRTUAL) { - kind = VarKind.SYNTHETIC; + birVarDcl = this.env.syntheticVariableDclMap.computeIfAbsent(astVarDefStmt.var.symbol, k -> { + isExistingVarDef.set(false); + return new BIRVariableDcl(astVarDefStmt.pos, astVarDefStmt.var.symbol.type, + this.env.nextLocalVarId(names), VarScope.FUNCTION, VarKind.SYNTHETIC, + astVarDefStmt.var.name.value); + }); } else { - kind = VarKind.LOCAL; + birVarDcl = new BIRVariableDcl(astVarDefStmt.pos, astVarDefStmt.var.symbol.type, + this.env.nextLocalVarId(names), VarScope.FUNCTION, VarKind.LOCAL, astVarDefStmt.var.name.value); + isExistingVarDef.set(false); + } + if (!isExistingVarDef.get()) { + birVarDcl.startBB = this.env.enclBB; + this.env.varDclsByBlock.get(this.currentBlock).add(birVarDcl); + this.env.enclFunc.localVars.add(birVarDcl); + // We maintain a mapping from variable symbol to the bir_variable declaration. + // This is required to pull the correct bir_variable declaration for variable references. + this.env.symbolVarMap.put(astVarDefStmt.var.symbol, birVarDcl); + + BirScope newScope = new BirScope(this.currentScope.id + 1, this.currentScope); + birVarDcl.insScope = newScope; + this.currentScope = newScope; } - BIRVariableDcl birVarDcl = new BIRVariableDcl(astVarDefStmt.pos, astVarDefStmt.var.symbol.type, - this.env.nextLocalVarId(names), VarScope.FUNCTION, kind, astVarDefStmt.var.name.value); - birVarDcl.startBB = this.env.enclBB; - this.env.varDclsByBlock.get(this.currentBlock).add(birVarDcl); - this.env.enclFunc.localVars.add(birVarDcl); - // We maintain a mapping from variable symbol to the bir_variable declaration. - // This is required to pull the correct bir_variable declaration for variable references. - this.env.symbolVarMap.put(astVarDefStmt.var.symbol, birVarDcl); - - BirScope newScope = new BirScope(this.currentScope.id + 1, this.currentScope); - birVarDcl.insScope = newScope; - this.currentScope = newScope; if (astVarDefStmt.var.expr == null) { return; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGenEnv.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGenEnv.java index 3963fa5e0314..a05966fd6b60 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGenEnv.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGenEnv.java @@ -25,6 +25,8 @@ import org.wso2.ballerinalang.compiler.bir.model.BIRNode.BIRVariableDcl; import org.wso2.ballerinalang.compiler.bir.model.BIROperand; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol; +import org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol; +import org.wso2.ballerinalang.compiler.tree.statements.BLangFail; import org.wso2.ballerinalang.compiler.util.Name; import org.wso2.ballerinalang.compiler.util.Names; @@ -32,6 +34,7 @@ import java.util.List; import java.util.Map; import java.util.Stack; +import java.util.concurrent.ConcurrentHashMap; /** * Stores the state such as the current node, enclosing package, function etc, during bir generation. @@ -62,6 +65,8 @@ class BIRGenEnv { Stack> trapBlocks = new Stack<>(); Map> varDclsByBlock = new HashMap<>(); + Map syntheticVariableDclMap = new ConcurrentHashMap<>(); + Map onFailStartBlockByFailNode = new HashMap<>(); // This is to hold variables to unlock in each scope // for example when we are to return from somewhere, we need to unlock all the diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java index 0b64834fe637..ce5c9c8896f5 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java @@ -424,6 +424,8 @@ public class Desugar extends BLangNodeVisitor { private Map declaredVarDef = new HashMap<>(); private List inlineXMLNamespaces; private Map stmtsToBePropagatedToQuery = new HashMap<>(); + private final Map onFailClauseErrorVariable = new HashMap<>(); + private final Map bLangFailNodeByOnFailClause = new HashMap<>(); // Reuse the strand annotation in isolated workers and start action private BLangAnnotationAttachment strandAnnotAttachement; @@ -9355,12 +9357,18 @@ private BLangBlockStmt getSafeErrorAssignment(Location location, BLangSimpleVarR .anyMatch(retType -> types.isAssignable(errorType, retType))); String patternFailureCaseVarName = GEN_VAR_PREFIX.value + "t_failure"; - BLangSimpleVariable errorVar = - ASTBuilderUtil.createVariable(location, patternFailureCaseVarName, symTable.errorType, - createTypeCastExpr(ref, symTable.errorType), - new BVarSymbol(0, names.fromString(patternFailureCaseVarName), - this.env.scope.owner.pkgID, symTable.errorType, - this.env.scope.owner, location, VIRTUAL)); + BVarSymbol errorVarSymbol; + if (!isCheckPanicExpr && this.onFailClause != null) { + errorVarSymbol = onFailClauseErrorVariable.computeIfAbsent(this.onFailClause, + k -> new BVarSymbol(0, names.fromString(patternFailureCaseVarName), + this.env.scope.owner.pkgID, symTable.errorType, this.env.scope.owner, null, VIRTUAL)); + } else { + errorVarSymbol = new BVarSymbol(0, names.fromString(patternFailureCaseVarName), + this.env.scope.owner.pkgID, symTable.errorType, this.env.scope.owner, location, VIRTUAL); + } + + BLangSimpleVariable errorVar = ASTBuilderUtil.createVariable(location, patternFailureCaseVarName, + symTable.errorType, createTypeCastExpr(ref, symTable.errorType), errorVarSymbol); BLangBlockStmt blockStmt = ASTBuilderUtil.createBlockStmt(location); BLangSimpleVariableDef errorVarDef = ASTBuilderUtil.createVariableDef(location, errorVar); @@ -9368,7 +9376,13 @@ private BLangBlockStmt getSafeErrorAssignment(Location location, BLangSimpleVarR BLangVariableReference errorVarRef = ASTBuilderUtil.createVariableRef(location, errorVar.symbol); if (!isCheckPanicExpr && (returnOnError || this.onFailClause != null)) { // fail e; - BLangFail failStmt = (BLangFail) TreeBuilder.createFailNode(); + BLangFail failStmt; + if (this.onFailClause != null) { + failStmt = bLangFailNodeByOnFailClause.computeIfAbsent(this.onFailClause, + k -> (BLangFail) TreeBuilder.createFailNode()); + } else { + failStmt = (BLangFail) TreeBuilder.createFailNode(); + } failStmt.pos = location; failStmt.expr = errorVarRef; blockStmt.addStatement(failStmt); From 6cc803dea5fef7d1efa719bc8ad85e980b079989 Mon Sep 17 00:00:00 2001 From: gabilang Date: Fri, 7 Oct 2022 10:15:03 +0530 Subject: [PATCH 028/450] Reuse fail node when it has nested fail stmts --- .../ballerinalang/compiler/bir/BIRGen.java | 25 +++++++ .../ballerinalang/compiler/bir/BIRGenEnv.java | 3 + .../compiler/desugar/Desugar.java | 73 ++++++++++--------- .../tree/statements/BLangBlockStmt.java | 1 + .../test-src/bir/bir-dump/failWithinOnFail | 21 +++--- 5 files changed, 80 insertions(+), 43 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java index 4011fbf3562c..e307d66471cb 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java @@ -961,6 +961,12 @@ public void visit(BLangBlockStmt astBlockStmt) { if (astBlockStmt.failureBreakMode != BLangBlockStmt.FailureBreakMode.NOT_BREAKABLE) { blockEndBB = beginBreakableBlock(astBlockStmt.failureBreakMode); } + if (astBlockStmt.isFromFailNode) { + breakIntoNewBasicBlock(astBlockStmt); + if (this.env.failStartBBAlreadyAvailable) { + return; + } + } for (BLangStatement astStmt : astBlockStmt.stmts) { astStmt.accept(this); } @@ -985,6 +991,25 @@ private void breakBBForLetExprVariables(Location pos) { this.env.enclBB = letExprEndBB; } + private void breakIntoNewBasicBlock(BLangBlockStmt bLangBlockStmt) { + BIRBasicBlock blockBB = this.env.failStartBasicBlockMap.get(bLangBlockStmt); + if (blockBB == null) { + this.env.failStartBBAlreadyAvailable = false; + blockBB = new BIRBasicBlock(this.env.nextBBId(names)); + this.env.enclBasicBlocks.add(blockBB); + // Insert a GOTO instruction as the terminal instruction into current basic block. + this.env.enclBB.terminator = new BIRTerminator.GOTO(null, blockBB, this.currentScope); + this.env.enclBB = blockBB; + + this.env.failStartBasicBlockMap.put(bLangBlockStmt, blockBB); + return; + } + this.env.failStartBBAlreadyAvailable = true; + // Insert a GOTO instruction as the terminal instruction into current basic block. + this.env.enclBB.terminator = new BIRTerminator.GOTO(null, blockBB, this.currentScope); + this.env.enclBB = blockBB; + } + @Override public void visit(BLangFail failNode) { if (failNode.expr == null) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGenEnv.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGenEnv.java index a05966fd6b60..fbb2eda2438d 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGenEnv.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGenEnv.java @@ -26,6 +26,7 @@ import org.wso2.ballerinalang.compiler.bir.model.BIROperand; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol; +import org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt; import org.wso2.ballerinalang.compiler.tree.statements.BLangFail; import org.wso2.ballerinalang.compiler.util.Name; import org.wso2.ballerinalang.compiler.util.Names; @@ -67,6 +68,8 @@ class BIRGenEnv { Map> varDclsByBlock = new HashMap<>(); Map syntheticVariableDclMap = new ConcurrentHashMap<>(); Map onFailStartBlockByFailNode = new HashMap<>(); + Map failStartBasicBlockMap = new HashMap<>(); + boolean failStartBBAlreadyAvailable; // This is to hold variables to unlock in each scope // for example when we are to return from somewhere, we need to unlock all the diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java index ce5c9c8896f5..d9bb1f639d69 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java @@ -426,6 +426,7 @@ public class Desugar extends BLangNodeVisitor { private Map stmtsToBePropagatedToQuery = new HashMap<>(); private final Map onFailClauseErrorVariable = new HashMap<>(); private final Map bLangFailNodeByOnFailClause = new HashMap<>(); + private final Map blockStmtByFailNode = new HashMap<>(); // Reuse the strand annotation in isolated workers and start action private BLangAnnotationAttachment strandAnnotAttachement; @@ -5127,42 +5128,46 @@ onFailErrorVariableSymbol.name.value, onFailErrorVariableSymbol.type, rewrite(fa private BLangBlockStmt rewriteNestedOnFail(BLangOnFailClause onFailClause, BLangFail fail) { BLangOnFailClause currentOnFail = this.onFailClause; - - BLangBlockStmt onFailBody = ASTBuilderUtil.createBlockStmt(onFailClause.pos); - onFailBody.stmts.addAll(onFailClause.body.stmts); - onFailBody.scope = onFailClause.body.scope; - onFailBody.mapSymbol = onFailClause.body.mapSymbol; - onFailBody.failureBreakMode = onFailClause.body.failureBreakMode; - VariableDefinitionNode onFailVarDefNode = onFailClause.variableDefinitionNode; - - if (onFailVarDefNode != null) { - BVarSymbol onFailErrorVariableSymbol = - ((BLangSimpleVariableDef) onFailVarDefNode).var.symbol; - BLangSimpleVariable errorVar = ASTBuilderUtil.createVariable(onFailErrorVariableSymbol.pos, - onFailErrorVariableSymbol.name.value, onFailErrorVariableSymbol.type, rewrite(fail.expr, env), - onFailErrorVariableSymbol); - BLangSimpleVariableDef errorVarDef = ASTBuilderUtil.createVariableDef(onFailClause.pos, errorVar); - onFailBody.scope.define(onFailErrorVariableSymbol.name, onFailErrorVariableSymbol); - onFailBody.stmts.add(0, errorVarDef); - } - - int currentOnFailIndex = this.enclosingOnFailClause.indexOf(this.onFailClause); - int enclosingOnFailIndex = currentOnFailIndex <= 0 ? this.enclosingOnFailClause.size() - 1 - : (currentOnFailIndex - 1); - this.onFailClause = this.enclosingOnFailClause.get(enclosingOnFailIndex); - onFailBody = rewrite(onFailBody, env); - BLangFail failToEndBlock = new BLangFail(); - if (onFailClause.isInternal && fail.exprStmt != null) { - if (fail.exprStmt instanceof BLangPanic) { - setPanicErrorToTrue(onFailBody, onFailClause); - } else { - onFailBody.stmts.add((BLangStatement) fail.exprStmt); + BLangBlockStmt onFailBody = blockStmtByFailNode.get(fail); + if (onFailBody == null) { + onFailBody = ASTBuilderUtil.createBlockStmt(onFailClause.pos); + onFailBody.stmts.addAll(onFailClause.body.stmts); + onFailBody.scope = onFailClause.body.scope; + onFailBody.mapSymbol = onFailClause.body.mapSymbol; + onFailBody.failureBreakMode = onFailClause.body.failureBreakMode; + onFailBody.isFromFailNode = true; + VariableDefinitionNode onFailVarDefNode = onFailClause.variableDefinitionNode; + + if (onFailVarDefNode != null) { + BVarSymbol onFailErrorVariableSymbol = + ((BLangSimpleVariableDef) onFailVarDefNode).var.symbol; + BLangSimpleVariable errorVar = ASTBuilderUtil.createVariable(onFailErrorVariableSymbol.pos, + onFailErrorVariableSymbol.name.value, onFailErrorVariableSymbol.type, rewrite(fail.expr, env), + onFailErrorVariableSymbol); + BLangSimpleVariableDef errorVarDef = ASTBuilderUtil.createVariableDef(onFailClause.pos, errorVar); + onFailBody.scope.define(onFailErrorVariableSymbol.name, onFailErrorVariableSymbol); + onFailBody.stmts.add(0, errorVarDef); + } + + int currentOnFailIndex = this.enclosingOnFailClause.indexOf(this.onFailClause); + int enclosingOnFailIndex = currentOnFailIndex <= 0 ? this.enclosingOnFailClause.size() - 1 + : (currentOnFailIndex - 1); + this.onFailClause = this.enclosingOnFailClause.get(enclosingOnFailIndex); + onFailBody = rewrite(onFailBody, env); + BLangFail failToEndBlock = new BLangFail(); + if (onFailClause.isInternal && fail.exprStmt != null) { + if (fail.exprStmt instanceof BLangPanic) { + setPanicErrorToTrue(onFailBody, onFailClause); + } else { + onFailBody.stmts.add((BLangStatement) fail.exprStmt); + } } + if (onFailClause.bodyContainsFail && !onFailClause.isInternal) { + onFailBody.stmts.add(failToEndBlock); + } + this.onFailClause = currentOnFail; + blockStmtByFailNode.put(fail, onFailBody); } - if (onFailClause.bodyContainsFail && !onFailClause.isInternal) { - onFailBody.stmts.add(failToEndBlock); - } - this.onFailClause = currentOnFail; return onFailBody; } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/statements/BLangBlockStmt.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/statements/BLangBlockStmt.java index 2eba7251279c..24d77c741039 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/statements/BLangBlockStmt.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/statements/BLangBlockStmt.java @@ -44,6 +44,7 @@ public class BLangBlockStmt extends BLangStatement implements BlockStatementNode public FailureBreakMode failureBreakMode = FailureBreakMode.NOT_BREAKABLE; public boolean isLetExpr = false; + public boolean isFromFailNode = false; /** * We need to keep a reference to the block statements scope here. diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/bir/bir-dump/failWithinOnFail b/tests/jballerina-unit-test/src/test/resources/test-src/bir/bir-dump/failWithinOnFail index c931e893439c..efb87f13b746 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/bir/bir-dump/failWithinOnFail +++ b/tests/jballerina-unit-test/src/test/resources/test-src/bir/bir-dump/failWithinOnFail @@ -22,13 +22,16 @@ failWithinOnFail function() -> string|error { bb1 { %6 = ConstLoad 2; %7 = %1 < %6; - %7? bb2 : bb5; + %7? bb2 : bb6; } bb2 { %9 = ConstLoad -> Within do statement; %3 = %3 + %9; %6 = ConstLoad 1; %1 = %1 + %6; + GOTO bb3; + } + bb3 { %9 = ConstLoad custom error; %18 = ConstLoad 0; %17 = %18; @@ -36,29 +39,29 @@ failWithinOnFail function() -> string|error { %21 = ConstLoad message; %22 = ConstLoad error value; %20 = NewMap %19; - %23 = cloneReadOnly(%20) -> bb3; + %23 = cloneReadOnly(%20) -> bb4; } - bb3 { + bb4 { %14 = error error(%9, %17, %23); %21 = ConstLoad -> Error caught in inner on fail; %3 = %3 + %21; %0 = %14; - GOTO bb6; + GOTO bb7; } - bb4 { + bb5 { %22 = ConstLoad -> After do statement; %3 = %3 + %22; GOTO bb1; } - bb5 { + bb6 { %9 = ConstLoad -> Execution completed.; %3 = %3 + %9; %0 = %3; - GOTO bb6; + GOTO bb7; } - bb6 { + bb7 { return; } -} +} \ No newline at end of file From 630e1a818a18f8ee147180f0d6f094995b8021fa Mon Sep 17 00:00:00 2001 From: gabilang Date: Tue, 11 Oct 2022 10:37:41 +0530 Subject: [PATCH 029/450] Exclude fail nodes used in virtual functions --- .../java/org/wso2/ballerinalang/compiler/desugar/Desugar.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java index d9bb1f639d69..3190abd9ce69 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java @@ -9363,7 +9363,7 @@ private BLangBlockStmt getSafeErrorAssignment(Location location, BLangSimpleVarR String patternFailureCaseVarName = GEN_VAR_PREFIX.value + "t_failure"; BVarSymbol errorVarSymbol; - if (!isCheckPanicExpr && this.onFailClause != null) { + if (!isCheckPanicExpr && this.onFailClause != null && invokableSymbol.origin != VIRTUAL) { errorVarSymbol = onFailClauseErrorVariable.computeIfAbsent(this.onFailClause, k -> new BVarSymbol(0, names.fromString(patternFailureCaseVarName), this.env.scope.owner.pkgID, symTable.errorType, this.env.scope.owner, null, VIRTUAL)); @@ -9382,7 +9382,7 @@ private BLangBlockStmt getSafeErrorAssignment(Location location, BLangSimpleVarR if (!isCheckPanicExpr && (returnOnError || this.onFailClause != null)) { // fail e; BLangFail failStmt; - if (this.onFailClause != null) { + if (this.onFailClause != null && invokableSymbol.origin != VIRTUAL) { failStmt = bLangFailNodeByOnFailClause.computeIfAbsent(this.onFailClause, k -> (BLangFail) TreeBuilder.createFailNode()); } else { From 342eb4c7437ae3535e908d44c06bcd52f8f21b27 Mon Sep 17 00:00:00 2001 From: gabilang Date: Tue, 11 Oct 2022 11:48:46 +0530 Subject: [PATCH 030/450] Add bir-dump tests --- .../test-src/bir/bir-dump/failWithinOnFail | 2 +- .../safeErrorAssignmentWithQueryAction | 253 ++++++++++++++++++ .../resources/test-src/bir/biroptimizer.bal | 45 ++++ 3 files changed, 299 insertions(+), 1 deletion(-) create mode 100644 tests/jballerina-unit-test/src/test/resources/test-src/bir/bir-dump/safeErrorAssignmentWithQueryAction diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/bir/bir-dump/failWithinOnFail b/tests/jballerina-unit-test/src/test/resources/test-src/bir/bir-dump/failWithinOnFail index efb87f13b746..f3eed2ed14ce 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/bir/bir-dump/failWithinOnFail +++ b/tests/jballerina-unit-test/src/test/resources/test-src/bir/bir-dump/failWithinOnFail @@ -64,4 +64,4 @@ failWithinOnFail function() -> string|error { } -} \ No newline at end of file +} diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/bir/bir-dump/safeErrorAssignmentWithQueryAction b/tests/jballerina-unit-test/src/test/resources/test-src/bir/bir-dump/safeErrorAssignmentWithQueryAction new file mode 100644 index 000000000000..1cb379ec882d --- /dev/null +++ b/tests/jballerina-unit-test/src/test/resources/test-src/bir/bir-dump/safeErrorAssignmentWithQueryAction @@ -0,0 +1,253 @@ +safeErrorAssignmentWithQueryAction function() -> error|() { + %0(RETURN) error|(); + %1(SYNTHETIC) (); + %2(SYNTHETIC) error|(); + %4(TEMP) boolean; + %8(SYNTHETIC) error; + %11(LOCAL) error; + %13(LOCAL) int; + %15(SYNTHETIC) (); + %16(SYNTHETIC) error|(); + %22(SYNTHETIC) error; + %29(SYNTHETIC) int; + %30(SYNTHETIC) int; + %31(SYNTHETIC) int|error; + %40(SYNTHETIC) (); + %41(SYNTHETIC) error|(); + %42(SYNTHETIC) ballerina/lang.__internal:0.0.0:$anonType$return$createIntRange$_0; + %44(SYNTHETIC) int; + %46(SYNTHETIC) int; + %50(TEMP) ballerina/lang.__internal:0.0.0:$anonType$return$createIntRange$_0; + %51(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamPipeline; + %52(SYNTHETIC) ballerina/lang.__internal:0.0.0:$anonType$return$createIntRange$_0; + %54(SYNTHETIC) typeDesc; + %56(SYNTHETIC) typeDesc; + %62(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamFunction; + %63(SYNTHETIC) function(ballerina/lang.query:0.0.0:_Frame) -> ballerina/lang.query:0.0.0:_Frame|error|(); + %67(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamPipeline; + %69(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamFunction; + %73(TEMP) (); + %74(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamFunction; + %75(SYNTHETIC) function(ballerina/lang.query:0.0.0:_Frame) -> any|error; + %79(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamPipeline; + %81(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamFunction; + %85(TEMP) (); + %86(SYNTHETIC) stream, typeRefDesc<>>; + %87(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamPipeline; + %91(SYNTHETIC) error|(); + %93(SYNTHETIC) stream, typeRefDesc<>>; + %96(TEMP) any|error{map}; + %99(TEMP) boolean; + %110(SYNTHETIC) (); + %111(SYNTHETIC) typeRefDesc<>|(); + %120(SYNTHETIC) (); + %121(SYNTHETIC) error{map}|(); + %127(SYNTHETIC) error; + %130(LOCAL) string; + %132(SYNTHETIC) (); + %133(SYNTHETIC) error|(); + %142(SYNTHETIC) (); + %143(SYNTHETIC) Error|(); + %153(SYNTHETIC) (); + %154(SYNTHETIC) Error|(); + + bb0 { + %2 = foo() -> bb1; + } + bb1 { + %4 = %2 is (); + %4? bb2 : bb3; + } + bb2 { + %1 = <()> %2; + GOTO bb9; + } + bb3 { + %8 = %2; + GOTO bb4; + } + bb4 { + %11 = %8; + %13 = ConstLoad 10; + %16 = foo() -> bb5; + } + bb5 { + %4 = %16 is (); + %4? bb6 : bb7; + } + bb6 { + %15 = <()> %16; + GOTO bb8; + } + bb7 { + %22 = %16; + %0 = %22; + GOTO bb47; + } + bb8 { + %0 = %11; + GOTO bb47; + } + bb9 { + %31 = bar() -> bb10; + } + bb10 { + %4 = %31 is int; + %4? bb11 : bb12; + } + bb11 { + %30 = %31; + GOTO bb13; + } + bb12 { + %8 = %31; + GOTO bb4; + } + bb13 { + %29 = %30; + %44 = ConstLoad 1; + %46 = ConstLoad 2; + %50 = createIntRange(%44, %46) -> bb14; + } + bb14 { + %42 = %50; + %52 = %42; + %54 = newType error|(); + %56 = newType error|(); + %51 = createPipeline(%52, %54, %56) -> bb15; + } + bb15 { + %63 = fp $anon/.:0.0.0::$streamLambda$_0; + %62 = createInputFunction(%63) -> bb16; + } + bb16 { + %67 = %51; + %69 = %62; + %73 = addStreamFunction(%67, %69) -> bb17; + } + bb17 { + %75 = fp $anon/.:0.0.0::$streamLambda$_1; + %74 = createDoFunction(%75) -> bb18; + } + bb18 { + %79 = %51; + %81 = %74; + %85 = addStreamFunction(%79, %81) -> bb19; + } + bb19 { + %87 = %51; + %86 = getStreamFromPipeline(%87) -> bb20; + } + bb20 { + %93 = %86; + %96 = consumeStream(%93) -> bb21; + } + bb21 { + %91 = %96; + %4 = %91 is (); + %99 = not %4; + %99? bb22 : bb23; + } + bb22 { + %0 = %91; + GOTO bb47; + } + bb23 { + %41 = %91; + %4 = %41 is (); + %4? bb24 : bb25; + } + bb24 { + %40 = <()> %41; + GOTO bb26; + } + bb25 { + %8 = %41; + GOTO bb4; + } + bb26 { + %111 = baz() -> bb27; + } + bb27 { + %99 = %111 is (); + %99? bb28 : bb29; + } + bb28 { + %110 = <()> %111; + GOTO bb30; + } + bb29 { + %8 = %111; + GOTO bb4; + } + bb30 { + %121 = foo() -> bb31; + } + bb31 { + %4 = %121 is (); + %4? bb32 : bb33; + } + bb32 { + %120 = <()> %121; + GOTO bb42; + } + bb33 { + %127 = %121; + GOTO bb34; + } + bb34 { + %130 = ConstLoad abc; + %133 = foo() -> bb35; + } + bb35 { + %99 = %133 is (); + %99? bb36 : bb37; + } + bb36 { + %132 = <()> %133; + GOTO bb38; + } + bb37 { + %8 = %133; + GOTO bb4; + } + bb38 { + %143 = baz() -> bb39; + } + bb39 { + %4 = %143 is (); + %4? bb40 : bb41; + } + bb40 { + %142 = <()> %143; + GOTO bb46; + } + bb41 { + %8 = %143; + GOTO bb4; + } + bb42 { + %154 = baz() -> bb43; + } + bb43 { + %99 = %154 is (); + %99? bb44 : bb45; + } + bb44 { + %153 = <()> %154; + GOTO bb46; + } + bb45 { + %127 = %154; + GOTO bb34; + } + bb46 { + %0 = ConstLoad 0; + GOTO bb47; + } + bb47 { + return; + } + + +} diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/bir/biroptimizer.bal b/tests/jballerina-unit-test/src/test/resources/test-src/bir/biroptimizer.bal index 432cf2e36cdd..6a2e2408863d 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/bir/biroptimizer.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/bir/biroptimizer.bal @@ -116,3 +116,48 @@ function failLockWithinLock() returns [int, string] { } return [lockWithinLockInt, lockWithinLockString]; } + +type Error distinct error; + +function safeErrorAssignmentWithQueryAction() returns error? { + do { + check foo(); + int _ = check bar(); + check from int i in 1 ... 2 + do { + check baz(); + do { + int a = check bar(); + check foo(); + } on fail var e { + return e; + } + }; + check baz(); + do { + check foo(); + check baz(); + } on fail { + string s = "abc"; + check foo(); + check baz(); + } + } + on fail var e { + int i = 10; + check foo(); + return e; + } +} + +function foo() returns error? { + return error("Dummy error"); +} + +function bar() returns int|error { + return 5; +} + +function baz() returns Error? { + return error("Custom Error"); +} From 8a4514f2507ad925fd1215f0e079cb1943c6c4cf Mon Sep 17 00:00:00 2001 From: HindujaB Date: Thu, 13 Oct 2022 12:58:00 +0530 Subject: [PATCH 031/450] Fix type constants ordering --- .../compiler/bir/codegen/JvmConstants.java | 22 +++++------ .../bir/codegen/split/JvmConstantsGen.java | 16 ++++++++ .../bir/codegen/split/JvmCreateTypeGen.java | 38 ++++++++++++++++++- .../constants/JvmArrayTypeConstantsGen.java | 24 ++++-------- .../constants/JvmRefTypeConstantsGen.java | 23 +++-------- .../constants/JvmTupleTypeConstantsGen.java | 26 ++++--------- .../constants/JvmUnionTypeConstantsGen.java | 27 ++++--------- .../semantics/analyzer/SymbolEnter.java | 2 +- 8 files changed, 90 insertions(+), 88 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java index 7eeaa922f298..0f09ff02433f 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java @@ -94,8 +94,6 @@ public class JvmConstants { public static final String B_INITIAL_VALUE_ENTRY = "io/ballerina/runtime/api/values/BInitialValueEntry"; public static final String B_LIST_INITIAL_VALUE_ENTRY = "io/ballerina/runtime/api/values/BListInitialValueEntry"; public static final String B_MAPPING_INITIAL_VALUE_ENTRY = "io/ballerina/runtime/api/values/BMapInitialValueEntry"; - public static final String MAPPING_INITIAL_VALUE_ENTRY = - "io/ballerina/runtime/internal/values/MappingInitialValueEntry"; public static final String MAPPING_INITIAL_KEY_VALUE_ENTRY = "io/ballerina/runtime/internal/values/MappingInitialValueEntry$KeyValueEntry"; public static final String MAPPING_INITIAL_SPREAD_FIELD_ENTRY = @@ -124,7 +122,6 @@ public class JvmConstants { public static final String ERROR_TYPE = "io/ballerina/runtime/api/types/ErrorType"; public static final String TUPLE_TYPE = "io/ballerina/runtime/api/types/TupleType"; public static final String FUNCTION_TYPE = "io/ballerina/runtime/api/types/FunctionType"; - public static final String TYPEDESC_TYPE = "io/ballerina/runtime/api/types/TypedescType"; public static final String FIELD = "io/ballerina/runtime/api/types/Field"; public static final String METHOD_TYPE = "io/ballerina/runtime/api/types/MethodType"; public static final String RESOURCE_METHOD_TYPE = "io/ballerina/runtime/api/types/ResourceMethodType"; @@ -146,8 +143,6 @@ public class JvmConstants { public static final String INTERSECTABLE_REFERENCE_TYPE = "io/ballerina/runtime/api/types/IntersectableReferenceType"; - - public static final String TYPE_IMPL = "io/ballerina/runtime/internal/types/BType"; public static final String ARRAY_TYPE_IMPL = "io/ballerina/runtime/internal/types/BArrayType"; public static final String MAP_TYPE_IMPL = "io/ballerina/runtime/internal/types/BMapType"; public static final String XML_TYPE_IMPL = "io/ballerina/runtime/internal/types/BXmlType"; @@ -313,11 +308,14 @@ public class JvmConstants { public static final String MODULE_ERRORS_CREATOR_CLASS_NAME = "creators/$_errors"; public static final String MODULE_ANNOTATIONS_CLASS_NAME = "annotations/$_annotations"; public static final String B_STRING_INIT_METHOD_PREFIX = "$string_init"; - public static final String B_UNION_TYPE_INIT_METHOD_PREFIX = "$union_type_init"; - public static final String B_TUPLE_TYPE_INIT_METHOD_PREFIX = "$tuple_type_init"; - public static final String B_ARRAY_TYPE_INIT_METHOD_PREFIX = "$array_type_init"; - public static final String B_TYPEREF_TYPE_INIT_METHOD_PREFIX = "$typeref_type_init"; - public static final String B_FUNCTION_TYPE_INIT_METHOD_PREFIX = "$function_type_init"; + public static final String B_UNION_TYPE_INIT_METHOD = "$union_type_init"; + public static final String B_TUPLE_TYPE_INIT_METHOD = "$tuple_type_init"; + public static final String B_ARRAY_TYPE_INIT_METHOD = "$array_type_init"; + public static final String B_TYPEREF_TYPE_INIT_METHOD = "$typeref_type_init"; + public static final String B_UNION_TYPE_POPULATE_METHOD = "$populate_union_types"; + public static final String B_TUPLE_TYPE_POPULATE_METHOD = "$populate_tuple_types"; + public static final String B_ARRAY_TYPE_POPULATE_METHOD = "$populate_array_types"; + public static final String B_TYPEREF_TYPE_POPULATE_METHOD = "$populate_typeref_types"; public static final String MODULE_INIT_METHOD_PREFIX = "$module_init"; public static final String CONSTANT_INIT_METHOD_PREFIX = "$constant_init"; public static final String ANNOTATIONS_METHOD_PREFIX = "$process_annotations"; @@ -339,7 +337,6 @@ public class JvmConstants { public static final String BUILT_IN_PACKAGE_NAME = "lang" + ENCODED_DOT_CHARACTER + "annotations"; public static final String MODULE_START_ATTEMPTED = "$moduleStartAttempted"; public static final String MODULE_STARTED = "$moduleStarted"; - public static final String DESUGARED_BB_ID_NAME = "desugaredBB"; public static final String WRAPPER_GEN_BB_ID_NAME = "wrapperGen"; public static final String JVM_INIT_METHOD = ""; public static final String JVM_STATIC_INIT_METHOD = ""; @@ -356,6 +353,7 @@ public class JvmConstants { public static final String EQUALS_METHOD = "equals"; public static final String POPULATE_INITIAL_VALUES_METHOD = "populateInitialValues"; public static final String CREATE_TYPES_METHOD = "$createTypes"; + public static final String CREATE_TYPE_CONSTANTS_METHOD = "$createTypeConstants"; public static final String CREATE_TYPE_INSTANCES_METHOD = "$createTypeInstances"; public static final String GLOBAL_LOCK_NAME = "lock"; public static final String SERVICE_EP_AVAILABLE = "$serviceEPAvailable"; @@ -413,8 +411,6 @@ public class JvmConstants { public static final int BAL_SERVICE = 262144; // type flags - public static final int TYPE_FLAG_NILABLE = 1; - public static final int TYPE_FLAG_ANYDATA = 2; public static final int TYPE_FLAG_PURETYPE = 4; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmConstantsGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmConstantsGen.java index 3551c00c35d4..e3158aaf9802 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmConstantsGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmConstantsGen.java @@ -133,6 +133,22 @@ public String getModuleConstantClass() { return moduleConstantsGen.getModuleConstantClass(); } + public String getRefTypeConstantsClass() { + return refTypeConstantsGen.getRefTypeConstantsClass(); + } + + public String getArrayTypeConstantClass() { + return arrayTypeConstantsGen.getArrayTypeConstantClass(); + } + + public String getTupleTypeConstantsClass() { + return tupleTypeConstantsGen.getTupleTypeConstantsClass(); + } + + public String getUnionTypeConstantClass() { + return unionTypeConstantsGen.getUnionTypeConstantClass(); + } + public String getConstantClass() { return jvmBallerinaConstantsGen.getConstantClass(); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmCreateTypeGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmCreateTypeGen.java index 2f6c53b571a3..d6cd0e133d40 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmCreateTypeGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmCreateTypeGen.java @@ -91,7 +91,16 @@ import static org.objectweb.asm.Opcodes.V1_8; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmCodeGenUtil.createDefaultCase; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmCodeGenUtil.getModuleLevelClassName; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_ARRAY_TYPE_INIT_METHOD; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_ARRAY_TYPE_POPULATE_METHOD; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_TUPLE_TYPE_INIT_METHOD; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_TUPLE_TYPE_POPULATE_METHOD; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_TYPEREF_TYPE_INIT_METHOD; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_TYPEREF_TYPE_POPULATE_METHOD; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_UNION_TYPE_INIT_METHOD; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_UNION_TYPE_POPULATE_METHOD; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.CREATE_TYPES_METHOD; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.CREATE_TYPE_CONSTANTS_METHOD; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.CREATE_TYPE_INSTANCES_METHOD; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.FIELD_IMPL; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.GET_ANON_TYPE_METHOD; @@ -170,9 +179,33 @@ public void generateTypeClass(JvmPackageGen jvmPackageGen, BIRNode.BIRPackage mo jarEntries.put(typesClass + ".class", jvmPackageGen.getBytes(typesCw, module)); } + void createTypeConstants(ClassWriter cw) { + MethodVisitor mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, CREATE_TYPE_CONSTANTS_METHOD, "()V", null, null); + mv.visitCode(); + + String refTypeConstantsClass = jvmConstantsGen.getRefTypeConstantsClass(); + String arrayTypeConstantClass = jvmConstantsGen.getArrayTypeConstantClass(); + String tupleTypeConstantsClass = jvmConstantsGen.getTupleTypeConstantsClass(); + String unionTypeConstantClass = jvmConstantsGen.getUnionTypeConstantClass(); + + mv.visitMethodInsn(INVOKESTATIC, refTypeConstantsClass, B_TYPEREF_TYPE_INIT_METHOD, "()V", false); + mv.visitMethodInsn(INVOKESTATIC, arrayTypeConstantClass, B_ARRAY_TYPE_INIT_METHOD, "()V", false); + mv.visitMethodInsn(INVOKESTATIC, tupleTypeConstantsClass, B_TUPLE_TYPE_INIT_METHOD, "()V", false); + mv.visitMethodInsn(INVOKESTATIC, unionTypeConstantClass, B_UNION_TYPE_INIT_METHOD, "()V", false); + + mv.visitMethodInsn(INVOKESTATIC, refTypeConstantsClass, B_TYPEREF_TYPE_POPULATE_METHOD, "()V", false); + mv.visitMethodInsn(INVOKESTATIC, arrayTypeConstantClass, B_ARRAY_TYPE_POPULATE_METHOD, "()V", false); + mv.visitMethodInsn(INVOKESTATIC, tupleTypeConstantsClass, B_TUPLE_TYPE_POPULATE_METHOD, "()V", false); + mv.visitMethodInsn(INVOKESTATIC, unionTypeConstantClass, B_UNION_TYPE_POPULATE_METHOD, "()V", false); + + mv.visitInsn(RETURN); + mv.visitMaxs(0, 0); + mv.visitEnd(); + } + void generateCreateTypesMethod(ClassWriter cw, List typeDefs, String moduleInitClass, SymbolTable symbolTable) { - + createTypeConstants(cw); createTypesInstance(cw, typeDefs, moduleInitClass); Map populateTypeFuncNames = populateTypes(cw, typeDefs, moduleInitClass, symbolTable); @@ -182,6 +215,9 @@ void generateCreateTypesMethod(ClassWriter cw, List typeDefs, // Invoke create-type-instances method mv.visitMethodInsn(INVOKESTATIC, typesClass, CREATE_TYPE_INSTANCES_METHOD, "()V", false); + // Invoke create-type-constants method + mv.visitMethodInsn(INVOKESTATIC, typesClass, CREATE_TYPE_CONSTANTS_METHOD, "()V", false); + // Invoke the populate-type functions for (Map.Entry entry : populateTypeFuncNames.entrySet()) { String funcName = entry.getKey(); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmArrayTypeConstantsGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmArrayTypeConstantsGen.java index aa3e809bcb8d..005d88e87f67 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmArrayTypeConstantsGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmArrayTypeConstantsGen.java @@ -43,6 +43,8 @@ import static org.objectweb.asm.Opcodes.ACC_STATIC; import static org.objectweb.asm.Opcodes.GETSTATIC; import static org.objectweb.asm.Opcodes.INVOKESTATIC; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_ARRAY_TYPE_INIT_METHOD; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_ARRAY_TYPE_POPULATE_METHOD; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_ARRAY_TYPE_IMPL; import static org.wso2.ballerinalang.compiler.bir.codegen.split.constants.JvmConstantGenCommons.genMethodReturn; import static org.wso2.ballerinalang.compiler.bir.codegen.split.constants.JvmConstantGenCommons.generateConstantsClassInit; @@ -55,9 +57,8 @@ public class JvmArrayTypeConstantsGen { private final String arrayConstantsClass; - private ClassWriter cw; + private final ClassWriter cw; private MethodVisitor mv; - private int methodCount; private final Map arrayTypeVarMap; private int constantIndex = 0; private JvmArrayTypeGen jvmArrayTypeGen; @@ -69,7 +70,7 @@ public JvmArrayTypeConstantsGen(PackageID packageID, BTypeHashComparator bTypeHa JvmCodeGenUtil.getModuleLevelClassName(packageID, JvmConstants.ARRAY_TYPE_CONSTANT_CLASS_NAME); cw = new BallerinaClassWriter(COMPUTE_FRAMES); generateConstantsClassInit(cw, arrayConstantsClass); - visitArrayTypeInitMethod(); + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, B_ARRAY_TYPE_INIT_METHOD, "()V", null, null); this.arrayTypeVarMap = new TreeMap<>(bTypeHashComparator); this.funcNames = new ArrayList<>(); this.types = types; @@ -79,11 +80,6 @@ public void setJvmArrayTypeGen(JvmArrayTypeGen jvmArrayTypeGen) { this.jvmArrayTypeGen = jvmArrayTypeGen; } - private void visitArrayTypeInitMethod() { - mv = cw.visitMethod(ACC_STATIC, JvmConstants.B_ARRAY_TYPE_INIT_METHOD_PREFIX + methodCount++, "()V", null, - null); - } - public String add(BArrayType arrayType) { String varName = arrayTypeVarMap.get(arrayType); if (varName == null) { @@ -126,22 +122,16 @@ public void generateGetBArrayType(MethodVisitor mv, String varName) { public void generateClass(Map jarEntries) { genMethodReturn(mv); - visitArrayTypeInitMethod(); + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, B_ARRAY_TYPE_POPULATE_METHOD, "()V", null, null); for (String funcName : funcNames) { mv.visitMethodInsn(INVOKESTATIC, arrayConstantsClass, funcName, "()V", false); } genMethodReturn(mv); - generateStaticInitializer(cw); cw.visitEnd(); jarEntries.put(arrayConstantsClass + ".class", cw.toByteArray()); } - private void generateStaticInitializer(ClassWriter cw) { - MethodVisitor methodVisitor = cw.visitMethod(ACC_STATIC, "", "()V", null, null); - for (int i = 0; i < methodCount; i++) { - methodVisitor.visitMethodInsn(INVOKESTATIC, arrayConstantsClass, - JvmConstants.B_ARRAY_TYPE_INIT_METHOD_PREFIX + i, "()V", false); - } - genMethodReturn(methodVisitor); + public String getArrayTypeConstantClass() { + return this.arrayConstantsClass; } } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmRefTypeConstantsGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmRefTypeConstantsGen.java index b43df3a257a6..f42db1b45736 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmRefTypeConstantsGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmRefTypeConstantsGen.java @@ -41,7 +41,8 @@ import static org.objectweb.asm.Opcodes.ACC_STATIC; import static org.objectweb.asm.Opcodes.GETSTATIC; import static org.objectweb.asm.Opcodes.INVOKESTATIC; -import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_TYPEREF_TYPE_INIT_METHOD_PREFIX; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_TYPEREF_TYPE_INIT_METHOD; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_TYPEREF_TYPE_POPULATE_METHOD; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_TYPE_REF_TYPE_IMPL; import static org.wso2.ballerinalang.compiler.bir.codegen.split.constants.JvmConstantGenCommons.genMethodReturn; import static org.wso2.ballerinalang.compiler.bir.codegen.split.constants.JvmConstantGenCommons.generateConstantsClassInit; @@ -57,7 +58,6 @@ public class JvmRefTypeConstantsGen { private JvmRefTypeGen jvmRefTypeGen; private final ClassWriter cw; private MethodVisitor mv; - private int methodCount; private final List funcNames; private final Map typeRefVarMap; @@ -67,7 +67,7 @@ public JvmRefTypeConstantsGen(PackageID packageID, BTypeHashComparator bTypeHash JvmConstants.TYPEREF_TYPE_CONSTANT_CLASS_NAME); cw = new BallerinaClassWriter(COMPUTE_FRAMES); generateConstantsClassInit(cw, typeRefVarConstantsClass); - visitTypeRefTypeInitMethod(); + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, B_TYPEREF_TYPE_INIT_METHOD, "()V", null, null); funcNames = new ArrayList<>(); typeRefVarMap = new TreeMap<>(bTypeHashComparator); } @@ -85,10 +85,6 @@ public String add(BTypeReferenceType type) { return varName; } - private void visitTypeRefTypeInitMethod() { - mv = cw.visitMethod(ACC_STATIC, B_TYPEREF_TYPE_INIT_METHOD_PREFIX + methodCount++, "()V", null, null); - } - private String generateTypeRefInits(BTypeReferenceType type) { String varName = JvmCodeGenUtil.getRefTypeConstantName(type); visitTypeRefField(varName); @@ -125,23 +121,16 @@ public void generateGetBTypeRefType(MethodVisitor mv, String varName) { public void generateClass(Map jarEntries) { genMethodReturn(mv); - visitTypeRefTypeInitMethod(); + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, B_TYPEREF_TYPE_POPULATE_METHOD, "()V", null, null); for (String funcName : funcNames) { mv.visitMethodInsn(INVOKESTATIC, typeRefVarConstantsClass, funcName, "()V", false); } genMethodReturn(mv); - generateStaticInitializer(cw); cw.visitEnd(); jarEntries.put(typeRefVarConstantsClass + ".class", cw.toByteArray()); } - private void generateStaticInitializer(ClassWriter cw) { - MethodVisitor methodVisitor = cw.visitMethod(ACC_STATIC, "", "()V", null, null); - for (int i = 0; i < methodCount; i++) { - methodVisitor.visitMethodInsn(INVOKESTATIC, typeRefVarConstantsClass, - B_TYPEREF_TYPE_INIT_METHOD_PREFIX + i, "()V", false); - } - genMethodReturn(methodVisitor); + public String getRefTypeConstantsClass() { + return this.typeRefVarConstantsClass; } - } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmTupleTypeConstantsGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmTupleTypeConstantsGen.java index c1d38474719d..1cd7e2db4e7d 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmTupleTypeConstantsGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmTupleTypeConstantsGen.java @@ -45,7 +45,8 @@ import static org.objectweb.asm.Opcodes.ACC_STATIC; import static org.objectweb.asm.Opcodes.GETSTATIC; import static org.objectweb.asm.Opcodes.INVOKESTATIC; -import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_TUPLE_TYPE_INIT_METHOD_PREFIX; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_TUPLE_TYPE_INIT_METHOD; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_TUPLE_TYPE_POPULATE_METHOD; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_TUPLE_TYPE_IMPL; import static org.wso2.ballerinalang.compiler.bir.codegen.split.constants.JvmConstantGenCommons.genMethodReturn; import static org.wso2.ballerinalang.compiler.bir.codegen.split.constants.JvmConstantGenCommons.generateConstantsClassInit; @@ -60,9 +61,8 @@ public class JvmTupleTypeConstantsGen { private final String tupleVarConstantsClass; private int constantIndex = 0; private JvmTupleTypeGen jvmTupleTypeGen; - private ClassWriter cw; + private final ClassWriter cw; private MethodVisitor mv; - private int methodCount; private final List funcNames; private final Queue queue; private final Map tupleTypeVarMap; @@ -72,7 +72,7 @@ public JvmTupleTypeConstantsGen(PackageID packageID, BTypeHashComparator bTypeHa JvmConstants.TUPLE_TYPE_CONSTANT_CLASS_NAME); cw = new BallerinaClassWriter(COMPUTE_FRAMES); generateConstantsClassInit(cw, tupleVarConstantsClass); - visitTupleTypeInitMethod(); + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, B_TUPLE_TYPE_INIT_METHOD, "()V", null, null); funcNames = new ArrayList<>(); queue = new LinkedList<>(); tupleTypeVarMap = new TreeMap<>(bTypeHashComparator); @@ -91,11 +91,6 @@ public String add(BTupleType type, SymbolTable symbolTable) { return varName; } - private void visitTupleTypeInitMethod() { - mv = cw.visitMethod(ACC_STATIC, B_TUPLE_TYPE_INIT_METHOD_PREFIX + methodCount++, - "()V", null, null); - } - /** * Stack keeps track of recursion in tuple types. The method creation is performed only if recursion is completed. */ @@ -145,23 +140,16 @@ public void generateGetBTupleType(MethodVisitor mv, String varName) { public void generateClass(Map jarEntries) { genMethodReturn(mv); - visitTupleTypeInitMethod(); + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, B_TUPLE_TYPE_POPULATE_METHOD, "()V", null, null); for (String funcName : funcNames) { mv.visitMethodInsn(INVOKESTATIC, tupleVarConstantsClass, funcName, "()V", false); } genMethodReturn(mv); - generateStaticInitializer(cw); cw.visitEnd(); jarEntries.put(tupleVarConstantsClass + ".class", cw.toByteArray()); } - private void generateStaticInitializer(ClassWriter cw) { - MethodVisitor methodVisitor = cw.visitMethod(ACC_STATIC, "", "()V", null, null); - for (int i = 0; i < methodCount; i++) { - methodVisitor.visitMethodInsn(INVOKESTATIC, tupleVarConstantsClass, - B_TUPLE_TYPE_INIT_METHOD_PREFIX + i, "()V", false); - } - genMethodReturn(methodVisitor); + public String getTupleTypeConstantsClass() { + return this.tupleVarConstantsClass; } - } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmUnionTypeConstantsGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmUnionTypeConstantsGen.java index c89ff076a8c6..94a50f41e494 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmUnionTypeConstantsGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmUnionTypeConstantsGen.java @@ -45,7 +45,8 @@ import static org.objectweb.asm.Opcodes.ACC_STATIC; import static org.objectweb.asm.Opcodes.GETSTATIC; import static org.objectweb.asm.Opcodes.INVOKESTATIC; -import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_UNION_TYPE_INIT_METHOD_PREFIX; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_UNION_TYPE_INIT_METHOD; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_UNION_TYPE_POPULATE_METHOD; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_UNION_TYPE_IMPL; import static org.wso2.ballerinalang.compiler.bir.codegen.split.constants.JvmConstantGenCommons.genMethodReturn; import static org.wso2.ballerinalang.compiler.bir.codegen.split.constants.JvmConstantGenCommons.generateConstantsClassInit; @@ -60,9 +61,8 @@ public class JvmUnionTypeConstantsGen { private final String unionVarConstantsClass; private int constantIndex = 0; private JvmUnionTypeGen jvmUnionTypeGen; - private ClassWriter cw; + private final ClassWriter cw; private MethodVisitor mv; - private int methodCount; private final List funcNames; private final Queue queue; private final Map unionTypeVarMap; @@ -75,7 +75,7 @@ public JvmUnionTypeConstantsGen(PackageID packageID, BTypeHashComparator bTypeHa JvmConstants.UNION_TYPE_CONSTANT_CLASS_NAME); cw = new BallerinaClassWriter(COMPUTE_FRAMES); generateConstantsClassInit(cw, unionVarConstantsClass); - visitUnionTypeInitMethod(); + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, B_UNION_TYPE_INIT_METHOD, "()V", null, null); funcNames = new ArrayList<>(); queue = new LinkedList<>(); unionTypeVarMap = new TreeMap<>(bTypeHashComparator); @@ -94,11 +94,6 @@ public String add(BUnionType type, SymbolTable symbolTable) { return varName; } - private void visitUnionTypeInitMethod() { - mv = cw.visitMethod(ACC_STATIC, B_UNION_TYPE_INIT_METHOD_PREFIX + methodCount++, - "()V", null, null); - } - private String generateBUnionInits(BUnionType type, SymbolTable symbolTable) { String varName = JvmConstants.UNION_TYPE_VAR_PREFIX + constantIndex++; visitBUnionField(varName); @@ -146,24 +141,16 @@ public void generateGetBUnionType(MethodVisitor mv, String varName) { public void generateClass(Map jarEntries) { genMethodReturn(mv); - visitUnionTypeInitMethod(); + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, B_UNION_TYPE_POPULATE_METHOD, "()V", null, null); for (String funcName : funcNames) { mv.visitMethodInsn(INVOKESTATIC, unionVarConstantsClass, funcName, "()V", false); } genMethodReturn(mv); - generateStaticInitializer(cw); cw.visitEnd(); jarEntries.put(unionVarConstantsClass + ".class", cw.toByteArray()); } - private void generateStaticInitializer(ClassWriter cw) { - MethodVisitor methodVisitor = cw.visitMethod(ACC_STATIC, "", "()V", null, null); - for (int i = 0; i < methodCount; i++) { - methodVisitor.visitMethodInsn(INVOKESTATIC, unionVarConstantsClass, - B_UNION_TYPE_INIT_METHOD_PREFIX + i, - "()V", false); - } - genMethodReturn(methodVisitor); + public String getUnionTypeConstantClass() { + return this.unionVarConstantsClass; } - } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolEnter.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolEnter.java index 8feca2df458a..50c02034952f 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolEnter.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolEnter.java @@ -4705,7 +4705,7 @@ public void defineInvokableTypeNode(BLangFunctionTypeNode functionTypeNode, long bInvokableType.paramTypes = paramTypes; bInvokableType.retType = retType; bInvokableType.restType = restType; - bInvokableType.flags = flags; + bInvokableType.flags |= flags; functionTypeNode.setBType(bInvokableType); List allConstituentTypes = new ArrayList<>(paramTypes); From be0d3d516dac49b55fe9c275f5852c7af4ef45a4 Mon Sep 17 00:00:00 2001 From: gabilang Date: Fri, 14 Oct 2022 10:48:17 +0530 Subject: [PATCH 032/450] Address review suggestions --- .../ballerinalang/compiler/bir/BIRGen.java | 30 ++++++++++--------- .../ballerinalang/compiler/bir/BIRGenEnv.java | 3 +- .../compiler/desugar/Desugar.java | 8 +++-- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java index e307d66471cb..f4b22937c416 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java @@ -213,7 +213,6 @@ import java.util.Map; import java.util.Set; import java.util.TreeMap; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; import javax.xml.XMLConstants; @@ -1075,26 +1074,29 @@ public void visit(BLangFail failNode) { @Override public void visit(BLangSimpleVariableDef astVarDefStmt) { BIRVariableDcl birVarDcl; - AtomicBoolean isExistingVarDef = new AtomicBoolean(true); - if (astVarDefStmt.var.symbol.origin == SymbolOrigin.VIRTUAL) { - birVarDcl = this.env.syntheticVariableDclMap.computeIfAbsent(astVarDefStmt.var.symbol, k -> { - isExistingVarDef.set(false); - return new BIRVariableDcl(astVarDefStmt.pos, astVarDefStmt.var.symbol.type, - this.env.nextLocalVarId(names), VarScope.FUNCTION, VarKind.SYNTHETIC, - astVarDefStmt.var.name.value); - }); + BVarSymbol varSymbol = astVarDefStmt.var.symbol; + boolean isExistingVarDef = true; + if (varSymbol.origin == SymbolOrigin.VIRTUAL) { + birVarDcl = this.env.syntheticErrorVarDclMap.get(varSymbol); + if (birVarDcl == null) { + birVarDcl = new BIRVariableDcl(astVarDefStmt.pos, varSymbol.type, + this.env.nextLocalVarId(names), VarScope.FUNCTION, VarKind.SYNTHETIC, + astVarDefStmt.var.name.value); + this.env.syntheticErrorVarDclMap.put(varSymbol, birVarDcl); + isExistingVarDef = false; + } } else { - birVarDcl = new BIRVariableDcl(astVarDefStmt.pos, astVarDefStmt.var.symbol.type, - this.env.nextLocalVarId(names), VarScope.FUNCTION, VarKind.LOCAL, astVarDefStmt.var.name.value); - isExistingVarDef.set(false); + birVarDcl = new BIRVariableDcl(astVarDefStmt.pos, varSymbol.type, this.env.nextLocalVarId(names), + VarScope.FUNCTION, VarKind.LOCAL, astVarDefStmt.var.name.value); + isExistingVarDef = false; } - if (!isExistingVarDef.get()) { + if (!isExistingVarDef) { birVarDcl.startBB = this.env.enclBB; this.env.varDclsByBlock.get(this.currentBlock).add(birVarDcl); this.env.enclFunc.localVars.add(birVarDcl); // We maintain a mapping from variable symbol to the bir_variable declaration. // This is required to pull the correct bir_variable declaration for variable references. - this.env.symbolVarMap.put(astVarDefStmt.var.symbol, birVarDcl); + this.env.symbolVarMap.put(varSymbol, birVarDcl); BirScope newScope = new BirScope(this.currentScope.id + 1, this.currentScope); birVarDcl.insScope = newScope; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGenEnv.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGenEnv.java index fbb2eda2438d..2f3cfa39a88c 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGenEnv.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGenEnv.java @@ -35,7 +35,6 @@ import java.util.List; import java.util.Map; import java.util.Stack; -import java.util.concurrent.ConcurrentHashMap; /** * Stores the state such as the current node, enclosing package, function etc, during bir generation. @@ -66,7 +65,7 @@ class BIRGenEnv { Stack> trapBlocks = new Stack<>(); Map> varDclsByBlock = new HashMap<>(); - Map syntheticVariableDclMap = new ConcurrentHashMap<>(); + Map syntheticErrorVarDclMap = new HashMap<>(); Map onFailStartBlockByFailNode = new HashMap<>(); Map failStartBasicBlockMap = new HashMap<>(); boolean failStartBBAlreadyAvailable; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java index 3190abd9ce69..55c17d6a48d4 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java @@ -5128,6 +5128,8 @@ onFailErrorVariableSymbol.name.value, onFailErrorVariableSymbol.type, rewrite(fa private BLangBlockStmt rewriteNestedOnFail(BLangOnFailClause onFailClause, BLangFail fail) { BLangOnFailClause currentOnFail = this.onFailClause; + // Create BLangBlockStmt per on-fail clause since we can reuse the contents of the + // BLangBlockStmt without duplicating. BLangBlockStmt onFailBody = blockStmtByFailNode.get(fail); if (onFailBody == null) { onFailBody = ASTBuilderUtil.createBlockStmt(onFailClause.pos); @@ -5150,13 +5152,13 @@ onFailErrorVariableSymbol.name.value, onFailErrorVariableSymbol.type, rewrite(fa } int currentOnFailIndex = this.enclosingOnFailClause.indexOf(this.onFailClause); - int enclosingOnFailIndex = currentOnFailIndex <= 0 ? this.enclosingOnFailClause.size() - 1 + int enclosingOnFailIndex = currentOnFailIndex <= 0 ? (this.enclosingOnFailClause.size() - 1) : (currentOnFailIndex - 1); this.onFailClause = this.enclosingOnFailClause.get(enclosingOnFailIndex); onFailBody = rewrite(onFailBody, env); BLangFail failToEndBlock = new BLangFail(); if (onFailClause.isInternal && fail.exprStmt != null) { - if (fail.exprStmt instanceof BLangPanic) { + if (fail.exprStmt.getKind() == NodeKind.PANIC) { setPanicErrorToTrue(onFailBody, onFailClause); } else { onFailBody.stmts.add((BLangStatement) fail.exprStmt); @@ -9369,7 +9371,7 @@ private BLangBlockStmt getSafeErrorAssignment(Location location, BLangSimpleVarR this.env.scope.owner.pkgID, symTable.errorType, this.env.scope.owner, null, VIRTUAL)); } else { errorVarSymbol = new BVarSymbol(0, names.fromString(patternFailureCaseVarName), - this.env.scope.owner.pkgID, symTable.errorType, this.env.scope.owner, location, VIRTUAL); + this.env.scope.owner.pkgID, symTable.errorType, this.env.scope.owner, null, VIRTUAL); } BLangSimpleVariable errorVar = ASTBuilderUtil.createVariable(location, patternFailureCaseVarName, From 09787452e9d02de805416173bdf9f8dc4d00db64 Mon Sep 17 00:00:00 2001 From: gabilang Date: Fri, 14 Oct 2022 10:49:42 +0530 Subject: [PATCH 033/450] Add test cases for check-expr error return type --- .../CheckedExprErrorReturnTypeTest.java | 59 ++++++++++++ .../checked_expr_error_return_type.bal | 92 +++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/checkedexpr/CheckedExprErrorReturnTypeTest.java create mode 100644 tests/jballerina-unit-test/src/test/resources/test-src/expressions/checkedexpr/checked_expr_error_return_type.bal diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/checkedexpr/CheckedExprErrorReturnTypeTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/checkedexpr/CheckedExprErrorReturnTypeTest.java new file mode 100644 index 000000000000..3502b9d2658b --- /dev/null +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/checkedexpr/CheckedExprErrorReturnTypeTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com) All Rights Reserved. + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.ballerinalang.test.expressions.checkedexpr; + +import org.ballerinalang.test.BCompileUtil; +import org.ballerinalang.test.BRunUtil; +import org.ballerinalang.test.CompileResult; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * This class contain safe assignment error return type related test cases. + */ +public class CheckedExprErrorReturnTypeTest { + + private CompileResult result; + + @BeforeClass + public void setup() { + result = BCompileUtil.compile( + "test-src/expressions/checkedexpr/checked_expr_error_return_type.bal"); + } + + @Test(dataProvider = "checkedExprErrorReturnTypeTestFunctions") + public void testCheckedExpressionErrorReturnType(String function) { + BRunUtil.invoke(result, function); + } + + @DataProvider(name = "checkedExprErrorReturnTypeTestFunctions") + public Object[] checkedExprErrorReturnTypeTestFunctions() { + return new Object[] { + "testCheckedExprErrorReturnType", + "testCheckedExprErrorReturnTypeWithOnFail", + "testCheckedExprErrorReturnTypeWithNestedFailStmt" + }; + } + + @AfterClass + public void tearDown() { + result = null; + } +} diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/expressions/checkedexpr/checked_expr_error_return_type.bal b/tests/jballerina-unit-test/src/test/resources/test-src/expressions/checkedexpr/checked_expr_error_return_type.bal new file mode 100644 index 000000000000..81d95f8e9f3a --- /dev/null +++ b/tests/jballerina-unit-test/src/test/resources/test-src/expressions/checkedexpr/checked_expr_error_return_type.bal @@ -0,0 +1,92 @@ +// Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com) All Rights Reserved. +// +// WSO2 LLC. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +import ballerina/test; + +type E1 distinct error; +type E2 distinct error; + +function foo(int state) returns int|E1|E2 { + if (state == 0) { + return error("Custom Error E1"); + } else if (state == 1) { + return error E2("Custom Error E2"); + } else { + return state; + } +} + +function bar() returns error? { + return error("Dummy error"); +} + +function checkedExprErrorReturnType(int state) returns int|error { + return check foo(state); +} + +function testCheckedExprErrorReturnType() { + test:assertTrue(checkedExprErrorReturnType(0) is E1); + test:assertTrue(checkedExprErrorReturnType(1) is E2); + test:assertTrue(checkedExprErrorReturnType(5) is int); + test:assertFalse(checkedExprErrorReturnType(0) is E2); + test:assertFalse(checkedExprErrorReturnType(1) is E1); +} + +function checkedExprErrorReturnTypeWithOnFail(int state) returns int|error { + do { + if (foo(state) == state) { + return check foo(state - 2); + } else { + return check foo(state); + } + } on fail var e { + return e; + } +} + +function testCheckedExprErrorReturnTypeWithOnFail() { + test:assertTrue(checkedExprErrorReturnTypeWithOnFail(0) is E1); + test:assertTrue(checkedExprErrorReturnTypeWithOnFail(1) is E2); + test:assertTrue(checkedExprErrorReturnTypeWithOnFail(2) is E1); + test:assertTrue(checkedExprErrorReturnTypeWithOnFail(3) is E2); + test:assertTrue(checkedExprErrorReturnTypeWithOnFail(5) is int); + test:assertFalse(checkedExprErrorReturnTypeWithOnFail(0) is E2); + test:assertFalse(checkedExprErrorReturnTypeWithOnFail(1) is E1); +} + +function checkedExprErrorReturnTypeWithNestedFailStmt(int state) returns int|error { + do { + if (foo(state) == state) { + return check foo(state - 2); + } else { + return check foo(state); + } + } on fail var e { + check bar(); + return e; + } +} + +function testCheckedExprErrorReturnTypeWithNestedFailStmt() { + test:assertTrue(checkedExprErrorReturnTypeWithNestedFailStmt(0) is error); + test:assertTrue(checkedExprErrorReturnTypeWithNestedFailStmt(1) is error); + test:assertTrue(checkedExprErrorReturnTypeWithNestedFailStmt(5) is int); + test:assertFalse(checkedExprErrorReturnTypeWithNestedFailStmt(0) is E1); + test:assertFalse(checkedExprErrorReturnTypeWithNestedFailStmt(0) is E2); + test:assertFalse(checkedExprErrorReturnTypeWithNestedFailStmt(1) is E1); + test:assertFalse(checkedExprErrorReturnTypeWithNestedFailStmt(1) is E2); + test:assertFalse(checkedExprErrorReturnTypeWithNestedFailStmt(5) is error); +} From 0302205c1d92eaa5218c537c9f5a9d900398cd96 Mon Sep 17 00:00:00 2001 From: gabilang Date: Tue, 18 Oct 2022 10:50:26 +0530 Subject: [PATCH 034/450] Create synthetic error var per invokable symbol --- .../compiler/desugar/Desugar.java | 15 +- .../safeErrorAssignmentWithQueryAction | 204 +++++++++--------- 2 files changed, 105 insertions(+), 114 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java index 55c17d6a48d4..9d81af1a09b2 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java @@ -424,7 +424,7 @@ public class Desugar extends BLangNodeVisitor { private Map declaredVarDef = new HashMap<>(); private List inlineXMLNamespaces; private Map stmtsToBePropagatedToQuery = new HashMap<>(); - private final Map onFailClauseErrorVariable = new HashMap<>(); + private final Map syntheticErrorVariableByInvokableSymbol = new HashMap<>(); private final Map bLangFailNodeByOnFailClause = new HashMap<>(); private final Map blockStmtByFailNode = new HashMap<>(); // Reuse the strand annotation in isolated workers and start action @@ -9364,16 +9364,9 @@ private BLangBlockStmt getSafeErrorAssignment(Location location, BLangSimpleVarR .anyMatch(retType -> types.isAssignable(errorType, retType))); String patternFailureCaseVarName = GEN_VAR_PREFIX.value + "t_failure"; - BVarSymbol errorVarSymbol; - if (!isCheckPanicExpr && this.onFailClause != null && invokableSymbol.origin != VIRTUAL) { - errorVarSymbol = onFailClauseErrorVariable.computeIfAbsent(this.onFailClause, - k -> new BVarSymbol(0, names.fromString(patternFailureCaseVarName), - this.env.scope.owner.pkgID, symTable.errorType, this.env.scope.owner, null, VIRTUAL)); - } else { - errorVarSymbol = new BVarSymbol(0, names.fromString(patternFailureCaseVarName), - this.env.scope.owner.pkgID, symTable.errorType, this.env.scope.owner, null, VIRTUAL); - } - + BVarSymbol errorVarSymbol = syntheticErrorVariableByInvokableSymbol.computeIfAbsent(invokableSymbol, + k -> new BVarSymbol(0, Names.fromString(patternFailureCaseVarName), + this.env.scope.owner.pkgID, symTable.errorType, this.env.scope.owner, null, VIRTUAL)); BLangSimpleVariable errorVar = ASTBuilderUtil.createVariable(location, patternFailureCaseVarName, symTable.errorType, createTypeCastExpr(ref, symTable.errorType), errorVarSymbol); diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/bir/bir-dump/safeErrorAssignmentWithQueryAction b/tests/jballerina-unit-test/src/test/resources/test-src/bir/bir-dump/safeErrorAssignmentWithQueryAction index 1cb379ec882d..2992bacfbfb7 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/bir/bir-dump/safeErrorAssignmentWithQueryAction +++ b/tests/jballerina-unit-test/src/test/resources/test-src/bir/bir-dump/safeErrorAssignmentWithQueryAction @@ -8,48 +8,46 @@ safeErrorAssignmentWithQueryAction function() -> error|() { %13(LOCAL) int; %15(SYNTHETIC) (); %16(SYNTHETIC) error|(); - %22(SYNTHETIC) error; + %28(SYNTHETIC) int; %29(SYNTHETIC) int; - %30(SYNTHETIC) int; - %31(SYNTHETIC) int|error; - %40(SYNTHETIC) (); - %41(SYNTHETIC) error|(); - %42(SYNTHETIC) ballerina/lang.__internal:0.0.0:$anonType$return$createIntRange$_0; - %44(SYNTHETIC) int; - %46(SYNTHETIC) int; - %50(TEMP) ballerina/lang.__internal:0.0.0:$anonType$return$createIntRange$_0; - %51(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamPipeline; - %52(SYNTHETIC) ballerina/lang.__internal:0.0.0:$anonType$return$createIntRange$_0; - %54(SYNTHETIC) typeDesc; - %56(SYNTHETIC) typeDesc; - %62(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamFunction; - %63(SYNTHETIC) function(ballerina/lang.query:0.0.0:_Frame) -> ballerina/lang.query:0.0.0:_Frame|error|(); - %67(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamPipeline; - %69(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamFunction; - %73(TEMP) (); - %74(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamFunction; - %75(SYNTHETIC) function(ballerina/lang.query:0.0.0:_Frame) -> any|error; - %79(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamPipeline; - %81(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamFunction; - %85(TEMP) (); - %86(SYNTHETIC) stream, typeRefDesc<>>; - %87(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamPipeline; - %91(SYNTHETIC) error|(); - %93(SYNTHETIC) stream, typeRefDesc<>>; - %96(TEMP) any|error{map}; - %99(TEMP) boolean; - %110(SYNTHETIC) (); - %111(SYNTHETIC) typeRefDesc<>|(); - %120(SYNTHETIC) (); - %121(SYNTHETIC) error{map}|(); - %127(SYNTHETIC) error; - %130(LOCAL) string; - %132(SYNTHETIC) (); - %133(SYNTHETIC) error|(); - %142(SYNTHETIC) (); - %143(SYNTHETIC) Error|(); - %153(SYNTHETIC) (); - %154(SYNTHETIC) Error|(); + %30(SYNTHETIC) int|error; + %39(SYNTHETIC) (); + %40(SYNTHETIC) error|(); + %41(SYNTHETIC) ballerina/lang.__internal:0.0.0:$anonType$return$createIntRange$_0; + %43(SYNTHETIC) int; + %45(SYNTHETIC) int; + %49(TEMP) ballerina/lang.__internal:0.0.0:$anonType$return$createIntRange$_0; + %50(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamPipeline; + %51(SYNTHETIC) ballerina/lang.__internal:0.0.0:$anonType$return$createIntRange$_0; + %53(SYNTHETIC) typeDesc; + %55(SYNTHETIC) typeDesc; + %61(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamFunction; + %62(SYNTHETIC) function(ballerina/lang.query:0.0.0:_Frame) -> ballerina/lang.query:0.0.0:_Frame|error|(); + %66(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamPipeline; + %68(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamFunction; + %72(TEMP) (); + %73(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamFunction; + %74(SYNTHETIC) function(ballerina/lang.query:0.0.0:_Frame) -> any|error; + %78(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamPipeline; + %80(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamFunction; + %84(TEMP) (); + %85(SYNTHETIC) stream, typeRefDesc<>>; + %86(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamPipeline; + %90(SYNTHETIC) error|(); + %92(SYNTHETIC) stream, typeRefDesc<>>; + %95(TEMP) any|error{map}; + %98(TEMP) boolean; + %109(SYNTHETIC) (); + %110(SYNTHETIC) typeRefDesc<>|(); + %119(SYNTHETIC) (); + %120(SYNTHETIC) error{map}|(); + %128(LOCAL) string; + %130(SYNTHETIC) (); + %131(SYNTHETIC) error|(); + %140(SYNTHETIC) (); + %141(SYNTHETIC) Error|(); + %151(SYNTHETIC) (); + %152(SYNTHETIC) Error|(); bb0 { %2 = foo() -> bb1; @@ -80,8 +78,8 @@ safeErrorAssignmentWithQueryAction function() -> error|() { GOTO bb8; } bb7 { - %22 = %16; - %0 = %22; + %8 = %16; + %0 = %8; GOTO bb47; } bb8 { @@ -89,156 +87,156 @@ safeErrorAssignmentWithQueryAction function() -> error|() { GOTO bb47; } bb9 { - %31 = bar() -> bb10; + %30 = bar() -> bb10; } bb10 { - %4 = %31 is int; + %4 = %30 is int; %4? bb11 : bb12; } bb11 { - %30 = %31; + %29 = %30; GOTO bb13; } bb12 { - %8 = %31; + %8 = %30; GOTO bb4; } bb13 { - %29 = %30; - %44 = ConstLoad 1; - %46 = ConstLoad 2; - %50 = createIntRange(%44, %46) -> bb14; + %28 = %29; + %43 = ConstLoad 1; + %45 = ConstLoad 2; + %49 = createIntRange(%43, %45) -> bb14; } bb14 { - %42 = %50; - %52 = %42; - %54 = newType error|(); - %56 = newType error|(); - %51 = createPipeline(%52, %54, %56) -> bb15; + %41 = %49; + %51 = %41; + %53 = newType error|(); + %55 = newType error|(); + %50 = createPipeline(%51, %53, %55) -> bb15; } bb15 { - %63 = fp $anon/.:0.0.0::$streamLambda$_0; - %62 = createInputFunction(%63) -> bb16; + %62 = fp $anon/.:0.0.0::$streamLambda$_0; + %61 = createInputFunction(%62) -> bb16; } bb16 { - %67 = %51; - %69 = %62; - %73 = addStreamFunction(%67, %69) -> bb17; + %66 = %50; + %68 = %61; + %72 = addStreamFunction(%66, %68) -> bb17; } bb17 { - %75 = fp $anon/.:0.0.0::$streamLambda$_1; - %74 = createDoFunction(%75) -> bb18; + %74 = fp $anon/.:0.0.0::$streamLambda$_1; + %73 = createDoFunction(%74) -> bb18; } bb18 { - %79 = %51; - %81 = %74; - %85 = addStreamFunction(%79, %81) -> bb19; + %78 = %50; + %80 = %73; + %84 = addStreamFunction(%78, %80) -> bb19; } bb19 { - %87 = %51; - %86 = getStreamFromPipeline(%87) -> bb20; + %86 = %50; + %85 = getStreamFromPipeline(%86) -> bb20; } bb20 { - %93 = %86; - %96 = consumeStream(%93) -> bb21; + %92 = %85; + %95 = consumeStream(%92) -> bb21; } bb21 { - %91 = %96; - %4 = %91 is (); - %99 = not %4; - %99? bb22 : bb23; + %90 = %95; + %4 = %90 is (); + %98 = not %4; + %98? bb22 : bb23; } bb22 { - %0 = %91; + %0 = %90; GOTO bb47; } bb23 { - %41 = %91; - %4 = %41 is (); + %40 = %90; + %4 = %40 is (); %4? bb24 : bb25; } bb24 { - %40 = <()> %41; + %39 = <()> %40; GOTO bb26; } bb25 { - %8 = %41; + %8 = %40; GOTO bb4; } bb26 { - %111 = baz() -> bb27; + %110 = baz() -> bb27; } bb27 { - %99 = %111 is (); - %99? bb28 : bb29; + %98 = %110 is (); + %98? bb28 : bb29; } bb28 { - %110 = <()> %111; + %109 = <()> %110; GOTO bb30; } bb29 { - %8 = %111; + %8 = %110; GOTO bb4; } bb30 { - %121 = foo() -> bb31; + %120 = foo() -> bb31; } bb31 { - %4 = %121 is (); + %4 = %120 is (); %4? bb32 : bb33; } bb32 { - %120 = <()> %121; + %119 = <()> %120; GOTO bb42; } bb33 { - %127 = %121; + %8 = %120; GOTO bb34; } bb34 { - %130 = ConstLoad abc; - %133 = foo() -> bb35; + %128 = ConstLoad abc; + %131 = foo() -> bb35; } bb35 { - %99 = %133 is (); - %99? bb36 : bb37; + %98 = %131 is (); + %98? bb36 : bb37; } bb36 { - %132 = <()> %133; + %130 = <()> %131; GOTO bb38; } bb37 { - %8 = %133; + %8 = %131; GOTO bb4; } bb38 { - %143 = baz() -> bb39; + %141 = baz() -> bb39; } bb39 { - %4 = %143 is (); + %4 = %141 is (); %4? bb40 : bb41; } bb40 { - %142 = <()> %143; + %140 = <()> %141; GOTO bb46; } bb41 { - %8 = %143; + %8 = %141; GOTO bb4; } bb42 { - %154 = baz() -> bb43; + %152 = baz() -> bb43; } bb43 { - %99 = %154 is (); - %99? bb44 : bb45; + %98 = %152 is (); + %98? bb44 : bb45; } bb44 { - %153 = <()> %154; + %151 = <()> %152; GOTO bb46; } bb45 { - %127 = %154; + %8 = %152; GOTO bb34; } bb46 { From 9a7ede6462a79f711c785882f2606d2373536ee4 Mon Sep 17 00:00:00 2001 From: gabilang Date: Fri, 21 Oct 2022 14:33:05 +0530 Subject: [PATCH 035/450] Enable intermittently failed dynamic listener test --- .../packaging/ModuleExecutionFlowTests.java | 11 +-- .../main.bal | 77 +++++++++++-------- 2 files changed, 45 insertions(+), 43 deletions(-) diff --git a/tests/jballerina-integration-test/src/test/java/org/ballerinalang/test/packaging/ModuleExecutionFlowTests.java b/tests/jballerina-integration-test/src/test/java/org/ballerinalang/test/packaging/ModuleExecutionFlowTests.java index 11dbd3c3ba04..94323f7080c2 100644 --- a/tests/jballerina-integration-test/src/test/java/org/ballerinalang/test/packaging/ModuleExecutionFlowTests.java +++ b/tests/jballerina-integration-test/src/test/java/org/ballerinalang/test/packaging/ModuleExecutionFlowTests.java @@ -113,18 +113,11 @@ public void testDynamicListenerDeregister() throws BallerinaTestException { runAssertDynamicListener(projectPath); } - @Test(enabled = false) + @Test public void testMultipleDynamicListenersWithAsyncCall() throws BallerinaTestException { Path projectPath = Paths.get("src", "test", "resources", "packaging", "dynamic_listener_async_call_test_project"); - BServerInstance serverInstance = new BServerInstance(balServer); - serverInstance.startServer(projectPath.toAbsolutePath().toString(), projectPath.getFileName().toString(), null, - null, null); - LogLeecher errLeecherA = new LogLeecher("Stopped module A", LogLeecher.LeecherType.ERROR); - serverInstance.addErrorLogLeecher(errLeecherA); - serverInstance.shutdownServer(); - errLeecherA.waitForText(15000); - serverInstance.removeAllLeechers(); + runAssertDynamicListener(projectPath); } private void runAssertDynamicListener(Path projectPath) throws BallerinaTestException { diff --git a/tests/jballerina-integration-test/src/test/resources/packaging/dynamic_listener_async_call_test_project/main.bal b/tests/jballerina-integration-test/src/test/resources/packaging/dynamic_listener_async_call_test_project/main.bal index 79fd968253f7..1725eed7388f 100644 --- a/tests/jballerina-integration-test/src/test/resources/packaging/dynamic_listener_async_call_test_project/main.bal +++ b/tests/jballerina-integration-test/src/test/resources/packaging/dynamic_listener_async_call_test_project/main.bal @@ -15,6 +15,14 @@ // under the License. import ballerina/lang.runtime; +import ballerina/test; + +int count = 0; + +function init() { + incrementCount(); + assertCount(1); +} public class ListenerObject1 { @@ -25,11 +33,20 @@ public class ListenerObject1 { } public function 'start() returns error? { + incrementCount(); + if (self.name == "DynamicListenerObject1") { + assertCount(2); + } else if (self.name == "ListenerObject1") { + assertCount(3); + } } public function gracefulStop() returns error? { - runtime:sleep(2); - if (self.name == "ModA") { + incrementCount(); + future f = start waitAndReturnInt(1250); + int i = check wait f; + if (self.name == "ListenerObject1") { + assertCount(4); panic error("Stopped module A"); } } @@ -47,10 +64,12 @@ public class ListenerObject1 { public class ListenerObject2 { public function init() {} - public function 'start() returns error? {} + public function 'start() returns error? { + } public function gracefulStop() returns error? { - runtime:sleep(1); + future f = start waitAndReturnInt(1250); + int _ = check wait f; } public function immediateStop() returns error? {} @@ -62,40 +81,30 @@ public class ListenerObject2 { } } -public class ListenerObject3 { - - private string name = ""; - - public function init(string name){ - self.name = name; - } - - public function 'start() returns error? { - } - - public function gracefulStop() returns error? { - } +listener ListenerObject1 ep1 = new ListenerObject1("ListenerObject1"); +listener ListenerObject2 ep2 = new(); - public function immediateStop() returns error? { - } +public function main() { + ListenerObject1 ep1 = new("DynamicListenerObject1"); + checkpanic ep1.'start(); + runtime:registerListener(ep1); - public function attach(service object {} s, string[]|string? name = ()) returns error? { - } + ListenerObject2 ep2 = new(); + checkpanic ep2.'start(); + runtime:registerListener(ep2); - public function detach(service object {} s) returns error? { - } + runtime:deregisterListener(ep1); + runtime:deregisterListener(ep2); } -final ListenerObject1 ep = new ListenerObject1("ModA"); -final ListenerObject2 lo2 = new ListenerObject2(); -final ListenerObject3 lo3 = new ListenerObject3("ListenerObject3"); +function waitAndReturnInt(int i) returns int { + runtime:sleep( i/1000); + return i; +} -public function main() { - runtime:registerListener(ep); - runtime:registerListener(lo2); - runtime:registerListener(lo3); - runtime:sleep(2); - runtime:deregisterListener(ep); - runtime:deregisterListener(lo2); - runtime:deregisterListener(lo3); +public function incrementCount() { + count += 1; +} +public function assertCount(int val) { + test:assertEquals(count, val); } From 4478ce9d3f60cff14a789c1fa542d705b9f0a01f Mon Sep 17 00:00:00 2001 From: Chiran Fernando Date: Thu, 27 Oct 2022 13:58:56 +0530 Subject: [PATCH 036/450] Handle non-matching capturing groups (cherry picked from commit b8422da87e21ffc4ed26c2c6832366f25968b740) --- .../ballerinalang/langlib/regexp/Find.java | 36 +++++++------------ .../ballerinalang/langlib/regexp/Matches.java | 24 +++---------- .../langlib/regexp/RegexUtil.java | 26 ++++++++++++++ .../ballerinalang/langlib/regexp/Replace.java | 15 ++++---- 4 files changed, 49 insertions(+), 52 deletions(-) diff --git a/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/Find.java b/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/Find.java index 364e5639604d..36fc9e3e11f6 100644 --- a/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/Find.java +++ b/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/Find.java @@ -19,13 +19,14 @@ package org.ballerinalang.langlib.regexp; import io.ballerina.runtime.api.creators.ValueCreator; -import io.ballerina.runtime.api.utils.StringUtils; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BRegexpValue; import io.ballerina.runtime.api.values.BString; import java.util.regex.Matcher; +import static org.ballerinalang.langlib.regexp.RegexUtil.GROUPS_AS_SPAN_ARRAY_TYPE; + /** * Native implementation of lang.regexp:find(string). * @@ -36,29 +37,17 @@ public class Find { public static BArray find(BRegexpValue regExp, BString str, int startIndex) { Matcher matcher = RegexUtil.getMatcher(regExp, str); if (matcher.find(startIndex)) { - BArray resultTuple = ValueCreator.createTupleValue(RegexUtil.SPAN_AS_TUPLE_TYPE); - resultTuple.add(0, matcher.start()); - resultTuple.add(1, matcher.end()); - resultTuple.add(2, StringUtils.fromString(matcher.group())); - return resultTuple; + return RegexUtil.getGroupZeroAsSpan(matcher); } return null; } public static BArray findGroups(BRegexpValue regExp, BString str, int startIndex) { Matcher matcher = RegexUtil.getMatcher(regExp, str); - BArray resultArray = ValueCreator.createArrayValue(RegexUtil.GROUPS_AS_SPAN_ARRAY_TYPE); + BArray resultArray = ValueCreator.createArrayValue(GROUPS_AS_SPAN_ARRAY_TYPE); + matcher.region(startIndex, str.length()); while (matcher.find()) { - int matcherStart = matcher.start(); - if (matcherStart >= startIndex) { - int matcherEnd = matcher.end(); - String matcherStr = matcher.group(); - BArray resultTuple = ValueCreator.createTupleValue(RegexUtil.SPAN_AS_TUPLE_TYPE); - resultTuple.add(0, matcherStart); - resultTuple.add(1, matcherEnd); - resultTuple.add(2, StringUtils.fromString(matcherStr)); - resultArray.append(resultTuple); - } + resultArray.append(RegexUtil.getGroupZeroAsSpan(matcher)); } if (resultArray.getLength() == 0) { return null; @@ -71,14 +60,13 @@ public static BArray findAllGroups(BRegexpValue regExp, BString str, int startIn matcher.region(startIndex, str.length()); BArray groupArray = ValueCreator.createArrayValue(RegexUtil.GROUPS_ARRAY_TYPE); while (matcher.find()) { - BArray group = ValueCreator.createArrayValue(RegexUtil.GROUPS_AS_SPAN_ARRAY_TYPE); - for (int i = 1; i <= matcher.groupCount(); i++) { - BArray resultTuple = ValueCreator.createTupleValue(RegexUtil.SPAN_AS_TUPLE_TYPE); - resultTuple.add(0, matcher.start(i)); - resultTuple.add(1, matcher.end(i)); - resultTuple.add(2, StringUtils.fromString(matcher.group(i))); - group.append(resultTuple); + if (matcher.groupCount() == 0) { + BArray group = ValueCreator.createArrayValue(GROUPS_AS_SPAN_ARRAY_TYPE); + group.append(RegexUtil.getGroupZeroAsSpan(matcher)); + groupArray.append(group); + break; } + BArray group = RegexUtil.getMatcherGroupsAsSpanArr(matcher); if (group.getLength() != 0) { groupArray.append(group); } diff --git a/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/Matches.java b/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/Matches.java index 31f21957629a..a61b5edb0aac 100644 --- a/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/Matches.java +++ b/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/Matches.java @@ -18,8 +18,6 @@ package org.ballerinalang.langlib.regexp; -import io.ballerina.runtime.api.creators.ValueCreator; -import io.ballerina.runtime.api.utils.StringUtils; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BRegexpValue; import io.ballerina.runtime.api.values.BString; @@ -36,33 +34,19 @@ public static BArray matchAt(BRegexpValue regExp, BString str, int startIndex) { Matcher matcher = RegexUtil.getMatcher(regExp, str); matcher.region(startIndex, str.length()); if (matcher.matches()) { - BArray resultTuple = ValueCreator.createTupleValue(RegexUtil.SPAN_AS_TUPLE_TYPE); - resultTuple.add(0, matcher.start()); - resultTuple.add(1, matcher.end()); - resultTuple.add(2, StringUtils.fromString(matcher.group())); - return resultTuple; + return RegexUtil.getGroupZeroAsSpan(matcher); } return null; } public static BArray matchGroupsAt(BRegexpValue regExp, BString str, int startIndex) { Matcher matcher = RegexUtil.getMatcher(regExp, str); - BArray resultArray = ValueCreator.createArrayValue(RegexUtil.GROUPS_AS_SPAN_ARRAY_TYPE); matcher.region(startIndex, str.length()); + BArray resultArray = null; if (matcher.matches()) { - for (int i = 1; i <= matcher.groupCount(); i++) { - int matcherStart = matcher.start(i); - if (matcher.start(i) == -1) { - continue; - } - BArray resultTuple = ValueCreator.createTupleValue(RegexUtil.SPAN_AS_TUPLE_TYPE); - resultTuple.add(0, matcherStart); - resultTuple.add(1, matcher.end(i)); - resultTuple.add(2, StringUtils.fromString(matcher.group(i))); - resultArray.append(resultTuple); - } + resultArray = RegexUtil.getMatcherGroupsAsSpanArr(matcher); } - if (resultArray.getLength() == 0) { + if (resultArray == null || resultArray.getLength() == 0) { return null; } return resultArray; diff --git a/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/RegexUtil.java b/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/RegexUtil.java index 14e00ababe76..933ecb45d738 100644 --- a/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/RegexUtil.java +++ b/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/RegexUtil.java @@ -18,7 +18,9 @@ package org.ballerinalang.langlib.regexp; import io.ballerina.runtime.api.PredefinedTypes; +import io.ballerina.runtime.api.creators.ValueCreator; import io.ballerina.runtime.api.utils.StringUtils; +import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BRegexpValue; import io.ballerina.runtime.api.values.BString; import io.ballerina.runtime.internal.regexp.RegExpFactory; @@ -53,4 +55,28 @@ static Matcher getMatcher(BRegexpValue regexpVal, String inputStr) { Pattern pattern = Pattern.compile(patternStr); return pattern.matcher(inputStr); } + + static BArray getGroupZeroAsSpan(Matcher matcher) { + BArray resultTuple = ValueCreator.createTupleValue(SPAN_AS_TUPLE_TYPE); + resultTuple.add(0, matcher.start()); + resultTuple.add(1, matcher.end()); + resultTuple.add(2, StringUtils.fromString(matcher.group())); + return resultTuple; + } + + static BArray getMatcherGroupsAsSpanArr(Matcher matcher) { + BArray group = ValueCreator.createArrayValue(GROUPS_AS_SPAN_ARRAY_TYPE); + for (int i = 1; i <= matcher.groupCount(); i++) { + int matcherStart = matcher.start(i); + if (matcherStart == -1) { + continue; + } + BArray resultTuple = ValueCreator.createTupleValue(SPAN_AS_TUPLE_TYPE); + resultTuple.add(0, matcherStart); + resultTuple.add(1, matcher.end(i)); + resultTuple.add(2, StringUtils.fromString(matcher.group(i))); + group.append(resultTuple); + } + return group; + } } diff --git a/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/Replace.java b/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/Replace.java index d19bbe11d7af..c130cb4d463e 100644 --- a/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/Replace.java +++ b/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/Replace.java @@ -43,16 +43,15 @@ private static BString replaceFromString(BRegexpValue regExp, BString str, BStri boolean isReplaceAll) { String originalStr = str.getValue(); String replacementString = replacingStr.getValue(); - Matcher matcher = RegexUtil.getMatcher(regExp, originalStr); - matcher.region(startIndex, originalStr.length()); + String prefixStr = ""; + String subStr = originalStr; + if (startIndex != 0) { + prefixStr = originalStr.substring(0, startIndex); + subStr = originalStr.substring(startIndex); + } + Matcher matcher = RegexUtil.getMatcher(regExp, subStr); if (matcher.find()) { - String prefixStr = ""; String updatedSubStr; - if (startIndex != 0) { - prefixStr = originalStr.substring(0, startIndex); - String substr = originalStr.substring(startIndex); - matcher = RegexUtil.getMatcher(regExp, substr); - } if (isReplaceAll) { updatedSubStr = matcher.replaceAll(replacementString); } else { From 0dce3cd0735e475b11554f8eb82dda2f4171f672 Mon Sep 17 00:00:00 2001 From: Chiran Fernando Date: Thu, 27 Oct 2022 14:05:09 +0530 Subject: [PATCH 037/450] Add non-capturing group match tests (cherry picked from commit b85027cd63665f6234c6a8fbb2677c8116a93264) --- .../test/resources/test-src/regexp_test.bal | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/langlib/langlib-test/src/test/resources/test-src/regexp_test.bal b/langlib/langlib-test/src/test/resources/test-src/regexp_test.bal index 22baabb4463d..345547205f8c 100644 --- a/langlib/langlib-test/src/test/resources/test-src/regexp_test.bal +++ b/langlib/langlib-test/src/test/resources/test-src/regexp_test.bal @@ -360,6 +360,112 @@ function testFindAllGroups() { assertEquality(15, resultSpan1_3_2.startIndex); assertEquality(18, resultSpan1_3_2.endIndex); assertEquality("FGF", resultSpan1_3_2.substring()); + + string str2 = "abab"; + string:RegExp regExpr2 = re `((a)(b))`; + + regexp:Groups[] groupsArr2 = regExpr2.findAllGroups(str2); + assertEquality(2, groupsArr2.length()); + + regexp:Groups groups2_1 = groupsArr2[0]; + regexp:Span? resultSpanOrNil2_1_1 = groups2_1[0]; + assertTrue(resultSpanOrNil2_1_1 is regexp:Span); + regexp:Span resultSpan2_1_1 = resultSpanOrNil2_1_1; + assertEquality(0, resultSpan2_1_1.startIndex); + assertEquality(2, resultSpan2_1_1.endIndex); + assertEquality("ab", resultSpan2_1_1.substring()); + + regexp:Span? resultSpanOrNil2_1_2 = groups2_1[1]; + assertTrue(resultSpanOrNil2_1_2 is regexp:Span); + regexp:Span resultSpan2_1_2 = resultSpanOrNil2_1_2; + assertEquality(0, resultSpan2_1_2.startIndex); + assertEquality(1, resultSpan2_1_2.endIndex); + assertEquality("a", resultSpan2_1_2.substring()); + + regexp:Span? resultSpanOrNil2_1_3 = groups2_1[2]; + assertTrue(resultSpanOrNil2_1_3 is regexp:Span); + regexp:Span resultSpan2_1_3 = resultSpanOrNil2_1_3; + assertEquality(1, resultSpan2_1_3.startIndex); + assertEquality(2, resultSpan2_1_3.endIndex); + assertEquality("b", resultSpan2_1_3.substring()); + + regexp:Groups groups2_2 = groupsArr2[1]; + regexp:Span? resultSpanOrNil2_2_1 = groups2_2[0]; + assertTrue(resultSpanOrNil2_2_1 is regexp:Span); + regexp:Span resultSpan2_2_1 = resultSpanOrNil2_2_1; + assertEquality(2, resultSpan2_2_1.startIndex); + assertEquality(4, resultSpan2_2_1.endIndex); + assertEquality("ab", resultSpan2_2_1.substring()); + + regexp:Span? resultSpanOrNil2_2_2 = groups2_2[1]; + assertTrue(resultSpanOrNil2_2_2 is regexp:Span); + regexp:Span resultSpan2_2_2 = resultSpanOrNil2_2_2; + assertEquality(2, resultSpan2_2_2.startIndex); + assertEquality(3, resultSpan2_2_2.endIndex); + assertEquality("a", resultSpan2_2_2.substring()); + + regexp:Span? resultSpanOrNil2_2_3 = groups2_2[2]; + assertTrue(resultSpanOrNil2_2_3 is regexp:Span); + regexp:Span resultSpan2_2_3 = resultSpanOrNil2_2_3; + assertEquality(3, resultSpan2_2_3.startIndex); + assertEquality(4, resultSpan2_2_3.endIndex); + assertEquality("b", resultSpan2_2_3.substring()); + + string:RegExp regExpr3 = re `(a|b)`; + regexp:Groups[] groupsArr3 = regExpr3.findAllGroups(str2); + assertEquality(4, groupsArr3.length()); + + regexp:Groups groups3_1 = groupsArr3[0]; + regexp:Span? resultSpanOrNil3_1_1 = groups3_1[0]; + assertTrue(resultSpanOrNil3_1_1 is regexp:Span); + regexp:Span resultSpan3_1_1 = resultSpanOrNil3_1_1; + assertEquality(0, resultSpan3_1_1.startIndex); + assertEquality(1, resultSpan3_1_1.endIndex); + assertEquality("a", resultSpan3_1_1.substring()); + + regexp:Groups groups3_2 = groupsArr3[1]; + regexp:Span? resultSpanOrNil3_2_1 = groups3_2[0]; + assertTrue(resultSpanOrNil3_2_1 is regexp:Span); + regexp:Span resultSpan3_2_1 = resultSpanOrNil3_2_1; + assertEquality(1, resultSpan3_2_1.startIndex); + assertEquality(2, resultSpan3_2_1.endIndex); + assertEquality("b", resultSpan3_2_1.substring()); + + regexp:Groups groups3_3 = groupsArr3[2]; + regexp:Span? resultSpanOrNil3_3_1 = groups3_3[0]; + assertTrue(resultSpanOrNil3_3_1 is regexp:Span); + regexp:Span resultSpan3_3_1 = resultSpanOrNil3_3_1; + assertEquality(2, resultSpan3_3_1.startIndex); + assertEquality(3, resultSpan3_3_1.endIndex); + assertEquality("a", resultSpan3_3_1.substring()); + + regexp:Groups groups3_4 = groupsArr3[3]; + regexp:Span? resultSpanOrNil3_4_1 = groups3_4[0]; + assertTrue(resultSpanOrNil3_4_1 is regexp:Span); + regexp:Span resultSpan3_4_1 = resultSpanOrNil3_4_1; + assertEquality(3, resultSpan3_4_1.startIndex); + assertEquality(4, resultSpan3_4_1.endIndex); + assertEquality("b", resultSpan3_4_1.substring()); + + string:RegExp regExpr4 = re `a|b`; + regexp:Groups[] groupsArr4 = regExpr4.findAllGroups(str2); + assertEquality(1, groupsArr4.length()); + + regexp:Groups groups4_1 = groupsArr4[0]; + regexp:Span? resultSpanOrNil4_1_1 = groups4_1[0]; + assertTrue(resultSpanOrNil4_1_1 is regexp:Span); + regexp:Span resultSpan4_1_1 = resultSpanOrNil4_1_1; + assertEquality(0, resultSpan4_1_1.startIndex); + assertEquality(1, resultSpan4_1_1.endIndex); + assertEquality("a", resultSpan4_1_1.substring()); + + string:RegExp regExpr5 = re `(c|d)`; + regexp:Groups[] groupsArr5 = regExpr5.findAllGroups(str2); + assertEquality(0, groupsArr5.length()); + + string:RegExp regExpr6 = re `((c)(d))`; + regexp:Groups[] groupsArr6 = regExpr6.findAllGroups(str2); + assertEquality(0, groupsArr6.length()); } function testMatchAt() { From 22a2cf8b07516b4d0b17cca4edad0889810d2c6f Mon Sep 17 00:00:00 2001 From: gabilang Date: Wed, 2 Nov 2022 16:33:32 +0530 Subject: [PATCH 038/450] Address review suggestions --- .../dynamic_listener_async_call_test_project/main.bal | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/jballerina-integration-test/src/test/resources/packaging/dynamic_listener_async_call_test_project/main.bal b/tests/jballerina-integration-test/src/test/resources/packaging/dynamic_listener_async_call_test_project/main.bal index 1725eed7388f..9407ce1bdc11 100644 --- a/tests/jballerina-integration-test/src/test/resources/packaging/dynamic_listener_async_call_test_project/main.bal +++ b/tests/jballerina-integration-test/src/test/resources/packaging/dynamic_listener_async_call_test_project/main.bal @@ -43,7 +43,7 @@ public class ListenerObject1 { public function gracefulStop() returns error? { incrementCount(); - future f = start waitAndReturnInt(1250); + future f = start waitAndReturnInt(850); int i = check wait f; if (self.name == "ListenerObject1") { assertCount(4); @@ -68,7 +68,7 @@ public class ListenerObject2 { } public function gracefulStop() returns error? { - future f = start waitAndReturnInt(1250); + future f = start waitAndReturnInt(750); int _ = check wait f; } @@ -105,6 +105,7 @@ function waitAndReturnInt(int i) returns int { public function incrementCount() { count += 1; } + public function assertCount(int val) { test:assertEquals(count, val); } From 0d15abfe17d2f5ea6312ad0f57ef3e6a1a627597 Mon Sep 17 00:00:00 2001 From: Nipuna Ranasinghe Date: Wed, 2 Nov 2022 19:27:13 +0530 Subject: [PATCH 039/450] Fix debugger integration test failures on type reference changes --- .../main/ballerina/arithmetic_operations.bal | 56 +++++++++---------- .../src/main/ballerina/unary_operations.bal | 32 +++++------ 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/misc/debug-adapter/modules/debug-adapter-runtime/src/main/ballerina/arithmetic_operations.bal b/misc/debug-adapter/modules/debug-adapter-runtime/src/main/ballerina/arithmetic_operations.bal index f62c2688399a..6e64fdf69842 100644 --- a/misc/debug-adapter/modules/debug-adapter-runtime/src/main/ballerina/arithmetic_operations.bal +++ b/misc/debug-adapter/modules/debug-adapter-runtime/src/main/ballerina/arithmetic_operations.bal @@ -15,18 +15,18 @@ // under the License. // -function add(any lhs, any rhs) returns any|error { +function add(any lhs, any rhs) returns int|float|decimal|string|xml|error { - any|error result; - if (lhs is int && rhs is int) { + int|float|decimal|string|xml|error result; + if lhs is int && rhs is int { result = trap (lhs + rhs); // int + int - } else if (lhs is float && rhs is float) { + } else if lhs is float && rhs is float { result = trap (lhs + rhs); // float + float - } else if (lhs is decimal && rhs is decimal) { + } else if lhs is decimal && rhs is decimal { result = trap (lhs + rhs); // decimal + decimal - } else if (lhs is string && rhs is string) { + } else if lhs is string && rhs is string { result = trap (lhs + rhs); // string + string - } else if (lhs is xml && rhs is xml) { + } else if lhs is xml && rhs is xml { result = trap (lhs + rhs); // xml + xml } else { result = error("operator '+' not defined for '" + check getType(lhs) + "' and '" + check getType(rhs) + "'."); @@ -34,14 +34,14 @@ function add(any lhs, any rhs) returns any|error { return result; } -function subtract(any lhs, any rhs) returns any|error { +function subtract(any lhs, any rhs) returns int|float|decimal|error { - any|error result; - if (lhs is int && rhs is int) { + int|float|decimal|error result; + if lhs is int && rhs is int { result = trap (lhs - rhs); // int - int - } else if (lhs is float && rhs is float) { + } else if lhs is float && rhs is float { result = trap (lhs - rhs); // float - float - } else if (lhs is decimal && rhs is decimal) { + } else if lhs is decimal && rhs is decimal { result = trap (lhs - rhs); // decimal - decimal } else { result = error("operator '-' not defined for '" + check getType(lhs) + "' and '" + check getType(rhs) + "'."); @@ -49,14 +49,14 @@ function subtract(any lhs, any rhs) returns any|error { return result; } -function multiply(any lhs, any rhs) returns any|error { +function multiply(any lhs, any rhs) returns int|float|decimal|error { - any|error result; - if (lhs is int && rhs is int) { + int|float|decimal|error result; + if lhs is int && rhs is int { result = trap (lhs * rhs); // int * int - } else if (lhs is float && rhs is float) { + } else if lhs is float && rhs is float { result = trap (lhs * rhs); // float * float - } else if (lhs is decimal && rhs is decimal) { + } else if lhs is decimal && rhs is decimal { result = trap (lhs * rhs); // decimal * decimal } else { result = error("operator '*' not defined for '" + check getType(lhs) + "' and '" + check getType(rhs) + "'."); @@ -64,14 +64,14 @@ function multiply(any lhs, any rhs) returns any|error { return result; } -function divide(any lhs, any rhs) returns any|error { +function divide(any lhs, any rhs) returns int|float|decimal|error { - any|error result; - if (lhs is int && rhs is int) { + int|float|decimal|error result; + if lhs is int && rhs is int { result = trap (lhs / rhs); // int / int - } else if (lhs is float && rhs is float) { + } else if lhs is float && rhs is float { result = trap (lhs / rhs); // float / float - } else if (lhs is decimal && rhs is decimal) { + } else if lhs is decimal && rhs is decimal { result = trap (lhs / rhs); // decimal / decimal } else { result = error("operator '/' not defined for '" + check getType(lhs) + "' and '" + check getType(rhs) + "'."); @@ -79,17 +79,17 @@ function divide(any lhs, any rhs) returns any|error { return result; } -function modulus(any lhs, any rhs) returns any|error { +function modulus(any lhs, any rhs) returns int|float|decimal|error { - any|error result; - if (lhs is int && rhs is int) { + int|float|decimal|error result; + if lhs is int && rhs is int { result = trap (lhs % rhs); // int % int - } else if (lhs is float && rhs is float) { + } else if lhs is float && rhs is float { result = trap (lhs % rhs); // float % float - } else if (lhs is decimal && rhs is decimal) { + } else if lhs is decimal && rhs is decimal { result = trap (lhs % rhs); // decimal % decimal } else { - result = error("operator '%' not defined for '" + check getType(lhs) + "' and '" + check getType(rhs)+ "'."); + result = error("operator '%' not defined for '" + check getType(lhs) + "' and '" + check getType(rhs) + "'."); } return result; } diff --git a/misc/debug-adapter/modules/debug-adapter-runtime/src/main/ballerina/unary_operations.bal b/misc/debug-adapter/modules/debug-adapter-runtime/src/main/ballerina/unary_operations.bal index 7fa689d8c812..4c1d37c86498 100644 --- a/misc/debug-adapter/modules/debug-adapter-runtime/src/main/ballerina/unary_operations.bal +++ b/misc/debug-adapter/modules/debug-adapter-runtime/src/main/ballerina/unary_operations.bal @@ -15,14 +15,14 @@ // under the License. // -function unaryPlus(any value) returns any|error { +function unaryPlus(any value) returns int|float|decimal|error { // Todo - Add proper syntax for for int and float, after fixing runtime exception. - any|error result; - if (value is int) { + int|float|decimal|error result; + if value is int { result = value; - } else if (value is float) { + } else if value is float { result = value; - } else if (value is decimal) { + } else if value is decimal { result = trap +value; } else { result = error("operator '+' not defined for '" + check getType(value) + "'"); @@ -30,13 +30,13 @@ function unaryPlus(any value) returns any|error { return result; } -function unaryMinus(any value) returns any|error { - any|error result; - if (value is int) { +function unaryMinus(any value) returns int|float|decimal|error { + int|float|decimal|error result; + if value is int { result = trap -value; - } else if (value is float) { + } else if value is float { result = trap -value; - } else if (value is decimal) { + } else if value is decimal { result = trap -value; } else { result = error("operator '-' not defined for '" + check getType(value) + "'"); @@ -44,9 +44,9 @@ function unaryMinus(any value) returns any|error { return result; } -function unaryInvert(any value) returns any|error { - any|error result; - if (value is int) { +function unaryInvert(any value) returns int|error { + int|error result; + if value is int { result = trap ~value; } else { result = error("operator '~' not defined for '" + check getType(value) + "'"); @@ -54,9 +54,9 @@ function unaryInvert(any value) returns any|error { return result; } -function unaryNot(any value) returns any|error { - any|error result; - if (value is boolean) { +function unaryNot(any value) returns boolean|error { + boolean|error result; + if value is boolean { result = trap !value; } else { result = error("operator '!' not defined for '" + check getType(value) + "'"); From f24b66244f8504137566ae0fad38e68490e57dc1 Mon Sep 17 00:00:00 2001 From: gayalkuruppu Date: Tue, 8 Nov 2022 09:27:33 +0530 Subject: [PATCH 040/450] Improve error-constructor-expr sorting --- ...ErrorConstructorExpressionNodeContext.java | 60 ++++++++++++++----- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ErrorConstructorExpressionNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ErrorConstructorExpressionNodeContext.java index 5ec1b4d170aa..cfd3781dddd2 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ErrorConstructorExpressionNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ErrorConstructorExpressionNodeContext.java @@ -16,11 +16,13 @@ package org.ballerinalang.langserver.completions.providers.context; import io.ballerina.compiler.api.SemanticModel; +import io.ballerina.compiler.api.Types; import io.ballerina.compiler.api.symbols.RecordFieldSymbol; import io.ballerina.compiler.api.symbols.RecordTypeSymbol; import io.ballerina.compiler.api.symbols.Symbol; import io.ballerina.compiler.api.symbols.TypeDescKind; import io.ballerina.compiler.api.symbols.TypeSymbol; +import io.ballerina.compiler.api.symbols.UnionTypeSymbol; import io.ballerina.compiler.syntax.tree.ErrorConstructorExpressionNode; import io.ballerina.compiler.syntax.tree.FunctionArgumentNode; import io.ballerina.compiler.syntax.tree.NamedArgumentNode; @@ -61,12 +63,14 @@ public class ErrorConstructorExpressionNodeContext extends AbstractCompletionProvider { public ErrorConstructorExpressionNodeContext() { + super(ErrorConstructorExpressionNode.class); } @Override public List getCompletions(BallerinaCompletionContext context, ErrorConstructorExpressionNode node) { + List completionItems = new ArrayList<>(); if (withinArgs(context, node)) { @@ -91,6 +95,7 @@ public List getCompletions(BallerinaCompletionContext context, } private boolean withinTypeRefContext(BallerinaCompletionContext context, ErrorConstructorExpressionNode node) { + int cursor = context.getCursorPositionInTree(); Token errorKeyword = node.errorKeyword(); Optional typeDescNode = node.typeReference(); @@ -101,6 +106,7 @@ private boolean withinTypeRefContext(BallerinaCompletionContext context, ErrorCo private List getCompletionWithinArgs(BallerinaCompletionContext ctx, ErrorConstructorExpressionNode node) { + List completionItems = new ArrayList<>(); NonTerminalNode nodeAtCursor = ctx.getNodeAtCursor(); if (QNameRefCompletionUtil.onQualifiedNameIdentifier(ctx, nodeAtCursor)) { @@ -115,6 +121,7 @@ private List getCompletionWithinArgs(BallerinaCompletionContex } private List getErrorTypeRefCompletions(BallerinaCompletionContext ctx) { + NonTerminalNode nodeAtCursor = ctx.getNodeAtCursor(); if (QNameRefCompletionUtil.onQualifiedNameIdentifier(ctx, nodeAtCursor)) { QualifiedNameReferenceNode qNameRef = (QualifiedNameReferenceNode) nodeAtCursor; @@ -138,31 +145,40 @@ private List getErrorTypeRefCompletions(BallerinaCompletionCon public void sort(BallerinaCompletionContext context, ErrorConstructorExpressionNode node, List completionItems) { - if (!withinArgs(context, node)) { + if (!withinArgs(context, node) || context.currentSemanticModel().isEmpty()) { super.sort(context, node, completionItems); return; } + + Types types = context.currentSemanticModel().get().types(); + if (isInErrorMessageArgContext(context, node)) { /* - Covers the following. - error(,) + Covers the following. + error(,) */ - Optional semanticModel = context.currentSemanticModel(); - if (semanticModel.isEmpty()) { - super.sort(context, node, completionItems); - return; - } - TypeSymbol typeSymbol = semanticModel.get().types().STRING; + TypeSymbol stringTypeSymbol = types.STRING; for (LSCompletionItem completionItem : completionItems) { completionItem.getCompletionItem() - .setSortText(SortingUtil.genSortTextByAssignability(context, completionItem, typeSymbol)); + .setSortText(SortingUtil.genSortTextByAssignability(context, completionItem, stringTypeSymbol)); + } + return; + } + + if (isInErrorCauseArgContext(context, node)) { + /* + Covers the following. + error(arg1, ) + */ + UnionTypeSymbol optionalErrorTypeSymbol = types.builder().UNION_TYPE + .withMemberTypes(types.ERROR, types.NIL).build(); + for (LSCompletionItem completionItem : completionItems) { + completionItem.getCompletionItem().setSortText(SortingUtil + .genSortTextByAssignability(context, completionItem, optionalErrorTypeSymbol)); } return; } - /* - Covers the following. - error(arg1, ) - */ + for (LSCompletionItem completionItem : completionItems) { String sortText; if (completionItem.getType() == LSCompletionItem.CompletionItemType.NAMED_ARG) { @@ -177,6 +193,7 @@ public void sort(BallerinaCompletionContext context, ErrorConstructorExpressionN } private boolean withinArgs(BallerinaCompletionContext context, ErrorConstructorExpressionNode node) { + int cursor = context.getCursorPositionInTree(); Token openParenToken = node.openParenToken(); Token closeParenToken = node.closeParenToken(); @@ -188,6 +205,7 @@ private boolean withinArgs(BallerinaCompletionContext context, ErrorConstructorE private boolean isInErrorMessageArgContext(BallerinaCompletionContext context, ErrorConstructorExpressionNode node) { + if (!withinArgs(context, node)) { return false; } @@ -201,8 +219,22 @@ private boolean isInErrorMessageArgContext(BallerinaCompletionContext context, && textRange.startOffset() <= cursor && cursor <= textRange.endOffset()); } + private boolean isInErrorCauseArgContext(BallerinaCompletionContext context, + ErrorConstructorExpressionNode node) { + + if (!withinArgs(context, node) || node.arguments().isEmpty() || node.arguments().size() == 1) { + return false; + } + FunctionArgumentNode secondArgNode = node.arguments().get(1); + TextRange textRange = secondArgNode.textRange(); + int cursor = context.getCursorPositionInTree(); + return cursor < textRange.startOffset() || (secondArgNode.kind() == SyntaxKind.POSITIONAL_ARG + && textRange.startOffset() <= cursor && cursor <= textRange.endOffset()); + } + private List getNamedArgExpressionCompletionItems(BallerinaCompletionContext context, ErrorConstructorExpressionNode node) { + List completionItems = new ArrayList<>(); Optional semanticModel = context.currentSemanticModel(); if (semanticModel.isEmpty()) { From b5bc7349d5673f8939fc65571ec38cdfd7c486d9 Mon Sep 17 00:00:00 2001 From: gayalkuruppu Date: Tue, 8 Nov 2022 09:27:40 +0530 Subject: [PATCH 041/450] Add unit tests --- .../error_constructor_expr_ctx_config13.json | 715 ++++++++++++++++++ .../error_constructor_expr_ctx_source13.bal | 4 + 2 files changed, 719 insertions(+) create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config13.json create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/expression_context/source/error_constructor_expr_ctx_source13.bal diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config13.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config13.json new file mode 100644 index 000000000000..85797253f78c --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config13.json @@ -0,0 +1,715 @@ +{ + "position": { + "line": 2, + "character": 41 + }, + "source": "expression_context/source/error_constructor_expr_ctx_source13.bal", + "items": [ + { + "label": "ballerina/lang.runtime", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "runtime", + "insertText": "runtime", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.runtime;\n" + } + ] + }, + { + "label": "ballerina/lang.value", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "value", + "insertText": "value", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.value;\n" + } + ] + }, + { + "label": "ballerina/module1", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "module1", + "insertText": "module1", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/module1;\n" + } + ] + }, + { + "label": "ballerina/lang.array", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "array", + "insertText": "array", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.array;\n" + } + ] + }, + { + "label": "ballerina/jballerina.java", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "java", + "insertText": "java", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/jballerina.java;\n" + } + ] + }, + { + "label": "ballerina/lang.test", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "test", + "insertText": "test", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.test;\n" + } + ] + }, + { + "label": "boolean", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "map", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "map", + "insertTextFormat": "Snippet" + }, + { + "label": "object", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "object", + "insertTextFormat": "Snippet" + }, + { + "label": "stream", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "stream", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "table", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "table", + "insertTextFormat": "Snippet" + }, + { + "label": "transaction", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "transaction", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "new", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "new", + "insertText": "new ", + "insertTextFormat": "Snippet" + }, + { + "label": "isolated", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "isolated", + "insertText": "isolated ", + "insertTextFormat": "Snippet" + }, + { + "label": "transactional", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "transactional", + "insertText": "transactional", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "function", + "insertText": "function ", + "insertTextFormat": "Snippet" + }, + { + "label": "let", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "let", + "insertText": "let", + "insertTextFormat": "Snippet" + }, + { + "label": "typeof", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "typeof", + "insertText": "typeof ", + "insertTextFormat": "Snippet" + }, + { + "label": "trap", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "trap", + "insertText": "trap", + "insertTextFormat": "Snippet" + }, + { + "label": "client", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "client", + "insertText": "client ", + "insertTextFormat": "Snippet" + }, + { + "label": "true", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "true", + "insertText": "true", + "insertTextFormat": "Snippet" + }, + { + "label": "false", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "false", + "insertText": "false", + "insertTextFormat": "Snippet" + }, + { + "label": "null", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "null", + "insertText": "null", + "insertTextFormat": "Snippet" + }, + { + "label": "check", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "check", + "insertText": "check ", + "insertTextFormat": "Snippet" + }, + { + "label": "checkpanic", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "checkpanic", + "insertText": "checkpanic ", + "insertTextFormat": "Snippet" + }, + { + "label": "is", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "is", + "insertText": "is", + "insertTextFormat": "Snippet" + }, + { + "label": "error constructor", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "T", + "filterText": "error", + "insertText": "error(\"${1}\")", + "insertTextFormat": "Snippet" + }, + { + "label": "object constructor", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "T", + "filterText": "object", + "insertText": "object {${1}}", + "insertTextFormat": "Snippet" + }, + { + "label": "base16", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "T", + "filterText": "base16", + "insertText": "base16 `${1}`", + "insertTextFormat": "Snippet" + }, + { + "label": "base64", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "T", + "filterText": "base64", + "insertText": "base64 `${1}`", + "insertTextFormat": "Snippet" + }, + { + "label": "from", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "from", + "insertText": "from ", + "insertTextFormat": "Snippet" + }, + { + "label": "Thread", + "kind": "TypeParameter", + "detail": "Union", + "sortText": "R", + "insertText": "Thread", + "insertTextFormat": "Snippet" + }, + { + "label": "StrandData", + "kind": "Struct", + "detail": "Record", + "documentation": { + "left": "Describes Strand execution details for the runtime.\n" + }, + "sortText": "Q", + "insertText": "StrandData", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "start", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "start", + "insertText": "start ", + "insertTextFormat": "Snippet" + }, + { + "label": "wait", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "wait", + "insertText": "wait ", + "insertTextFormat": "Snippet" + }, + { + "label": "flush", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "flush", + "insertText": "flush ", + "insertTextFormat": "Snippet" + }, + { + "label": "from clause", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "T", + "filterText": "from", + "insertText": "from ${1:var} ${2:item} in ${3}", + "insertTextFormat": "Snippet" + }, + { + "label": "test/project2", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "project2", + "insertText": "project2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/project2;\n" + } + ] + }, + { + "label": "test/project1", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "project1", + "insertText": "project1", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/project1;\n" + } + ] + }, + { + "label": "test/local_project2", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "local_project2", + "insertText": "local_project2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/local_project2;\n" + } + ] + }, + { + "label": "test/local_project1", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "local_project1", + "insertText": "local_project1", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/local_project1;\n" + } + ] + }, + { + "label": "function", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "ballerina/lang.regexp", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "regexp", + "insertText": "regexp", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.regexp;\n" + } + ] + }, + { + "label": "testFunction()", + "kind": "Function", + "detail": "()", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _._ \n \n \n" + } + }, + "sortText": "AC", + "filterText": "testFunction", + "insertText": "testFunction()", + "insertTextFormat": "Snippet" + }, + { + "label": "errorCause", + "kind": "Variable", + "detail": "error?", + "sortText": "AB", + "insertText": "errorCause", + "insertTextFormat": "Snippet" + }, + { + "label": "newError", + "kind": "Variable", + "detail": "error", + "sortText": "AB", + "insertText": "newError", + "insertTextFormat": "Snippet" + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/source/error_constructor_expr_ctx_source13.bal b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/source/error_constructor_expr_ctx_source13.bal new file mode 100644 index 000000000000..111264da9808 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/source/error_constructor_expr_ctx_source13.bal @@ -0,0 +1,4 @@ +function testFunction() { + error? errorCause = error("error cause"); + error newError = error("error name", ); +} From ebffdc38caa92a13962af392c84ba43069e734f4 Mon Sep 17 00:00:00 2001 From: aneeshafedo Date: Wed, 9 Nov 2022 11:36:33 +0530 Subject: [PATCH 042/450] Add location for each node --- .../projectdesign/ComponentModel.java | 14 +++---- .../projectdesign/ComponentModelBuilder.java | 14 +++---- .../io/ballerina/projectdesign/Utils.java | 11 +++-- .../entity}/EntityModelGenerator.java | 37 +++++++++-------- .../service}/ServiceModelGenerator.java | 7 ++-- .../nodevisitors/ActionNodeVisitor.java | 32 +++++++++------ .../ServiceDeclarationNodeVisitor.java | 12 +++--- .../ServiceMemberFunctionNodeVisitor.java | 41 ++++++++++++------- .../nodevisitors/StatementNodeVisitor.java | 12 +++--- .../model/ComponentModelItem.java | 19 +++++++++ .../entity}/Association.java | 2 +- .../entity}/Attribute.java | 11 +++-- .../Entity.java => model/entity/Type.java} | 15 +++---- .../service}/FunctionParameter.java | 11 +++-- .../service}/Interaction.java | 11 +++-- .../service}/RemoteFunction.java | 11 +++-- .../service}/Resource.java | 11 +++-- .../service}/ResourceId.java | 2 +- .../service}/ResourceParameter.java | 12 ++++-- .../components => model/service}/Service.java | 13 ++---- .../service}/ServiceAnnotation.java | 15 +++++-- 21 files changed, 191 insertions(+), 122 deletions(-) rename misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/{entitymodel => generators/entity}/EntityModelGenerator.java (93%) rename misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/{servicemodel => generators/service}/ServiceModelGenerator.java (91%) rename misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/{servicemodel => generators/service}/nodevisitors/ActionNodeVisitor.java (91%) rename misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/{servicemodel => generators/service}/nodevisitors/ServiceDeclarationNodeVisitor.java (96%) rename misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/{servicemodel => generators/service}/nodevisitors/ServiceMemberFunctionNodeVisitor.java (90%) rename misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/{servicemodel => generators/service}/nodevisitors/StatementNodeVisitor.java (95%) create mode 100644 misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/ComponentModelItem.java rename misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/{entitymodel/components => model/entity}/Association.java (96%) rename misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/{entitymodel/components => model/entity}/Attribute.java (85%) rename misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/{entitymodel/components/Entity.java => model/entity/Type.java} (79%) rename misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/{servicemodel/components => model/service}/FunctionParameter.java (81%) rename misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/{servicemodel/components => model/service}/Interaction.java (81%) rename misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/{servicemodel/components => model/service}/RemoteFunction.java (82%) rename misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/{servicemodel/components => model/service}/Resource.java (84%) rename misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/{servicemodel/components => model/service}/ResourceId.java (95%) rename misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/{servicemodel/components => model/service}/ResourceParameter.java (82%) rename misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/{servicemodel/components => model/service}/Service.java (89%) rename misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/{servicemodel/components => model/service}/ServiceAnnotation.java (70%) diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModel.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModel.java index e71b3dfd6d20..65446cb73eb5 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModel.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModel.java @@ -18,8 +18,8 @@ package io.ballerina.projectdesign; -import io.ballerina.projectdesign.entitymodel.components.Entity; -import io.ballerina.projectdesign.servicemodel.components.Service; +import io.ballerina.projectdesign.model.entity.Type; +import io.ballerina.projectdesign.model.service.Service; import io.ballerina.projects.Package; import java.util.Map; @@ -33,13 +33,13 @@ public class ComponentModel { private final PackageId packageId; private final Map services; - private final Map entities; + private final Map types; - public ComponentModel(PackageId packageId, Map services, Map entities) { + public ComponentModel(PackageId packageId, Map services, Map entities) { this.packageId = packageId; this.services = services; - this.entities = entities; + this.types = entities; } public PackageId getPackageId() { @@ -52,9 +52,9 @@ public Map getServices() { return services; } - public Map getEntities() { + public Map getTypes() { - return entities; + return types; } /** diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModelBuilder.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModelBuilder.java index 7c6d4ec4b8a2..4eeebd79425d 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModelBuilder.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModelBuilder.java @@ -20,10 +20,10 @@ import io.ballerina.compiler.api.SemanticModel; import io.ballerina.projectdesign.ComponentModel.PackageId; -import io.ballerina.projectdesign.entitymodel.EntityModelGenerator; -import io.ballerina.projectdesign.entitymodel.components.Entity; -import io.ballerina.projectdesign.servicemodel.ServiceModelGenerator; -import io.ballerina.projectdesign.servicemodel.components.Service; +import io.ballerina.projectdesign.generators.entity.EntityModelGenerator; +import io.ballerina.projectdesign.generators.service.ServiceModelGenerator; +import io.ballerina.projectdesign.model.entity.Type; +import io.ballerina.projectdesign.model.service.Service; import io.ballerina.projects.DocumentId; import io.ballerina.projects.Package; @@ -42,7 +42,7 @@ public ComponentModel constructComponentModel(Package currentPackage) { Map services = new HashMap<>(); // todo: Change to TypeDefinition - Map entities = new HashMap<>(); + Map types = new HashMap<>(); PackageId packageId = new PackageId(currentPackage); @@ -61,9 +61,9 @@ public ComponentModel constructComponentModel(Package currentPackage) { EntityModelGenerator entityModelGenerator = new EntityModelGenerator( currentSemanticModel, packageId, moduleRootPath); - entities.putAll(entityModelGenerator.generate()); + types.putAll(entityModelGenerator.generate()); }); - return new ComponentModel(packageId, services, entities); + return new ComponentModel(packageId, services, types); } } diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/Utils.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/Utils.java index df25b3d5c542..5880536aa1c1 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/Utils.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/Utils.java @@ -8,8 +8,9 @@ import io.ballerina.compiler.syntax.tree.SeparatedNodeList; import io.ballerina.compiler.syntax.tree.SpecificFieldNode; import io.ballerina.compiler.syntax.tree.SyntaxKind; -import io.ballerina.projectdesign.servicemodel.components.ServiceAnnotation; +import io.ballerina.projectdesign.model.service.ServiceAnnotation; import io.ballerina.projects.Package; +import io.ballerina.tools.text.LineRange; import java.util.Map; @@ -36,13 +37,16 @@ public static boolean modelAlreadyExists(Map componentModelM return componentModelMap.containsKey(getQualifiedPackageName(packageId)); } - public static ServiceAnnotation getServiceAnnotation(NodeList annotationNodes) { + public static ServiceAnnotation getServiceAnnotation(NodeList annotationNodes, String filePath) { String id = ""; String label = ""; + LineRange lineRange = null; for (AnnotationNode annotationNode : annotationNodes) { String annotationName = annotationNode.annotReference().toString().trim(); if (annotationName.equals(DISPLAY_ANNOTATION)) { + lineRange = LineRange.from(filePath, annotationNode.lineRange().startLine(), + annotationNode.lineRange().endLine()); if (annotationNode.annotValue().isPresent()) { SeparatedNodeList fields = annotationNode.annotValue().get().fields(); for (MappingFieldNode mappingFieldNode : fields) { @@ -64,6 +68,7 @@ public static ServiceAnnotation getServiceAnnotation(NodeList an } } } - return new ServiceAnnotation(id, label); + + return new ServiceAnnotation(id, label, lineRange); } } diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/entitymodel/EntityModelGenerator.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/entity/EntityModelGenerator.java similarity index 93% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/entitymodel/EntityModelGenerator.java rename to misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/entity/EntityModelGenerator.java index 3575382121fd..57963aa33995 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/entitymodel/EntityModelGenerator.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/entity/EntityModelGenerator.java @@ -16,7 +16,7 @@ * under the License. */ -package io.ballerina.projectdesign.entitymodel; +package io.ballerina.projectdesign.generators.entity; import io.ballerina.compiler.api.SemanticModel; import io.ballerina.compiler.api.symbols.ArrayTypeSymbol; @@ -32,9 +32,9 @@ import io.ballerina.projectdesign.ComponentModel; import io.ballerina.projectdesign.ComponentModel.PackageId; import io.ballerina.projectdesign.ProjectDesignConstants.CardinalityValue; -import io.ballerina.projectdesign.entitymodel.components.Association; -import io.ballerina.projectdesign.entitymodel.components.Attribute; -import io.ballerina.projectdesign.entitymodel.components.Entity; +import io.ballerina.projectdesign.model.entity.Association; +import io.ballerina.projectdesign.model.entity.Attribute; +import io.ballerina.projectdesign.model.entity.Type; import io.ballerina.tools.text.LineRange; import java.util.ArrayList; @@ -66,9 +66,9 @@ public EntityModelGenerator(SemanticModel semanticModel, ComponentModel.PackageI this.moduleRootPath = moduleRootPath; } - public Map generate() { + public Map generate() { - Map entities = new HashMap<>(); + Map types = new HashMap<>(); List symbols = semanticModel.moduleSymbols(); for (Symbol symbol : symbols) { if (symbol.kind().equals(SymbolKind.TYPE_DEFINITION)) { @@ -92,22 +92,17 @@ public Map generate() { List associations = getAssociations(fieldEntryValue.typeDescriptor(), entityName, optional, nillable); Attribute attribute = - new Attribute(fieldName, fieldType, optional, nillable, defaultValue, associations); + new Attribute(fieldName, fieldType, optional, nillable, defaultValue, associations, + getLineRange(fieldEntryValue)); attributeList.add(attribute); } - LineRange recordLineRange = null; - if (typeDefinitionSymbol.getLocation().isPresent()) { - LineRange typeLineRange = typeDefinitionSymbol.getLocation().get().lineRange(); - String filePath = String.format("%s/%s", moduleRootPath, typeLineRange.filePath()); - recordLineRange = LineRange.from(filePath, typeLineRange.startLine(), typeLineRange.endLine()); - } - Entity entity = new Entity(attributeList, inclusionList, recordLineRange); - entities.put(entityName, entity); + Type type = new Type(attributeList, inclusionList, getLineRange(typeDefinitionSymbol)); + types.put(entityName, type); } } } - return entities; + return types; } private Map getOriginalFieldMap( @@ -289,4 +284,14 @@ private List getAssociations(TypeSymbol fieldTypeDescriptor, String } return associations; } + + private LineRange getLineRange(Symbol symbol) { + LineRange lineRange = null; + if (symbol.getLocation().isPresent()) { + LineRange typeLineRange = symbol.getLocation().get().lineRange(); + String filePath = String.format("%s/%s", moduleRootPath, typeLineRange.filePath()); + lineRange = LineRange.from(filePath, typeLineRange.startLine(), typeLineRange.endLine()); + } + return lineRange; + } } diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/ServiceModelGenerator.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/ServiceModelGenerator.java similarity index 91% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/ServiceModelGenerator.java rename to misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/ServiceModelGenerator.java index 53b1bd9b1e2a..7b94fc7feb4c 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/ServiceModelGenerator.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/ServiceModelGenerator.java @@ -16,13 +16,13 @@ * under the License. */ -package io.ballerina.projectdesign.servicemodel; +package io.ballerina.projectdesign.generators.service; import io.ballerina.compiler.api.SemanticModel; import io.ballerina.compiler.syntax.tree.SyntaxTree; import io.ballerina.projectdesign.ComponentModel; -import io.ballerina.projectdesign.servicemodel.components.Service; -import io.ballerina.projectdesign.servicemodel.nodevisitors.ServiceDeclarationNodeVisitor; +import io.ballerina.projectdesign.generators.service.nodevisitors.ServiceDeclarationNodeVisitor; +import io.ballerina.projectdesign.model.service.Service; import io.ballerina.projects.DocumentId; import io.ballerina.projects.Module; import io.ballerina.projects.Package; @@ -41,6 +41,7 @@ public class ServiceModelGenerator { private final SemanticModel semanticModel; private final ComponentModel.PackageId packageId; private final String moduleRootPath; + public ServiceModelGenerator(SemanticModel semanticModel, ComponentModel.PackageId packageId, String moduleRootPath) { diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/nodevisitors/ActionNodeVisitor.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ActionNodeVisitor.java similarity index 91% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/nodevisitors/ActionNodeVisitor.java rename to misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ActionNodeVisitor.java index 9f69c908e2c5..b50bd2735b8a 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/nodevisitors/ActionNodeVisitor.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ActionNodeVisitor.java @@ -16,7 +16,7 @@ * under the License. */ -package io.ballerina.projectdesign.servicemodel.nodevisitors; +package io.ballerina.projectdesign.generators.service.nodevisitors; import io.ballerina.compiler.api.ModuleID; import io.ballerina.compiler.api.SemanticModel; @@ -42,11 +42,12 @@ import io.ballerina.compiler.syntax.tree.SimpleNameReferenceNode; import io.ballerina.compiler.syntax.tree.SyntaxKind; import io.ballerina.compiler.syntax.tree.SyntaxTree; -import io.ballerina.projectdesign.servicemodel.components.Interaction; -import io.ballerina.projectdesign.servicemodel.components.ResourceId; +import io.ballerina.projectdesign.model.service.Interaction; +import io.ballerina.projectdesign.model.service.ResourceId; import io.ballerina.projects.DocumentId; import io.ballerina.projects.Package; import io.ballerina.tools.diagnostics.Location; +import io.ballerina.tools.text.LineRange; import java.util.Collection; import java.util.LinkedList; @@ -67,11 +68,13 @@ public class ActionNodeVisitor extends NodeVisitor { private final SemanticModel semanticModel; private final Package currentPackage; private final List interactionList = new LinkedList<>(); + private final String filePath; - public ActionNodeVisitor(SemanticModel semanticModel, Package currentPackage) { + public ActionNodeVisitor(SemanticModel semanticModel, Package currentPackage, String filePath) { this.semanticModel = semanticModel; this.currentPackage = currentPackage; + this.filePath = filePath; } public List getInteractionList() { @@ -85,7 +88,7 @@ public void visit(ClientResourceAccessActionNode clientResourceAccessActionNode) String resourceMethod = String.valueOf(clientResourceAccessActionNode.methodName().get().name().text()); String resourcePath = getResourcePath(clientResourceAccessActionNode.resourceAccessPath()); - StatementNodeVisitor statementVisitor = new StatementNodeVisitor(clientName, semanticModel); + StatementNodeVisitor statementVisitor = new StatementNodeVisitor(clientName, semanticModel, filePath); NonTerminalNode parent = clientResourceAccessActionNode.parent().parent(); // todo: get the connector type using semantic model @@ -99,10 +102,13 @@ public void visit(ClientResourceAccessActionNode clientResourceAccessActionNode) } } - Interaction resourceId = new Interaction( + LineRange lineRange = LineRange.from(filePath, clientResourceAccessActionNode.lineRange().startLine(), + clientResourceAccessActionNode.lineRange().endLine()); + + Interaction interaction = new Interaction( new ResourceId(statementVisitor.getServiceId(), resourceMethod, resourcePath), - statementVisitor.getConnectorType()); - interactionList.add(resourceId); + statementVisitor.getConnectorType(), lineRange); + interactionList.add(interaction); } @@ -123,7 +129,7 @@ public void visit(RemoteMethodCallActionNode remoteMethodCallActionNode) { // todo : Other combinations String resourceMethod = remoteMethodCallActionNode.methodName().name().text(); NonTerminalNode parent = remoteMethodCallActionNode.parent().parent(); - StatementNodeVisitor statementVisitor = new StatementNodeVisitor(clientName, semanticModel); + StatementNodeVisitor statementVisitor = new StatementNodeVisitor(clientName, semanticModel, filePath); //todo : implement using semantic model. Need to wait till bug fix // semanticModel.symbol(remoteMethodCallActionNode.expression()); -> returns null @@ -136,8 +142,10 @@ public void visit(RemoteMethodCallActionNode remoteMethodCallActionNode) { break; } } + LineRange lineRange = LineRange.from(filePath, remoteMethodCallActionNode.lineRange().startLine(), + remoteMethodCallActionNode.lineRange().endLine()); Interaction interaction = new Interaction(new ResourceId(statementVisitor.getServiceId(), - resourceMethod, null), statementVisitor.getConnectorType()); + resourceMethod, null), statementVisitor.getConnectorType(), lineRange); interactionList.add(interaction); } @@ -194,7 +202,7 @@ private void findInteractions(String methodName, Symbol methodSymbol) { String referencedFunctionName = functionDefinitionNode.functionName().text(); if (methodName.equals(referencedFunctionName)) { ActionNodeVisitor actionNodeVisitor = new ActionNodeVisitor(semanticModel, - currentPackage); + currentPackage, this.filePath); functionDefinitionNode.accept(actionNodeVisitor); interactionList.addAll(actionNodeVisitor.getInteractionList()); } @@ -203,7 +211,7 @@ private void findInteractions(String methodName, Symbol methodSymbol) { String referencedFunctionName = methodDeclarationNode.methodName().text(); if (methodName.equals(referencedFunctionName)) { ActionNodeVisitor actionNodeVisitor = new ActionNodeVisitor(semanticModel, - currentPackage); + currentPackage, this.filePath); methodDeclarationNode.accept(actionNodeVisitor); interactionList.addAll(actionNodeVisitor.getInteractionList()); } diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/nodevisitors/ServiceDeclarationNodeVisitor.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java similarity index 96% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/nodevisitors/ServiceDeclarationNodeVisitor.java rename to misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java index 3321749f8e07..2133f8ef877b 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/nodevisitors/ServiceDeclarationNodeVisitor.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java @@ -16,7 +16,7 @@ * under the License. */ -package io.ballerina.projectdesign.servicemodel.nodevisitors; +package io.ballerina.projectdesign.generators.service.nodevisitors; import io.ballerina.compiler.api.SemanticModel; import io.ballerina.compiler.api.symbols.Symbol; @@ -43,8 +43,8 @@ import io.ballerina.compiler.syntax.tree.VariableDeclarationNode; import io.ballerina.projectdesign.ComponentModel; import io.ballerina.projectdesign.Utils; -import io.ballerina.projectdesign.servicemodel.components.Service; -import io.ballerina.projectdesign.servicemodel.components.ServiceAnnotation; +import io.ballerina.projectdesign.model.service.Service; +import io.ballerina.projectdesign.model.service.ServiceAnnotation; import io.ballerina.projects.Package; import io.ballerina.tools.text.LineRange; @@ -85,7 +85,7 @@ public List getServices() { public void visit(ServiceDeclarationNode serviceDeclarationNode) { StringBuilder serviceNameBuilder = new StringBuilder(); - ServiceAnnotation serviceAnnotation = new ServiceAnnotation("", ""); + ServiceAnnotation serviceAnnotation = new ServiceAnnotation(); NodeList serviceNameNodes = serviceDeclarationNode.absoluteResourcePath(); for (Node serviceNameNode : serviceNameNodes) { serviceNameBuilder.append(serviceNameNode.toString().replace("\"", "")); @@ -94,7 +94,7 @@ public void visit(ServiceDeclarationNode serviceDeclarationNode) { Optional metadataNode = serviceDeclarationNode.metadata(); if (metadataNode.isPresent()) { NodeList annotationNodes = metadataNode.get().annotations(); - serviceAnnotation = Utils.getServiceAnnotation(annotationNodes); + serviceAnnotation = Utils.getServiceAnnotation(annotationNodes, this.filePath); } String serviceName = serviceNameBuilder.toString().startsWith(FORWARD_SLASH) ? @@ -102,7 +102,7 @@ public void visit(ServiceDeclarationNode serviceDeclarationNode) { ServiceMemberFunctionNodeVisitor serviceMemberFunctionNodeVisitor = new ServiceMemberFunctionNodeVisitor(serviceAnnotation.getId(), - semanticModel, currentPackage, packageId); + semanticModel, currentPackage, packageId, filePath); serviceDeclarationNode.accept(serviceMemberFunctionNodeVisitor); LineRange lineRange = LineRange.from(filePath, serviceDeclarationNode.lineRange().startLine(), serviceDeclarationNode.lineRange().endLine()); diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/nodevisitors/ServiceMemberFunctionNodeVisitor.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java similarity index 90% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/nodevisitors/ServiceMemberFunctionNodeVisitor.java rename to misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java index cc6a5930b1f6..70498006352b 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/nodevisitors/ServiceMemberFunctionNodeVisitor.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java @@ -16,7 +16,7 @@ * under the License. */ -package io.ballerina.projectdesign.servicemodel.nodevisitors; +package io.ballerina.projectdesign.generators.service.nodevisitors; import io.ballerina.compiler.api.SemanticModel; import io.ballerina.compiler.api.symbols.ArrayTypeSymbol; @@ -46,12 +46,13 @@ import io.ballerina.compiler.syntax.tree.VariableDeclarationNode; import io.ballerina.projectdesign.ComponentModel; import io.ballerina.projectdesign.ProjectDesignConstants.ParameterIn; -import io.ballerina.projectdesign.servicemodel.components.FunctionParameter; -import io.ballerina.projectdesign.servicemodel.components.RemoteFunction; -import io.ballerina.projectdesign.servicemodel.components.Resource; -import io.ballerina.projectdesign.servicemodel.components.ResourceId; -import io.ballerina.projectdesign.servicemodel.components.ResourceParameter; +import io.ballerina.projectdesign.model.service.FunctionParameter; +import io.ballerina.projectdesign.model.service.RemoteFunction; +import io.ballerina.projectdesign.model.service.Resource; +import io.ballerina.projectdesign.model.service.ResourceId; +import io.ballerina.projectdesign.model.service.ResourceParameter; import io.ballerina.projects.Package; +import io.ballerina.tools.text.LineRange; import java.util.ArrayList; import java.util.LinkedList; @@ -71,14 +72,16 @@ public class ServiceMemberFunctionNodeVisitor extends NodeVisitor { private List resources = new LinkedList<>(); private List remoteFunctions = new LinkedList<>(); private final ComponentModel.PackageId packageId; + private final String filePath; public ServiceMemberFunctionNodeVisitor(String serviceId, SemanticModel semanticModel, Package currentPackage, - ComponentModel.PackageId packageId) { + ComponentModel.PackageId packageId, String filePath) { this.serviceId = serviceId; this.semanticModel = semanticModel; this.currentPackage = currentPackage; this.packageId = packageId; + this.filePath = filePath; } public List getResources() { @@ -91,7 +94,8 @@ public List getRemoteFunctions() { @Override public void visit(FunctionDefinitionNode functionDefinitionNode) { - + LineRange lineRange = LineRange.from(filePath, + functionDefinitionNode.lineRange().startLine(), functionDefinitionNode.lineRange().endLine()); SyntaxKind kind = functionDefinitionNode.kind(); switch (kind) { case RESOURCE_ACCESSOR_DEFINITION: { @@ -119,12 +123,13 @@ public void visit(FunctionDefinitionNode functionDefinitionNode) { List returnTypes = getReturnTypes(functionDefinitionNode); ActionNodeVisitor actionNodeVisitor = - new ActionNodeVisitor(semanticModel, currentPackage); + new ActionNodeVisitor(semanticModel, currentPackage, filePath); functionDefinitionNode.accept(actionNodeVisitor); ResourceId resourceId = new ResourceId(this.serviceId, method, resourcePath); Resource resource = new Resource(identifierBuilder.toString().trim(), - resourceId, resourceParameterList, returnTypes, actionNodeVisitor.getInteractionList()); + resourceId, resourceParameterList, returnTypes, + actionNodeVisitor.getInteractionList(), lineRange); resources.add(resource); break; @@ -139,11 +144,12 @@ public void visit(FunctionDefinitionNode functionDefinitionNode) { false, null, parameterList); List returnTypes = getReturnTypes(functionDefinitionNode); - ActionNodeVisitor actionNodeVisitor = new ActionNodeVisitor(semanticModel, currentPackage); + ActionNodeVisitor actionNodeVisitor = new ActionNodeVisitor( + semanticModel, currentPackage, filePath); functionDefinitionNode.accept(actionNodeVisitor); RemoteFunction remoteFunction = new RemoteFunction(name, parameterList, returnTypes, - actionNodeVisitor.getInteractionList()); + actionNodeVisitor.getInteractionList(), lineRange); remoteFunctions.add(remoteFunction); } break; @@ -152,6 +158,8 @@ public void visit(FunctionDefinitionNode functionDefinitionNode) { } private ResourceParameter getPathParameter(ResourcePathParameterNode resourcePathParameterNode) { + LineRange lineRange = LineRange.from(filePath, + resourcePathParameterNode.lineRange().startLine(), resourcePathParameterNode.lineRange().endLine()); String name = resourcePathParameterNode.paramName().get().text(); List paramTypes = new LinkedList<>(); Optional symbol = semanticModel.symbol(resourcePathParameterNode); @@ -159,7 +167,7 @@ private ResourceParameter getPathParameter(ResourcePathParameterNode resourcePat PathParameterSymbol parameterSymbol = ((PathParameterSymbol) symbol.get()); paramTypes = getReferencedType(parameterSymbol.typeDescriptor()); } // todo : implement else - return new ResourceParameter(paramTypes, name, ParameterIn.PATH.getValue(), true); + return new ResourceParameter(paramTypes, name, ParameterIn.PATH.getValue(), true, lineRange); } private void getParameters(FunctionSignatureNode functionSignatureNode, boolean isResource, @@ -167,6 +175,8 @@ private void getParameters(FunctionSignatureNode functionSignatureNode, boolean SeparatedNodeList parameterNodes = functionSignatureNode.parameters(); for (ParameterNode parameterNode : parameterNodes) { + LineRange lineRange = LineRange.from(filePath, + parameterNode.lineRange().startLine(), parameterNode.lineRange().endLine()); Optional symbol = semanticModel.symbol(parameterNode); if (symbol.isPresent() && symbol.get().kind().equals(SymbolKind.PARAMETER)) { String paramIn = ""; @@ -196,9 +206,10 @@ private void getParameters(FunctionSignatureNode functionSignatureNode, boolean } if (isResource) { // todo : param kind - resourceParams.add(new ResourceParameter(paramTypes, paramName.trim(), paramIn, isRequired)); + resourceParams.add(new ResourceParameter( + paramTypes, paramName.trim(), paramIn, isRequired, lineRange)); } else { - remoteFunctionParams.add(new FunctionParameter(paramTypes, paramName, isRequired)); + remoteFunctionParams.add(new FunctionParameter(paramTypes, paramName, isRequired, lineRange)); } } } diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/nodevisitors/StatementNodeVisitor.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/StatementNodeVisitor.java similarity index 95% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/nodevisitors/StatementNodeVisitor.java rename to misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/StatementNodeVisitor.java index 14f40c1d7712..ff960cab0594 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/nodevisitors/StatementNodeVisitor.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/StatementNodeVisitor.java @@ -16,7 +16,7 @@ * under the License. */ -package io.ballerina.projectdesign.servicemodel.nodevisitors; +package io.ballerina.projectdesign.generators.service.nodevisitors; import io.ballerina.compiler.api.SemanticModel; import io.ballerina.compiler.api.symbols.Symbol; @@ -53,11 +53,13 @@ public class StatementNodeVisitor extends NodeVisitor { private String connectorType = null; private final SemanticModel semanticModel; private final String clientName; + private final String filePath; - public StatementNodeVisitor(String clientName, SemanticModel semanticModel) { + public StatementNodeVisitor(String clientName, SemanticModel semanticModel, String filePath) { this.clientName = clientName; this.semanticModel = semanticModel; + this.filePath = filePath; } public String getServiceId() { @@ -75,7 +77,7 @@ public void visit(VariableDeclarationNode variableDeclarationNode) { TypeDescriptorNode typeDescriptorNode = variableDeclarationNode.typedBindingPattern().typeDescriptor(); connectorType = getClientModuleName(typeDescriptorNode); NodeList annotations = variableDeclarationNode.annotations(); - this.serviceId = Utils.getServiceAnnotation(annotations).getId(); + this.serviceId = Utils.getServiceAnnotation(annotations, this.filePath).getId(); } } @@ -88,7 +90,7 @@ public void visit(ObjectFieldNode objectFieldNode) { Optional metadataNode = objectFieldNode.metadata(); if (metadataNode.isPresent()) { NodeList annotationNodes = metadataNode.get().annotations(); - serviceId = Utils.getServiceAnnotation(annotationNodes).getId(); + serviceId = Utils.getServiceAnnotation(annotationNodes, this.filePath).getId(); } } } @@ -103,7 +105,7 @@ public void visit(ModuleVariableDeclarationNode moduleVariableDeclarationNode) { Optional metadataNode = moduleVariableDeclarationNode.metadata(); if (metadataNode.isPresent()) { NodeList annotationNodes = metadataNode.get().annotations(); - serviceId = Utils.getServiceAnnotation(annotationNodes).getId(); + serviceId = Utils.getServiceAnnotation(annotationNodes, this.filePath).getId(); } } } diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/ComponentModelItem.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/ComponentModelItem.java new file mode 100644 index 000000000000..f75962cc083f --- /dev/null +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/ComponentModelItem.java @@ -0,0 +1,19 @@ +package io.ballerina.projectdesign.model; + +import io.ballerina.tools.text.LineRange; + +/** + * Represents the abstract model for a component model item. + */ +public abstract class ComponentModelItem { + + private final LineRange lineRange; + + public ComponentModelItem(LineRange lineRange) { + this.lineRange = lineRange; + } + + public LineRange getLineRange() { + return lineRange; + } +} diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/entitymodel/components/Association.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Association.java similarity index 96% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/entitymodel/components/Association.java rename to misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Association.java index 5ce1c1ab43ab..828a0d731f82 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/entitymodel/components/Association.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Association.java @@ -16,7 +16,7 @@ * under the License. */ -package io.ballerina.projectdesign.entitymodel.components; +package io.ballerina.projectdesign.model.entity; /** * Represent the relationship between records. diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/entitymodel/components/Attribute.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Attribute.java similarity index 85% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/entitymodel/components/Attribute.java rename to misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Attribute.java index 402af37629e5..41a93eaf6034 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/entitymodel/components/Attribute.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Attribute.java @@ -16,7 +16,10 @@ * under the License. */ -package io.ballerina.projectdesign.entitymodel.components; +package io.ballerina.projectdesign.model.entity; + +import io.ballerina.projectdesign.model.ComponentModelItem; +import io.ballerina.tools.text.LineRange; import java.util.List; @@ -25,7 +28,7 @@ * * @since 2201.2.2 */ -public class Attribute { +public class Attribute extends ComponentModelItem { private final String name; private final String type; @@ -35,8 +38,8 @@ public class Attribute { private final List associations; // can have multiple association when union is found public Attribute(String name, String type, boolean optional, boolean nillable, String defaultValue, - List associations) { - + List associations, LineRange lineRange) { + super(lineRange); this.name = name; this.type = type; this.optional = optional; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/entitymodel/components/Entity.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Type.java similarity index 79% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/entitymodel/components/Entity.java rename to misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Type.java index 912fad1825b7..9849e290758d 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/entitymodel/components/Entity.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Type.java @@ -16,8 +16,9 @@ * under the License. */ -package io.ballerina.projectdesign.entitymodel.components; +package io.ballerina.projectdesign.model.entity; +import io.ballerina.projectdesign.model.ComponentModelItem; import io.ballerina.tools.text.LineRange; import java.util.List; @@ -27,19 +28,17 @@ * * @since 2201.2.2 */ -public class Entity { +public class Type extends ComponentModelItem { private List attributes; private final List inclusions; - private final LineRange lineRange; // todo : send the location - public Entity(List attributes, List inclusions, LineRange lineRange) { - + public Type(List attributes, List inclusions, LineRange lineRange) { + super(lineRange); this.attributes = attributes; this.inclusions = inclusions; - this.lineRange = lineRange; } public List getAttributes() { @@ -53,9 +52,5 @@ public void setAttributes(List attributes) { public List getInclusions() { return inclusions; } - - public LineRange getLineRange() { - return lineRange; - } } diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/components/FunctionParameter.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/FunctionParameter.java similarity index 81% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/components/FunctionParameter.java rename to misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/FunctionParameter.java index 683543693be9..3229423234a4 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/components/FunctionParameter.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/FunctionParameter.java @@ -16,7 +16,10 @@ * under the License. */ -package io.ballerina.projectdesign.servicemodel.components; +package io.ballerina.projectdesign.model.service; + +import io.ballerina.projectdesign.model.ComponentModelItem; +import io.ballerina.tools.text.LineRange; import java.util.List; @@ -25,14 +28,14 @@ * * @since 2201.2.2 */ -public class FunctionParameter { +public class FunctionParameter extends ComponentModelItem { private final List type; private final String name; private final boolean isRequired; - public FunctionParameter(List type, String name, boolean isRequired) { - + public FunctionParameter(List type, String name, boolean isRequired, LineRange lineRange) { + super(lineRange); this.type = type; this.name = name; this.isRequired = isRequired; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/components/Interaction.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/Interaction.java similarity index 81% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/components/Interaction.java rename to misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/Interaction.java index 6dfbb1d0b12a..11d0685ed3b9 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/components/Interaction.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/Interaction.java @@ -16,20 +16,23 @@ * under the License. */ -package io.ballerina.projectdesign.servicemodel.components; +package io.ballerina.projectdesign.model.service; + +import io.ballerina.projectdesign.model.ComponentModelItem; +import io.ballerina.tools.text.LineRange; /** * Represent interaction with another service. * * @since 2201.2.2 */ -public class Interaction { +public class Interaction extends ComponentModelItem { private final ResourceId resourceId; private final String connectorType; - public Interaction(ResourceId resourceId, String connectorType) { - + public Interaction(ResourceId resourceId, String connectorType, LineRange lineRange) { + super(lineRange); this.resourceId = resourceId; this.connectorType = connectorType; } diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/components/RemoteFunction.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/RemoteFunction.java similarity index 82% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/components/RemoteFunction.java rename to misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/RemoteFunction.java index 7bfade08cdc7..c241b3fdfbd5 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/components/RemoteFunction.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/RemoteFunction.java @@ -16,7 +16,10 @@ * under the License. */ -package io.ballerina.projectdesign.servicemodel.components; +package io.ballerina.projectdesign.model.service; + +import io.ballerina.projectdesign.model.ComponentModelItem; +import io.ballerina.tools.text.LineRange; import java.util.List; @@ -25,7 +28,7 @@ * * @since 2201.2.2 */ -public class RemoteFunction { +public class RemoteFunction extends ComponentModelItem { private final String name; private final List parameters; @@ -34,8 +37,8 @@ public class RemoteFunction { private final List interactions; public RemoteFunction(String name, List parameters, List returns, - List interactions) { - + List interactions, LineRange lineRange) { + super(lineRange); this.name = name; this.parameters = parameters; this.returns = returns; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/components/Resource.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/Resource.java similarity index 84% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/components/Resource.java rename to misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/Resource.java index 6dc3054fccf6..e9b8a19a47b7 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/components/Resource.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/Resource.java @@ -16,7 +16,10 @@ * under the License. */ -package io.ballerina.projectdesign.servicemodel.components; +package io.ballerina.projectdesign.model.service; + +import io.ballerina.projectdesign.model.ComponentModelItem; +import io.ballerina.tools.text.LineRange; import java.util.List; @@ -25,7 +28,7 @@ * * @since 2201.2.2 */ -public class Resource { +public class Resource extends ComponentModelItem { private final String identifier; private final ResourceId resourceId; @@ -34,8 +37,8 @@ public class Resource { private final List interactions; public Resource(String identifier, ResourceId resourceId, List parameters, List returns, - List interactions) { - + List interactions, LineRange lineRange) { + super(lineRange); this.identifier = identifier; this.resourceId = resourceId; this.parameters = parameters; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/components/ResourceId.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/ResourceId.java similarity index 95% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/components/ResourceId.java rename to misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/ResourceId.java index f85278e99fd7..e3ed9f2d9ebd 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/components/ResourceId.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/ResourceId.java @@ -16,7 +16,7 @@ * under the License. */ -package io.ballerina.projectdesign.servicemodel.components; +package io.ballerina.projectdesign.model.service; /** * Provide resource information. diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/components/ResourceParameter.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/ResourceParameter.java similarity index 82% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/components/ResourceParameter.java rename to misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/ResourceParameter.java index c7c9cbad9dfe..c5bd2e6cbb78 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/components/ResourceParameter.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/ResourceParameter.java @@ -16,7 +16,10 @@ * under the License. */ -package io.ballerina.projectdesign.servicemodel.components; +package io.ballerina.projectdesign.model.service; + +import io.ballerina.projectdesign.model.ComponentModelItem; +import io.ballerina.tools.text.LineRange; import java.util.List; @@ -25,19 +28,20 @@ * * @since 2201.2.2 */ -public class ResourceParameter { +public class ResourceParameter extends ComponentModelItem { private final List type; private final String name; private final String in; private final boolean isRequired; - public ResourceParameter(List type, String name, String in, boolean isRequired) { - + public ResourceParameter(List type, String name, String in, boolean isRequired, LineRange lineRange) { + super(lineRange); this.type = type; this.name = name; this.in = in; this.isRequired = isRequired; + } public List getType() { diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/components/Service.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/Service.java similarity index 89% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/components/Service.java rename to misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/Service.java index 52737a908481..ba6eb4ff9dfd 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/components/Service.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/Service.java @@ -16,8 +16,9 @@ * under the License. */ -package io.ballerina.projectdesign.servicemodel.components; +package io.ballerina.projectdesign.model.service; +import io.ballerina.projectdesign.model.ComponentModelItem; import io.ballerina.tools.text.LineRange; import java.util.List; @@ -27,7 +28,7 @@ * * @since 2201.2.2 */ -public class Service { +public class Service extends ComponentModelItem { private final String path; private final String serviceId; @@ -35,19 +36,16 @@ public class Service { private final List resources; private final ServiceAnnotation annotation; private final List remoteFunctions; - private final LineRange lineRange; public Service(String path, String serviceId, String serviceType, List resources, List remoteFunctions, ServiceAnnotation annotation, LineRange lineRange) { - + super(lineRange); this.annotation = annotation; this.path = path; this.serviceId = serviceId; this.serviceType = serviceType; this.resources = resources; this.remoteFunctions = remoteFunctions; - this.lineRange = lineRange; - } public String getPath() { @@ -74,7 +72,4 @@ public ServiceAnnotation getAnnotation() { return annotation; } - public LineRange getLineRange() { - return lineRange; - } } diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/components/ServiceAnnotation.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/ServiceAnnotation.java similarity index 70% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/components/ServiceAnnotation.java rename to misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/ServiceAnnotation.java index 5fa88f167314..308bf8c8f75e 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/servicemodel/components/ServiceAnnotation.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/ServiceAnnotation.java @@ -16,20 +16,29 @@ * under the License. */ -package io.ballerina.projectdesign.servicemodel.components; +package io.ballerina.projectdesign.model.service; + +import io.ballerina.projectdesign.model.ComponentModelItem; +import io.ballerina.tools.text.LineRange; /** * Represents display annotation. * * @since 2201.2.2 */ -public class ServiceAnnotation { +public class ServiceAnnotation extends ComponentModelItem { private final String id; private final String label; - public ServiceAnnotation(String id, String label) { + public ServiceAnnotation() { + super(null); + this.id = ""; + this.label = ""; + } + public ServiceAnnotation(String id, String label, LineRange lineRange) { + super(lineRange); this.id = id; this.label = label; } From 7af9a1ed762c464f4d1778e1fbc53d942c551192 Mon Sep 17 00:00:00 2001 From: Thevakumar-Luheerathan Date: Tue, 8 Nov 2022 17:42:20 +0530 Subject: [PATCH 043/450] Add native support for function mocking --- .../cli/task/RunNativeImageTestTask.java | 288 +++++++++++++++++- .../src/main/java/module-info.java | 1 + .../test/runtime/entity/TestSuite.java | 4 + .../test/runtime/util/TesterinaConstants.java | 9 + 4 files changed, 299 insertions(+), 3 deletions(-) diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java index 9f2765aebeea..bea8ea7cbf24 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java @@ -34,32 +34,66 @@ import io.ballerina.projects.ProjectException; import io.ballerina.projects.ProjectKind; import io.ballerina.projects.internal.model.Target; +import org.apache.commons.compress.utils.IOUtils; +import org.ballerinalang.test.runtime.entity.MockFunctionReplaceVisitor; import org.ballerinalang.test.runtime.entity.ModuleStatus; import org.ballerinalang.test.runtime.entity.TestReport; import org.ballerinalang.test.runtime.entity.TestSuite; import org.ballerinalang.test.runtime.util.TesterinaConstants; +import org.ballerinalang.test.runtime.util.TesterinaUtils; import org.ballerinalang.testerina.core.TestProcessor; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.Type; import org.wso2.ballerinalang.util.Lists; import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.io.PrintStream; +import java.lang.reflect.Method; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.StringJoiner; +import java.util.jar.JarOutputStream; import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; import static io.ballerina.cli.launcher.LauncherUtils.createLauncherException; import static io.ballerina.cli.utils.NativeUtils.createReflectConfig; import static io.ballerina.cli.utils.TestUtils.generateCoverage; import static io.ballerina.cli.utils.TestUtils.generateTesterinaReports; import static io.ballerina.projects.util.ProjectConstants.BIN_DIR_NAME; +import static io.ballerina.runtime.api.constants.RuntimeConstants.FILE_NAME_PERIOD_SEPARATOR; +import static java.util.Objects.requireNonNull; +import static org.ballerinalang.test.runtime.util.TesterinaConstants.CACHE_DIR; +import static org.ballerinalang.test.runtime.util.TesterinaConstants.CLASS_EXTENSION; +import static org.ballerinalang.test.runtime.util.TesterinaConstants.DOT; +import static org.ballerinalang.test.runtime.util.TesterinaConstants.HYPHEN; +import static org.ballerinalang.test.runtime.util.TesterinaConstants.JAR_EXTENSION; +import static org.ballerinalang.test.runtime.util.TesterinaConstants.JAVA_11_DIR; +import static org.ballerinalang.test.runtime.util.TesterinaConstants.MOCK_FN_DELIMITER; +import static org.ballerinalang.test.runtime.util.TesterinaConstants.MOCK_FUNC_NAME_PREFIX; +import static org.ballerinalang.test.runtime.util.TesterinaConstants.MOCK_LEGACY_DELIMITER; +import static org.ballerinalang.test.runtime.util.TesterinaConstants.MODIFIED; +import static org.ballerinalang.test.runtime.util.TesterinaConstants.PATH_SEPARATOR; +import static org.ballerinalang.test.runtime.util.TesterinaConstants.TESTABLE; import static org.wso2.ballerinalang.compiler.util.ProjectDirConstants.BALLERINA_HOME; import static org.wso2.ballerinalang.compiler.util.ProjectDirConstants.BALLERINA_HOME_BRE; import static org.wso2.ballerinalang.compiler.util.ProjectDirConstants.BALLERINA_HOME_LIB; @@ -151,10 +185,12 @@ public void execute(Project project) { // Only tests in packages are executed so default packages i.e. single bal files which has the package name // as "." are ignored. This is to be consistent with the "bal test" command which only executes tests // in packages. + Map functionMockModuleMapping = new HashMap<>(); for (ModuleDescriptor moduleDescriptor : project.currentPackage().moduleDependencyGraph().toTopologicallySortedList()) { Module module = project.currentPackage().module(moduleDescriptor.name()); ModuleName moduleName = module.moduleName(); + boolean isMockFuncExist; TestSuite suite = testProcessor.testSuite(module).orElse(null); if (suite == null) { @@ -173,6 +209,15 @@ public void execute(Project project) { suite.setSourceFileName(project.sourceRoot().getFileName().toString()); } suite.setReportRequired(report || coverage); + try { + isMockFuncExist = modifyJarForFunctionMock(suite, target, moduleName.toString(), + functionMockModuleMapping); + } catch (IOException e) { + throw createLauncherException("error occurred while running tests", e); + } + if (isMockFuncExist) { + suite.removeAllMockFunctions(); + } String resolvedModuleName = module.isDefaultModule() ? moduleName.toString() : module.moduleName().moduleNamePart(); testSuiteMap.put(resolvedModuleName, suite); @@ -184,7 +229,8 @@ public void execute(Project project) { if (hasTests) { int testResult = 1; try { - testResult = runTestSuiteWithNativeImage(project.currentPackage(), jBallerinaBackend, target); + testResult = runTestSuiteWithNativeImage(project.currentPackage(), jBallerinaBackend, target, + functionMockModuleMapping); if (report || coverage) { for (String moduleName : moduleNamesList) { @@ -225,10 +271,21 @@ public void execute(Project project) { } } - private int runTestSuiteWithNativeImage(Package currentPackage, JBallerinaBackend jBallerinaBackend, Target target) - throws IOException, InterruptedException { + private int runTestSuiteWithNativeImage(Package currentPackage, JBallerinaBackend jBallerinaBackend, Target target, + Map functionMockModuleMappings) + throws IOException, InterruptedException { String packageName = currentPackage.packageName().toString(); String classPath = getClassPath(jBallerinaBackend, currentPackage); + String modClassPath; + for (Map.Entry functionMockModuleMapping : functionMockModuleMappings.entrySet()) { + String moduleJar = functionMockModuleMapping.getKey(); + String replacedJar = functionMockModuleMappings.get(moduleJar); + if (replacedJar != null) { + modClassPath = classPath.replace(moduleJar, replacedJar); + classPath = modClassPath; + } + } + String jacocoAgentJarPath = ""; String nativeImageCommand = System.getenv("GRAALVM_HOME"); @@ -365,4 +422,229 @@ private String getClassPath(JBallerinaBackend jBallerinaBackend, Package current return classPath.toString(); } + private boolean modifyJarForFunctionMock(TestSuite testSuite, Target target, String moduleName, + Map functionMockModuleMapping) throws IOException { + String mainJarName = testSuite.getOrgName() + HYPHEN + moduleName + HYPHEN + + testSuite.getVersion() + JAR_EXTENSION; + String testJardName = testSuite.getOrgName() + HYPHEN + moduleName + HYPHEN + + testSuite.getVersion() + HYPHEN + TESTABLE + JAR_EXTENSION; + String modJar = testSuite.getOrgName() + HYPHEN + moduleName + HYPHEN + testSuite.getVersion() + HYPHEN + + MODIFIED + JAR_EXTENSION; + if (testSuite.getMockFunctionNamesMap().isEmpty()) { + functionMockModuleMapping.put(mainJarName, null); + return false; + } + functionMockModuleMapping.put(mainJarName, modJar); + List testExecutionDependencies = testSuite.getTestExecutionDependencies(); + + + List mockFunctionDependencies = new ArrayList<>(); + for (String testExecutionDependency : testExecutionDependencies) { + if (testExecutionDependency.endsWith(mainJarName) || testExecutionDependency.endsWith(testJardName)) { + mockFunctionDependencies.add(testExecutionDependency); + } + } + ClassLoader classLoader = AccessController.doPrivileged( + (PrivilegedAction) () -> new URLClassLoader(getURLList(mockFunctionDependencies). + toArray(new URL[0]), ClassLoader.getSystemClassLoader())); + + + Map> classVsMockFunctionsMap = new HashMap<>(); + Map mockFunctionMap = testSuite.getMockFunctionNamesMap(); + populateClassNameVsFunctionToMockMap(classVsMockFunctionsMap, mockFunctionMap); + Map modifiedClassDef = new HashMap<>(); + for (Map.Entry> entry : classVsMockFunctionsMap.entrySet()) { + String className = entry.getKey(); + List functionNamesList = entry.getValue(); + byte[] classFile = getModifiedClassBytes(className, functionNamesList, testSuite, classLoader); + modifiedClassDef.put(className, classFile); + } + Map unmodifiedFiles = loadUnmodifiedFilesWithinJar(mockFunctionDependencies, mainJarName); + String modifiedJarPath = (target.path().resolve(CACHE_DIR).resolve(testSuite.getOrgName()).resolve + (testSuite.getPackageName()).resolve(testSuite.getVersion()).resolve(JAVA_11_DIR)).toString() + + PATH_SEPARATOR + modJar; + dumpJar(modifiedClassDef, unmodifiedFiles, modifiedJarPath); + return true; + } + + private void dumpJar(Map modifiedClassDefs, Map unmodifiedFiles, + String modifiedJarPath) throws IOException { + List duplicatePaths = new ArrayList<>(); + JarOutputStream jarOutputStream = new JarOutputStream(new FileOutputStream(modifiedJarPath)); + try { + for (Map.Entry modifiedClassDef : modifiedClassDefs.entrySet()) { + String entry = modifiedClassDef.getKey(); + String path = entry.replaceAll("\\.", PATH_SEPARATOR) + CLASS_EXTENSION; + duplicatePaths.add(path); + jarOutputStream.putNextEntry(new ZipEntry(path)); + jarOutputStream.write(modifiedClassDefs.get(entry)); + jarOutputStream.closeEntry(); + } + for (Map.Entry unmodifiedFile : unmodifiedFiles.entrySet()) { + String entry = unmodifiedFile.getKey(); + if (!duplicatePaths.contains(entry)) { + jarOutputStream.putNextEntry(new ZipEntry(entry)); + jarOutputStream.write(unmodifiedFiles.get(entry)); + jarOutputStream.closeEntry(); + } + } + } finally { + jarOutputStream.close(); + } + + } + + public static byte[] getModifiedClassBytes(String className, List functionNames, TestSuite suite, + ClassLoader classLoader) { + Class functionToMockClass; + try { + functionToMockClass = classLoader.loadClass(className); + } catch (Throwable e) { + throw createLauncherException("failed to load class: " + className); + } + + byte[] classFile = new byte[0]; + boolean readFromBytes = false; + for (Method method1 : functionToMockClass.getDeclaredMethods()) { + if (functionNames.contains(MOCK_FN_DELIMITER + method1.getName())) { + String desugaredMockFunctionName = MOCK_FUNC_NAME_PREFIX + method1.getName(); + String testClassName = TesterinaUtils.getQualifiedClassName(suite.getOrgName(), + suite.getTestPackageID(), suite.getVersion(), + suite.getPackageID().replace(DOT, FILE_NAME_PERIOD_SEPARATOR)); + Class testClass; + try { + testClass = classLoader.loadClass(testClassName); + } catch (Throwable e) { + throw createLauncherException("failed to load class :" + testClassName); + } + for (Method method2 : testClass.getDeclaredMethods()) { + if (method2.getName().equals(desugaredMockFunctionName)) { + if (!readFromBytes) { + classFile = replaceMethodBody(method1, method2); + readFromBytes = true; + } else { + classFile = replaceMethodBody(classFile, method1, method2); + } + } + } + } else if (functionNames.contains(MOCK_LEGACY_DELIMITER + method1.getName())) { + String key = className + MOCK_LEGACY_DELIMITER + method1.getName(); + String mockFunctionName = suite.getMockFunctionNamesMap().get(key); + if (mockFunctionName != null) { + String mockFunctionClassName = suite.getTestUtilityFunctions().get(mockFunctionName); + Class mockFunctionClass; + try { + mockFunctionClass = classLoader.loadClass(mockFunctionClassName); + } catch (ClassNotFoundException e) { + throw createLauncherException("failed to load class: " + mockFunctionClassName); + } + for (Method method2 : mockFunctionClass.getDeclaredMethods()) { + if (method2.getName().equals(mockFunctionName)) { + if (!readFromBytes) { + classFile = replaceMethodBody(method1, method2); + readFromBytes = true; + } else { + classFile = replaceMethodBody(classFile, method1, method2); + } + } + } + } else { + continue; + } + } + } + return classFile; + } + + private static byte[] replaceMethodBody(Method method, Method mockMethod) { + Class clazz = method.getDeclaringClass(); + ClassReader cr; + try { + InputStream ins; + ins = clazz.getResourceAsStream(clazz.getSimpleName() + CLASS_EXTENSION); + cr = new ClassReader(requireNonNull(ins)); + } catch (IOException e) { + throw createLauncherException("failed to get the class reader object for the class " + + clazz.getSimpleName()); + } + ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); + ClassVisitor cv = new MockFunctionReplaceVisitor(Opcodes.ASM7, cw, method.getName(), + Type.getMethodDescriptor(method), mockMethod); + cr.accept(cv, 0); + return cw.toByteArray(); + } + + private static byte[] replaceMethodBody(byte[] classFile, Method method, Method mockMethod) { + ClassReader cr = new ClassReader(classFile); + ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); + ClassVisitor cv = new MockFunctionReplaceVisitor(Opcodes.ASM7, cw, method.getName(), + Type.getMethodDescriptor(method), mockMethod); + cr.accept(cv, 0); + return cw.toByteArray(); + } + public static List getURLList(List jarFilePaths) { + List urlList = new ArrayList<>(); + + for (String jarFilePath : jarFilePaths) { + try { + urlList.add(Paths.get(jarFilePath).toUri().toURL()); + } catch (MalformedURLException e) { + // This path cannot get executed + throw new RuntimeException("Failed to create classloader with all jar files", e); + } + } + return urlList; + } + + private static void populateClassNameVsFunctionToMockMap(Map> classVsMockFunctionsMap, + Map mockFunctionMap) { + for (Map.Entry entry : mockFunctionMap.entrySet()) { + String key = entry.getKey(); + String functionToMockClassName; + String functionToMock; + if (key.indexOf(MOCK_LEGACY_DELIMITER) == -1) { + functionToMockClassName = key.substring(0, key.indexOf(MOCK_FN_DELIMITER)); + functionToMock = key.substring(key.indexOf(MOCK_FN_DELIMITER)); + } else if (key.indexOf(MOCK_FN_DELIMITER) == -1) { + functionToMockClassName = key.substring(0, key.indexOf(MOCK_LEGACY_DELIMITER)); + functionToMock = key.substring(key.indexOf(MOCK_LEGACY_DELIMITER)); + } else { + if (key.indexOf(MOCK_FN_DELIMITER) < key.indexOf(MOCK_LEGACY_DELIMITER)) { + functionToMockClassName = key.substring(0, key.indexOf(MOCK_FN_DELIMITER)); + functionToMock = key.substring(key.indexOf(MOCK_FN_DELIMITER)); + } else { + functionToMockClassName = key.substring(0, key.indexOf(MOCK_LEGACY_DELIMITER)); + functionToMock = key.substring(key.indexOf(MOCK_LEGACY_DELIMITER)); + } + } + functionToMock = functionToMock.replaceAll("\\\\", ""); + classVsMockFunctionsMap.computeIfAbsent(functionToMockClassName, + k -> new ArrayList<>()).add(functionToMock); + } + } + + private Map loadUnmodifiedFilesWithinJar(List codeGeneratedJarPaths, String mainJarName) + throws IOException { + String mainJarPath = null; + Map unmodifiedFiles = new HashMap(); + for (String codeGeneratedJarPath : codeGeneratedJarPaths) { + if (codeGeneratedJarPath.endsWith(mainJarName)) { + mainJarPath = codeGeneratedJarPath; + } + } + File jarFile = new File(mainJarPath); + ZipInputStream jarInputStream = new ZipInputStream(new FileInputStream(jarFile)); + ZipEntry entry; + while ((entry = jarInputStream.getNextEntry()) != null) { + String path = entry.getName(); + if (!entry.isDirectory()) { + byte[] bytes = IOUtils.toByteArray(jarInputStream); + unmodifiedFiles.put(path, bytes); + } + jarInputStream.closeEntry(); + } + jarInputStream.close(); + return unmodifiedFiles; + } + } diff --git a/cli/ballerina-cli/src/main/java/module-info.java b/cli/ballerina-cli/src/main/java/module-info.java index 13f86da0462d..fc930faf636a 100644 --- a/cli/ballerina-cli/src/main/java/module-info.java +++ b/cli/ballerina-cli/src/main/java/module-info.java @@ -19,4 +19,5 @@ requires io.ballerina.shell.cli; requires io.ballerina.toml; requires io.ballerina.identifier; + requires org.objectweb.asm; } diff --git a/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/entity/TestSuite.java b/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/entity/TestSuite.java index 58539bbda5d4..7cdf699aab1b 100644 --- a/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/entity/TestSuite.java +++ b/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/entity/TestSuite.java @@ -246,6 +246,10 @@ public Map getMockFunctionNamesMap() { return this.mockFunctionNamesMap; } + public void removeAllMockFunctions() { + this.mockFunctionNamesMap = new HashMap<>(); + } + public void addTestUtilityFunction(String functionName, String functionClassName) { this.testUtilityFunctions.put(functionName, functionClassName); } diff --git a/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/TesterinaConstants.java b/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/TesterinaConstants.java index 745780f443f7..b03b6d00dd2e 100644 --- a/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/TesterinaConstants.java +++ b/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/TesterinaConstants.java @@ -33,10 +33,19 @@ public class TesterinaConstants { public static final String TEST_RUNTIME_JAR_PREFIX = "testerina-runtime-"; public static final String ORIGINAL_FUNC_NAME_PREFIX = "$ORIG_"; + public static final String MOCK_FUNC_NAME_PREFIX = "$MOCK_"; public static final String TARGET_DIR_NAME = "target"; public static final String DOT = "."; + public static final String HYPHEN = "-"; + public static final String PATH_SEPARATOR = "/"; + public static final String JAR_EXTENSION = ".jar"; + public static final String CLASS_EXTENSION = ".class"; + public static final String TESTABLE = "testable"; + public static final String MODIFIED = "mod"; + public static final String CACHE_DIR = "cache"; + public static final String JAVA_11_DIR = "java11"; public static final String ANON_ORG = "$anon"; public static final String WILDCARD = "*"; From d7f010401e3ce1c594ed7e4713e7f214944b1bd2 Mon Sep 17 00:00:00 2001 From: Thevakumar-Luheerathan Date: Thu, 10 Nov 2022 11:26:25 +0530 Subject: [PATCH 044/450] Address the review --- .../cli/task/RunNativeImageTestTask.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java index bea8ea7cbf24..5555d8c17235 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java @@ -280,10 +280,9 @@ private int runTestSuiteWithNativeImage(Package currentPackage, JBallerinaBacken for (Map.Entry functionMockModuleMapping : functionMockModuleMappings.entrySet()) { String moduleJar = functionMockModuleMapping.getKey(); String replacedJar = functionMockModuleMappings.get(moduleJar); - if (replacedJar != null) { - modClassPath = classPath.replace(moduleJar, replacedJar); - classPath = modClassPath; - } + modClassPath = classPath.replace(moduleJar, replacedJar); + classPath = modClassPath; + } String jacocoAgentJarPath = ""; @@ -426,21 +425,20 @@ private boolean modifyJarForFunctionMock(TestSuite testSuite, Target target, Str Map functionMockModuleMapping) throws IOException { String mainJarName = testSuite.getOrgName() + HYPHEN + moduleName + HYPHEN + testSuite.getVersion() + JAR_EXTENSION; - String testJardName = testSuite.getOrgName() + HYPHEN + moduleName + HYPHEN + + String testJarName = testSuite.getOrgName() + HYPHEN + moduleName + HYPHEN + testSuite.getVersion() + HYPHEN + TESTABLE + JAR_EXTENSION; - String modJar = testSuite.getOrgName() + HYPHEN + moduleName + HYPHEN + testSuite.getVersion() + HYPHEN + + String modifiedJar = testSuite.getOrgName() + HYPHEN + moduleName + HYPHEN + testSuite.getVersion() + HYPHEN + MODIFIED + JAR_EXTENSION; if (testSuite.getMockFunctionNamesMap().isEmpty()) { - functionMockModuleMapping.put(mainJarName, null); return false; } - functionMockModuleMapping.put(mainJarName, modJar); + functionMockModuleMapping.put(mainJarName, modifiedJar); List testExecutionDependencies = testSuite.getTestExecutionDependencies(); List mockFunctionDependencies = new ArrayList<>(); for (String testExecutionDependency : testExecutionDependencies) { - if (testExecutionDependency.endsWith(mainJarName) || testExecutionDependency.endsWith(testJardName)) { + if (testExecutionDependency.endsWith(mainJarName) || testExecutionDependency.endsWith(testJarName)) { mockFunctionDependencies.add(testExecutionDependency); } } @@ -462,7 +460,7 @@ private boolean modifyJarForFunctionMock(TestSuite testSuite, Target target, Str Map unmodifiedFiles = loadUnmodifiedFilesWithinJar(mockFunctionDependencies, mainJarName); String modifiedJarPath = (target.path().resolve(CACHE_DIR).resolve(testSuite.getOrgName()).resolve (testSuite.getPackageName()).resolve(testSuite.getVersion()).resolve(JAVA_11_DIR)).toString() - + PATH_SEPARATOR + modJar; + + PATH_SEPARATOR + modifiedJar; dumpJar(modifiedClassDef, unmodifiedFiles, modifiedJarPath); return true; } From 477f2ed20a25f77cd5ae677da28b42af0fe8b141 Mon Sep 17 00:00:00 2001 From: aneeshafedo Date: Fri, 11 Nov 2022 10:29:07 +0530 Subject: [PATCH 045/450] Construct components for anonymous records --- .../projectdesign/ComponentModel.java | 23 +++-- .../projectdesign/ComponentModelBuilder.java | 20 ++-- .../entity/EntityModelGenerator.java | 91 +++++++++++++------ .../model/entity/{Type.java => Entity.java} | 4 +- 4 files changed, 95 insertions(+), 43 deletions(-) rename misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/{Type.java => Entity.java} (90%) diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModel.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModel.java index 65446cb73eb5..90edbe818501 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModel.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModel.java @@ -18,7 +18,7 @@ package io.ballerina.projectdesign; -import io.ballerina.projectdesign.model.entity.Type; +import io.ballerina.projectdesign.model.entity.Entity; import io.ballerina.projectdesign.model.service.Service; import io.ballerina.projects.Package; @@ -33,13 +33,16 @@ public class ComponentModel { private final PackageId packageId; private final Map services; - private final Map types; + private final Map entities; - public ComponentModel(PackageId packageId, Map services, Map entities) { + private boolean hasDiagnosticErrors; + + public ComponentModel(PackageId packageId, Map services, Map entities, boolean hasDiagnosticErrors) { this.packageId = packageId; this.services = services; - this.types = entities; + this.entities = entities; + this.hasDiagnosticErrors = hasDiagnosticErrors; } public PackageId getPackageId() { @@ -52,9 +55,13 @@ public Map getServices() { return services; } - public Map getTypes() { + public Map getEntities() { + + return entities; + } - return types; + public boolean isHasDiagnosticErrors() { + return hasDiagnosticErrors; } /** @@ -74,18 +81,16 @@ public PackageId(Package currentPackage) { } public String getName() { - return name; } public String getOrg() { - return org; } public String getVersion() { - return version; } + } } diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModelBuilder.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModelBuilder.java index 4eeebd79425d..0dde62cea96a 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModelBuilder.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModelBuilder.java @@ -22,14 +22,16 @@ import io.ballerina.projectdesign.ComponentModel.PackageId; import io.ballerina.projectdesign.generators.entity.EntityModelGenerator; import io.ballerina.projectdesign.generators.service.ServiceModelGenerator; -import io.ballerina.projectdesign.model.entity.Type; +import io.ballerina.projectdesign.model.entity.Entity; import io.ballerina.projectdesign.model.service.Service; import io.ballerina.projects.DocumentId; import io.ballerina.projects.Package; +import io.ballerina.projects.PackageCompilation; import java.util.Collection; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; /** * Construct component model fpr project with multiple service. @@ -40,20 +42,26 @@ public class ComponentModelBuilder { public ComponentModel constructComponentModel(Package currentPackage) { + Map services = new HashMap<>(); // todo: Change to TypeDefinition - Map types = new HashMap<>(); + Map entities = new HashMap<>(); PackageId packageId = new PackageId(currentPackage); + AtomicBoolean hasDiagnosticErrors = new AtomicBoolean(false); + currentPackage.modules().forEach(module -> { String moduleRootPath = module.project().sourceRoot().toAbsolutePath().toString(); if (module.moduleName().moduleNamePart() != null) { moduleRootPath = moduleRootPath + "/" + module.moduleName().moduleNamePart(); } Collection documentIds = module.documentIds(); - SemanticModel currentSemanticModel = - currentPackage.getCompilation().getSemanticModel(module.moduleId()); + PackageCompilation currentPackageCompilation = currentPackage.getCompilation(); + SemanticModel currentSemanticModel = currentPackageCompilation.getSemanticModel(module.moduleId()); + if (currentPackageCompilation.diagnosticResult().hasErrors() && !hasDiagnosticErrors.get()) { + hasDiagnosticErrors.set(true); + } // todo : Check project diagnostics ServiceModelGenerator serviceModelGenerator = new ServiceModelGenerator( currentSemanticModel, packageId, moduleRootPath); @@ -61,9 +69,9 @@ public ComponentModel constructComponentModel(Package currentPackage) { EntityModelGenerator entityModelGenerator = new EntityModelGenerator( currentSemanticModel, packageId, moduleRootPath); - types.putAll(entityModelGenerator.generate()); + entities.putAll(entityModelGenerator.generate()); }); - return new ComponentModel(packageId, services, types); + return new ComponentModel(packageId, services, entities, hasDiagnosticErrors.get()); } } diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/entity/EntityModelGenerator.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/entity/EntityModelGenerator.java index 57963aa33995..43c5923e2b74 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/entity/EntityModelGenerator.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/entity/EntityModelGenerator.java @@ -26,6 +26,7 @@ import io.ballerina.compiler.api.symbols.Symbol; import io.ballerina.compiler.api.symbols.SymbolKind; import io.ballerina.compiler.api.symbols.TypeDefinitionSymbol; +import io.ballerina.compiler.api.symbols.TypeDescKind; import io.ballerina.compiler.api.symbols.TypeReferenceTypeSymbol; import io.ballerina.compiler.api.symbols.TypeSymbol; import io.ballerina.compiler.api.symbols.UnionTypeSymbol; @@ -34,11 +35,12 @@ import io.ballerina.projectdesign.ProjectDesignConstants.CardinalityValue; import io.ballerina.projectdesign.model.entity.Association; import io.ballerina.projectdesign.model.entity.Attribute; -import io.ballerina.projectdesign.model.entity.Type; +import io.ballerina.projectdesign.model.entity.Entity; import io.ballerina.tools.text.LineRange; import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -58,6 +60,8 @@ public class EntityModelGenerator { private final ComponentModel.PackageId packageId; private final String moduleRootPath; + private final Map types = new HashMap<>(); + public EntityModelGenerator(SemanticModel semanticModel, ComponentModel.PackageId packageId, String moduleRootPath) { @@ -66,45 +70,80 @@ public EntityModelGenerator(SemanticModel semanticModel, ComponentModel.PackageI this.moduleRootPath = moduleRootPath; } - public Map generate() { - Map types = new HashMap<>(); + + public Map generate() { List symbols = semanticModel.moduleSymbols(); for (Symbol symbol : symbols) { if (symbol.kind().equals(SymbolKind.TYPE_DEFINITION)) { TypeDefinitionSymbol typeDefinitionSymbol = (TypeDefinitionSymbol) symbol; if (typeDefinitionSymbol.typeDescriptor() instanceof RecordTypeSymbol) { String entityName = getEntityName(packageId, typeDefinitionSymbol.moduleQualifiedName()); - List attributeList = new ArrayList<>(); - List inclusionList = new ArrayList<>(); RecordTypeSymbol recordTypeSymbol = (RecordTypeSymbol) typeDefinitionSymbol.typeDescriptor(); - Map recordFieldSymbolMap = - getOriginalFieldMap(recordTypeSymbol, inclusionList, entityName); - for (Map.Entry fieldEntry : recordFieldSymbolMap.entrySet()) { - - RecordFieldSymbol fieldEntryValue = fieldEntry.getValue(); - // when is the field name is optional? Tested with record inclusion and res types - String fieldName = fieldEntryValue.getName().get(); // need to handle - String fieldType = fieldEntryValue.typeDescriptor().signature(); - boolean optional = fieldEntryValue.isOptional(); - String defaultValue = ""; //need to address - boolean nillable = isNillable(fieldEntryValue.typeDescriptor()); - List associations = - getAssociations(fieldEntryValue.typeDescriptor(), entityName, optional, nillable); - Attribute attribute = - new Attribute(fieldName, fieldType, optional, nillable, defaultValue, associations, - getLineRange(fieldEntryValue)); - attributeList.add(attribute); - } - - Type type = new Type(attributeList, inclusionList, getLineRange(typeDefinitionSymbol)); - types.put(entityName, type); + this.types.put(entityName, getType(recordTypeSymbol, entityName, + getLineRange(typeDefinitionSymbol))); } } } return types; } + private Entity getType(RecordTypeSymbol recordTypeSymbol, String entityName, LineRange lineRange) { + List attributeList = new ArrayList<>(); + List inclusionList = new ArrayList<>(); + Map recordFieldSymbolMap = + getOriginalFieldMap(recordTypeSymbol, inclusionList, entityName); + for (Map.Entry fieldEntry : recordFieldSymbolMap.entrySet()) { + attributeList.add(getAttribute(fieldEntry.getValue(), entityName)); + } + return new Entity(attributeList, inclusionList, lineRange); + } + + private Attribute getAttribute(RecordFieldSymbol recordFieldSymbol, String entityName) { + TypeDescKind fieldTypeDescKind = recordFieldSymbol.typeDescriptor().typeKind(); + TypeSymbol fieldTypeSymbol = recordFieldSymbol.typeDescriptor(); + + String fieldName = recordFieldSymbol.getName().get(); // need to handle + String fieldType = recordFieldSymbol.typeDescriptor().signature(); + List associations = new LinkedList<>(); + boolean optional = recordFieldSymbol.isOptional(); + String defaultValue = ""; //need to address + boolean nillable = isNillable(recordFieldSymbol.typeDescriptor()); + + if (fieldTypeDescKind.equals(TypeDescKind.RECORD)) { + RecordTypeSymbol inlineRecordTypeSymbol = (RecordTypeSymbol) fieldTypeSymbol; + fieldType = entityName + fieldName.substring(0,1).toUpperCase() + + fieldName.substring(1); + this.types.put(fieldType, getType(inlineRecordTypeSymbol, fieldType, + getLineRange(recordFieldSymbol))); + String associateCardinality = optional ? CardinalityValue.ZERO_OR_ONE.getValue() : + CardinalityValue.ONE_AND_ONLY_ONE.getValue(); + Association association = new Association(fieldType, new Association.Cardinality( + CardinalityValue.ONE_AND_ONLY_ONE.getValue(), associateCardinality)); + associations = new LinkedList<>(List.of(association)); + } else if (fieldTypeDescKind.equals(TypeDescKind.ARRAY) && + ((ArrayTypeSymbol) fieldTypeSymbol).memberTypeDescriptor().typeKind().equals(TypeDescKind.RECORD)) { + RecordTypeSymbol inlineRecordTypeSymbol = (RecordTypeSymbol) ((ArrayTypeSymbol) fieldTypeSymbol).memberTypeDescriptor(); + String inlineRecordName = fieldType; + fieldType = entityName + fieldName.substring(0,1).toUpperCase() + + fieldName.substring(1) + ARRAY; + String associateCardinality = optional ? CardinalityValue.ZERO_OR_MANY.getValue() : + CardinalityValue.ONE_OR_MANY.getValue(); + Association association = new Association(fieldType, new Association.Cardinality( + CardinalityValue.ONE_AND_ONLY_ONE.getValue(), associateCardinality)); + associations = new LinkedList<>(List.of(association)); + this.types.put(inlineRecordName, getType(inlineRecordTypeSymbol, inlineRecordName, + getLineRange(recordFieldSymbol))); + + } else { + associations = + getAssociations(recordFieldSymbol.typeDescriptor(), entityName, optional, nillable); + + } + return new Attribute(fieldName, fieldType, optional, nillable, defaultValue, associations, + getLineRange(recordFieldSymbol)); + } + private Map getOriginalFieldMap( RecordTypeSymbol recordTypeSymbol, List inclusionList, String entityName) { diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Type.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Entity.java similarity index 90% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Type.java rename to misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Entity.java index 9849e290758d..6db8bac99b1c 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Type.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Entity.java @@ -28,14 +28,14 @@ * * @since 2201.2.2 */ -public class Type extends ComponentModelItem { +public class Entity extends ComponentModelItem { private List attributes; private final List inclusions; // todo : send the location - public Type(List attributes, List inclusions, LineRange lineRange) { + public Entity(List attributes, List inclusions, LineRange lineRange) { super(lineRange); this.attributes = attributes; this.inclusions = inclusions; From 0db4453ebb1619a4df1d4fb98835371a1a71c06d Mon Sep 17 00:00:00 2001 From: HindujaB Date: Fri, 11 Nov 2022 10:29:33 +0530 Subject: [PATCH 046/450] Rename runtime-api test modules --- .../jvm/runtime/api/tests/Enums.java | 2 +- .../jvm/runtime/api/tests/Errors.java | 2 +- .../jvm/runtime/api/tests/Values.java | 8 ++-- .../test/runtime/api/RuntimeAPITest.java | 2 +- .../test-src/runtime/api/async/Ballerina.toml | 2 +- .../runtime/api/errors/Ballerina.toml | 2 +- .../test-src/runtime/api/errors/main.bal | 38 +++++++++---------- .../error_utils.bal} | 0 .../api/identifier_utils/Ballerina.toml | 2 +- .../runtime/api/stop_handler/Ballerina.toml | 2 +- .../runtime/api/stop_handler/main.bal | 2 +- .../test-src/runtime/api/types/Ballerina.toml | 2 +- .../test-src/runtime/api/types/main.bal | 14 +++---- .../api/types/modules/typeref/typeref.bal | 2 +- .../test-src/runtime/api/utils/Ballerina.toml | 2 +- .../test-src/runtime/api/utils/main.bal | 2 +- .../runtime/api/utils/modules/jsons/jsons.bal | 2 +- .../runtime/api/values/Ballerina.toml | 2 +- .../test-src/runtime/api/values/main.bal | 10 ++--- .../api/values/modules/objects/objects.bal | 2 +- .../api/values/modules/records/records.bal | 2 +- 21 files changed, 51 insertions(+), 51 deletions(-) rename tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/errors/modules/{errors/errors.bal => error_utils/error_utils.bal} (100%) diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Enums.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Enums.java index 4ac1a6c7f457..eb8c502a8c1f 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Enums.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Enums.java @@ -42,7 +42,7 @@ */ public class Enums { - private static final Module enumModule = new Module("testorg", "runtime_api.enum", "1"); + private static final Module enumModule = new Module("testorg", "values.enum", "1"); public static BArray createEnumArray(BString enumName) { List memberTypes = new ArrayList<>(2); diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Errors.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Errors.java index 773ecdc44c95..a8929f8bf872 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Errors.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Errors.java @@ -44,7 +44,7 @@ */ public class Errors { - private static Module errorModule = new Module("testorg", "runtime_api.errors", "1"); + private static Module errorModule = new Module("testorg", "errors.error_utils", "1"); public static BError getError(BString errorName) { BMap errorDetails = ValueCreator.createMapValue(); diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Values.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Values.java index ddb303c00d06..a38a7b571e58 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Values.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Values.java @@ -74,10 +74,10 @@ */ public class Values { - private static final Module objectModule = new Module("testorg", "runtime_api.objects", "1"); - private static final Module recordModule = new Module("testorg", "runtime_api.records", "1"); + private static final Module objectModule = new Module("testorg", "values.objects", "1"); + private static final Module recordModule = new Module("testorg", "values.records", "1"); private static final Module invalidValueModule = new Module("testorg", "invalid_values", "1"); - private static final BString intAnnotation = StringUtils.fromString("testorg/runtime_api_types.typeref:1:Int"); + private static final BString intAnnotation = StringUtils.fromString("testorg/types.typeref:1:Int"); private static final BError constraintError = ErrorCreator.createError(StringUtils.fromString("Validation failed for 'minValue' constraint(s).")); @@ -358,7 +358,7 @@ public static Object validateArrayElements(Object value, BTypedesc typedesc) { public static Object validateArrayConstraint(Object value, BTypedesc typedesc) { Type describingType = typedesc.getDescribingType(); BMap annotations = ((AnnotatableType) describingType).getAnnotations(); - BString annotKey = StringUtils.fromString("testorg/runtime_api_types.typeref:1:Array"); + BString annotKey = StringUtils.fromString("testorg/types.typeref:1:Array"); if (annotations.containsKey(annotKey)) { Object annotValue = annotations.get(annotKey); Long maxLength = (Long) ((BMap) annotValue).get(StringUtils.fromString("maxLength")); diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/runtime/api/RuntimeAPITest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/runtime/api/RuntimeAPITest.java index 5796621246a7..c3a45b56d5a8 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/runtime/api/RuntimeAPITest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/runtime/api/RuntimeAPITest.java @@ -39,11 +39,11 @@ public void testRuntimeAPIs(String packageName) { @DataProvider public Object[] packageNameProvider() { return new String[]{ - "async", "values", "errors", "types", "invalid_values", + "async", "utils", "stop_handler", "identifier_utils" diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/async/Ballerina.toml b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/async/Ballerina.toml index fe809864511f..b26a1e9d9198 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/async/Ballerina.toml +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/async/Ballerina.toml @@ -1,4 +1,4 @@ [package] org= "testorg" -name="runtime_api" +name="async" version= "1.0.0" diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/errors/Ballerina.toml b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/errors/Ballerina.toml index fe809864511f..968bb2143a0d 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/errors/Ballerina.toml +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/errors/Ballerina.toml @@ -1,4 +1,4 @@ [package] org= "testorg" -name="runtime_api" +name="errors" version= "1.0.0" diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/errors/main.bal b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/errors/main.bal index b521c4bbd913..d6f561eb6e62 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/errors/main.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/errors/main.bal @@ -14,72 +14,72 @@ // specific language governing permissions and limitations // under the License. -import testorg/runtime_api.errors; +import testorg/errors.error_utils; import ballerina/lang.test as test; public function main() { - error userError = errors:getError("UserError"); - test:assertTrue(userError is errors:GenericError); + error userError = error_utils:getError("UserError"); + test:assertTrue(userError is error_utils:GenericError); // check cast - errors:GenericError error1 = userError; - errors:UserError error2 = userError; + error_utils:GenericError error1 = userError; + error_utils:UserError error2 = userError; // Negative Tests - error invalidError = trap errors:getError("UserError2"); + error invalidError = trap error_utils:getError("UserError2"); test:assertValueEqual(invalidError.message(), "No such error: UserError2"); testTypeIds(); - errors:IOError|error res = trap errors:getDistinctErrorNegative("UserError"); + error_utils:IOError|error res = trap error_utils:getDistinctErrorNegative("UserError"); test:assertTrue(res is error); error e = res; test:assertValueEqual(e.message(), "'class java.lang.String' is not from a valid java runtime class. " + "It should be a subclass of one of the following: java.lang.Number, java.lang.Boolean or " + "from the package 'io.ballerina.runtime.api.values'"); - error err = trap errors:getErrorNegative1("error message"); + error err = trap error_utils:getErrorNegative1("error message"); test:assertValueEqual(err.message(), "'class java.lang.String' is not from a valid java runtime class. " + "It should be a subclass of one of the following: java.lang.Number, java.lang.Boolean or " + "from the package 'io.ballerina.runtime.api.values'"); - err = trap errors:getErrorWithTypeNegative("error message"); + err = trap error_utils:getErrorWithTypeNegative("error message"); test:assertValueEqual(err.message(), "'class java.lang.String' is not from a valid java runtime class. " + "It should be a subclass of one of the following: java.lang.Number, java.lang.Boolean or " + "from the package 'io.ballerina.runtime.api.values'"); - err = trap errors:getErrorNegative2("error message"); + err = trap error_utils:getErrorNegative2("error message"); test:assertValueEqual(err.message(), "'class java.lang.String' is not from a valid java runtime class. " + "It should be a subclass of one of the following: java.lang.Number, java.lang.Boolean or " + "from the package 'io.ballerina.runtime.api.values'"); - err = trap errors:getDistinctErrorWithNullDetailNegative("error message"); + err = trap error_utils:getDistinctErrorWithNullDetailNegative("error message"); test:assertValueEqual(err.message(), "No such error: error message"); - err = trap errors:getErrorWithEmptyDetailNegative("error message"); + err = trap error_utils:getErrorWithEmptyDetailNegative("error message"); test:assertValueEqual(err.message(), "error message"); - err = trap errors:getErrorWithNullDetailNegative("error message"); + err = trap error_utils:getErrorWithNullDetailNegative("error message"); test:assertValueEqual(err.message(), "error message"); - err = trap errors:getErrorWithEmptyDetailNegative2("error message"); + err = trap error_utils:getErrorWithEmptyDetailNegative2("error message"); test:assertValueEqual(err.message(), "error message"); - err = trap errors:getErrorWithNullDetailNegative2("error message"); + err = trap error_utils:getErrorWithNullDetailNegative2("error message"); test:assertValueEqual(err.message(), "error message"); - err = trap errors:getDistinctErrorWithEmptyDetailNegative2("error message"); + err = trap error_utils:getDistinctErrorWithEmptyDetailNegative2("error message"); test:assertValueEqual(err.message(), "error message"); - err = trap errors:getDistinctErrorWithNullDetailNegative2("error message"); + err = trap error_utils:getDistinctErrorWithNullDetailNegative2("error message"); test:assertValueEqual(err.message(), "error message"); } function testTypeIds() { - error userError = error errors:UserError("Whoops!"); - string[] types = errors:getTypeIds(userError); + error userError = error error_utils:UserError("Whoops!"); + string[] types = error_utils:getTypeIds(userError); test:assertValueEqual(types.length(), 2); test:assertValueEqual(types[0], "UserError"); test:assertValueEqual(types[1], "GenericError"); diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/errors/modules/errors/errors.bal b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/errors/modules/error_utils/error_utils.bal similarity index 100% rename from tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/errors/modules/errors/errors.bal rename to tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/errors/modules/error_utils/error_utils.bal diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/identifier_utils/Ballerina.toml b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/identifier_utils/Ballerina.toml index fe809864511f..af7a6ab62820 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/identifier_utils/Ballerina.toml +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/identifier_utils/Ballerina.toml @@ -1,4 +1,4 @@ [package] org= "testorg" -name="runtime_api" +name="identifier_utils" version= "1.0.0" diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/stop_handler/Ballerina.toml b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/stop_handler/Ballerina.toml index fe809864511f..1b09d3767f68 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/stop_handler/Ballerina.toml +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/stop_handler/Ballerina.toml @@ -1,4 +1,4 @@ [package] org= "testorg" -name="runtime_api" +name="stop_handler" version= "1.0.0" diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/stop_handler/main.bal b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/stop_handler/main.bal index 10f5b7d01435..5660560faa34 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/stop_handler/main.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/stop_handler/main.bal @@ -17,7 +17,7 @@ import ballerina/lang.runtime; import ballerina/test; -import runtime_api.moduleA; +import stop_handler.moduleA; function stopHandlerFunc1() returns error? { runtime:sleep(1); diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/Ballerina.toml b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/Ballerina.toml index ba4f7e5ad9d7..3680aa621707 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/Ballerina.toml +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/Ballerina.toml @@ -1,4 +1,4 @@ [package] org= "testorg" -name="runtime_api_types" +name="types" version= "1.0.0" diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/main.bal b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/main.bal index d0b7fc9ec4ff..ca9c2c004155 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/main.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/main.bal @@ -15,8 +15,8 @@ // under the License. import ballerina/test; -import testorg/runtime_api_types.objects; -import runtime_api_types.typeref; +import types.objects; +import types.typeref; objects:PublicClientObject obj = new (); @@ -42,17 +42,17 @@ function testTypeIds() { objects:Apple apple = new("red"); string[] types = objects:getTypeIds(apple); test:assertEquals(types.length(), 3); - test:assertEquals(types[0], "Apple"); + test:assertEquals(types[0], "Common"); test:assertEquals(types[1], "Fruit"); - test:assertEquals(types[2], "Common"); + test:assertEquals(types[2], "Apple"); // service type objects:Collection collection = new("waruna"); types = objects:getTypeIds(collection); test:assertEquals(types.length(), 3); - test:assertEquals(types[0], "Common"); - test:assertEquals(types[1], "Collection"); - test:assertEquals(types[2], "Iterable"); + test:assertEquals(types[0], "Iterable"); + test:assertEquals(types[1], "Common"); + test:assertEquals(types[2], "Collection"); } function testFunctionToString() { diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeref.bal b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeref.bal index 9171180f356f..8d0baad6a129 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeref.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeref.bal @@ -16,7 +16,7 @@ import ballerina/test; import ballerina/jballerina.java; -import testorg/runtime_api_types.objects as o; +import types.objects as o; public annotation IntConstraints Int on type, record field; diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/utils/Ballerina.toml b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/utils/Ballerina.toml index 8d105db18630..4040c76c10f3 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/utils/Ballerina.toml +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/utils/Ballerina.toml @@ -1,4 +1,4 @@ [package] org= "testorg" -name="utils_api" +name="utils" version= "1.0.0" diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/utils/main.bal b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/utils/main.bal index 4fce65ade97e..54d11c3d3879 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/utils/main.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/utils/main.bal @@ -14,7 +14,7 @@ // specific language governing permissions and limitations // under the License. -import testorg/utils_api.jsons; +import testorg/utils.jsons; public function main() { jsons:validateAPI(); diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/utils/modules/jsons/jsons.bal b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/utils/modules/jsons/jsons.bal index 1eaa50a405c6..3e4e94f6aad9 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/utils/modules/jsons/jsons.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/utils/modules/jsons/jsons.bal @@ -162,7 +162,7 @@ public function validateStringAPI() { res = trap convertJSONToString(tab1); test:assertTrue(res is error); error err = res; - test:assertEquals(checkpanic err.detail()["message"], "'table' value cannot be" + + test:assertEquals(checkpanic err.detail()["message"], "'table' value cannot be" + " converted to 'json': cannot construct json object from 'table>' type data"); test:assertEquals(err.message(), "{ballerina/lang.value}ConversionError"); diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/values/Ballerina.toml b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/values/Ballerina.toml index fe809864511f..b965071872ef 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/values/Ballerina.toml +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/values/Ballerina.toml @@ -1,4 +1,4 @@ [package] org= "testorg" -name="runtime_api" +name="values" version= "1.0.0" diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/values/main.bal b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/values/main.bal index ec0422100bb7..ff08223ba628 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/values/main.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/values/main.bal @@ -14,11 +14,11 @@ // specific language governing permissions and limitations // under the License. -import testorg/runtime_api.records; -import testorg/runtime_api.objects; -import testorg/runtime_api.maps; -import runtime_api.arrays; -import testorg/runtime_api.enums; +import values.records; +import values.objects; +import values.maps; +import values.arrays; +import values.enums; import ballerina/lang.test as test; public function main() { diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/values/modules/objects/objects.bal b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/values/modules/objects/objects.bal index 52c7990e9dd8..8062132e37aa 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/values/modules/objects/objects.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/values/modules/objects/objects.bal @@ -15,7 +15,7 @@ // under the License. import ballerina/jballerina.java; -import testorg/runtime_api.records; +import testorg/values.records; public class Person { diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/values/modules/records/records.bal b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/values/modules/records/records.bal index 6600e1eb37f4..e3b002977877 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/values/modules/records/records.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/values/modules/records/records.bal @@ -80,7 +80,7 @@ public function validateAPI() { if (studentRec2 is error) { test:assertEquals("{ballerina/lang.map}KeyNotFound", studentRec2.message()); test:assertEquals("invalid field access: field 'postalCode' not found in record type " + - "'runtime_api.records:Student'", checkpanic studentRec2.detail()["message"]); + "'values.records:Student'", checkpanic studentRec2.detail()["message"]); } } From 43d412279ce1f088e31456f004f782302f16bfc2 Mon Sep 17 00:00:00 2001 From: gabilang Date: Fri, 11 Nov 2022 12:51:11 +0530 Subject: [PATCH 047/450] Add support negative values as CLI arguments --- .../runtime/internal/cli/CliUtil.java | 26 ++++++++++++++----- .../runtime/internal/cli/Option.java | 13 +++++++++- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/CliUtil.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/CliUtil.java index 91b860ac8f5d..64ea17c47364 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/CliUtil.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/CliUtil.java @@ -102,22 +102,30 @@ static boolean isUnionWithNil(List unionMemberTypes) { private static long getIntegerValue(String argument, String parameterName) { try { - if (argument.toUpperCase().startsWith(HEX_PREFIX)) { + if (isHexValueString(argument)) { return Long.parseLong(argument.toUpperCase().replace(HEX_PREFIX, ""), 16); } return Long.parseLong(argument); } catch (NumberFormatException e) { - throw ErrorCreator.createError( - StringUtils.fromString(String.format(INVALID_ARGUMENT_ERROR, argument, parameterName, "integer"))); + throw getInvalidArgumentError(argument, parameterName, "integer"); } } + private static boolean isHexValueString(String value) { + String upperCaseVal = value.toUpperCase(); + return upperCaseVal.startsWith("0X") || upperCaseVal.startsWith("-0X"); + } + private static double getFloatValue(String argument, String parameterName) { + String upperCaseValue = argument.toUpperCase(); + if (upperCaseValue.endsWith("F") || upperCaseValue.endsWith("D")) { + throw getInvalidArgumentError(argument, parameterName, "float"); + } + try { return Double.parseDouble(argument); } catch (NumberFormatException e) { - throw ErrorCreator.createError( - StringUtils.fromString(String.format(INVALID_ARGUMENT_ERROR, argument, parameterName, "float"))); + throw getInvalidArgumentError(argument, parameterName, "float"); } } @@ -125,11 +133,15 @@ private static DecimalValue getDecimalValue(String argument, String parameterNam try { return new DecimalValue(argument); } catch (NumberFormatException | BError e) { - throw ErrorCreator.createError( - StringUtils.fromString(String.format(INVALID_ARGUMENT_ERROR, argument, parameterName, "decimal"))); + throw getInvalidArgumentError(argument, parameterName, "decimal"); } } + private static BError getInvalidArgumentError(String argument, String parameterName, String type) { + return ErrorCreator.createError( + StringUtils.fromString(String.format(INVALID_ARGUMENT_ERROR, argument, parameterName, type))); + } + static boolean isSupportedType(int tag) { return tag == TypeTags.STRING_TAG || tag == TypeTags.INT_TAG || tag == TypeTags.FLOAT_TAG || tag == TypeTags.DECIMAL_TAG || tag == TypeTags.BOOLEAN_TAG; diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java index 3575ff7f6161..c363830d62b9 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java @@ -35,6 +35,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.regex.Pattern; import static io.ballerina.runtime.api.utils.TypeUtils.getReferredType; @@ -50,6 +51,9 @@ public class Option { private final Set recordKeysFound; private final int location; + private final Pattern NUMBER_PATTERN = Pattern.compile("[-+]?\\d+(\\.\\d+)?([eE][-+]?\\d+)?[fd]?"); + private static final Pattern HEX_LITERAL = Pattern.compile("[-+]?0[xX][\\dA-Fa-f.pP\\-+]+"); + public Option(Type recordType, int location) { this((RecordType) recordType, ValueCreator.createRecordValue(recordType.getPackage(), recordType.getName()), location); @@ -84,7 +88,14 @@ public BMap parseRecord(String[] args) { } private boolean isShortOption(String arg) { - return arg.startsWith("-"); + return arg.startsWith("-") && !isNumeric(arg); + } + + private boolean isNumeric(String str) { + if (str == null) { + return false; + } + return HEX_LITERAL.matcher(str).matches() || NUMBER_PATTERN.matcher(str).matches(); } private void validateConfigOption(String arg) { From 7c0759aafebb6751610cb8b88d3679d93617cec5 Mon Sep 17 00:00:00 2001 From: gabilang Date: Fri, 11 Nov 2022 12:52:10 +0530 Subject: [PATCH 048/450] Add CLI test cases --- .../function/ArgumentParserNegativeTest.java | 32 +++++++++++++++- .../function/ArgumentParserPositiveTest.java | 37 +++++++++++++++++-- .../test_main_with_float_param.bal | 25 +++++++++++++ 3 files changed, 89 insertions(+), 5 deletions(-) create mode 100644 tests/jballerina-unit-test/src/test/resources/test-src/main.function/test_main_with_float_param.bal diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/main/function/ArgumentParserNegativeTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/main/function/ArgumentParserNegativeTest.java index 40a5e673bd46..588686b0d0dc 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/main/function/ArgumentParserNegativeTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/main/function/ArgumentParserNegativeTest.java @@ -70,6 +70,18 @@ public void testInvalidIntArg(String arg) { } } + @Test(dataProvider = "floatValues") + public void testInvalidFloatArg(String arg) { + try { + CompileResult compileResult = BCompileUtil.compile(MAIN_FUNCTION_TEST_SRC_DIR + + "test_main_with_float_param.bal"); + BRunUtil.runMain(compileResult, new String[]{arg}); + } catch (RuntimeException e) { + Assert.assertEquals(e.getMessage(), "error: invalid argument '" + arg + + "' for parameter 'f', expected float value"); + } + } + @Test(dataProvider = "decimalValues") public void testInvalidDecimalArg(String arg) { try { @@ -129,13 +141,31 @@ public Object[][] intValues() { }; } + @DataProvider(name = "floatValues") + public Object[] floatValues() { + return new Object[]{ + "13.24f", + "123asd", + "0x1ef.a2pa5", + "2.0d", + "-2d", + "-4.5f", + "0x23dfp-2d" + }; + } + @DataProvider(name = "decimalValues") public Object[] decimalValues() { return new Object[]{ "13.24f", "123asd", "0x1ef.a2", - "0X1EF.A2P-2" + "0X1EF.A2P-2", + "-0X1EF.A2p-2", + "2.0d", + "-2d", + "4.5f", + "0x23dfp-2d" }; } } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/main/function/ArgumentParserPositiveTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/main/function/ArgumentParserPositiveTest.java index cc552eb2a351..ed9c6c645b27 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/main/function/ArgumentParserPositiveTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/main/function/ArgumentParserPositiveTest.java @@ -76,6 +76,14 @@ public void testIntArg(String specifiedInt, String expectedInt) { Assert.assertEquals(output, expectedInt, "string arg parsed as invalid int"); } + @Test(dataProvider = "floatValues") + public void testFloatArg(String specifiedFloat, String expectedFloat) { + compileResult = BCompileUtil.compile(MAIN_FUNCTION_TEST_SRC_DIR + + "test_main_with_float_param.bal"); + String output = runMain(compileResult, new String[]{specifiedFloat}); + Assert.assertEquals(output, expectedFloat, "string arg parsed as invalid float"); + } + @Test(dataProvider = "decimalValues") public void testDecimalArg(String specifiedDecimal, String expectedDecimal) { compileResult = BCompileUtil.compile(MAIN_FUNCTION_TEST_SRC_DIR + @@ -147,18 +155,39 @@ public Object[][] mainFunctionArgsAndResult() { public Object[][] intValues() { return new Object[][]{ {"10", "10"}, + {"-10", "-10"}, {"0x1efa2", "126882"}, - {"0XFAF1", "64241"} + {"-0x1efa2", "-126882"}, + {"0XFAF1", "64241"}, + {"-0XFAF1", "-64241"} + }; + } + + @DataProvider(name = "floatValues") + public Object[][] floatValues() { + return new Object[][]{ + {"10.5", "10.5"}, + {"-10", "-10.0"}, + {"-216.538", "-216.538"}, + {"0x1efa2p0", "126882.0"}, + {"-0x1efa2p1", "-253764.0"}, + {"0XFAF1P2", "256964.0"}, + {"-0XFAF1P2", "-256964.0"}, + {"0XFAf1p-25", "0.0019145309925079346"}, + {"-0XFaF1P-25", "-0.0019145309925079346"}, + {"0x1ef.a2p5", "15860.25"}, + {"-0x1ef.a2p5", "-15860.25"}, + {"-0X1EF.A2P-2", "-123.908203125"} }; } - //Todo: commented tests to be fixed with #30394 @DataProvider(name = "decimalValues") public Object[][] decimalValues() { return new Object[][]{ {"10", "10"}, -// {"-10.123", "-10.123"}, - {"10.123e1423", "1.0123E+1424"} + {"-10.123", "-10.123"}, + {"10.123e1423", "1.0123E+1424"}, + {"-10.123e1423", "-1.0123E+1424"} }; } diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/main.function/test_main_with_float_param.bal b/tests/jballerina-unit-test/src/test/resources/test-src/main.function/test_main_with_float_param.bal new file mode 100644 index 000000000000..0d7076da8a9f --- /dev/null +++ b/tests/jballerina-unit-test/src/test/resources/test-src/main.function/test_main_with_float_param.bal @@ -0,0 +1,25 @@ +// Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com) All Rights Reserved. +// +// WSO2 LLC. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +import ballerina/jballerina.java; + +public function main(float f) { + print(f); +} + +public function print(any|error... values) = @java:Method { + 'class: "org.ballerinalang.test.utils.interop.Utils" +} external; \ No newline at end of file From 56fb2d1fd4e30ff7ebd0a3a0d23383e6a92069de Mon Sep 17 00:00:00 2001 From: gabilang Date: Fri, 11 Nov 2022 13:03:01 +0530 Subject: [PATCH 049/450] Add missing additional line --- .../test-src/main.function/test_main_with_float_param.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/main.function/test_main_with_float_param.bal b/tests/jballerina-unit-test/src/test/resources/test-src/main.function/test_main_with_float_param.bal index 0d7076da8a9f..5f79fe22c5ee 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/main.function/test_main_with_float_param.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/main.function/test_main_with_float_param.bal @@ -22,4 +22,4 @@ public function main(float f) { public function print(any|error... values) = @java:Method { 'class: "org.ballerinalang.test.utils.interop.Utils" -} external; \ No newline at end of file +} external; From e485eba5e10528bf2c46de7572174971502466bf Mon Sep 17 00:00:00 2001 From: gabilang Date: Fri, 11 Nov 2022 14:54:54 +0530 Subject: [PATCH 050/450] Fix checkstyle issue with regex --- .../src/main/java/io/ballerina/runtime/internal/cli/Option.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java index c363830d62b9..e53c00fb51de 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java @@ -51,7 +51,7 @@ public class Option { private final Set recordKeysFound; private final int location; - private final Pattern NUMBER_PATTERN = Pattern.compile("[-+]?\\d+(\\.\\d+)?([eE][-+]?\\d+)?[fd]?"); + private final Pattern NUMBER_PATTERN = Pattern.compile("-?[0-9]+(\\.[0-9]+)?([eE][-+]?[0-9]+)?[fFdD]?"); private static final Pattern HEX_LITERAL = Pattern.compile("[-+]?0[xX][\\dA-Fa-f.pP\\-+]+"); public Option(Type recordType, int location) { From f45bee11f277db1c6091214b0218e5c1cb885c09 Mon Sep 17 00:00:00 2001 From: HindujaB Date: Fri, 11 Nov 2022 16:54:57 +0530 Subject: [PATCH 051/450] Add PR workflows for type-reference-support --- .github/workflows/pull_request_full_build.yml | 1 + .github/workflows/pull_request_ubuntu_build.yml | 1 + .github/workflows/pull_request_windows_build.yml | 1 + 3 files changed, 3 insertions(+) diff --git a/.github/workflows/pull_request_full_build.yml b/.github/workflows/pull_request_full_build.yml index b9850e2be06f..9d15b67ad1c3 100644 --- a/.github/workflows/pull_request_full_build.yml +++ b/.github/workflows/pull_request_full_build.yml @@ -4,6 +4,7 @@ on: pull_request: branches: - master + - type-reference-support jobs: build-lang: diff --git a/.github/workflows/pull_request_ubuntu_build.yml b/.github/workflows/pull_request_ubuntu_build.yml index 01fd9e4f219d..be3ac9f60d2f 100644 --- a/.github/workflows/pull_request_ubuntu_build.yml +++ b/.github/workflows/pull_request_ubuntu_build.yml @@ -13,6 +13,7 @@ on: - 2201.[0-9]+.x - 2201.[0-9]+.[0-9]+-stage - native-build + - type-reference-support jobs: ubuntu_build: diff --git a/.github/workflows/pull_request_windows_build.yml b/.github/workflows/pull_request_windows_build.yml index 03ebfdbe648c..26548eec2366 100644 --- a/.github/workflows/pull_request_windows_build.yml +++ b/.github/workflows/pull_request_windows_build.yml @@ -13,6 +13,7 @@ on: - 2201.[0-9]+.x - 2201.[0-9]+.[0-9]+-stage - native-build + - type-reference-support jobs: windows_build: From 3ff0f938110c4f380226c4f2ee012031ec4f29f4 Mon Sep 17 00:00:00 2001 From: Nipuna Ranasinghe Date: Fri, 11 Nov 2022 23:19:33 +0530 Subject: [PATCH 052/450] Disable expression evaluation tests for array value comparisons --- .../evaluation/ExpressionEvaluationTest.java | 64 ++++++++++--------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationTest.java b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationTest.java index f1aa8d8b8d1a..8fb13a0e72ae 100644 --- a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationTest.java +++ b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationTest.java @@ -630,21 +630,23 @@ public void comparisonEvaluationTest() throws BallerinaTestException { // string - string debugTestRunner.assertExpression(context, String.format("%s < %s", STRING_VAR, STRING_VAR), "false", "boolean"); - // boolean[] - boolean[] - debugTestRunner.assertExpression(context, String.format("%s < %s", "booleanArrayVar", "booleanArrayVar"), - "false", "boolean"); - // int[] - int[] - debugTestRunner.assertExpression(context, String.format("%s < %s", "intArrayVar", "intArrayVar"), - "false", "boolean"); - // float[] - float[] - debugTestRunner.assertExpression(context, String.format("%s < %s", "floatArrayVar", "floatArrayVar"), - "false", "boolean"); - // decimal[] - decimal[] - debugTestRunner.assertExpression(context, String.format("%s < %s", "decimalArrayVar", "decimalArrayVar"), - "false", "boolean"); - // string[] - string[] - debugTestRunner.assertExpression(context, String.format("%s < %s", "stringArrayVar", "stringArrayVar"), - "false", "boolean"); + +// Todo - enable once https://github.com/ballerina-platform/ballerina-lang/issues/38642 is fixed +// // boolean[] - boolean[] +// debugTestRunner.assertExpression(context, String.format("%s < %s", "booleanArrayVar", "booleanArrayVar"), +// "false", "boolean"); +// // int[] - int[] +// debugTestRunner.assertExpression(context, String.format("%s < %s", "intArrayVar", "intArrayVar"), +// "false", "boolean"); +// // float[] - float[] +// debugTestRunner.assertExpression(context, String.format("%s < %s", "floatArrayVar", "floatArrayVar"), +// "false", "boolean"); +// // decimal[] - decimal[] +// debugTestRunner.assertExpression(context, String.format("%s < %s", "decimalArrayVar", "decimalArrayVar"), +// "false", "boolean"); +// // string[] - string[] +// debugTestRunner.assertExpression(context, String.format("%s < %s", "stringArrayVar", "stringArrayVar"), +// "false", "boolean"); // expression <= expression // nil - nil @@ -662,21 +664,23 @@ public void comparisonEvaluationTest() throws BallerinaTestException { // string - string debugTestRunner.assertExpression(context, String.format("%s <= %s", STRING_VAR, STRING_VAR), "true", "boolean"); - // boolean[] - boolean[] - debugTestRunner.assertExpression(context, String.format("%s <= %s", "booleanArrayVar", "booleanArrayVar"), - "true", "boolean"); - // int[] - int[] - debugTestRunner.assertExpression(context, String.format("%s <= %s", "intArrayVar", "intArrayVar"), - "true", "boolean"); - // float[] - float[] - debugTestRunner.assertExpression(context, String.format("%s <= %s", "floatArrayVar", "floatArrayVar"), - "true", "boolean"); - // decimal[] - decimal[] - debugTestRunner.assertExpression(context, String.format("%s <= %s", "decimalArrayVar", "decimalArrayVar"), - "true", "boolean"); - // string[] - string[] - debugTestRunner.assertExpression(context, String.format("%s <= %s", "stringArrayVar", "stringArrayVar"), - "true", "boolean"); + +// Todo - enable once https://github.com/ballerina-platform/ballerina-lang/issues/38642 is fixed +// // boolean[] - boolean[] +// debugTestRunner.assertExpression(context, String.format("%s <= %s", "booleanArrayVar", "booleanArrayVar"), +// "true", "boolean"); +// // int[] - int[] +// debugTestRunner.assertExpression(context, String.format("%s <= %s", "intArrayVar", "intArrayVar"), +// "true", "boolean"); +// // float[] - float[] +// debugTestRunner.assertExpression(context, String.format("%s <= %s", "floatArrayVar", "floatArrayVar"), +// "true", "boolean"); +// // decimal[] - decimal[] +// debugTestRunner.assertExpression(context, String.format("%s <= %s", "decimalArrayVar", "decimalArrayVar"), +// "true", "boolean"); +// // string[] - string[] +// debugTestRunner.assertExpression(context, String.format("%s <= %s", "stringArrayVar", "stringArrayVar"), +// "true", "boolean"); // expression > expression // Note ::= Not required to test all the possibilities in here, as 'X > Y' is processed as '!(X <= Y)' by the From a02b84e3d9e3aab736f827c0b53b7a9a50818ced Mon Sep 17 00:00:00 2001 From: gabilang Date: Mon, 14 Nov 2022 11:23:52 +0530 Subject: [PATCH 053/450] Fix issues with floating-point suffix --- .../io/ballerina/runtime/internal/cli/CliUtil.java | 5 ----- .../io/ballerina/runtime/internal/cli/Option.java | 12 ++++++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/CliUtil.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/CliUtil.java index 64ea17c47364..9b3b256d535c 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/CliUtil.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/CliUtil.java @@ -117,11 +117,6 @@ private static boolean isHexValueString(String value) { } private static double getFloatValue(String argument, String parameterName) { - String upperCaseValue = argument.toUpperCase(); - if (upperCaseValue.endsWith("F") || upperCaseValue.endsWith("D")) { - throw getInvalidArgumentError(argument, parameterName, "float"); - } - try { return Double.parseDouble(argument); } catch (NumberFormatException e) { diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java index e53c00fb51de..be33fb049250 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java @@ -51,7 +51,7 @@ public class Option { private final Set recordKeysFound; private final int location; - private final Pattern NUMBER_PATTERN = Pattern.compile("-?[0-9]+(\\.[0-9]+)?([eE][-+]?[0-9]+)?[fFdD]?"); + private final Pattern NUMBER_PATTERN = Pattern.compile("-?[0-9]+(\\.[0-9]+)?([eE][-+]?[0-9]+)?"); private static final Pattern HEX_LITERAL = Pattern.compile("[-+]?0[xX][\\dA-Fa-f.pP\\-+]+"); public Option(Type recordType, int location) { @@ -91,11 +91,15 @@ private boolean isShortOption(String arg) { return arg.startsWith("-") && !isNumeric(arg); } - private boolean isNumeric(String str) { - if (str == null) { + private boolean isNumeric(String stringVal) { + if (stringVal == null || stringVal.length() == 0) { return false; } - return HEX_LITERAL.matcher(str).matches() || NUMBER_PATTERN.matcher(str).matches(); + String upperCaseValue = stringVal.toUpperCase(); + if (upperCaseValue.endsWith("F") || upperCaseValue.endsWith("D")) { + stringVal = upperCaseValue.substring(0, stringVal.length() - 1); + } + return HEX_LITERAL.matcher(stringVal).matches() || NUMBER_PATTERN.matcher(stringVal).matches(); } private void validateConfigOption(String arg) { From a33873956d4e0aa28969010d0da7a8a9ef1ee65d Mon Sep 17 00:00:00 2001 From: gabilang Date: Mon, 14 Nov 2022 15:48:29 +0530 Subject: [PATCH 054/450] Add missing static keyword --- .../src/main/java/io/ballerina/runtime/internal/cli/Option.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java index be33fb049250..50a45fdbf738 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java @@ -51,7 +51,7 @@ public class Option { private final Set recordKeysFound; private final int location; - private final Pattern NUMBER_PATTERN = Pattern.compile("-?[0-9]+(\\.[0-9]+)?([eE][-+]?[0-9]+)?"); + private static final Pattern NUMBER_PATTERN = Pattern.compile("-?[0-9]+(\\.[0-9]+)?([eE][-+]?[0-9]+)?"); private static final Pattern HEX_LITERAL = Pattern.compile("[-+]?0[xX][\\dA-Fa-f.pP\\-+]+"); public Option(Type recordType, int location) { From 63b0cf4028fd1599c13f2c23bc706e1620da652d Mon Sep 17 00:00:00 2001 From: Nipuna Ranasinghe Date: Mon, 14 Nov 2022 17:50:52 +0530 Subject: [PATCH 055/450] Refactor debugger runtime helpers --- .../main/ballerina/relational_operations.bal | 20 ------------------- .../src/main/ballerina/utils.bal | 14 ++++++++----- 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/misc/debug-adapter/modules/debug-adapter-runtime/src/main/ballerina/relational_operations.bal b/misc/debug-adapter/modules/debug-adapter-runtime/src/main/ballerina/relational_operations.bal index 72b49ec70b0c..e876ef379910 100644 --- a/misc/debug-adapter/modules/debug-adapter-runtime/src/main/ballerina/relational_operations.bal +++ b/misc/debug-adapter/modules/debug-adapter-runtime/src/main/ballerina/relational_operations.bal @@ -29,16 +29,6 @@ function lessThan(any lhs, any rhs) returns boolean|error { result = trap (lhs < rhs); // decimal < decimal } else if (lhs is string && rhs is string) { result = trap (lhs < rhs); // string < string - } else if (lhs is boolean[] && rhs is boolean[]) { - result = trap (lhs < rhs); // boolean[] < boolean[] - } else if (lhs is int[] && rhs is int[]) { - result = trap (lhs < rhs); // int[] < int[] - } else if (lhs is float[] && rhs is float[]) { - result = trap (lhs < rhs); // float[] < float[] - } else if (lhs is decimal[] && rhs is decimal[]) { - result = trap (lhs < rhs); // decimal[] < decimal[] - } else if (lhs is string[] && rhs is string[]) { - result = trap (lhs < rhs); // string[] < string[] } else { result = error("operator '<' not defined for '" + check getType(lhs) + "' and '" + check getType(rhs) + "'."); } @@ -59,16 +49,6 @@ function lessThanOrEquals(any lhs, any rhs) returns boolean|error { result = trap (lhs <= rhs); // decimal <= decimal } else if (lhs is string && rhs is string) { result = trap (lhs <= rhs); // string <= string - } else if (lhs is boolean[] && rhs is boolean[]) { - result = trap (lhs <= rhs); // boolean[] <= boolean[] - } else if (lhs is int[] && rhs is int[]) { - result = trap (lhs <= rhs); // int[] <= int[] - } else if (lhs is float[] && rhs is float[]) { - result = trap (lhs <= rhs); // float[] <= float[] - } else if (lhs is decimal[] && rhs is decimal[]) { - result = trap (lhs <= rhs); // decimal[] <= decimal[] - } else if (lhs is string[] && rhs is string[]) { - result = trap (lhs <= rhs); // string[] <= string[] } else { result = error("operator '<=' not defined for '" + check getType(lhs) + "' and '" + check getType(rhs) + "'."); } diff --git a/misc/debug-adapter/modules/debug-adapter-runtime/src/main/ballerina/utils.bal b/misc/debug-adapter/modules/debug-adapter-runtime/src/main/ballerina/utils.bal index 3d672a79d82d..9bb20cb63d9c 100644 --- a/misc/debug-adapter/modules/debug-adapter-runtime/src/main/ballerina/utils.bal +++ b/misc/debug-adapter/modules/debug-adapter-runtime/src/main/ballerina/utils.bal @@ -17,15 +17,19 @@ function getType(any value) returns string|error { // Need to handle simple values separately, since `typeof` operation returns the singleton type for simple values. - if (value is int) { + if value is () { + return "nil"; + } else if value is int { return "int"; - } else if (value is float) { + } else if value is float { return "float"; - } else if (value is boolean) { + } else if value is decimal { + return "decimal"; + } else if value is boolean { return "boolean"; - } else if (value is byte) { + } else if value is byte { return "byte"; - } else if (value is string) { + } else if value is string { return "string"; } else { var result = trap (typeof value); From b3d346c0cf770dac98c809c9ccb2efe62cbde1a1 Mon Sep 17 00:00:00 2001 From: Tharik Kanaka Date: Mon, 14 Nov 2022 21:25:18 +0530 Subject: [PATCH 056/450] Update Jackson Databind version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index fe771adaa446..f6a641b2b3fc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -76,7 +76,7 @@ harbbyGradleServiceloaderVersion=1.1.5 hdrHistogramVersion=2.1.11 hikariCPVersion=3.3.1 hsqldbVersion=2.4.1 -jacksonDatabindVersion=2.13.4 +jacksonDatabindVersion=2.14.0 jacksonDataformatYamlVersion=2.13.2 jacksonDatatypeJsr310Version=2.13.2 jacksonCoreVersion=2.13.2 From 6120feb12b49f2d8bf6f30b739e1d2a86a8a1724 Mon Sep 17 00:00:00 2001 From: malinthar Date: Tue, 15 Nov 2022 12:08:40 +0530 Subject: [PATCH 057/450] Revert IDL client declaration related changes --- .../workflows/pull_request_ubuntu_build.yml | 1 + .../workflows/pull_request_windows_build.yml | 1 + .../modules/langserver-core/build.gradle | 1 - .../ExtractToConstantCodeAction.java | 2 - .../ExtractToFunctionCodeAction.java | 7 +- .../ExtractToLocalVarCodeAction.java | 3 - ...GenerateModuleForClientDeclCodeAction.java | 85 -- .../GenerateModuleForClientDeclExecutor.java | 163 ---- .../langserver/common/utils/ModuleUtil.java | 22 - .../providers/AbstractCompletionProvider.java | 53 - .../context/AnnotationNodeContext.java | 3 - .../context/BlockNodeContextProvider.java | 2 - .../context/ClientDeclarationNodeContext.java | 72 -- .../ModuleClientDeclarationNodeContext.java | 82 -- .../context/ModulePartNodeContext.java | 2 - .../util/ModulePartNodeContextUtil.java | 2 +- .../langserver/completions/util/Snippet.java | 2 - .../completions/util/SnippetGenerator.java | 12 - .../codeaction/ExtractToConstantTest.java | 4 +- .../ExtractToFunctionCodeActionTest.java | 4 +- .../codeaction/ExtractToLocalVarTest.java | 4 +- ...rateModuleForClientDeclCodeActionTest.java | 92 -- ...nerateModuleForClientDeclExecutorTest.java | 132 --- .../ClientDeclarationContextTest.java | 57 -- .../ModuleClientDeclarationContextTest.java | 62 -- ...rviceUriInClientDeclarationToConstant.json | 12 - ...erviceUriInModuleClientDeclToConstant.json | 12 - ...ctToConstantClientDeclarationsNegative.bal | 5 - ...pos_service_uri_in_client_declaration.json | 13 - ...vice_uri_in_module_client_declaration.json | 13 - ..._pos_service_uri_in_client_declaration.bal | 3 - ...rvice_uri_in_module_client_declaration.bal | 1 - ...extractToVariableInClientDeclNegative.json | 12 - ...tToVariableInModuleClientDeclNegative.json | 12 - .../source/extractToVariableInClientDecl.bal | 5 - .../generate_module_for_client_decl1.json | 24 - .../source/client_decl/Ballerina.toml | 7 - .../source/client_decl/main.bal | 6 - .../source/client_decl/Ballerina.toml | 7 - .../source/client_decl/main.bal | 6 - .../config/clientDeclAnnotation1.json | 396 -------- .../config/clientDeclAnnotation2.json | 396 -------- .../config/clientDeclAnnotation3.json | 54 -- .../config/clientDeclAnnotation4.json | 54 -- .../config/moduleClientDeclAnnotation1.json | 396 -------- .../config/moduleClientDeclAnnotation2.json | 396 -------- .../config/moduleClientDeclAnnotation3.json | 54 -- .../config/moduleClientDeclAnnotation4.json | 54 -- .../config/moduleLevelAnnotation1.json | 18 - .../source/clientDeclAnnotation1.bal | 17 - .../source/clientDeclAnnotation2.bal | 17 - .../source/clientDeclAnnotation3.bal | 17 - .../source/clientDeclAnnotation4.bal | 17 - .../source/moduleClientDeclAnnotation1.bal | 15 - .../source/moduleClientDeclAnnotation2.bal | 15 - .../source/moduleClientDeclAnnotation3.bal | 15 - .../source/moduleClientDeclAnnotation4.bal | 15 - .../annotation_decl/config/config21.json | 9 - .../completion/class_def/config/config22.json | 9 - .../completion/class_def/config/config24.json | 9 - .../client_declaration_after_as_keyword.json | 8 - ...ient_declaration_after_client_keyword.json | 8 - .../client_declaration_after_service_uri.json | 18 - .../client_declaration_client_keyword.json | 914 ------------------ ...odule_prefix_reference_in_block_level.json | 25 - ...nt_declaration_on_expected_as_keyword.json | 18 - ...t_declaration_on_expected_service_uri.json | 8 - ...tion_remote_method_access_block_level.json | 24 - ...mpletions_inside_generated_idl_client.json | 663 ------------- .../source/client_decl_test/Ballerina.toml | 8 - .../generated/idl-plugin-cache.json | 1 - .../generated/myapi/idl_client.bal | 18 - .../source/client_decl_test/main.bal | 7 - .../client_decl_test/projectapiclientplugin | 1 - .../client_decl_test/remote_method_access.bal | 7 - .../client_declaration_after_as_keyword.bal | 3 - ...lient_declaration_after_client_keyword.bal | 3 - .../client_declaration_after_service_uri.bal | 3 - .../client_declaration_client_keyword.bal | 3 - ...ent_declaration_on_expected_as_keyword.bal | 3 - ...nt_declaration_on_expected_service_uri.bal | 3 - .../config/comment_config3.json | 9 - .../config/comment_config4.json | 9 - .../enum_decl_ctx/config/config5.json | 9 - .../config/anon_func_expr_ctx_config10.json | 9 - .../function_call_expression_ctx_config7.json | 9 - .../function_call_expression_ctx_config8.json | 9 - .../config/module_ctx_config1.json | 9 - .../config/module_ctx_config3.json | 9 - .../config/module_ctx_config4.json | 9 - .../config/module_ctx_config5.json | 9 - .../config/field_access_ctx_config21.json | 9 - .../config/foreach_stmt_ctx_config7.json | 9 - .../config/foreach_stmt_ctx_config8.json | 9 - .../function_body/config/config1.json | 9 - .../function_body/config/config10.json | 9 - .../function_body/config/config12.json | 9 - .../function_body/config/config13.json | 9 - .../function_body/config/config14.json | 9 - .../config/config15_client_declaration.json | 18 - .../config/config16_client_declaration.json | 27 - .../function_body/config/config2.json | 9 - .../function_body/config/config3.json | 9 - .../function_body/config/config4.json | 9 - .../function_body/config/config5.json | 9 - .../function_body/config/config6.json | 9 - .../import_decl/config/config11.json | 9 - .../import_decl/config/config12.json | 9 - .../import_decl/config/config21.json | 9 - .../import_decl/config/config26.json | 9 - ...dule_prefix_reference_in_module_level.json | 25 - ...e_client_declaration_after_as_keyword.json | 8 - ...ient_declaration_after_client_keyword.json | 54 -- ..._client_declaration_after_service_uri.json | 18 - ...ule_client_declaration_client_keyword.json | 875 ----------------- ...nt_declaration_on_expected_as_keyword.json | 18 - ...t_declaration_on_expected_service_uri.json | 8 - .../module_client_decl_test/Ballerina.toml | 8 - .../generated/idl-plugin-cache.json | 1 - .../generated/myapi/idl_client.bal | 18 - .../source/module_client_decl_test/main.bal | 7 - .../projectapiclientplugin | 1 - .../remote_method_access.bal | 5 - ...le_client_declaration_after_as_keyword.bal | 1 - ...lient_declaration_after_client_keyword.bal | 1 - ...e_client_declaration_after_service_uri.bal | 1 - ...dule_client_declaration_client_keyword.bal | 1 - ...ent_declaration_on_expected_as_keyword.bal | 1 - ...nt_declaration_on_expected_service_uri.bal | 1 - .../module_part_context/config/config1.json | 9 - .../module_part_context/config/config14.json | 9 - .../module_part_context/config/config15.json | 9 - .../config/config15_client_declaration.json | 884 ----------------- .../module_part_context/config/config16.json | 9 - .../module_part_context/config/config2.json | 9 - .../module_part_context/config/config3.json | 9 - .../module_part_context/config/config6.json | 9 - ...le_level_after_annotation_decl_config.json | 9 - .../module_level_after_class_defn_config.json | 9 - .../module_level_after_const_decl_config.json | 9 - .../module_level_after_enum_decl_config.json | 9 - ...dule_level_after_funciton_defn_config.json | 9 - ...module_level_after_import_decl_config.json | 9 - ...dule_level_after_listener_decl_config.json | 9 - ...odule_level_after_service_decl_config.json | 9 - .../module_level_after_type_defn_config.json | 9 - .../module_level_after_var_decl_config.json | 9 - .../module_level_after_xmlns_decl_config.json | 9 - ...e_level_before_annotation_decl_config.json | 9 - ...module_level_before_class_defn_config.json | 9 - ...module_level_before_const_decl_config.json | 9 - .../module_level_before_enum_decl_config.json | 9 - ...ule_level_before_function_defn_config.json | 9 - ...odule_level_before_import_decl_config.json | 9 - ...ule_level_before_listener_decl_config.json | 9 - ...dule_level_before_service_decl_config.json | 9 - .../module_level_before_type_defn_config.json | 9 - .../module_level_before_var_decl_config.json | 9 - ...module_level_before_xmlns_decl_config.json | 9 - .../source/source15_client_declaration.bal | 7 - .../service_body/config/config4.json | 9 - .../service_decl/config/config16.json | 9 - .../service_decl/config/config17.json | 9 - .../service_decl/config/config18.json | 9 - .../service_decl/config/config7.json | 9 - .../continue_break_stmt_ctx_config1.json | 9 - .../continue_break_stmt_ctx_config2.json | 9 - .../config/do_stmt_ctx_config1.json | 9 - .../config/else_stmt_ctx_config1.json | 9 - .../config/else_stmt_ctx_config2.json | 9 - .../config/elseif_stmt_ctx_config1.json | 9 - .../config/elseif_stmt_ctx_config2.json | 9 - .../function_call_stmt_ctx_config1.json | 9 - .../function_call_stmt_ctx_config2.json | 9 - .../config/if_stmt_ctx_config1.json | 9 - .../config/if_stmt_ctx_config2.json | 9 - .../config/if_stmt_ctx_config7.json | 9 - .../config/if_stmt_ctx_config8.json | 9 - .../local_var_decl_stmt_ctx_config1.json | 9 - .../config/lock_stmt_ctx_config1.json | 9 - .../config/lock_stmt_ctx_config3.json | 9 - .../config/onfail_clause_ctx_config1.json | 9 - .../config/onfail_clause_ctx_config1a.json | 9 - .../config/onfail_clause_ctx_config2.json | 9 - .../config/onfail_clause_ctx_config2a.json | 9 - .../config/onfail_clause_ctx_config3.json | 9 - .../config/onfail_clause_ctx_config4.json | 9 - .../config/onfail_clause_ctx_config5.json | 9 - .../config/onfail_clause_ctx_config5a.json | 9 - .../config/onfail_clause_ctx_config6.json | 9 - .../config/onfail_clause_ctx_config6a.json | 9 - .../config/panic_stmt_ctx_config1.json | 10 - .../config/return_stmt_ctx_config1.json | 9 - .../config/return_stmt_ctx_config10.json | 9 - .../config/return_stmt_ctx_config11.json | 9 - .../config/return_stmt_ctx_config12.json | 9 - .../config/return_stmt_ctx_config13.json | 9 - .../config/return_stmt_ctx_config14.json | 9 - .../config/return_stmt_ctx_config15.json | 9 - .../config/return_stmt_ctx_config2.json | 9 - .../config/return_stmt_ctx_config3.json | 9 - .../config/return_stmt_ctx_config4.json | 9 - .../config/return_stmt_ctx_config5.json | 9 - .../config/return_stmt_ctx_config6.json | 9 - .../config/return_stmt_ctx_config7.json | 9 - .../config/return_stmt_ctx_config8.json | 9 - .../config/return_stmt_ctx_config9.json | 9 - .../config/transaction_config1.json | 9 - .../config/while_stmt_ctx_config1.json | 9 - .../config/while_stmt_ctx_config2.json | 9 - .../worker_declaration_ctx_config1.json | 9 - .../worker_declaration_ctx_config2.json | 9 - .../config/array_typedesc5.json | 9 - .../src/main/ballerina/annotation_source1.bal | 4 - 214 files changed, 8 insertions(+), 7693 deletions(-) delete mode 100644 language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/GenerateModuleForClientDeclCodeAction.java delete mode 100644 language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/command/executors/GenerateModuleForClientDeclExecutor.java delete mode 100644 language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ClientDeclarationNodeContext.java delete mode 100644 language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ModuleClientDeclarationNodeContext.java delete mode 100644 language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/GenerateModuleForClientDeclCodeActionTest.java delete mode 100644 language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/command/GenerateModuleForClientDeclExecutorTest.java delete mode 100644 language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/completion/ClientDeclarationContextTest.java delete mode 100644 language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/completion/ModuleClientDeclarationContextTest.java delete mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/config/extractServiceUriInClientDeclarationToConstant.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/config/extractServiceUriInModuleClientDeclToConstant.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/source/extractToConstantClientDeclarationsNegative.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/config/neg_extract_to_function_exprs_pos_service_uri_in_client_declaration.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/config/neg_extract_to_function_exprs_pos_service_uri_in_module_client_declaration.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/source/neg_extract_to_function_exprs_pos_service_uri_in_client_declaration.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/source/neg_extract_to_function_exprs_pos_service_uri_in_module_client_declaration.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-local-variable/config/extractToVariableInClientDeclNegative.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-local-variable/config/extractToVariableInModuleClientDeclNegative.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-local-variable/source/extractToVariableInClientDecl.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/generate-module-for-client-decl/config/generate_module_for_client_decl1.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/generate-module-for-client-decl/source/client_decl/Ballerina.toml delete mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/generate-module-for-client-decl/source/client_decl/main.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/command/generate-module-for-client-decl/source/client_decl/Ballerina.toml delete mode 100644 language-server/modules/langserver-core/src/test/resources/command/generate-module-for-client-decl/source/client_decl/main.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/clientDeclAnnotation1.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/clientDeclAnnotation2.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/clientDeclAnnotation3.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/clientDeclAnnotation4.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClientDeclAnnotation1.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClientDeclAnnotation2.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClientDeclAnnotation3.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClientDeclAnnotation4.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/clientDeclAnnotation1.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/clientDeclAnnotation2.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/clientDeclAnnotation3.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/clientDeclAnnotation4.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleClientDeclAnnotation1.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleClientDeclAnnotation2.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleClientDeclAnnotation3.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleClientDeclAnnotation4.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_after_as_keyword.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_after_client_keyword.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_after_service_uri.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_client_keyword.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_module_prefix_reference_in_block_level.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_on_expected_as_keyword.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_on_expected_service_uri.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_remote_method_access_block_level.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/completions_inside_generated_idl_client.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_decl_test/Ballerina.toml delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_decl_test/generated/idl-plugin-cache.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_decl_test/generated/myapi/idl_client.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_decl_test/main.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_decl_test/projectapiclientplugin delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_decl_test/remote_method_access.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_declaration_after_as_keyword.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_declaration_after_client_keyword.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_declaration_after_service_uri.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_declaration_client_keyword.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_declaration_on_expected_as_keyword.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_declaration_on_expected_service_uri.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/client_declaration_module_prefix_reference_in_module_level.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_after_as_keyword.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_after_client_keyword.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_after_service_uri.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_client_keyword.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_on_expected_as_keyword.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_on_expected_service_uri.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_decl_test/Ballerina.toml delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_decl_test/generated/idl-plugin-cache.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_decl_test/generated/myapi/idl_client.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_decl_test/main.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_decl_test/projectapiclientplugin delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_decl_test/remote_method_access.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_declaration_after_as_keyword.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_declaration_after_client_keyword.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_declaration_after_service_uri.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_declaration_client_keyword.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_declaration_on_expected_as_keyword.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_declaration_on_expected_service_uri.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config15_client_declaration.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/module_part_context/source/source15_client_declaration.bal diff --git a/.github/workflows/pull_request_ubuntu_build.yml b/.github/workflows/pull_request_ubuntu_build.yml index 56f697eecf04..1251699bec28 100644 --- a/.github/workflows/pull_request_ubuntu_build.yml +++ b/.github/workflows/pull_request_ubuntu_build.yml @@ -13,6 +13,7 @@ on: - 2201.[0-9]+.x - 2201.[0-9]+.[0-9]+-stage - native-build + - revert-client-decl-master jobs: ubuntu_build: diff --git a/.github/workflows/pull_request_windows_build.yml b/.github/workflows/pull_request_windows_build.yml index 03ebfdbe648c..45addbe0669c 100644 --- a/.github/workflows/pull_request_windows_build.yml +++ b/.github/workflows/pull_request_windows_build.yml @@ -13,6 +13,7 @@ on: - 2201.[0-9]+.x - 2201.[0-9]+.[0-9]+-stage - native-build + - revert-client-decl-master jobs: windows_build: diff --git a/language-server/modules/langserver-core/build.gradle b/language-server/modules/langserver-core/build.gradle index 7c951ec9027f..bd94847d7cd2 100644 --- a/language-server/modules/langserver-core/build.gradle +++ b/language-server/modules/langserver-core/build.gradle @@ -84,7 +84,6 @@ dependencies { testImplementation 'org.powermock:powermock-mockito-release-full' testImplementation 'org.powermock:powermock-module-testng-common' - testRuntime project(':project-api-test-artifact:idl-client-gen-plugin') } description = 'Ballerina - Language server - Core' diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToConstantCodeAction.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToConstantCodeAction.java index 5a3b318887f2..06d707db6e79 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToConstantCodeAction.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToConstantCodeAction.java @@ -72,8 +72,6 @@ public boolean validate(CodeActionContext context, RangeBasedPositionDetails pos return context.currentSyntaxTree().isPresent() && context.currentSemanticModel().isPresent() && parentKind != SyntaxKind.CONST_DECLARATION && parentKind != SyntaxKind.INVALID_EXPRESSION_STATEMENT - && parentKind != SyntaxKind.CLIENT_DECLARATION - && parentKind != SyntaxKind.MODULE_CLIENT_DECLARATION && CodeActionNodeValidator.validate(context.nodeAtRange()); } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToFunctionCodeAction.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToFunctionCodeAction.java index 0c8b8db89e55..5a043249f27e 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToFunctionCodeAction.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToFunctionCodeAction.java @@ -77,8 +77,7 @@ public class ExtractToFunctionCodeAction implements RangeBasedCodeActionProvider private static final String EXTRACTED_PREFIX = "extracted"; private static final Set unSupportedModuleLevelSyntaxKinds = Set.of(SyntaxKind.CONST_DECLARATION, - SyntaxKind.MODULE_XML_NAMESPACE_DECLARATION, SyntaxKind.ENUM_DECLARATION, SyntaxKind.TYPE_DEFINITION, - SyntaxKind.MODULE_CLIENT_DECLARATION); + SyntaxKind.MODULE_XML_NAMESPACE_DECLARATION, SyntaxKind.ENUM_DECLARATION, SyntaxKind.TYPE_DEFINITION); @Override public boolean validate(CodeActionContext context, RangeBasedPositionDetails positionDetails) { @@ -547,7 +546,6 @@ private boolean isExpressionExtractable(RangeBasedPositionDetails positionDetail * 5.1. with self keyword inside its expression * 5.2. as varRef() in assignment statement * 5.3. as lhsExpression() in compound assignment statement - * 6. a client declaration (module client declaration is covered inside unSupportedModuleLevelSyntaxKinds) **/ return !unSupportedModuleLevelSyntaxKinds.contains(enclosingModulePartNode.kind()) && (nodeKind != SyntaxKind.MAPPING_CONSTRUCTOR || parentKind != SyntaxKind.TABLE_CONSTRUCTOR) @@ -558,8 +556,7 @@ private boolean isExpressionExtractable(RangeBasedPositionDetails positionDetail && (parentKind != SyntaxKind.ASSIGNMENT_STATEMENT || !((AssignmentStatementNode) node.parent()).varRef().equals(node)) && (parentKind != SyntaxKind.COMPOUND_ASSIGNMENT_STATEMENT - || !((CompoundAssignmentStatementNode) node.parent()).lhsExpression().equals(node)))) - && parentKind != SyntaxKind.CLIENT_DECLARATION; + || !((CompoundAssignmentStatementNode) node.parent()).lhsExpression().equals(node)))); } public static List getSupportedExpressionSyntaxKindsList() { diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToLocalVarCodeAction.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToLocalVarCodeAction.java index 9d1f9fe0d436..1e822e9866f5 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToLocalVarCodeAction.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToLocalVarCodeAction.java @@ -86,7 +86,6 @@ public boolean validate(CodeActionContext context, RangeBasedPositionDetails pos // 6. the qualified name reference of a function call expression // 7. a record field with default value // 8. a function call expression used in a start action - // 9. a client declaration or a module client declaration return context.currentSyntaxTree().isPresent() && context.currentSemanticModel().isPresent() && !(nodeKind == SyntaxKind.MAPPING_CONSTRUCTOR && parentKind == SyntaxKind.TABLE_CONSTRUCTOR) && !(nodeKind == SyntaxKind.FUNCTION_CALL && parentKind == SyntaxKind.LOCAL_VAR_DECL) @@ -99,8 +98,6 @@ public boolean validate(CodeActionContext context, RangeBasedPositionDetails pos && parentKind != SyntaxKind.RECORD_FIELD_WITH_DEFAULT_VALUE && parentKind != SyntaxKind.ENUM_MEMBER && !(nodeKind == SyntaxKind.FUNCTION_CALL && parentKind == SyntaxKind.START_ACTION) - && parentKind != SyntaxKind.CLIENT_DECLARATION - && parentKind != SyntaxKind.MODULE_CLIENT_DECLARATION && CodeActionNodeValidator.validate(context.nodeAtRange()); } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/GenerateModuleForClientDeclCodeAction.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/GenerateModuleForClientDeclCodeAction.java deleted file mode 100644 index 5a9b474a9d71..000000000000 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/GenerateModuleForClientDeclCodeAction.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://wso2.com) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.ballerinalang.langserver.codeaction.providers; - -import io.ballerina.projects.PackageCompilation; -import io.ballerina.tools.diagnostics.Diagnostic; -import org.ballerinalang.annotation.JavaSPIService; -import org.ballerinalang.langserver.codeaction.CodeActionUtil; -import org.ballerinalang.langserver.command.executors.GenerateModuleForClientDeclExecutor; -import org.ballerinalang.langserver.common.constants.CommandConstants; -import org.ballerinalang.langserver.commons.CodeActionContext; -import org.ballerinalang.langserver.commons.codeaction.spi.DiagBasedPositionDetails; -import org.ballerinalang.langserver.commons.codeaction.spi.DiagnosticBasedCodeActionProvider; -import org.ballerinalang.langserver.commons.command.CommandArgument; -import org.ballerinalang.util.diagnostic.DiagnosticErrorCode; -import org.eclipse.lsp4j.CodeAction; -import org.eclipse.lsp4j.CodeActionKind; -import org.eclipse.lsp4j.Command; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -/** - * Code Action for generating modules for client declarations. - * - * @since 2201.3.0 - */ -@JavaSPIService("org.ballerinalang.langserver.commons.codeaction.spi.LSCodeActionProvider") -public class GenerateModuleForClientDeclCodeAction implements DiagnosticBasedCodeActionProvider { - - private static final String NAME = "GENERATE_MODULE_FOR_CLIENT_DECLARATION"; - - public static final String DIAGNOSTIC_CODE = - DiagnosticErrorCode.NO_MODULE_GENERATED_FOR_CLIENT_DECL.diagnosticId(); - public static final String DIAGNOSTIC_CODE_EXCLUDE = "BCE5304"; - - @Override - public boolean validate(Diagnostic diagnostic, - DiagBasedPositionDetails positionDetails, - CodeActionContext context) { - return DIAGNOSTIC_CODE.equals(diagnostic.diagnosticInfo().code()); - } - - @Override - public List getCodeActions(Diagnostic diagnostic, - DiagBasedPositionDetails positionDetails, - CodeActionContext context) { - - Optional packageCompilation = context.workspace() - .waitAndGetPackageCompilation(context.filePath()); - //Ensure that the user's project is not stand-alone Ballerina file. - if (packageCompilation.isEmpty() || - packageCompilation.get().diagnosticResult().diagnostics().stream() - .anyMatch(diag -> DIAGNOSTIC_CODE_EXCLUDE.equals(diag.diagnosticInfo().code()))) { - return Collections.emptyList(); - } - CommandArgument uriArg = CommandArgument.from(CommandConstants.ARG_KEY_DOC_URI, context.fileUri()); - List args = new ArrayList<>(); - args.add(uriArg); - String commandTitle = CommandConstants.GENERATE_MODULE_FOR_CLIENT_DECLARATION_TITLE; - Command command = new Command(commandTitle, GenerateModuleForClientDeclExecutor.COMMAND, args); - CodeAction action = CodeActionUtil.createCodeAction(commandTitle, command, CodeActionKind.QuickFix); - return Collections.singletonList(action); - } - - @Override - public String getName() { - return NAME; - } -} diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/command/executors/GenerateModuleForClientDeclExecutor.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/command/executors/GenerateModuleForClientDeclExecutor.java deleted file mode 100644 index 41e5eabc4fbd..000000000000 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/command/executors/GenerateModuleForClientDeclExecutor.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://wso2.com) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.ballerinalang.langserver.command.executors; - -import io.ballerina.projects.IDLClientGeneratorResult; -import io.ballerina.projects.Project; -import org.ballerinalang.annotation.JavaSPIService; -import org.ballerinalang.langserver.LSClientLogger; -import org.ballerinalang.langserver.LSContextOperation; -import org.ballerinalang.langserver.command.CommandUtil; -import org.ballerinalang.langserver.common.constants.CommandConstants; -import org.ballerinalang.langserver.common.utils.PathUtil; -import org.ballerinalang.langserver.commons.DocumentServiceContext; -import org.ballerinalang.langserver.commons.ExecuteCommandContext; -import org.ballerinalang.langserver.commons.client.ExtendedLanguageClient; -import org.ballerinalang.langserver.commons.command.CommandArgument; -import org.ballerinalang.langserver.commons.command.LSCommandExecutorException; -import org.ballerinalang.langserver.commons.command.spi.LSCommandExecutor; -import org.ballerinalang.langserver.contexts.ContextBuilder; -import org.ballerinalang.langserver.diagnostic.DiagnosticsHelper; -import org.ballerinalang.langserver.exception.UserErrorException; -import org.ballerinalang.util.diagnostic.DiagnosticErrorCode; -import org.eclipse.lsp4j.MessageType; -import org.eclipse.lsp4j.Position; -import org.eclipse.lsp4j.ProgressParams; -import org.eclipse.lsp4j.WorkDoneProgressBegin; -import org.eclipse.lsp4j.WorkDoneProgressCreateParams; -import org.eclipse.lsp4j.WorkDoneProgressEnd; -import org.eclipse.lsp4j.jsonrpc.messages.Either; - -import java.nio.file.Path; -import java.util.Optional; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.CompletableFuture; - -/** - * Command executor for generating modules for client declaration. - * - * @since 2201.3.0 - */ -@JavaSPIService("org.ballerinalang.langserver.commons.command.spi.LSCommandExecutor") -public class GenerateModuleForClientDeclExecutor implements LSCommandExecutor { - - public static final String COMMAND = "GENERATE_MODULE_FOR_CLIENT_DECL"; - - public static final Set DIAGNOSTIC_CODES = Set.of( - DiagnosticErrorCode.NO_MODULE_GENERATED_FOR_CLIENT_DECL.diagnosticId(), "BCE5303"); - - @Override - public Object execute(ExecuteCommandContext context) throws LSCommandExecutorException { - String fileUri = null; - for (CommandArgument arg : context.getArguments()) { - switch (arg.key()) { - case CommandConstants.ARG_KEY_DOC_URI: - fileUri = arg.valueAs(String.class); - break; - default: - //continue - } - } - - String taskId = UUID.randomUUID().toString(); - Path filePath = PathUtil.getPathFromURI(fileUri) - .orElseThrow(() -> new UserErrorException("Couldn't determine file path")); - - Project project = context.workspace().project(filePath) - .orElseThrow(() -> new UserErrorException("Failed to resolve project for provided file URI")); - - ExtendedLanguageClient languageClient = context.getLanguageClient(); - LSClientLogger clientLogger = LSClientLogger.getInstance(context.languageServercontext()); - - CompletableFuture - .runAsync(() -> { - clientLogger.logTrace("Generating modules for client declarations"); - - // Initialize progress notification - WorkDoneProgressCreateParams workDoneProgressCreateParams = new WorkDoneProgressCreateParams(); - workDoneProgressCreateParams.setToken(taskId); - languageClient.createProgress(workDoneProgressCreateParams); - - // Start progress - WorkDoneProgressBegin beginNotification = new WorkDoneProgressBegin(); - beginNotification.setTitle(CommandConstants.GENERATE_MODULE_FOR_CLIENT_DECLARATION_TITLE); - beginNotification.setCancellable(false); - beginNotification.setMessage("Generating modules for client declarations"); - languageClient.notifyProgress(new ProgressParams(Either.forLeft(taskId), - Either.forLeft(beginNotification))); - }) - .thenRunAsync(() -> { - Optional idlClientGeneratorResult = - context.workspace().waitAndRunIDLGeneratorPlugins(filePath, project); - boolean diagnosticNotResolved = true; - if (idlClientGeneratorResult.isPresent()) { - diagnosticNotResolved = idlClientGeneratorResult.get().reportedDiagnostics().diagnostics() - .stream().anyMatch(diagnostic -> - DIAGNOSTIC_CODES.contains(diagnostic.diagnosticInfo().code())); - } - if (diagnosticNotResolved) { - throw new UserErrorException("Failed to generate modules for client declarations"); - } - }) - .thenRunAsync(() -> { - DocumentServiceContext docContext = ContextBuilder.buildDocumentServiceContext( - filePath.toUri().toString(), - context.workspace(), LSContextOperation.TXT_DID_CHANGE, - context.languageServercontext()); - DiagnosticsHelper.getInstance(context.languageServercontext()) - .schedulePublishDiagnostics(languageClient, docContext); - }) - .whenComplete((result, throwable) -> { - boolean failed = false; - if (throwable != null) { - failed = true; - clientLogger.logError(LSContextOperation.TXT_RESOLVE_CODE_ACTION, - "Generate modules for client declarations failed : " + project.sourceRoot().toString(), - throwable, null, (Position) null); - if (throwable.getCause() instanceof UserErrorException) { - String errorMessage = throwable.getCause().getMessage(); - CommandUtil.notifyClient(languageClient, MessageType.Error, errorMessage); - } else { - CommandUtil.notifyClient(languageClient, MessageType.Error, - "Failed to generate modules for " + "client declarations"); - } - } else { - CommandUtil - .notifyClient(languageClient, MessageType.Info, - "Modules for client declarations generated successfully!"); - clientLogger - .logTrace("Finished generating modules for client declarations " - + project.sourceRoot().toString()); - } - WorkDoneProgressEnd endNotification = new WorkDoneProgressEnd(); - if (failed) { - endNotification.setMessage("Failed to generate modules for client declarations!"); - } else { - endNotification.setMessage("Generated modules for client declarations successfully!"); - } - languageClient.notifyProgress(new ProgressParams(Either.forLeft(taskId), - Either.forLeft(endNotification))); - - }); - return new Object(); - } - - @Override - public String getCommand() { - return COMMAND; - } -} diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/ModuleUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/ModuleUtil.java index 1503cd50fcc3..7c0b9e4cd222 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/ModuleUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/ModuleUtil.java @@ -17,7 +17,6 @@ import io.ballerina.compiler.api.ModuleID; import io.ballerina.compiler.api.symbols.ClassSymbol; -import io.ballerina.compiler.api.symbols.ClientDeclSymbol; import io.ballerina.compiler.api.symbols.ModuleSymbol; import io.ballerina.compiler.api.symbols.Symbol; import io.ballerina.compiler.api.symbols.TypeDefinitionSymbol; @@ -45,7 +44,6 @@ import java.util.Optional; import java.util.stream.Collectors; -import static io.ballerina.compiler.api.symbols.SymbolKind.CLIENT_DECLARATION; import static io.ballerina.compiler.api.symbols.SymbolKind.MODULE; /** @@ -104,26 +102,6 @@ public static Optional searchModuleForAlias(PositionedOperationCon return Optional.empty(); } - /** - * Get the client declaration symbol associated with the given alias. - * - * @param context Language server operation context - * @param alias alias value - * @return {@link Optional} scope entry for the client declaration symbol - */ - public static Optional searchClientDeclarationForAlias(PositionedOperationContext context, - String alias) { - List visibleSymbols = context.visibleSymbols(context.getCursorPosition()); - for (Symbol symbol : visibleSymbols) { - if (symbol.kind() == CLIENT_DECLARATION && symbol.getModule().isPresent() - && Objects.equals(symbol.getName().orElse(null), alias)) { - return Optional.of(((ClientDeclSymbol) symbol)); - } - } - - return Optional.empty(); - } - /** * Returns module prefix and process imports required. * diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/AbstractCompletionProvider.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/AbstractCompletionProvider.java index 027fcfddd171..28815dac7ec0 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/AbstractCompletionProvider.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/AbstractCompletionProvider.java @@ -18,7 +18,6 @@ package org.ballerinalang.langserver.completions.providers; import io.ballerina.compiler.api.symbols.ClassSymbol; -import io.ballerina.compiler.api.symbols.ClientDeclSymbol; import io.ballerina.compiler.api.symbols.ConstantSymbol; import io.ballerina.compiler.api.symbols.FunctionSymbol; import io.ballerina.compiler.api.symbols.FunctionTypeSymbol; @@ -324,30 +323,10 @@ protected List getTypeDescContextItems(BallerinaCompletionCont List completionItems = new ArrayList<>(); completionItems.addAll(this.getTypeItems(context)); completionItems.addAll(this.getModuleCompletionItems(context)); - completionItems.addAll(this.getClientDeclarationCompletionItems(context)); return completionItems; } - /** - * Get the completion item for a client declaration both statement level and module level. - * - * @param context Ballerina Completion context - * @return {@link List} List of client declaration completion items - */ - private List getClientDeclarationCompletionItems(BallerinaCompletionContext context) { - List visibleSymbols = context.visibleSymbols(context.getCursorPosition()); - List completionItems = new ArrayList<>(); - visibleSymbols.stream() - .filter(symbol -> symbol.kind() == SymbolKind.CLIENT_DECLARATION && symbol.getName().isPresent()) - .forEach(symbol -> { - String prefix = symbol.getName().get(); - CompletionItem item = this.getModuleCompletionItem(prefix, prefix, new ArrayList<>(), prefix); - completionItems.add(new SymbolCompletionItem(context, symbol, item)); - }); - return completionItems; - } - /** * Get the completion item for a package import. * If the package is already imported, additional text edit for the import statement will not be added. @@ -837,36 +816,4 @@ protected void sortByAssignability(BallerinaCompletionContext context, LSComplet completionItem.getCompletionItem().setSortText(sortText); } - - /** - * Get the completion item list for client declaration module prefix reference, when the node is within the - * qualified name reference node. - * - * @param context Ballerina Completion Context - * @param qNameRef Qualified Name Reference Node - * @param predicate Predicate to filter symbols - * @return Client Declaration Completion Item List - */ - protected List getClientDeclCompletionItemList(BallerinaCompletionContext context, - QualifiedNameReferenceNode qNameRef, - Predicate predicate) { - Optional clientDeclSymbol = ModuleUtil.searchClientDeclarationForAlias(context, - QNameRefCompletionUtil.getAlias(qNameRef)); - List clientDeclContent = clientDeclSymbol.map(symbol -> symbol.moduleSymbol().allSymbols().stream() - .filter(predicate) - .collect(Collectors.toList())) - .orElseGet(ArrayList::new); - - List completionItemList = this.getCompletionItemList(clientDeclContent, context); - String clientKW = ItemResolverConstants.CLIENT; - for (LSCompletionItem item: completionItemList) { - CompletionItem cItem = item.getCompletionItem(); - if (cItem.getLabel().equals(CommonUtil.escapeReservedKeyword(clientKW))) { - cItem.setLabel(clientKW); - cItem.setInsertText(clientKW); - } - } - - return completionItemList; - } } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/AnnotationNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/AnnotationNodeContext.java index 7207a9e80772..10e57d36a52a 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/AnnotationNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/AnnotationNodeContext.java @@ -194,9 +194,6 @@ private boolean matchingAnnotation(AnnotationSymbol symbol, AnnotationNode annot && ((ObjectConstructorExpressionNode) attachedNode).objectTypeQualifiers() .stream() .anyMatch(token -> token.kind() == SyntaxKind.SERVICE_KEYWORD); - case MODULE_CLIENT_DECLARATION: - case CLIENT_DECLARATION: - return AnnotationUtil.hasAttachment(symbol, AnnotationAttachPoint.CLIENT); default: return false; } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/BlockNodeContextProvider.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/BlockNodeContextProvider.java index 7a43a8ab44af..b0b39da85f4c 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/BlockNodeContextProvider.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/BlockNodeContextProvider.java @@ -79,7 +79,6 @@ public List getCompletions(BallerinaCompletionContext context, List moduleContent = QNameRefCompletionUtil.getModuleContent(context, nameRef, filter); completionItems.addAll(this.getCompletionItemList(moduleContent, context)); - completionItems.addAll(this.getClientDeclCompletionItemList(context, nameRef, filter)); } else if (onSuggestionsAfterQualifiers(context, nodeAtCursor)) { completionItems.addAll(getCompletionItemsOnQualifiers(nodeAtCursor, context)); } else { @@ -105,7 +104,6 @@ protected List getStaticCompletionItems(BallerinaCompletionCon ArrayList completionItems = new ArrayList<>(); // Remove the function keyword suggestion from here, since it is suggested by typeItems API - completionItems.add(new SnippetCompletionItem(context, Snippet.DEF_CLIENT_DECLARATION.get())); completionItems.add(new SnippetCompletionItem(context, Snippet.STMT_NAMESPACE_DECLARATION.get())); completionItems.add(new SnippetCompletionItem(context, Snippet.KW_XMLNS.get())); completionItems.add(new SnippetCompletionItem(context, Snippet.KW_VAR.get())); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ClientDeclarationNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ClientDeclarationNodeContext.java deleted file mode 100644 index 18071eb14504..000000000000 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ClientDeclarationNodeContext.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://wso2.com) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.ballerinalang.langserver.completions.providers.context; - -import io.ballerina.compiler.syntax.tree.BasicLiteralNode; -import io.ballerina.compiler.syntax.tree.ClientDeclarationNode; -import org.ballerinalang.annotation.JavaSPIService; -import org.ballerinalang.langserver.commons.BallerinaCompletionContext; -import org.ballerinalang.langserver.commons.completion.LSCompletionItem; -import org.ballerinalang.langserver.completions.SnippetCompletionItem; -import org.ballerinalang.langserver.completions.providers.AbstractCompletionProvider; -import org.ballerinalang.langserver.completions.util.Snippet; - -import java.util.ArrayList; -import java.util.List; - -/** - * Completion provider for {@link ClientDeclarationNode} context. - * - * @since 2201.3.0 - */ -@JavaSPIService("org.ballerinalang.langserver.commons.completion.spi.BallerinaCompletionProvider") -public class ClientDeclarationNodeContext extends AbstractCompletionProvider { - - public ClientDeclarationNodeContext() { - super(ClientDeclarationNode.class); - } - - @Override - public List getCompletions(BallerinaCompletionContext context, - ClientDeclarationNode node) { - List completionItems = new ArrayList<>(); - - if (this.onSuggestClientUri(context, node)) { - return completionItems; - } else if (this.onSuggestAsKeyword(context, node)) { - completionItems.add(new SnippetCompletionItem(context, Snippet.KW_AS.get())); - } - this.sort(context, node, completionItems); - - return completionItems; - } - - private boolean onSuggestClientUri(BallerinaCompletionContext context, ClientDeclarationNode node) { - int cursor = context.getCursorPositionInTree(); - BasicLiteralNode clientUri = node.clientUri(); - - return node.clientKeyword().textRange().endOffset() < cursor - && node.asKeyword().textRange().startOffset() > cursor - && (clientUri.isMissing() || cursor <= clientUri.textRange().endOffset()); - } - - private boolean onSuggestAsKeyword(BallerinaCompletionContext context, ClientDeclarationNode node) { - int cursor = context.getCursorPositionInTree(); - BasicLiteralNode clientUri = node.clientUri(); - - return !clientUri.isMissing() && cursor > clientUri.textRange().endOffset() && node.asKeyword().isMissing(); - } -} diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ModuleClientDeclarationNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ModuleClientDeclarationNodeContext.java deleted file mode 100644 index 610278899646..000000000000 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ModuleClientDeclarationNodeContext.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://wso2.com) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.ballerinalang.langserver.completions.providers.context; - -import io.ballerina.compiler.syntax.tree.BasicLiteralNode; -import io.ballerina.compiler.syntax.tree.ModuleClientDeclarationNode; -import io.ballerina.compiler.syntax.tree.Token; -import org.ballerinalang.annotation.JavaSPIService; -import org.ballerinalang.langserver.commons.BallerinaCompletionContext; -import org.ballerinalang.langserver.commons.completion.LSCompletionItem; -import org.ballerinalang.langserver.completions.SnippetCompletionItem; -import org.ballerinalang.langserver.completions.providers.AbstractCompletionProvider; -import org.ballerinalang.langserver.completions.util.Snippet; - -import java.util.ArrayList; -import java.util.List; - -/** - * Completion provider for {@link ModuleClientDeclarationNode} context. - * - * @since 2201.3.0 - */ -@JavaSPIService("org.ballerinalang.langserver.commons.completion.spi.BallerinaCompletionProvider") -public class ModuleClientDeclarationNodeContext extends AbstractCompletionProvider { - - public ModuleClientDeclarationNodeContext() { - super(ModuleClientDeclarationNode.class); - } - - @Override - public List getCompletions(BallerinaCompletionContext context, - ModuleClientDeclarationNode node) { - List completionItems = new ArrayList<>(); - - if (this.onSuggestClientUri(context, node)) { - return completionItems; - } else if (this.onSuggestAsKeyword(context, node)) { - completionItems.add(new SnippetCompletionItem(context, Snippet.KW_AS.get())); - } - this.sort(context, node, completionItems); - - return completionItems; - } - - private boolean onSuggestClientUri(BallerinaCompletionContext context, ModuleClientDeclarationNode node) { - int cursor = context.getCursorPositionInTree(); - BasicLiteralNode clientUri = node.clientUri(); - - return node.clientKeyword().textRange().endOffset() < cursor - && node.asKeyword().textRange().startOffset() > cursor - && (clientUri.isMissing() || cursor <= clientUri.textRange().endOffset()); - } - - private boolean onSuggestAsKeyword(BallerinaCompletionContext context, ModuleClientDeclarationNode node) { - int cursor = context.getCursorPositionInTree(); - BasicLiteralNode clientUri = node.clientUri(); - - return !clientUri.isMissing() && cursor > clientUri.textRange().endOffset() && node.asKeyword().isMissing(); - } - - @Override - public boolean onPreValidation(BallerinaCompletionContext context, ModuleClientDeclarationNode node) { - int cursor = context.getCursorPositionInTree(); - Token clientKeyword = node.clientKeyword(); - - return !clientKeyword.isMissing() && cursor > clientKeyword.textRange().endOffset() - && cursor <= node.semicolonToken().textRange().endOffset(); - } -} diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ModulePartNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ModulePartNodeContext.java index 6b0eac57e219..de3fa7f29b0f 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ModulePartNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ModulePartNodeContext.java @@ -170,8 +170,6 @@ private List getModulePartContextItems(BallerinaCompletionCont List types = QNameRefCompletionUtil.getModuleContent(context, (QualifiedNameReferenceNode) nodeAtCursor, predicate); completionItems.addAll(this.getCompletionItemList(types, context)); - QualifiedNameReferenceNode nameRef = (QualifiedNameReferenceNode) nodeAtCursor; - completionItems.addAll(this.getClientDeclCompletionItemList(context, nameRef, predicate)); return completionItems; } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ModulePartNodeContextUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ModulePartNodeContextUtil.java index c69df2977a03..cbd85b62e94d 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ModulePartNodeContextUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ModulePartNodeContextUtil.java @@ -70,7 +70,7 @@ public static List getTopLevelItems(BallerinaCompletionContext Snippet.KW_CONFIGURABLE, Snippet.DEF_ANNOTATION, Snippet.DEF_RECORD, Snippet.STMT_NAMESPACE_DECLARATION, Snippet.DEF_OBJECT_SNIPPET, Snippet.DEF_CLASS, Snippet.DEF_ENUM, Snippet.DEF_CLOSED_RECORD, Snippet.DEF_ERROR_TYPE, Snippet.DEF_TABLE_TYPE_DESC, Snippet.DEF_TABLE_WITH_KEY_TYPE_DESC, - Snippet.DEF_STREAM, Snippet.DEF_SERVICE_COMMON, Snippet.DEF_CLIENT_DECLARATION + Snippet.DEF_STREAM, Snippet.DEF_SERVICE_COMMON ); snippets.forEach(snippet -> completionItems.add(new SnippetCompletionItem(context, snippet.get()))); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/Snippet.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/Snippet.java index 34b7570f637d..1042cbd86c9c 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/Snippet.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/Snippet.java @@ -106,8 +106,6 @@ public enum Snippet { // DEF_SERVICE_VAR(SnippetGenerator.getServiceVarSnippet()), - DEF_CLIENT_DECLARATION(SnippetGenerator.getClientDeclarationSnippet()), - DEF_CLASS(SnippetGenerator.getClassDefSnippet()), DEF_ENUM(SnippetGenerator.getEnumDefSnippet()), diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/SnippetGenerator.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/SnippetGenerator.java index 70bdc32bc72f..936c2cbd53db 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/SnippetGenerator.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/SnippetGenerator.java @@ -587,18 +587,6 @@ public static SnippetBlock getXMLNSDeclarationSnippet() { ItemResolverConstants.SNIPPET_TYPE, Kind.STATEMENT); } - /** - * Get Namespace Declaration Statement Snippet Block. - * - * @return {@link SnippetBlock} Generated Snippet Block - */ - public static SnippetBlock getClientDeclarationSnippet() { - String snippet = "client \"${1}\" as ${2:clientName};"; - - return new SnippetBlock(ItemResolverConstants.CLIENT, ItemResolverConstants.CLIENT, snippet, - ItemResolverConstants.SNIPPET_TYPE, Kind.STATEMENT); - } - /** * Get Object Type Descriptor Snippet Block. * diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToConstantTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToConstantTest.java index ced00f76fbf4..b8088bfccd13 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToConstantTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToConstantTest.java @@ -71,9 +71,7 @@ public Object[][] negativeDataProvider() { {"extractInvalidExprStmtToConstant.json"}, {"extractExpressionToConstant1.json"}, {"extractExpressionToConstant2.json"}, - {"extractExpressionToConstant3.json"}, - {"extractServiceUriInModuleClientDeclToConstant.json"}, - {"extractServiceUriInClientDeclarationToConstant.json"} + {"extractExpressionToConstant3.json"} }; } diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToFunctionCodeActionTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToFunctionCodeActionTest.java index 6caa7b709cd6..ac374f66ce5a 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToFunctionCodeActionTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToFunctionCodeActionTest.java @@ -258,9 +258,7 @@ public Object[][] negativeDataProvider() { {"neg_extract_to_function_exprs_pos_in_type_definition.json"}, {"neg_extract_to_function_exprs_pos_in_function_call_with_qualNameRef.json"}, {"neg_extract_to_function_exprs_pos_mapping_cons_cur_inside_fields.json"}, - {"negative_extract_to_function_exprs_pos_function_call_in_let_expr.json"}, - {"neg_extract_to_function_exprs_pos_service_uri_in_module_client_declaration.json"}, - {"neg_extract_to_function_exprs_pos_service_uri_in_client_declaration.json"}, + {"negative_extract_to_function_exprs_pos_function_call_in_let_expr.json"} }; } diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToLocalVarTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToLocalVarTest.java index 813e68083251..6fd0b249688e 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToLocalVarTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToLocalVarTest.java @@ -95,9 +95,7 @@ public Object[][] negativeDataProvider() { {"extractToVariableInQNameRefNegative.json"}, {"extractToVariableInModLevelDeclNegative.json"}, {"extractToVariableInModLevelDeclNegative2.json"}, - {"extractToVariableInStartActionNegative.json"}, - {"extractToVariableInClientDeclNegative.json"}, - {"extractToVariableInModuleClientDeclNegative.json"} + {"extractToVariableInStartActionNegative.json"} }; } diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/GenerateModuleForClientDeclCodeActionTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/GenerateModuleForClientDeclCodeActionTest.java deleted file mode 100644 index 4844467ecdb5..000000000000 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/GenerateModuleForClientDeclCodeActionTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://wso2.com) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.ballerinalang.langserver.codeaction; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import org.ballerinalang.langserver.common.utils.PathUtil; -import org.ballerinalang.langserver.commons.workspace.WorkspaceDocumentException; -import org.ballerinalang.langserver.util.TestUtil; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -import java.io.IOException; -import java.nio.file.Path; -import java.util.Optional; - -/** - * Unit tests for {@link org.ballerinalang.langserver.codeaction.providers.GenerateModuleForClientDeclCodeAction} . - * - * @since 2201.3.0 - */ -public class GenerateModuleForClientDeclCodeActionTest extends AbstractCodeActionTest { - - @Test(dataProvider = "codeaction-data-provider") - @Override - public void test(String config) throws IOException, WorkspaceDocumentException { - super.test(config); - } - - @DataProvider(name = "codeaction-data-provider") - @Override - public Object[][] dataProvider() { - return new Object[][]{ - {"generate_module_for_client_decl1.json"} - }; - } - - @Override - public String getResourceDir() { - return "generate-module-for-client-decl"; - } - - @Override - protected boolean validateAndModifyArguments(JsonObject actualCommand, - JsonArray actualArgs, - JsonArray expArgs, - Path sourceRoot, - Path sourcePath) { - for (JsonElement actualArg : actualArgs) { - JsonObject arg = actualArg.getAsJsonObject(); - if ("doc.uri".equals(arg.get("key").getAsString())) { - Optional docPath = PathUtil.getPathFromURI(arg.get("value").getAsString()); - Optional actualFilePath = - docPath.map(path -> path.toString().replace(sourceRoot.toString(), "")); - JsonObject docUriObj = expArgs.get(0).getAsJsonObject(); - String expectedFilePath = docUriObj.get("value").getAsString(); - if (docPath.isPresent()) { - // We just check file names, since one refers to file in build/ while - // the other refers to the file in test resources - String actualPath = actualFilePath.get(); - if (actualFilePath.get().startsWith("/") || actualFilePath.get().startsWith("\\")) { - actualPath = actualFilePath.get().substring(1); - } - if (sourceRoot.resolve(actualPath).equals(sourceRoot.resolve(expectedFilePath))) { - return true; - } - JsonArray newArgs = new JsonArray(); - docUriObj.addProperty("value", actualPath); - newArgs.add(docUriObj); - actualCommand.add("arguments", newArgs); - return false; - } - return false; - } - } - return TestUtil.isArgumentsSubArray(actualArgs, expArgs); - } -} diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/command/GenerateModuleForClientDeclExecutorTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/command/GenerateModuleForClientDeclExecutorTest.java deleted file mode 100644 index e1f754f102a4..000000000000 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/command/GenerateModuleForClientDeclExecutorTest.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://wso2.com) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.ballerinalang.langserver.command; - -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import io.ballerina.projects.DiagnosticResult; -import org.ballerinalang.langserver.BallerinaLanguageServer; -import org.ballerinalang.langserver.command.executors.GenerateModuleForClientDeclExecutor; -import org.ballerinalang.langserver.common.constants.CommandConstants; -import org.ballerinalang.langserver.commons.LanguageServerContext; -import org.ballerinalang.langserver.commons.command.CommandArgument; -import org.ballerinalang.langserver.commons.workspace.WorkspaceManager; -import org.ballerinalang.langserver.util.TestUtil; -import org.ballerinalang.util.diagnostic.DiagnosticErrorCode; -import org.eclipse.lsp4j.ExecuteCommandParams; -import org.eclipse.lsp4j.jsonrpc.Endpoint; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.List; - -/** - * Unit Test for {@link org.ballerinalang.langserver.command.executors.GenerateModuleForClientDeclExecutor}. - * - * @since 2201.3.0 - */ -public class GenerateModuleForClientDeclExecutorTest { - - private BallerinaLanguageServer languageServer; - - private LanguageServerContext serverContext; - - private WorkspaceManager workspaceManager; - - protected Endpoint serviceEndpoint; - - private final Path resourcesPath = - new File(getClass().getClassLoader().getResource("command").getFile()).toPath(); - - private final Path sourcesDir = new File(getClass().getClassLoader() - .getResource("command").getFile()).toPath(); - - private final JsonParser parser = new JsonParser(); - private final Gson gson = new Gson(); - - @BeforeClass - public void init() throws Exception { - System.clearProperty("LANG_REPO_BUILD"); - this.languageServer = new BallerinaLanguageServer(); - this.serverContext = languageServer.getServerContext(); - this.workspaceManager = languageServer.getWorkspaceManager(); - this.serviceEndpoint = TestUtil.initializeLanguageSever(languageServer); - } - - @Test - public void test() throws IOException, InterruptedException { - Path sourcePath = sourcesDir.resolve("generate-module-for-client-decl") - .resolve("source").resolve("client_decl").resolve("main.bal"); - - TestUtil.openDocument(serviceEndpoint, sourcePath); - DiagnosticResult diagnosticResult = workspaceManager.waitAndGetPackageCompilation(sourcePath) - .get().diagnosticResult(); - long noModuleGeneratedCount = diagnosticResult.diagnostics().stream() - .filter(diagnostic -> DiagnosticErrorCode.NO_MODULE_GENERATED_FOR_CLIENT_DECL.diagnosticId() - .equals(diagnostic.diagnosticInfo().code())) - .count(); - Assert.assertEquals(noModuleGeneratedCount, 1); - - List args = new ArrayList<>(); - args.add(CommandArgument.from(CommandConstants.ARG_KEY_DOC_URI, sourcePath.toUri().toString())); - JsonObject response = getCommandResponse(args, GenerateModuleForClientDeclExecutor.COMMAND); - Assert.assertNotNull(response); - - Thread.sleep(20 * 1000); - - diagnosticResult = workspaceManager.waitAndGetPackageCompilation(sourcePath) - .get().diagnosticResult(); - noModuleGeneratedCount = diagnosticResult.diagnostics().stream() - .filter(diagnostic -> DiagnosticErrorCode.NO_MODULE_GENERATED_FOR_CLIENT_DECL.diagnosticId() - .equals(diagnostic.diagnosticInfo().code())) - .count(); - //Todo:Diagnostic does not clear - Assert.assertEquals(noModuleGeneratedCount, 0); - - TestUtil.closeDocument(serviceEndpoint, sourcePath); - } - - @AfterClass - public void shutdown() { - languageServer.shutdown(); - System.setProperty("LANG_REPO_BUILD", "true"); - } - - private JsonObject getCommandResponse(List args, String command) { - List argsList = argsToJson(args); - ExecuteCommandParams params = new ExecuteCommandParams(command, argsList); - String response = TestUtil.getExecuteCommandResponse(params, this.serviceEndpoint) - .replace("\\r\\n", "\\n"); - JsonObject responseJson = parser.parse(response).getAsJsonObject(); - responseJson.remove("id"); - return responseJson; - } - - private List argsToJson(List args) { - List jsonArgs = new ArrayList<>(); - for (Object arg : args) { - jsonArgs.add((JsonObject) gson.toJsonTree(arg)); - } - return jsonArgs; - } -} diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/completion/ClientDeclarationContextTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/completion/ClientDeclarationContextTest.java deleted file mode 100644 index 5fc2fea3bb90..000000000000 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/completion/ClientDeclarationContextTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://wso2.com) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.ballerinalang.langserver.completion; - -import org.ballerinalang.langserver.commons.workspace.WorkspaceDocumentException; -import org.ballerinalang.langserver.completions.providers.context.ClientDeclarationNodeContext; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -/** - * Completion tests for {@link ClientDeclarationNodeContext}. - * - * @since 2201.3.0 - */ -public class ClientDeclarationContextTest extends CompletionTest { - - @Test(dataProvider = "completion-data-provider") - public void test(String config, String configPath) throws IOException, WorkspaceDocumentException { - super.test(config, configPath); - } - - @DataProvider(name = "completion-data-provider") - @Override - public Object[][] dataProvider() { - return this.getConfigsList(); - } - - @Override - public String getTestResourceDir() { - return "client_declaration_context"; - } - - @Override - public List skipList() { - List skipList = new ArrayList<>(); - // Skipping due to https://github.com/ballerina-platform/ballerina-lang/issues/38234 - skipList.add("completions_inside_generated_idl_client.json"); - return skipList; - } -} diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/completion/ModuleClientDeclarationContextTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/completion/ModuleClientDeclarationContextTest.java deleted file mode 100644 index d5171028430c..000000000000 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/completion/ModuleClientDeclarationContextTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://wso2.com) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.ballerinalang.langserver.completion; - -import org.ballerinalang.langserver.commons.workspace.WorkspaceDocumentException; -import org.ballerinalang.langserver.completions.providers.context.ModuleClientDeclarationNodeContext; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -import java.io.IOException; -import java.util.Collections; -import java.util.List; - -/** - * Completion tests for {@link ModuleClientDeclarationNodeContext}. - * - * @since 2201.3.0 - */ -public class ModuleClientDeclarationContextTest extends CompletionTest { - - @BeforeClass - @Override - public void init() throws Exception { - super.init(); - preLoadAndInit(); - } - - @Test(dataProvider = "completion-data-provider") - public void test(String config, String configPath) throws IOException, WorkspaceDocumentException { - super.test(config, configPath); - } - - @DataProvider(name = "completion-data-provider") - @Override - public Object[][] dataProvider() { - return this.getConfigsList(); - } - - @Override - public String getTestResourceDir() { - return "module_client_declaration_context"; - } - - @Override - public List skipList() { - return Collections.emptyList(); - } -} diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/config/extractServiceUriInClientDeclarationToConstant.json b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/config/extractServiceUriInClientDeclarationToConstant.json deleted file mode 100644 index d59860f0db17..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/config/extractServiceUriInClientDeclarationToConstant.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "position": { - "line": 3, - "character": 42 - }, - "source": "extractToConstantClientDeclarationsNegative.bal", - "expected": [ - { - "title": "Extract to constant" - } - ] -} diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/config/extractServiceUriInModuleClientDeclToConstant.json b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/config/extractServiceUriInModuleClientDeclToConstant.json deleted file mode 100644 index 0e2abdeb5d32..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/config/extractServiceUriInModuleClientDeclToConstant.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "position": { - "line": 0, - "character": 41 - }, - "source": "extractToConstantClientDeclarationsNegative.bal", - "expected": [ - { - "title": "Extract to constant" - } - ] -} diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/source/extractToConstantClientDeclarationsNegative.bal b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/source/extractToConstantClientDeclarationsNegative.bal deleted file mode 100644 index 65cf92867b6d..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/source/extractToConstantClientDeclarationsNegative.bal +++ /dev/null @@ -1,5 +0,0 @@ -client "https://postman-echo.com/get?name=projectapiclientplugin" as myapi1; - -public function main() { - client "https://postman-echo.com/get?name=projectapiclientplugin" as myapi2; -} diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/config/neg_extract_to_function_exprs_pos_service_uri_in_client_declaration.json b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/config/neg_extract_to_function_exprs_pos_service_uri_in_client_declaration.json deleted file mode 100644 index 8ca6ba4ec76f..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/config/neg_extract_to_function_exprs_pos_service_uri_in_client_declaration.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "position": { - "line": 1, - "character": 34 - }, - "source": "neg_extract_to_function_exprs_pos_service_uri_in_client_declaration.bal", - "expected": [ - { - "title": "Extract to function" - } - ], - "description": "Extract to function negative case for client declarations" -} diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/config/neg_extract_to_function_exprs_pos_service_uri_in_module_client_declaration.json b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/config/neg_extract_to_function_exprs_pos_service_uri_in_module_client_declaration.json deleted file mode 100644 index 913a26f1840b..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/config/neg_extract_to_function_exprs_pos_service_uri_in_module_client_declaration.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "position": { - "line": 0, - "character": 44 - }, - "source": "neg_extract_to_function_exprs_pos_service_uri_in_module_client_declaration.bal", - "expected": [ - { - "title": "Extract to function" - } - ], - "description": "Extract to function negative case for module client declarations" -} diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/source/neg_extract_to_function_exprs_pos_service_uri_in_client_declaration.bal b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/source/neg_extract_to_function_exprs_pos_service_uri_in_client_declaration.bal deleted file mode 100644 index db8452a355cc..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/source/neg_extract_to_function_exprs_pos_service_uri_in_client_declaration.bal +++ /dev/null @@ -1,3 +0,0 @@ -function testFunction() { - client "https://postman-echo.com/get?name=projectapiclientplugin" as myapi; -} diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/source/neg_extract_to_function_exprs_pos_service_uri_in_module_client_declaration.bal b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/source/neg_extract_to_function_exprs_pos_service_uri_in_module_client_declaration.bal deleted file mode 100644 index e6288b16dc16..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/source/neg_extract_to_function_exprs_pos_service_uri_in_module_client_declaration.bal +++ /dev/null @@ -1 +0,0 @@ -client "https://postman-echo.com/get?name=projectapiclientplugin" as myapi; diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-local-variable/config/extractToVariableInClientDeclNegative.json b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-local-variable/config/extractToVariableInClientDeclNegative.json deleted file mode 100644 index 39257dff35ba..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-local-variable/config/extractToVariableInClientDeclNegative.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "position": { - "line": 3, - "character": 50 - }, - "source": "extractToVariableInClientDecl.bal", - "expected": [ - { - "title": "Extract to local variable" - } - ] -} diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-local-variable/config/extractToVariableInModuleClientDeclNegative.json b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-local-variable/config/extractToVariableInModuleClientDeclNegative.json deleted file mode 100644 index 91f1641f0e75..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-local-variable/config/extractToVariableInModuleClientDeclNegative.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "position": { - "line": 0, - "character": 44 - }, - "source": "extractToVariableInClientDecl.bal", - "expected": [ - { - "title": "Extract to local variable" - } - ] -} diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-local-variable/source/extractToVariableInClientDecl.bal b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-local-variable/source/extractToVariableInClientDecl.bal deleted file mode 100644 index 65cf92867b6d..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-local-variable/source/extractToVariableInClientDecl.bal +++ /dev/null @@ -1,5 +0,0 @@ -client "https://postman-echo.com/get?name=projectapiclientplugin" as myapi1; - -public function main() { - client "https://postman-echo.com/get?name=projectapiclientplugin" as myapi2; -} diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/generate-module-for-client-decl/config/generate_module_for_client_decl1.json b/language-server/modules/langserver-core/src/test/resources/codeaction/generate-module-for-client-decl/config/generate_module_for_client_decl1.json deleted file mode 100644 index e926100211df..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/codeaction/generate-module-for-client-decl/config/generate_module_for_client_decl1.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "position": { - "line": 1, - "character": 43 - }, - "source": "client_decl/main.bal", - "expected": [ - { - "title": "Generate module for client declaration", - "kind": "quickfix", - "command": { - "title": "Generate module for client declaration", - "command": "GENERATE_MODULE_FOR_CLIENT_DECL", - "arguments": [ - { - "key": "doc.uri", - "value": "client_decl/main.bal" - } - ] - }, - "resolvable": false - } - ] -} diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/generate-module-for-client-decl/source/client_decl/Ballerina.toml b/language-server/modules/langserver-core/src/test/resources/codeaction/generate-module-for-client-decl/source/client_decl/Ballerina.toml deleted file mode 100644 index 7270d1404c1d..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/codeaction/generate-module-for-client-decl/source/client_decl/Ballerina.toml +++ /dev/null @@ -1,7 +0,0 @@ -[package] -org = "lstest" -name = "client_decl" -version = "0.1.0" - -[build-options] -observabilityIncluded = false diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/generate-module-for-client-decl/source/client_decl/main.bal b/language-server/modules/langserver-core/src/test/resources/codeaction/generate-module-for-client-decl/source/client_decl/main.bal deleted file mode 100644 index 0340c8896f51..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/codeaction/generate-module-for-client-decl/source/client_decl/main.bal +++ /dev/null @@ -1,6 +0,0 @@ - -client "https://postman-echo.com/get?name=projectapiclientplugin" as myapi; - -public function main() { - myapi:client cli; -} diff --git a/language-server/modules/langserver-core/src/test/resources/command/generate-module-for-client-decl/source/client_decl/Ballerina.toml b/language-server/modules/langserver-core/src/test/resources/command/generate-module-for-client-decl/source/client_decl/Ballerina.toml deleted file mode 100644 index 7270d1404c1d..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/command/generate-module-for-client-decl/source/client_decl/Ballerina.toml +++ /dev/null @@ -1,7 +0,0 @@ -[package] -org = "lstest" -name = "client_decl" -version = "0.1.0" - -[build-options] -observabilityIncluded = false diff --git a/language-server/modules/langserver-core/src/test/resources/command/generate-module-for-client-decl/source/client_decl/main.bal b/language-server/modules/langserver-core/src/test/resources/command/generate-module-for-client-decl/source/client_decl/main.bal deleted file mode 100644 index 228b55e875f5..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/command/generate-module-for-client-decl/source/client_decl/main.bal +++ /dev/null @@ -1,6 +0,0 @@ - -client "https://postman-echo.com/get?name=projectapiclientplugin" as myapi; - -public function main() { - -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/clientDeclAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/clientDeclAnnotation1.json deleted file mode 100644 index dbe46ce912c9..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/clientDeclAnnotation1.json +++ /dev/null @@ -1,396 +0,0 @@ -{ - "position": { - "line": 3, - "character": 5 - }, - "source": "annotation_ctx/source/clientDeclAnnotation1.bal", - "items": [ - { - "label": "module1", - "kind": "Module", - "detail": "Module", - "sortText": "Q", - "filterText": "module1", - "insertText": "module1", - "insertTextFormat": "Snippet" - }, - { - "label": "ballerina/lang.test", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "test", - "insertText": "test", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.test;\n" - } - ] - }, - { - "label": "ballerina/lang.array", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "array", - "insertText": "array", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.array;\n" - } - ] - }, - { - "label": "ballerina/jballerina.java", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "java", - "insertText": "java", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/jballerina.java;\n" - } - ] - }, - { - "label": "ballerina/lang.value", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "value", - "insertText": "value", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.value;\n" - } - ] - }, - { - "label": "ballerina/lang.runtime", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "runtime", - "insertText": "runtime", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.runtime;\n" - } - ] - }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, - { - "label": "map", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "map", - "insertTextFormat": "Snippet" - }, - { - "label": "object", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "object", - "insertTextFormat": "Snippet" - }, - { - "label": "stream", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "stream", - "insertTextFormat": "Snippet" - }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, - { - "label": "table", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "table", - "insertTextFormat": "Snippet" - }, - { - "label": "transaction", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "transaction", - "insertTextFormat": "Snippet" - }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, - { - "label": "test/project2", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "project2", - "insertText": "project2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/project2;\n" - } - ] - }, - { - "label": "test/project1", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "project1", - "insertText": "project1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/project1;\n" - } - ] - }, - { - "label": "test/local_project2", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "local_project2", - "insertText": "local_project2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/local_project2;\n" - } - ] - }, - { - "label": "test/local_project1", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "local_project1", - "insertText": "local_project1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/local_project1;\n" - } - ] - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "commonAnnotation", - "kind": "Property", - "detail": "Annotation", - "sortText": "A", - "insertText": "commonAnnotation", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "clientAnnot1", - "kind": "Property", - "detail": "Annotation", - "sortText": "A", - "insertText": "clientAnnot1 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] - } - ] -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/clientDeclAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/clientDeclAnnotation2.json deleted file mode 100644 index 477cf94570de..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/clientDeclAnnotation2.json +++ /dev/null @@ -1,396 +0,0 @@ -{ - "position": { - "line": 3, - "character": 6 - }, - "source": "annotation_ctx/source/clientDeclAnnotation2.bal", - "items": [ - { - "label": "module1", - "kind": "Module", - "detail": "Module", - "sortText": "Q", - "filterText": "module1", - "insertText": "module1", - "insertTextFormat": "Snippet" - }, - { - "label": "ballerina/lang.test", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "test", - "insertText": "test", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.test;\n" - } - ] - }, - { - "label": "ballerina/lang.array", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "array", - "insertText": "array", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.array;\n" - } - ] - }, - { - "label": "ballerina/jballerina.java", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "java", - "insertText": "java", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/jballerina.java;\n" - } - ] - }, - { - "label": "ballerina/lang.value", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "value", - "insertText": "value", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.value;\n" - } - ] - }, - { - "label": "ballerina/lang.runtime", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "runtime", - "insertText": "runtime", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.runtime;\n" - } - ] - }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, - { - "label": "map", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "map", - "insertTextFormat": "Snippet" - }, - { - "label": "object", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "object", - "insertTextFormat": "Snippet" - }, - { - "label": "stream", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "stream", - "insertTextFormat": "Snippet" - }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, - { - "label": "table", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "table", - "insertTextFormat": "Snippet" - }, - { - "label": "transaction", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "transaction", - "insertTextFormat": "Snippet" - }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, - { - "label": "test/project2", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "project2", - "insertText": "project2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/project2;\n" - } - ] - }, - { - "label": "test/project1", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "project1", - "insertText": "project1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/project1;\n" - } - ] - }, - { - "label": "test/local_project2", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "local_project2", - "insertText": "local_project2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/local_project2;\n" - } - ] - }, - { - "label": "test/local_project1", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "local_project1", - "insertText": "local_project1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/local_project1;\n" - } - ] - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "commonAnnotation", - "kind": "Property", - "detail": "Annotation", - "sortText": "A", - "insertText": "commonAnnotation", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "clientAnnot1", - "kind": "Property", - "detail": "Annotation", - "sortText": "A", - "insertText": "clientAnnot1 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] - } - ] -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/clientDeclAnnotation3.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/clientDeclAnnotation3.json deleted file mode 100644 index 502eb692efbd..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/clientDeclAnnotation3.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "position": { - "line": 3, - "character": 13 - }, - "source": "annotation_ctx/source/clientDeclAnnotation3.bal", - "items": [ - { - "label": "annotationCommon", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "annotationCommon {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "sourceVarAnnotation1", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "sourceVarAnnotation1 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "sourceVarAnnotation2", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "sourceVarAnnotation2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "commonAnnotation1", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "commonAnnotation1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "commonAnnotation2", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "commonAnnotation2 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - } - ] -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/clientDeclAnnotation4.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/clientDeclAnnotation4.json deleted file mode 100644 index 236deec9b890..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/clientDeclAnnotation4.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "position": { - "line": 3, - "character": 14 - }, - "source": "annotation_ctx/source/clientDeclAnnotation4.bal", - "items": [ - { - "label": "annotationCommon", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "annotationCommon {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "commonAnnotation1", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "commonAnnotation1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "commonAnnotation2", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "commonAnnotation2 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "sourceClientDeclaration1", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "sourceClientDeclaration1 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "sourceClientDeclaration2", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "sourceClientDeclaration2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - } - ] -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClientDeclAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClientDeclAnnotation1.json deleted file mode 100644 index bcb00ea037b2..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClientDeclAnnotation1.json +++ /dev/null @@ -1,396 +0,0 @@ -{ - "position": { - "line": 2, - "character": 1 - }, - "source": "annotation_ctx/source/moduleClientDeclAnnotation1.bal", - "items": [ - { - "label": "module1", - "kind": "Module", - "detail": "Module", - "sortText": "Q", - "filterText": "module1", - "insertText": "module1", - "insertTextFormat": "Snippet" - }, - { - "label": "ballerina/lang.test", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "test", - "insertText": "test", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.test;\n" - } - ] - }, - { - "label": "ballerina/lang.array", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "array", - "insertText": "array", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.array;\n" - } - ] - }, - { - "label": "ballerina/jballerina.java", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "java", - "insertText": "java", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/jballerina.java;\n" - } - ] - }, - { - "label": "ballerina/lang.value", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "value", - "insertText": "value", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.value;\n" - } - ] - }, - { - "label": "ballerina/lang.runtime", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "runtime", - "insertText": "runtime", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.runtime;\n" - } - ] - }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, - { - "label": "map", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "map", - "insertTextFormat": "Snippet" - }, - { - "label": "object", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "object", - "insertTextFormat": "Snippet" - }, - { - "label": "stream", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "stream", - "insertTextFormat": "Snippet" - }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, - { - "label": "table", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "table", - "insertTextFormat": "Snippet" - }, - { - "label": "transaction", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "transaction", - "insertTextFormat": "Snippet" - }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, - { - "label": "test/project2", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "project2", - "insertText": "project2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/project2;\n" - } - ] - }, - { - "label": "test/project1", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "project1", - "insertText": "project1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/project1;\n" - } - ] - }, - { - "label": "test/local_project2", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "local_project2", - "insertText": "local_project2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/local_project2;\n" - } - ] - }, - { - "label": "test/local_project1", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "local_project1", - "insertText": "local_project1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/local_project1;\n" - } - ] - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "commonAnnotation", - "kind": "Property", - "detail": "Annotation", - "sortText": "A", - "insertText": "commonAnnotation", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "clientAnnot1", - "kind": "Property", - "detail": "Annotation", - "sortText": "A", - "insertText": "clientAnnot1 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] - } - ] -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClientDeclAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClientDeclAnnotation2.json deleted file mode 100644 index 14f13b988a15..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClientDeclAnnotation2.json +++ /dev/null @@ -1,396 +0,0 @@ -{ - "position": { - "line": 2, - "character": 2 - }, - "source": "annotation_ctx/source/moduleClientDeclAnnotation2.bal", - "items": [ - { - "label": "module1", - "kind": "Module", - "detail": "Module", - "sortText": "Q", - "filterText": "module1", - "insertText": "module1", - "insertTextFormat": "Snippet" - }, - { - "label": "ballerina/lang.test", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "test", - "insertText": "test", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.test;\n" - } - ] - }, - { - "label": "ballerina/lang.array", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "array", - "insertText": "array", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.array;\n" - } - ] - }, - { - "label": "ballerina/jballerina.java", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "java", - "insertText": "java", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/jballerina.java;\n" - } - ] - }, - { - "label": "ballerina/lang.value", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "value", - "insertText": "value", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.value;\n" - } - ] - }, - { - "label": "ballerina/lang.runtime", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "runtime", - "insertText": "runtime", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.runtime;\n" - } - ] - }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, - { - "label": "map", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "map", - "insertTextFormat": "Snippet" - }, - { - "label": "object", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "object", - "insertTextFormat": "Snippet" - }, - { - "label": "stream", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "stream", - "insertTextFormat": "Snippet" - }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, - { - "label": "table", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "table", - "insertTextFormat": "Snippet" - }, - { - "label": "transaction", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "transaction", - "insertTextFormat": "Snippet" - }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, - { - "label": "test/project2", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "project2", - "insertText": "project2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/project2;\n" - } - ] - }, - { - "label": "test/project1", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "project1", - "insertText": "project1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/project1;\n" - } - ] - }, - { - "label": "test/local_project2", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "local_project2", - "insertText": "local_project2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/local_project2;\n" - } - ] - }, - { - "label": "test/local_project1", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "local_project1", - "insertText": "local_project1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/local_project1;\n" - } - ] - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "commonAnnotation", - "kind": "Property", - "detail": "Annotation", - "sortText": "A", - "insertText": "commonAnnotation", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "clientAnnot1", - "kind": "Property", - "detail": "Annotation", - "sortText": "A", - "insertText": "clientAnnot1 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] - } - ] -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClientDeclAnnotation3.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClientDeclAnnotation3.json deleted file mode 100644 index 00e6cd7ba50f..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClientDeclAnnotation3.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "position": { - "line": 2, - "character": 9 - }, - "source": "annotation_ctx/source/moduleClientDeclAnnotation3.bal", - "items": [ - { - "label": "annotationCommon", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "annotationCommon {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "sourceVarAnnotation1", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "sourceVarAnnotation1 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "sourceVarAnnotation2", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "sourceVarAnnotation2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "commonAnnotation1", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "commonAnnotation1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "commonAnnotation2", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "commonAnnotation2 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - } - ] -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClientDeclAnnotation4.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClientDeclAnnotation4.json deleted file mode 100644 index 52aaef72ce5c..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClientDeclAnnotation4.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "position": { - "line": 2, - "character": 10 - }, - "source": "annotation_ctx/source/moduleClientDeclAnnotation4.bal", - "items": [ - { - "label": "annotationCommon", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "annotationCommon {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "commonAnnotation1", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "commonAnnotation1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "commonAnnotation2", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "commonAnnotation2 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "sourceClientDeclaration1", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "sourceClientDeclaration1 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "sourceClientDeclaration2", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "sourceClientDeclaration2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - } - ] -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleLevelAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleLevelAnnotation1.json index 163e5c654b8d..0261e1d85e23 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleLevelAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleLevelAnnotation1.json @@ -373,24 +373,6 @@ "insertText": "serviceRemoteFunctionAnnotation1 {\n\tfoo: ${1:\"\"}\n}", "insertTextFormat": "Snippet", "additionalTextEdits": [] - }, - { - "label": "sourceClientDeclaration1", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "sourceClientDeclaration1 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "sourceClientDeclaration2", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "sourceClientDeclaration2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/clientDeclAnnotation1.bal b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/clientDeclAnnotation1.bal deleted file mode 100644 index 0d50027c66b9..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/clientDeclAnnotation1.bal +++ /dev/null @@ -1,17 +0,0 @@ -import ballerina/module1; - -function testFunction() { - @ - client "https://postman-echo.com/get?name=projectapiclientplugin" as foo; -} - -public type AnnotationType record { - string foo; - int bar?; -}; - -public annotation AnnotationType clientAnnot1 on source client; - -public annotation clientAnnot1 on source client; - -public annotation commonAnnotation; diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/clientDeclAnnotation2.bal b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/clientDeclAnnotation2.bal deleted file mode 100644 index e870c901ee64..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/clientDeclAnnotation2.bal +++ /dev/null @@ -1,17 +0,0 @@ -import ballerina/module1; - -function testFunction() { - @m - client "https://postman-echo.com/get?name=projectapiclientplugin" as foo; -} - -public type AnnotationType record { - string foo; - int bar?; -}; - -public annotation AnnotationType clientAnnot1 on source client; - -public annotation clientAnnot1 on source client; - -public annotation commonAnnotation; diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/clientDeclAnnotation3.bal b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/clientDeclAnnotation3.bal deleted file mode 100644 index 496b33db9f91..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/clientDeclAnnotation3.bal +++ /dev/null @@ -1,17 +0,0 @@ -import ballerina/module1; - -function testFunction() { - @module1: - client "https://postman-echo.com/get?name=projectapiclientplugin" as foo; -} - -public type AnnotationType record { - string foo; - int bar?; -}; - -public annotation AnnotationType clientAnnot1 on source client; - -public annotation clientAnnot1 on source client; - -public annotation commonAnnotation; diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/clientDeclAnnotation4.bal b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/clientDeclAnnotation4.bal deleted file mode 100644 index 629600e901e6..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/clientDeclAnnotation4.bal +++ /dev/null @@ -1,17 +0,0 @@ -import ballerina/module1; - -function testFunction() { - @module1:t - client "https://postman-echo.com/get?name=projectapiclientplugin" as foo; -} - -public type AnnotationType record { - string foo; - int bar?; -}; - -public annotation AnnotationType clientAnnot1 on source client; - -public annotation clientAnnot1 on source client; - -public annotation commonAnnotation; diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleClientDeclAnnotation1.bal b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleClientDeclAnnotation1.bal deleted file mode 100644 index 0252b1b15708..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleClientDeclAnnotation1.bal +++ /dev/null @@ -1,15 +0,0 @@ -import ballerina/module1; - -@ -client "https://postman-echo.com/get?name=projectapiclientplugin" as foo; - -public type AnnotationType record { - string foo; - int bar?; -}; - -public annotation AnnotationType clientAnnot1 on source client; - -public annotation clientAnnot1 on source client; - -public annotation commonAnnotation; diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleClientDeclAnnotation2.bal b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleClientDeclAnnotation2.bal deleted file mode 100644 index 2bbab05be01d..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleClientDeclAnnotation2.bal +++ /dev/null @@ -1,15 +0,0 @@ -import ballerina/module1; - -@m -client "https://postman-echo.com/get?name=projectapiclientplugin" as foo; - -public type AnnotationType record { - string foo; - int bar?; -}; - -public annotation AnnotationType clientAnnot1 on source client; - -public annotation clientAnnot1 on source client; - -public annotation commonAnnotation; diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleClientDeclAnnotation3.bal b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleClientDeclAnnotation3.bal deleted file mode 100644 index 2dedd197f131..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleClientDeclAnnotation3.bal +++ /dev/null @@ -1,15 +0,0 @@ -import ballerina/module1; - -@module1: -client "https://postman-echo.com/get?name=projectapiclientplugin" as foo; - -public type AnnotationType record { - string foo; - int bar?; -}; - -public annotation AnnotationType clientAnnot1 on source client; - -public annotation clientAnnot1 on source client; - -public annotation commonAnnotation; diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleClientDeclAnnotation4.bal b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleClientDeclAnnotation4.bal deleted file mode 100644 index 96fd27de614c..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleClientDeclAnnotation4.bal +++ /dev/null @@ -1,15 +0,0 @@ -import ballerina/module1; - -@module1:t -client "https://postman-echo.com/get?name=projectapiclientplugin" as foo; - -public type AnnotationType record { - string foo; - int bar?; -}; - -public annotation AnnotationType clientAnnot1 on source client; - -public annotation clientAnnot1 on source client; - -public annotation commonAnnotation; diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_decl/config/config21.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_decl/config/config21.json index 69ec5bf75f04..2fade15f3dd7 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_decl/config/config21.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_decl/config/config21.json @@ -800,15 +800,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config22.json b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config22.json index 3fd39e0373b4..7b1c067a2496 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config22.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config22.json @@ -845,15 +845,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config24.json b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config24.json index 645541e7ff1b..2b453aac58bb 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config24.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config24.json @@ -900,15 +900,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_after_as_keyword.json b/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_after_as_keyword.json deleted file mode 100644 index cc30cd6d00a4..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_after_as_keyword.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "position": { - "line": 1, - "character": 73 - }, - "source": "client_declaration_context/source/client_declaration_after_as_keyword.bal", - "items": [] -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_after_client_keyword.json b/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_after_client_keyword.json deleted file mode 100644 index 9966b2c85ceb..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_after_client_keyword.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "position": { - "line": 1, - "character": 11 - }, - "source": "client_declaration_context/source/client_declaration_after_client_keyword.bal", - "items": [] -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_after_service_uri.json b/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_after_service_uri.json deleted file mode 100644 index e23c54a23186..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_after_service_uri.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "position": { - "line": 1, - "character": 70 - }, - "source": "client_declaration_context/source/client_declaration_after_service_uri.bal", - "items": [ - { - "label": "as", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "as", - "insertText": "as ", - "insertTextFormat": "Snippet" - } - ] -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_client_keyword.json b/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_client_keyword.json deleted file mode 100644 index 03651679c056..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_client_keyword.json +++ /dev/null @@ -1,914 +0,0 @@ -{ - "position": { - "line": 1, - "character": 6 - }, - "source": "client_declaration_context/source/client_declaration_client_keyword.bal", - "items": [ - { - "label": "ballerina/module1", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "module1", - "insertText": "module1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/module1;\n" - } - ] - }, - { - "label": "ballerina/lang.test", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "test", - "insertText": "test", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.test;\n" - } - ] - }, - { - "label": "ballerina/lang.array", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "array", - "insertText": "array", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.array;\n" - } - ] - }, - { - "label": "ballerina/jballerina.java", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "java", - "insertText": "java", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/jballerina.java;\n" - } - ] - }, - { - "label": "ballerina/lang.value", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "value", - "insertText": "value", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.value;\n" - } - ] - }, - { - "label": "ballerina/lang.runtime", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "runtime", - "insertText": "runtime", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.runtime;\n" - } - ] - }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, - { - "label": "map", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "map", - "insertTextFormat": "Snippet" - }, - { - "label": "object", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "object", - "insertTextFormat": "Snippet" - }, - { - "label": "stream", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "stream", - "insertTextFormat": "Snippet" - }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, - { - "label": "table", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "table", - "insertTextFormat": "Snippet" - }, - { - "label": "transaction", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "transaction", - "insertTextFormat": "Snippet" - }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, - { - "label": "isolated", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "isolated", - "insertText": "isolated ", - "insertTextFormat": "Snippet" - }, - { - "label": "transactional", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "transactional", - "insertText": "transactional", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "function", - "insertText": "function ", - "insertTextFormat": "Snippet" - }, - { - "label": "client", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "client", - "insertText": "client ", - "insertTextFormat": "Snippet" - }, - { - "label": "true", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "true", - "insertText": "true", - "insertTextFormat": "Snippet" - }, - { - "label": "false", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "false", - "insertText": "false", - "insertTextFormat": "Snippet" - }, - { - "label": "object constructor", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "object", - "insertText": "object {${1}}", - "insertTextFormat": "Snippet" - }, - { - "label": "Thread", - "kind": "TypeParameter", - "detail": "Union", - "sortText": "N", - "insertText": "Thread", - "insertTextFormat": "Snippet" - }, - { - "label": "StrandData", - "kind": "Struct", - "detail": "Record", - "documentation": { - "left": "Describes Strand execution details for the runtime.\n" - }, - "sortText": "M", - "insertText": "StrandData", - "insertTextFormat": "Snippet" - }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "null", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "null", - "insertText": "null", - "insertTextFormat": "Snippet" - }, - { - "label": "test/project2", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "project2", - "insertText": "project2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/project2;\n" - } - ] - }, - { - "label": "test/project1", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "project1", - "insertText": "project1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/project1;\n" - } - ] - }, - { - "label": "test/local_project2", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "local_project2", - "insertText": "local_project2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/local_project2;\n" - } - ] - }, - { - "label": "test/local_project1", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "local_project1", - "insertText": "local_project1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/local_project1;\n" - } - ] - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "final", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "final", - "insertText": "final ", - "insertTextFormat": "Snippet" - }, - { - "label": "var", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "var", - "insertText": "var ", - "insertTextFormat": "Snippet" - }, - { - "label": "xmlns", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "xmlns", - "insertText": "xmlns ", - "insertTextFormat": "Snippet" - }, - { - "label": "xmlns", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "xmlns", - "insertText": "xmlns \"${1}\" as ${2:ns};", - "insertTextFormat": "Snippet" - }, - { - "label": "stream<> streamName = new;", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "stream", - "insertText": "stream<${1}> ${2:streamName} = new;", - "insertTextFormat": "Snippet" - }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, - { - "label": "record", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "record", - "insertText": "record ", - "insertTextFormat": "Snippet" - }, - { - "label": "record {}", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "record", - "insertText": "record {${1}}", - "insertTextFormat": "Snippet" - }, - { - "label": "record {||}", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "record", - "insertText": "record {|${1}|}", - "insertTextFormat": "Snippet" - }, - { - "label": "distinct", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "distinct", - "insertText": "distinct", - "insertTextFormat": "Snippet" - }, - { - "label": "wait", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "wait", - "insertText": "wait ", - "insertTextFormat": "Snippet" - }, - { - "label": "start", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "start", - "insertText": "start ", - "insertTextFormat": "Snippet" - }, - { - "label": "flush", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "flush", - "insertText": "flush ", - "insertTextFormat": "Snippet" - }, - { - "label": "new", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "new", - "insertText": "new ", - "insertTextFormat": "Snippet" - }, - { - "label": "let", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "let", - "insertText": "let", - "insertTextFormat": "Snippet" - }, - { - "label": "typeof", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "typeof", - "insertText": "typeof ", - "insertTextFormat": "Snippet" - }, - { - "label": "trap", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "trap", - "insertText": "trap", - "insertTextFormat": "Snippet" - }, - { - "label": "checkpanic", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "checkpanic", - "insertText": "checkpanic ", - "insertTextFormat": "Snippet" - }, - { - "label": "check", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "check", - "insertText": "check ", - "insertTextFormat": "Snippet" - }, - { - "label": "fail", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "fail", - "insertText": "fail ", - "insertTextFormat": "Snippet" - }, - { - "label": "error constructor", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "error", - "insertText": "error(\"${1}\")", - "insertTextFormat": "Snippet" - }, - { - "label": "base16", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "base16", - "insertText": "base16 `${1}`", - "insertTextFormat": "Snippet" - }, - { - "label": "base64", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "base64", - "insertText": "base64 `${1}`", - "insertTextFormat": "Snippet" - }, - { - "label": "from", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "from", - "insertText": "from ", - "insertTextFormat": "Snippet" - }, - { - "label": "if", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "if", - "insertText": "if ${1:true} {\n\t${2}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "while", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "while", - "insertText": "while ${1:true} {\n\t${2}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "do", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "do", - "insertText": "do {\n\t${1}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "lock", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "lock", - "insertText": "lock {\n\t${1}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "foreach", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "foreach", - "insertText": "foreach ${1:var} ${2:item} in ${3:itemList} {\n\t${4}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "foreach i", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "foreach", - "insertText": "foreach ${1:int} ${2:i} in ${3:0}...${4:9} {\n\t${5}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "fork", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "fork", - "insertText": "fork {\n\t${1}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "transaction", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "transaction", - "insertText": "transaction {\n\t${1}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "retry", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "retry", - "insertText": "retry {\n\t${1}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "retry transaction", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "retry_transaction", - "insertText": "retry transaction {\n\t${1}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "match", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "match", - "insertText": "match ", - "insertTextFormat": "Snippet" - }, - { - "label": "panic", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "panic", - "insertText": "panic ", - "insertTextFormat": "Snippet" - }, - { - "label": "return;", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "return;", - "insertText": "return;", - "insertTextFormat": "Snippet" - }, - { - "label": "object {}", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "object", - "insertText": "object {${1}}", - "insertTextFormat": "Snippet" - }, - { - "label": "testFunction()", - "kind": "Function", - "detail": "()", - "documentation": { - "right": { - "kind": "markdown", - "value": "**Package:** _._ \n \n \n" - } - }, - "sortText": "C", - "filterText": "testFunction", - "insertText": "testFunction()", - "insertTextFormat": "Snippet" - }, - { - "label": "worker", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "worker", - "insertText": "worker ${1:name} {\n\t${2}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] - } - ] -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_module_prefix_reference_in_block_level.json b/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_module_prefix_reference_in_block_level.json deleted file mode 100644 index 15bc48270233..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_module_prefix_reference_in_block_level.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "position": { - "line": 5, - "character": 10 - }, - "source": "client_declaration_context/source/client_decl_test/main.bal", - "items": [ - { - "label": "ClientConfiguration", - "kind": "Struct", - "detail": "Record", - "sortText": "M", - "insertText": "ClientConfiguration", - "insertTextFormat": "Snippet" - }, - { - "label": "client", - "kind": "Interface", - "detail": "Class", - "sortText": "K", - "insertText": "client", - "insertTextFormat": "Snippet" - } - ] -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_on_expected_as_keyword.json b/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_on_expected_as_keyword.json deleted file mode 100644 index 65912cc8e048..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_on_expected_as_keyword.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "position": { - "line": 1, - "character": 70 - }, - "source": "client_declaration_context/source/client_declaration_on_expected_as_keyword.bal", - "items": [ - { - "label": "as", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "as", - "insertText": "as ", - "insertTextFormat": "Snippet" - } - ] -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_on_expected_service_uri.json b/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_on_expected_service_uri.json deleted file mode 100644 index 9dd75ec571fe..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_on_expected_service_uri.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "position": { - "line": 1, - "character": 11 - }, - "source": "client_declaration_context/source/client_declaration_on_expected_service_uri.bal", - "items": [] -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_remote_method_access_block_level.json b/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_remote_method_access_block_level.json deleted file mode 100644 index 52ab1036c5bf..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_remote_method_access_block_level.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "position": { - "line": 5, - "character": 29 - }, - "source": "client_declaration_context/source/client_decl_test/remote_method_access.bal", - "items": [ - { - "label": "getSpecVersion()", - "kind": "Function", - "detail": "string", - "documentation": { - "right": { - "kind": "markdown", - "value": "**Package:** _gayal/client_decl_test.myapi:0.1.0_ \n \n \n \n \n**Return** `string` \n \n" - } - }, - "sortText": "AC", - "filterText": "getSpecVersion", - "insertText": "getSpecVersion()", - "insertTextFormat": "Snippet" - } - ] -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/completions_inside_generated_idl_client.json b/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/completions_inside_generated_idl_client.json deleted file mode 100644 index 7187306fdcef..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/completions_inside_generated_idl_client.json +++ /dev/null @@ -1,663 +0,0 @@ -{ - "position": { - "line": 16, - "character": 0 - }, - "source": "client_declaration_context/source/client_decl_test/generated/myapi/idl_client.bal", - "items": [ - { - "label": "private", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "private", - "insertText": "private ", - "insertTextFormat": "Snippet" - }, - { - "label": "public", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "public", - "insertText": "public ", - "insertTextFormat": "Snippet" - }, - { - "label": "final", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "final", - "insertText": "final ", - "insertTextFormat": "Snippet" - }, - { - "label": "remote", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "remote", - "insertText": "remote", - "insertTextFormat": "Snippet" - }, - { - "label": "resource", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "resource", - "insertText": "resource ", - "insertTextFormat": "Snippet" - }, - { - "label": "remote function ();", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "remote_function", - "insertText": "remote function ${1:name}(${2})${3} {\n\t${4}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "function", - "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "isolated", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "isolated", - "insertText": "isolated ", - "insertTextFormat": "Snippet" - }, - { - "label": "transactional", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "transactional", - "insertText": "transactional", - "insertTextFormat": "Snippet" - }, - { - "label": "resource function", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "resource_function", - "insertText": "resource function ${1:accessor} ${2:path} (${3})${4} {\n\t${5}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "'client", - "kind": "Interface", - "detail": "Class", - "sortText": "K", - "insertText": "'client", - "insertTextFormat": "Snippet" - }, - { - "label": "Thread", - "kind": "TypeParameter", - "detail": "Union", - "sortText": "N", - "insertText": "Thread", - "insertTextFormat": "Snippet" - }, - { - "label": "ClientConfiguration", - "kind": "Struct", - "detail": "Record", - "sortText": "M", - "insertText": "ClientConfiguration", - "insertTextFormat": "Snippet" - }, - { - "label": "StrandData", - "kind": "Struct", - "detail": "Record", - "documentation": { - "left": "Describes Strand execution details for the runtime.\n" - }, - "sortText": "M", - "insertText": "StrandData", - "insertTextFormat": "Snippet" - }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, - { - "label": "record", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "record", - "insertText": "record ", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "function", - "insertText": "function ", - "insertTextFormat": "Snippet" - }, - { - "label": "record {}", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "record", - "insertText": "record {${1}}", - "insertTextFormat": "Snippet" - }, - { - "label": "record {||}", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "record", - "insertText": "record {|${1}|}", - "insertTextFormat": "Snippet" - }, - { - "label": "distinct", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "distinct", - "insertText": "distinct", - "insertTextFormat": "Snippet" - }, - { - "label": "object {}", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "object", - "insertText": "object {${1}}", - "insertTextFormat": "Snippet" - }, - { - "label": "true", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "true", - "insertText": "true", - "insertTextFormat": "Snippet" - }, - { - "label": "false", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "false", - "insertText": "false", - "insertTextFormat": "Snippet" - }, - { - "label": "null", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "null", - "insertText": "null", - "insertTextFormat": "Snippet" - }, - { - "label": "test/project2", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "project2", - "insertText": "project2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/project2;\n" - } - ] - }, - { - "label": "test/project1", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "project1", - "insertText": "project1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/project1;\n" - } - ] - }, - { - "label": "ballerina/lang.runtime", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "runtime", - "insertText": "runtime", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.runtime;\n" - } - ] - }, - { - "label": "ballerina/module1", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "module1", - "insertText": "module1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/module1;\n" - } - ] - }, - { - "label": "ballerina/lang.test", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "test", - "insertText": "test", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.test;\n" - } - ] - }, - { - "label": "test/local_project2", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "local_project2", - "insertText": "local_project2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/local_project2;\n" - } - ] - }, - { - "label": "test/local_project1", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "local_project1", - "insertText": "local_project1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/local_project1;\n" - } - ] - }, - { - "label": "ballerina/lang.value", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "value", - "insertText": "value", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.value;\n" - } - ] - }, - { - "label": "ballerina/jballerina.java", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "java", - "insertText": "java", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/jballerina.java;\n" - } - ] - }, - { - "label": "ballerina/lang.array", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "array", - "insertText": "array", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.array;\n" - } - ] - }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, - { - "label": "map", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "map", - "insertTextFormat": "Snippet" - }, - { - "label": "object", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "object", - "insertTextFormat": "Snippet" - }, - { - "label": "stream", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "stream", - "insertTextFormat": "Snippet" - }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, - { - "label": "table", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "table", - "insertTextFormat": "Snippet" - }, - { - "label": "transaction", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "transaction", - "insertTextFormat": "Snippet" - }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, - { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] - } - ] -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_decl_test/Ballerina.toml b/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_decl_test/Ballerina.toml deleted file mode 100644 index 5eb290708330..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_decl_test/Ballerina.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -org = "gayal" -name = "client_decl_test" -version = "0.1.0" -distribution = "2201.2.0-rc1.2" - -[build-options] -observabilityIncluded = true diff --git a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_decl_test/generated/idl-plugin-cache.json b/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_decl_test/generated/idl-plugin-cache.json deleted file mode 100644 index 8c6a19d09a7a..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_decl_test/generated/idl-plugin-cache.json +++ /dev/null @@ -1 +0,0 @@ -[{"url":"https://postman-echo.com/get?name\u003dprojectapiclientplugin","annotations":[],"generatedModuleName":"myapi","filePath":"projectapiclientplugin","lastModifiedTime":1665986763203}] \ No newline at end of file diff --git a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_decl_test/generated/myapi/idl_client.bal b/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_decl_test/generated/myapi/idl_client.bal deleted file mode 100644 index b869df13434d..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_decl_test/generated/myapi/idl_client.bal +++ /dev/null @@ -1,18 +0,0 @@ -public type ClientConfiguration record { - string specVersion; -}; - -public isolated client class 'client { - public final string specVersion; - - public function init(*ClientConfiguration config) { - self.specVersion = config.specVersion; - } - - remote function getSpecVersion() returns string { - lock { - return self.specVersion; - } - } - -} \ No newline at end of file diff --git a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_decl_test/main.bal b/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_decl_test/main.bal deleted file mode 100644 index c4dad5be59f3..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_decl_test/main.bal +++ /dev/null @@ -1,7 +0,0 @@ -client "https://postman-echo.com/get?name=projectapiclientplugin" as myapi; - -myapi: - -public function main() { - myapi: -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_decl_test/projectapiclientplugin b/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_decl_test/projectapiclientplugin deleted file mode 100644 index ca252d479436..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_decl_test/projectapiclientplugin +++ /dev/null @@ -1 +0,0 @@ -{"args":{"name":"projectapiclientplugin"},"headers":{"x-forwarded-proto":"https","x-forwarded-port":"443","host":"postman-echo.com","x-amzn-trace-id":"Root=1-634cf0cb-5d437cca5f75e9324370028a","user-agent":"Java/11.0.8","accept":"text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"},"url":"https://postman-echo.com/get?name=projectapiclientplugin"} \ No newline at end of file diff --git a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_decl_test/remote_method_access.bal b/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_decl_test/remote_method_access.bal deleted file mode 100644 index c0cadb922cd8..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_decl_test/remote_method_access.bal +++ /dev/null @@ -1,7 +0,0 @@ -client "https://postman-echo.com/get?name=projectapiclientplugin" as myapi1; - -function name() { - myapi1:ClientConfiguration config = {specVersion : "3.0.0"}; - myapi1:client cl = new (config); - string specVersion = cl-> -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_declaration_after_as_keyword.bal b/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_declaration_after_as_keyword.bal deleted file mode 100644 index 7f9d6acac8c3..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_declaration_after_as_keyword.bal +++ /dev/null @@ -1,3 +0,0 @@ -function testFunction() { - client "https://postman-echo.com/get?name=projectapiclientplugin" as -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_declaration_after_client_keyword.bal b/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_declaration_after_client_keyword.bal deleted file mode 100644 index 8c353023171a..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_declaration_after_client_keyword.bal +++ /dev/null @@ -1,3 +0,0 @@ -function testFunction() { - client -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_declaration_after_service_uri.bal b/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_declaration_after_service_uri.bal deleted file mode 100644 index 208c2bb7c462..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_declaration_after_service_uri.bal +++ /dev/null @@ -1,3 +0,0 @@ -function testFunction() { - client "https://postman-echo.com/get?name=projectapiclientplugin" -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_declaration_client_keyword.bal b/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_declaration_client_keyword.bal deleted file mode 100644 index 33498ec2f75d..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_declaration_client_keyword.bal +++ /dev/null @@ -1,3 +0,0 @@ -function testFunction() { - cl -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_declaration_on_expected_as_keyword.bal b/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_declaration_on_expected_as_keyword.bal deleted file mode 100644 index 68571165da5c..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_declaration_on_expected_as_keyword.bal +++ /dev/null @@ -1,3 +0,0 @@ -function testFunction() { - client "https://postman-echo.com/get?name=projectapiclientplugin" foo; -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_declaration_on_expected_service_uri.bal b/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_declaration_on_expected_service_uri.bal deleted file mode 100644 index e7b3c87a4a1f..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/source/client_declaration_on_expected_service_uri.bal +++ /dev/null @@ -1,3 +0,0 @@ -function testFunction() { - client as foo; -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/comment_context/config/comment_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/comment_context/config/comment_config3.json index 7578a6c8c8bf..02e7d04b764d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/comment_context/config/comment_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/comment_context/config/comment_config3.json @@ -877,15 +877,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "Q", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/comment_context/config/comment_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/comment_context/config/comment_config4.json index b749594f9f79..f40b152f20d3 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/comment_context/config/comment_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/comment_context/config/comment_config4.json @@ -877,15 +877,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "Q", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/enum_decl_ctx/config/config5.json b/language-server/modules/langserver-core/src/test/resources/completion/enum_decl_ctx/config/config5.json index c2dc40407d3e..5be0eba3a784 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/enum_decl_ctx/config/config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/enum_decl_ctx/config/config5.json @@ -816,15 +816,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config10.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config10.json index abaabacbeab2..2f978722a351 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config10.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config10.json @@ -921,15 +921,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config7.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config7.json index 14e41ea53440..1ed14d471544 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config7.json @@ -916,15 +916,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config8.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config8.json index d81fa8df600a..87100a9ecd48 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config8.json @@ -928,15 +928,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config1.json index 467542e4e9dc..216f4bce2934 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config1.json @@ -954,15 +954,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config3.json index 91be2c905844..b302e2d9a682 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config3.json @@ -954,15 +954,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config4.json index 2b49f4dec1c6..640399e2985d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config4.json @@ -954,15 +954,6 @@ "insertText": "worker ${1:name} {\n\t${2}\n}", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config5.json index 7ff03aa82e76..5bbf2b715ce9 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config5.json @@ -876,15 +876,6 @@ "insertText": "worker ${1:name} {\n\t${2}\n}", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config21.json b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config21.json index b760a50970b5..042ed9204897 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config21.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config21.json @@ -890,15 +890,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config7.json b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config7.json index 4e6e9ebf2b56..bd7ff5da28f0 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config7.json @@ -917,15 +917,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config8.json b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config8.json index 65cb29bdb43f..fad1e2571c60 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config8.json @@ -917,15 +917,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config1.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config1.json index eb4313916e9b..f624025b5ac7 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config1.json @@ -862,15 +862,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config10.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config10.json index 7c9edcefa984..e8de124f7500 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config10.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config10.json @@ -896,15 +896,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config12.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config12.json index 347e560377db..dd6ca40d3e66 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config12.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config12.json @@ -897,15 +897,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "Q", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config13.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config13.json index ef9bd57470fb..084f029c5c05 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config13.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config13.json @@ -989,15 +989,6 @@ "insertText": "module1:TestRecord2", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "Q", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config14.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config14.json index 191b25006a37..256f708a1eaa 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config14.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config14.json @@ -885,15 +885,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config15_client_declaration.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config15_client_declaration.json index 1a86602aedfe..9aad2fb5e556 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config15_client_declaration.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config15_client_declaration.json @@ -862,24 +862,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, - { - "label": "testPrefix", - "kind": "Module", - "detail": "Module", - "sortText": "O", - "filterText": "testPrefix", - "insertText": "testPrefix", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config16_client_declaration.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config16_client_declaration.json index 8ddb65feece9..37e88409b751 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config16_client_declaration.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config16_client_declaration.json @@ -862,33 +862,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, - { - "label": "testPrefix", - "kind": "Module", - "detail": "Module", - "sortText": "O", - "filterText": "testPrefix", - "insertText": "testPrefix", - "insertTextFormat": "Snippet" - }, - { - "label": "testPrefixMod", - "kind": "Module", - "detail": "Module", - "sortText": "O", - "filterText": "testPrefixMod", - "insertText": "testPrefixMod", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config2.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config2.json index 9231d9349436..a476b8bd13f2 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config2.json @@ -862,15 +862,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config3.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config3.json index 0ba844df8f07..c9078f768d16 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config3.json @@ -853,15 +853,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config4.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config4.json index 25682d346b9e..2f705e7996f4 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config4.json @@ -864,15 +864,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config5.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config5.json index 8ec45b33f13a..846f1f367cbc 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config5.json @@ -882,15 +882,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config6.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config6.json index c870ab0a366a..4cd303f08ada 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config6.json @@ -882,15 +882,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config11.json b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config11.json index e46a5105db3b..a94cb606bd82 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config11.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config11.json @@ -964,15 +964,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config12.json b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config12.json index 4565f8070e10..fb547afa2282 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config12.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config12.json @@ -964,15 +964,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config21.json b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config21.json index 2d37da8d8f6a..d8cfa44db2ee 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config21.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config21.json @@ -964,15 +964,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config26.json b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config26.json index 0043fbdc0eb3..9e372533e763 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config26.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config26.json @@ -940,15 +940,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/client_declaration_module_prefix_reference_in_module_level.json b/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/client_declaration_module_prefix_reference_in_module_level.json deleted file mode 100644 index 7c2b513a20fd..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/client_declaration_module_prefix_reference_in_module_level.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "position": { - "line": 2, - "character": 6 - }, - "source": "module_client_declaration_context/source/module_client_decl_test/main.bal", - "items": [ - { - "label": "ClientConfiguration", - "kind": "Struct", - "detail": "Record", - "sortText": "D", - "insertText": "ClientConfiguration", - "insertTextFormat": "Snippet" - }, - { - "label": "client", - "kind": "Interface", - "detail": "Class", - "sortText": "D", - "insertText": "client", - "insertTextFormat": "Snippet" - } - ] -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_after_as_keyword.json b/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_after_as_keyword.json deleted file mode 100644 index 62dceeb1708a..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_after_as_keyword.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "position": { - "line": 0, - "character": 69 - }, - "source": "module_client_declaration_context/source/module_client_declaration_after_as_keyword.bal", - "items": [] -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_after_client_keyword.json b/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_after_client_keyword.json deleted file mode 100644 index 14a546365abe..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_after_client_keyword.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "position": { - "line": 0, - "character": 7 - }, - "source": "module_client_declaration_context/source/module_client_declaration_after_client_keyword.bal", - "items": [ - { - "label": "isolated", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "isolated", - "insertText": "isolated ", - "insertTextFormat": "Snippet" - }, - { - "label": "object {}", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "object", - "insertText": "object {${1}}", - "insertTextFormat": "Snippet" - }, - { - "label": "object", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "object", - "insertText": "object ", - "insertTextFormat": "Snippet" - }, - { - "label": "class", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "class", - "insertText": "class ", - "insertTextFormat": "Snippet" - }, - { - "label": "class", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "class", - "insertText": "class ${1:className} {\n\t${2}\n}", - "insertTextFormat": "Snippet" - } - ] -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_after_service_uri.json b/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_after_service_uri.json deleted file mode 100644 index 20cff02ce44f..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_after_service_uri.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "position": { - "line": 0, - "character": 66 - }, - "source": "module_client_declaration_context/source/module_client_declaration_after_service_uri.bal", - "items": [ - { - "label": "as", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "as", - "insertText": "as ", - "insertTextFormat": "Snippet" - } - ] -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_client_keyword.json b/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_client_keyword.json deleted file mode 100644 index f3835a3bc643..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_client_keyword.json +++ /dev/null @@ -1,875 +0,0 @@ -{ - "position": { - "line": 0, - "character": 2 - }, - "source": "module_client_declaration_context/source/module_client_declaration_client_keyword.bal", - "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, - { - "label": "type", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "type", - "insertText": "type ", - "insertTextFormat": "Snippet" - }, - { - "label": "public", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "public", - "insertText": "public ", - "insertTextFormat": "Snippet" - }, - { - "label": "isolated", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "isolated", - "insertText": "isolated ", - "insertTextFormat": "Snippet" - }, - { - "label": "final", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "final", - "insertText": "final ", - "insertTextFormat": "Snippet" - }, - { - "label": "const", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "const", - "insertText": "const ", - "insertTextFormat": "Snippet" - }, - { - "label": "listener", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "listener", - "insertText": "listener ", - "insertTextFormat": "Snippet" - }, - { - "label": "client", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "client", - "insertText": "client ", - "insertTextFormat": "Snippet" - }, - { - "label": "var", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "var", - "insertText": "var ", - "insertTextFormat": "Snippet" - }, - { - "label": "enum", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "enum", - "insertText": "enum ", - "insertTextFormat": "Snippet" - }, - { - "label": "xmlns", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "xmlns", - "insertText": "xmlns ", - "insertTextFormat": "Snippet" - }, - { - "label": "class", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "class", - "insertText": "class ", - "insertTextFormat": "Snippet" - }, - { - "label": "transactional", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "transactional", - "insertText": "transactional", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "function", - "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "public main function", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "public_function_main", - "insertText": "public function main() {\n\t${1}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "configurable", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "configurable", - "insertText": "configurable", - "insertTextFormat": "Snippet" - }, - { - "label": "annotation", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "annotation", - "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", - "insertTextFormat": "Snippet" - }, - { - "label": "type record {}", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "type_record", - "insertText": "type ${1:RecordName} record {\n\t${2}\n};", - "insertTextFormat": "Snippet" - }, - { - "label": "xmlns", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "xmlns", - "insertText": "xmlns \"${1}\" as ${2:ns};", - "insertTextFormat": "Snippet" - }, - { - "label": "type object", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "type_object", - "insertText": "type ${1:ObjectName} object {${2}};", - "insertTextFormat": "Snippet" - }, - { - "label": "class", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "class", - "insertText": "class ${1:className} {\n\t${2}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "enum", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "enum", - "insertText": "enum ${1:enumName} {\n\t${2}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "type record {||}", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "type_record", - "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", - "insertTextFormat": "Snippet" - }, - { - "label": "type error", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "type_error", - "insertText": "type ${1:ErrorName} error<${2:map}>;", - "insertTextFormat": "Snippet" - }, - { - "label": "type TypeName table<>;", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "type_table", - "insertText": "type ${1:TypeName} table<${2}>;", - "insertTextFormat": "Snippet" - }, - { - "label": "type TypeName table<> key", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "type_table_key", - "insertText": "type ${1:TypeName} table<${2}> key${3}", - "insertTextFormat": "Snippet" - }, - { - "label": "stream<> streamName = new;", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "stream", - "insertText": "stream<${1}> ${2:streamName} = new;", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "service", - "insertText": "service on ${1:listenerName} {\n\t${2}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, - { - "label": "Thread", - "kind": "TypeParameter", - "detail": "Union", - "sortText": "D", - "insertText": "Thread", - "insertTextFormat": "Snippet" - }, - { - "label": "StrandData", - "kind": "Struct", - "detail": "Record", - "documentation": { - "left": "Describes Strand execution details for the runtime.\n" - }, - "sortText": "D", - "insertText": "StrandData", - "insertTextFormat": "Snippet" - }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, - { - "label": "record", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "record", - "insertText": "record ", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "function", - "insertText": "function ", - "insertTextFormat": "Snippet" - }, - { - "label": "record {}", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "record", - "insertText": "record {${1}}", - "insertTextFormat": "Snippet" - }, - { - "label": "record {||}", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "record", - "insertText": "record {|${1}|}", - "insertTextFormat": "Snippet" - }, - { - "label": "distinct", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "distinct", - "insertText": "distinct", - "insertTextFormat": "Snippet" - }, - { - "label": "object {}", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "object", - "insertText": "object {${1}}", - "insertTextFormat": "Snippet" - }, - { - "label": "true", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "true", - "insertText": "true", - "insertTextFormat": "Snippet" - }, - { - "label": "false", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "false", - "insertText": "false", - "insertTextFormat": "Snippet" - }, - { - "label": "null", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "null", - "insertText": "null", - "insertTextFormat": "Snippet" - }, - { - "label": "test/project2", - "kind": "Module", - "detail": "Module", - "sortText": "C", - "filterText": "project2", - "insertText": "project2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/project2;\n" - } - ] - }, - { - "label": "test/project1", - "kind": "Module", - "detail": "Module", - "sortText": "C", - "filterText": "project1", - "insertText": "project1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/project1;\n" - } - ] - }, - { - "label": "ballerina/lang.runtime", - "kind": "Module", - "detail": "Module", - "sortText": "C", - "filterText": "runtime", - "insertText": "runtime", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.runtime;\n" - } - ] - }, - { - "label": "ballerina/module1", - "kind": "Module", - "detail": "Module", - "sortText": "C", - "filterText": "module1", - "insertText": "module1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/module1;\n" - } - ] - }, - { - "label": "ballerina/lang.test", - "kind": "Module", - "detail": "Module", - "sortText": "C", - "filterText": "test", - "insertText": "test", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.test;\n" - } - ] - }, - { - "label": "test/local_project2", - "kind": "Module", - "detail": "Module", - "sortText": "C", - "filterText": "local_project2", - "insertText": "local_project2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/local_project2;\n" - } - ] - }, - { - "label": "test/local_project1", - "kind": "Module", - "detail": "Module", - "sortText": "C", - "filterText": "local_project1", - "insertText": "local_project1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/local_project1;\n" - } - ] - }, - { - "label": "ballerina/lang.value", - "kind": "Module", - "detail": "Module", - "sortText": "C", - "filterText": "value", - "insertText": "value", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.value;\n" - } - ] - }, - { - "label": "ballerina/jballerina.java", - "kind": "Module", - "detail": "Module", - "sortText": "C", - "filterText": "java", - "insertText": "java", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/jballerina.java;\n" - } - ] - }, - { - "label": "ballerina/lang.array", - "kind": "Module", - "detail": "Module", - "sortText": "C", - "filterText": "array", - "insertText": "array", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.array;\n" - } - ] - }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, - { - "label": "map", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "map", - "insertTextFormat": "Snippet" - }, - { - "label": "object", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "object", - "insertTextFormat": "Snippet" - }, - { - "label": "stream", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "stream", - "insertTextFormat": "Snippet" - }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, - { - "label": "table", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "table", - "insertTextFormat": "Snippet" - }, - { - "label": "transaction", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "transaction", - "insertTextFormat": "Snippet" - }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, - { - "label": "service on lang.test:MockListener", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "E", - "filterText": "service_lang_test_MockListener", - "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.test;\n" - } - ] - }, - { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", - "sortText": "C", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] - }, - { - "label": "service on module1:Listener", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "E", - "filterText": "service_module1_Listener", - "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/module1;\n" - } - ] - }, - { - "label": "function (..) => ", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "function", - "insertText": "function ${1:name}(${2})${3} => (${4});", - "insertTextFormat": "Snippet" - } - ] -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_on_expected_as_keyword.json b/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_on_expected_as_keyword.json deleted file mode 100644 index 2604b55e9949..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_on_expected_as_keyword.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "position": { - "line": 0, - "character": 66 - }, - "source": "module_client_declaration_context/source/module_client_declaration_on_expected_as_keyword.bal", - "items": [ - { - "label": "as", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "as", - "insertText": "as ", - "insertTextFormat": "Snippet" - } - ] -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_on_expected_service_uri.json b/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_on_expected_service_uri.json deleted file mode 100644 index f5f0c2c1cb80..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_on_expected_service_uri.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "position": { - "line": 0, - "character": 7 - }, - "source": "module_client_declaration_context/source/module_client_declaration_on_expected_service_uri.bal", - "items": [] -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_decl_test/Ballerina.toml b/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_decl_test/Ballerina.toml deleted file mode 100644 index 26c7c11ae18d..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_decl_test/Ballerina.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -org = "gayal" -name = "module_client_decl_test" -version = "0.1.0" -distribution = "2201.2.0-rc1.2" - -[build-options] -observabilityIncluded = true diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_decl_test/generated/idl-plugin-cache.json b/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_decl_test/generated/idl-plugin-cache.json deleted file mode 100644 index 8c6a19d09a7a..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_decl_test/generated/idl-plugin-cache.json +++ /dev/null @@ -1 +0,0 @@ -[{"url":"https://postman-echo.com/get?name\u003dprojectapiclientplugin","annotations":[],"generatedModuleName":"myapi","filePath":"projectapiclientplugin","lastModifiedTime":1665986763203}] \ No newline at end of file diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_decl_test/generated/myapi/idl_client.bal b/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_decl_test/generated/myapi/idl_client.bal deleted file mode 100644 index 335db8fa6929..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_decl_test/generated/myapi/idl_client.bal +++ /dev/null @@ -1,18 +0,0 @@ -public type ClientConfiguration record { - string specVersion; -}; - -public isolated client class 'client { - public final string specVersion; - - public function init(*ClientConfiguration config) { - self.specVersion = config.specVersion; - } - - remote function getSpecVersion() returns string { - lock { - return self.specVersion; - } - } - -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_decl_test/main.bal b/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_decl_test/main.bal deleted file mode 100644 index c4dad5be59f3..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_decl_test/main.bal +++ /dev/null @@ -1,7 +0,0 @@ -client "https://postman-echo.com/get?name=projectapiclientplugin" as myapi; - -myapi: - -public function main() { - myapi: -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_decl_test/projectapiclientplugin b/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_decl_test/projectapiclientplugin deleted file mode 100644 index ca252d479436..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_decl_test/projectapiclientplugin +++ /dev/null @@ -1 +0,0 @@ -{"args":{"name":"projectapiclientplugin"},"headers":{"x-forwarded-proto":"https","x-forwarded-port":"443","host":"postman-echo.com","x-amzn-trace-id":"Root=1-634cf0cb-5d437cca5f75e9324370028a","user-agent":"Java/11.0.8","accept":"text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"},"url":"https://postman-echo.com/get?name=projectapiclientplugin"} \ No newline at end of file diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_decl_test/remote_method_access.bal b/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_decl_test/remote_method_access.bal deleted file mode 100644 index 775492289e7d..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_decl_test/remote_method_access.bal +++ /dev/null @@ -1,5 +0,0 @@ -client "https://postman-echo.com/get?name=projectapiclientplugin" as myapi1; - -myapi1:ClientConfiguration config = {specVersion : "3.0.0"}; -myapi1:client cl = new (config); -string specVersion = cl-> diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_declaration_after_as_keyword.bal b/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_declaration_after_as_keyword.bal deleted file mode 100644 index 379f080d219a..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_declaration_after_as_keyword.bal +++ /dev/null @@ -1 +0,0 @@ -client "https://postman-echo.com/get?name=projectapiclientplugin" as diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_declaration_after_client_keyword.bal b/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_declaration_after_client_keyword.bal deleted file mode 100644 index 180a76d2cdc7..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_declaration_after_client_keyword.bal +++ /dev/null @@ -1 +0,0 @@ -client diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_declaration_after_service_uri.bal b/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_declaration_after_service_uri.bal deleted file mode 100644 index fa5a4177fc13..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_declaration_after_service_uri.bal +++ /dev/null @@ -1 +0,0 @@ -client "https://postman-echo.com/get?name=projectapiclientplugin" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_declaration_client_keyword.bal b/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_declaration_client_keyword.bal deleted file mode 100644 index d6ead1270539..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_declaration_client_keyword.bal +++ /dev/null @@ -1 +0,0 @@ -cl diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_declaration_on_expected_as_keyword.bal b/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_declaration_on_expected_as_keyword.bal deleted file mode 100644 index 67f51658794a..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_declaration_on_expected_as_keyword.bal +++ /dev/null @@ -1 +0,0 @@ -client "https://postman-echo.com/get?name=projectapiclientplugin" foo; diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_declaration_on_expected_service_uri.bal b/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_declaration_on_expected_service_uri.bal deleted file mode 100644 index c9f181c8c38f..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/source/module_client_declaration_on_expected_service_uri.bal +++ /dev/null @@ -1 +0,0 @@ -client as foo; diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config1.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config1.json index 4c11d48979e4..0ddf18126c80 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config1.json @@ -829,15 +829,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config14.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config14.json index 4e6ca5ba50c0..3bd6d12263e5 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config14.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config14.json @@ -910,15 +910,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config15.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config15.json index 3f29f7f6dfda..cb55bb582d88 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config15.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config15.json @@ -826,15 +826,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config15_client_declaration.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config15_client_declaration.json deleted file mode 100644 index e32ecb93e1bf..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config15_client_declaration.json +++ /dev/null @@ -1,884 +0,0 @@ -{ - "position": { - "line": 1, - "character": 0 - }, - "source": "module_part_context/source/source15_client_declaration.bal", - "items": [ - { - "label": "ballerina/lang.test", - "kind": "Module", - "detail": "Module", - "sortText": "C", - "filterText": "test", - "insertText": "test", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.test;\n" - } - ] - }, - { - "label": "ballerina/lang.array", - "kind": "Module", - "detail": "Module", - "sortText": "C", - "filterText": "array", - "insertText": "array", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.array;\n" - } - ] - }, - { - "label": "ballerina/jballerina.java", - "kind": "Module", - "detail": "Module", - "sortText": "C", - "filterText": "java", - "insertText": "java", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/jballerina.java;\n" - } - ] - }, - { - "label": "ballerina/lang.value", - "kind": "Module", - "detail": "Module", - "sortText": "C", - "filterText": "value", - "insertText": "value", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.value;\n" - } - ] - }, - { - "label": "ballerina/module1", - "kind": "Module", - "detail": "Module", - "sortText": "C", - "filterText": "module1", - "insertText": "module1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/module1;\n" - } - ] - }, - { - "label": "ballerina/lang.runtime", - "kind": "Module", - "detail": "Module", - "sortText": "C", - "filterText": "runtime", - "insertText": "runtime", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.runtime;\n" - } - ] - }, - { - "label": "xmlns", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "xmlns", - "insertText": "xmlns \"${1}\" as ${2:ns};", - "insertTextFormat": "Snippet" - }, - { - "label": "xmlns", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "xmlns", - "insertText": "xmlns ", - "insertTextFormat": "Snippet" - }, - { - "label": "var", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "var", - "insertText": "var ", - "insertTextFormat": "Snippet" - }, - { - "label": "isolated", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "isolated", - "insertText": "isolated ", - "insertTextFormat": "Snippet" - }, - { - "label": "transactional", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "transactional", - "insertText": "transactional", - "insertTextFormat": "Snippet" - }, - { - "label": "client", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "client", - "insertText": "client ", - "insertTextFormat": "Snippet" - }, - { - "label": "final", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "final", - "insertText": "final ", - "insertTextFormat": "Snippet" - }, - { - "label": "object {}", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "object", - "insertText": "object {${1}}", - "insertTextFormat": "Snippet" - }, - { - "label": "stream<> streamName = new;", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "stream", - "insertText": "stream<${1}> ${2:streamName} = new;", - "insertTextFormat": "Snippet" - }, - { - "label": "StrandData", - "kind": "Struct", - "detail": "Record", - "documentation": { - "left": "Describes Strand execution details for the runtime.\n" - }, - "sortText": "D", - "insertText": "StrandData", - "insertTextFormat": "Snippet" - }, - { - "label": "Thread", - "kind": "TypeParameter", - "detail": "Union", - "sortText": "D", - "insertText": "Thread", - "insertTextFormat": "Snippet" - }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, - { - "label": "record", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "record", - "insertText": "record ", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "function", - "insertText": "function ", - "insertTextFormat": "Snippet" - }, - { - "label": "record {}", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "record", - "insertText": "record {${1}}", - "insertTextFormat": "Snippet" - }, - { - "label": "record {||}", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "record", - "insertText": "record {|${1}|}", - "insertTextFormat": "Snippet" - }, - { - "label": "distinct", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "distinct", - "insertText": "distinct", - "insertTextFormat": "Snippet" - }, - { - "label": "true", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "true", - "insertText": "true", - "insertTextFormat": "Snippet" - }, - { - "label": "false", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "false", - "insertText": "false", - "insertTextFormat": "Snippet" - }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, - { - "label": "map", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "map", - "insertTextFormat": "Snippet" - }, - { - "label": "object", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "object", - "insertTextFormat": "Snippet" - }, - { - "label": "stream", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "stream", - "insertTextFormat": "Snippet" - }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, - { - "label": "table", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "table", - "insertTextFormat": "Snippet" - }, - { - "label": "transaction", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "transaction", - "insertTextFormat": "Snippet" - }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, - { - "label": "test/project2", - "kind": "Module", - "detail": "Module", - "sortText": "C", - "filterText": "project2", - "insertText": "project2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/project2;\n" - } - ] - }, - { - "label": "test/project1", - "kind": "Module", - "detail": "Module", - "sortText": "C", - "filterText": "project1", - "insertText": "project1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/project1;\n" - } - ] - }, - { - "label": "test/local_project2", - "kind": "Module", - "detail": "Module", - "sortText": "C", - "filterText": "local_project2", - "insertText": "local_project2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/local_project2;\n" - } - ] - }, - { - "label": "test/local_project1", - "kind": "Module", - "detail": "Module", - "sortText": "C", - "filterText": "local_project1", - "insertText": "local_project1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/local_project1;\n" - } - ] - }, - { - "label": "null", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "null", - "insertText": "null", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, - { - "label": "type", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "type", - "insertText": "type ", - "insertTextFormat": "Snippet" - }, - { - "label": "public", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "public", - "insertText": "public ", - "insertTextFormat": "Snippet" - }, - { - "label": "const", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "const", - "insertText": "const ", - "insertTextFormat": "Snippet" - }, - { - "label": "listener", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "listener", - "insertText": "listener ", - "insertTextFormat": "Snippet" - }, - { - "label": "enum", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "enum", - "insertText": "enum ", - "insertTextFormat": "Snippet" - }, - { - "label": "class", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "class", - "insertText": "class ", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "function", - "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "public main function", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "public_function_main", - "insertText": "public function main() {\n\t${1}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "configurable", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "configurable", - "insertText": "configurable", - "insertTextFormat": "Snippet" - }, - { - "label": "annotation", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "annotation", - "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", - "insertTextFormat": "Snippet" - }, - { - "label": "type record {}", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "type_record", - "insertText": "type ${1:RecordName} record {\n\t${2}\n};", - "insertTextFormat": "Snippet" - }, - { - "label": "type object", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "type_object", - "insertText": "type ${1:ObjectName} object {${2}};", - "insertTextFormat": "Snippet" - }, - { - "label": "class", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "class", - "insertText": "class ${1:className} {\n\t${2}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "enum", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "enum", - "insertText": "enum ${1:enumName} {\n\t${2}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "type record {||}", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "type_record", - "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", - "insertTextFormat": "Snippet" - }, - { - "label": "type error", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "type_error", - "insertText": "type ${1:ErrorName} error<${2:map}>;", - "insertTextFormat": "Snippet" - }, - { - "label": "type TypeName table<>;", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "type_table", - "insertText": "type ${1:TypeName} table<${2}>;", - "insertTextFormat": "Snippet" - }, - { - "label": "type TypeName table<> key", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "type_table_key", - "insertText": "type ${1:TypeName} table<${2}> key${3}", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "service", - "insertText": "service on ${1:listenerName} {\n\t${2}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "testPrefixMod", - "kind": "Module", - "detail": "Module", - "sortText": "E", - "filterText": "testPrefixMod", - "insertText": "testPrefixMod", - "insertTextFormat": "Snippet" - }, - { - "label": "service on lang.test:MockListener", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "E", - "filterText": "service_lang_test_MockListener", - "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.test;\n" - } - ] - }, - { - "label": "service on module1:Listener", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "E", - "filterText": "service_module1_Listener", - "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/module1;\n" - } - ] - }, - { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", - "sortText": "C", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] - }, - { - "label": "function (..) => ", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "function", - "insertText": "function ${1:name}(${2})${3} => (${4});", - "insertTextFormat": "Snippet" - } - ] -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config16.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config16.json index 0045ec59e38f..53db77100fdb 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config16.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config16.json @@ -896,15 +896,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config2.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config2.json index 881376cace49..0cccae6a28ad 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config2.json @@ -829,15 +829,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config3.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config3.json index e27d98debd6d..8ca1fce994d4 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config3.json @@ -829,15 +829,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config6.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config6.json index 70764559ac05..3bd9a5b7f925 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config6.json @@ -800,15 +800,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_annotation_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_annotation_decl_config.json index 06c2e459e0c6..2675a3b3caf9 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_annotation_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_annotation_decl_config.json @@ -848,15 +848,6 @@ "insertText": "TestType", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_class_defn_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_class_defn_config.json index 7cac7878a3f7..045b4c184ab4 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_class_defn_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_class_defn_config.json @@ -848,15 +848,6 @@ "insertText": "TestType", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_const_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_const_decl_config.json index 7898f4d4ef04..86e218c6805b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_const_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_const_decl_config.json @@ -848,15 +848,6 @@ "insertText": "TestType", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_enum_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_enum_decl_config.json index 75ada66ed2d1..e95931a10b53 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_enum_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_enum_decl_config.json @@ -848,15 +848,6 @@ "insertText": "TestType", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_funciton_defn_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_funciton_defn_config.json index d4e255d21c23..d0d0fc393edf 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_funciton_defn_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_funciton_defn_config.json @@ -848,15 +848,6 @@ "insertText": "TestType", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_import_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_import_decl_config.json index 7b3cb728709e..9b83f184c28e 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_import_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_import_decl_config.json @@ -848,15 +848,6 @@ "insertText": "TestType", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_listener_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_listener_decl_config.json index 241c51582a44..1b5a19b74923 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_listener_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_listener_decl_config.json @@ -848,15 +848,6 @@ "insertText": "TestType", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_service_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_service_decl_config.json index e773778cb0ea..60e95f6ce6aa 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_service_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_service_decl_config.json @@ -848,15 +848,6 @@ "insertText": "TestType", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_type_defn_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_type_defn_config.json index 2dbf6410dce0..d379d1503deb 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_type_defn_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_type_defn_config.json @@ -848,15 +848,6 @@ "insertText": "TestType", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_var_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_var_decl_config.json index 6b05532d23f7..4a1e952b9eac 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_var_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_var_decl_config.json @@ -848,15 +848,6 @@ "insertText": "TestType", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_xmlns_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_xmlns_decl_config.json index 9f251ecc97e1..e2742a304e8d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_xmlns_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_xmlns_decl_config.json @@ -848,15 +848,6 @@ "insertText": "TestType", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_annotation_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_annotation_decl_config.json index 17c5c2cfdf2a..35e56bfc98f3 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_annotation_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_annotation_decl_config.json @@ -848,15 +848,6 @@ "insertText": "TestType", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_class_defn_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_class_defn_config.json index 42b64f7866af..ab678f59a17e 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_class_defn_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_class_defn_config.json @@ -848,15 +848,6 @@ "insertText": "TestType", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_const_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_const_decl_config.json index 64ee3e9a2095..1bafa4125241 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_const_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_const_decl_config.json @@ -848,15 +848,6 @@ "insertText": "TestType", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_enum_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_enum_decl_config.json index 132f188625d8..9a287433ace1 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_enum_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_enum_decl_config.json @@ -848,15 +848,6 @@ "insertText": "TestType", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_function_defn_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_function_defn_config.json index 724afad2e7db..fe30b2dd0f16 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_function_defn_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_function_defn_config.json @@ -848,15 +848,6 @@ "insertText": "TestType", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_import_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_import_decl_config.json index 87de2329bc1d..93efa15d3dfb 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_import_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_import_decl_config.json @@ -848,15 +848,6 @@ "insertText": "TestType", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_listener_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_listener_decl_config.json index f43bd48011aa..6b527709efcd 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_listener_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_listener_decl_config.json @@ -848,15 +848,6 @@ "insertText": "TestType", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_service_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_service_decl_config.json index b78629ecbb1b..c89a63f47ed8 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_service_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_service_decl_config.json @@ -848,15 +848,6 @@ "insertText": "TestType", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_type_defn_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_type_defn_config.json index ab92488aa068..860955c3c3e1 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_type_defn_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_type_defn_config.json @@ -848,15 +848,6 @@ "insertText": "TestType", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_var_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_var_decl_config.json index 7daecb806ba8..9e1bafe08c4e 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_var_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_var_decl_config.json @@ -848,15 +848,6 @@ "insertText": "TestType", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_xmlns_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_xmlns_decl_config.json index 08b2a499ccbd..ee3111cf2a77 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_xmlns_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_xmlns_decl_config.json @@ -848,15 +848,6 @@ "insertText": "TestType", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/source/source15_client_declaration.bal b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/source/source15_client_declaration.bal deleted file mode 100644 index e38f595ed8e7..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/source/source15_client_declaration.bal +++ /dev/null @@ -1,7 +0,0 @@ -client "https://postman-echo1.com/get?name=projectapiclientplugin" as testPrefixMod; - - -function testFunction() { - client "https://postman-echo2.com/get?name=projectapiclientplugin" as testPrefix; - -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_body/config/config4.json b/language-server/modules/langserver-core/src/test/resources/completion/service_body/config/config4.json index 4e6cfa16a3b7..46c255fe8ee8 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_body/config/config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_body/config/config4.json @@ -877,15 +877,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config16.json b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config16.json index c889d5fd0e87..064e0ca2f289 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config16.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config16.json @@ -877,15 +877,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config17.json b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config17.json index df6918c7c3ec..b88910127181 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config17.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config17.json @@ -808,15 +808,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config18.json b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config18.json index 0a49f7291aa7..e09ed2d3883d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config18.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config18.json @@ -808,15 +808,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config7.json b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config7.json index 3cd556977a3c..06a097ebdc14 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config7.json @@ -808,15 +808,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/continue_break_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/continue_break_stmt_ctx_config1.json index e496929cae9b..bbf587d09773 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/continue_break_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/continue_break_stmt_ctx_config1.json @@ -910,15 +910,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/continue_break_stmt_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/continue_break_stmt_ctx_config2.json index 556b0895eade..bdd76c83166d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/continue_break_stmt_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/continue_break_stmt_ctx_config2.json @@ -918,15 +918,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/do_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/do_stmt_ctx_config1.json index ff1aa3aded07..683d7407611a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/do_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/do_stmt_ctx_config1.json @@ -884,15 +884,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/else_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/else_stmt_ctx_config1.json index 2bdd0f149262..0deee0d96e15 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/else_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/else_stmt_ctx_config1.json @@ -891,15 +891,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/else_stmt_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/else_stmt_ctx_config2.json index a99ba16dad31..e38cdd14144f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/else_stmt_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/else_stmt_ctx_config2.json @@ -891,15 +891,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config1.json index 5ee9c0002c26..330ad24a0683 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config1.json @@ -891,15 +891,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config2.json index 4e93feab02c3..ede89b6b7dd4 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config2.json @@ -891,15 +891,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/function_call_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/function_call_stmt_ctx_config1.json index 62bc953cbdd2..84219253ace1 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/function_call_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/function_call_stmt_ctx_config1.json @@ -892,15 +892,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/function_call_stmt_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/function_call_stmt_ctx_config2.json index 0c9d1deed2ea..8d5ccb397d79 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/function_call_stmt_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/function_call_stmt_ctx_config2.json @@ -892,15 +892,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config1.json index 2c2d832185c6..bc370de04738 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config1.json @@ -883,15 +883,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config2.json index 365f41ca73aa..5843951dbeed 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config2.json @@ -883,15 +883,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config7.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config7.json index 0c5d3b93782e..52ffadb7f711 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config7.json @@ -918,15 +918,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config8.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config8.json index ac14d45b53c6..bdf0b71f0700 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config8.json @@ -918,15 +918,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/local_var_decl_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/local_var_decl_stmt_ctx_config1.json index e0c41400ef48..02501b364761 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/local_var_decl_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/local_var_decl_stmt_ctx_config1.json @@ -877,15 +877,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/lock_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/lock_stmt_ctx_config1.json index 182d8492f217..b35382e29efc 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/lock_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/lock_stmt_ctx_config1.json @@ -892,15 +892,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/lock_stmt_ctx_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/lock_stmt_ctx_config3.json index 4b00578eb24b..a5293959208a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/lock_stmt_ctx_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/lock_stmt_ctx_config3.json @@ -876,15 +876,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config1.json index 7a791f6401b6..766b5b300b6b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config1.json @@ -879,15 +879,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config1a.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config1a.json index a55c57ba9ab0..7e6a8b3f33fe 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config1a.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config1a.json @@ -879,15 +879,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config2.json index 111d5d77f148..971a9f605259 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config2.json @@ -879,15 +879,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config2a.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config2a.json index e5fdf1e6744e..06180a1f2d7f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config2a.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config2a.json @@ -879,15 +879,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config3.json index 5058777969b1..8a1eeef1bb4b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config3.json @@ -896,15 +896,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config4.json index 4e2751907182..73fd3c0dc7d0 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config4.json @@ -879,15 +879,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config5.json index 86c53a4079ac..815ae54ce3d1 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config5.json @@ -879,15 +879,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config5a.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config5a.json index bcf71316e56e..0b10a0fad991 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config5a.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config5a.json @@ -879,15 +879,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config6.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config6.json index 96015720253e..274a75fe47af 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config6.json @@ -883,15 +883,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config6a.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config6a.json index 206a0d77cf87..6bc6e35521a8 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config6a.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config6a.json @@ -883,15 +883,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/panic_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/panic_stmt_ctx_config1.json index 87bf77629e38..b3897d6e3c9e 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/panic_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/panic_stmt_ctx_config1.json @@ -4,7 +4,6 @@ "character": 9 }, "source": "statement_context/source/panic_stmt_ctx_source1.bal", - "description": "Checks for statement block completions (specifically the panic keyword snippet for panic statement)", "items": [ { "label": "start", @@ -889,15 +888,6 @@ "command": "editor.action.triggerParameterHints" } }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "Q", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config1.json index 546675400b16..57c09ea473cb 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config1.json @@ -862,15 +862,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "Q", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config10.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config10.json index ac38832968f6..cb0037fd05e6 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config10.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config10.json @@ -877,15 +877,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config11.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config11.json index e6f30bba27b8..817f4b52543d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config11.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config11.json @@ -884,15 +884,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config12.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config12.json index dc7024a58528..96e576f1dba4 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config12.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config12.json @@ -887,15 +887,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config13.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config13.json index a058765fb4ee..9f5b34338121 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config13.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config13.json @@ -887,15 +887,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config14.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config14.json index be5deb5aede7..4de5609ea2cb 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config14.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config14.json @@ -868,15 +868,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config15.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config15.json index 351fe6b1bc46..2a6bb1855f88 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config15.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config15.json @@ -877,15 +877,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config2.json index 4a38f1374a1b..146f1a9c826a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config2.json @@ -895,15 +895,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "Q", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config3.json index 3a6c49ea1074..692de60fb5dd 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config3.json @@ -861,15 +861,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "Q", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config4.json index 4d089575c053..32d5b74950e6 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config4.json @@ -853,15 +853,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "Q", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config5.json index 5399471371ac..926f8e38a163 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config5.json @@ -886,15 +886,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "Q", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config6.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config6.json index ac2c40d347f0..ae26576fca83 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config6.json @@ -868,15 +868,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config7.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config7.json index 2e419c23f88a..20fad3cb125d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config7.json @@ -877,15 +877,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "Q", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config8.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config8.json index fd2513f3abc2..1982bbc21dfc 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config8.json @@ -861,15 +861,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config9.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config9.json index 810eb005fd72..f841e2d81384 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config9.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config9.json @@ -861,15 +861,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/transaction_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/transaction_config1.json index 2fd04f63778e..f0a99bbf9515 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/transaction_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/transaction_config1.json @@ -894,15 +894,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config1.json index 861fdc212d9f..1cfb8b3d41c7 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config1.json @@ -901,15 +901,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config2.json index 5ff50125b00b..56451a48bd55 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config2.json @@ -901,15 +901,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/worker_declaration_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/worker_declaration_ctx_config1.json index 8ea0c6e4da3e..3ec1b702f704 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/worker_declaration_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/worker_declaration_ctx_config1.json @@ -883,15 +883,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/worker_declaration_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/worker_declaration_ctx_config2.json index df3428331e6c..fad1ac63827a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/worker_declaration_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/worker_declaration_ctx_config2.json @@ -883,15 +883,6 @@ "insertText": "function", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/array_typedesc5.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/array_typedesc5.json index 8be1a5efef70..e22ba0a1cbd7 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/array_typedesc5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/array_typedesc5.json @@ -908,15 +908,6 @@ "insertText": "module1:TestRecord2", "insertTextFormat": "Snippet" }, - { - "label": "client", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "client", - "insertText": "client \"${1}\" as ${2:clientName};", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", diff --git a/language-server/modules/langserver-stdlib/src/main/ballerina/annotation_source1.bal b/language-server/modules/langserver-stdlib/src/main/ballerina/annotation_source1.bal index c7177351d654..8074adab0658 100644 --- a/language-server/modules/langserver-stdlib/src/main/ballerina/annotation_source1.bal +++ b/language-server/modules/langserver-stdlib/src/main/ballerina/annotation_source1.bal @@ -87,7 +87,3 @@ public const annotation AnnotationType commonAnnotation2; public const annotation AnnotationType serviceRemoteFunctionAnnotation1 on service remote function; public const annotation serviceRemoteFunctionAnnotation2 on service remote function; - -public const annotation AnnotationType sourceClientDeclaration1 on source client; - -public const annotation sourceClientDeclaration2 on source client; From 6d7b10e8e6eb4ee541a0fc4fbf5eb25e0f19c9ed Mon Sep 17 00:00:00 2001 From: HindujaB Date: Tue, 15 Nov 2022 12:13:32 +0530 Subject: [PATCH 058/450] Fix hanging shell tests --- .../ballerina/runtime/internal/scheduling/AsyncUtils.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/scheduling/AsyncUtils.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/scheduling/AsyncUtils.java index a614b589f9e9..30bc94f00721 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/scheduling/AsyncUtils.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/scheduling/AsyncUtils.java @@ -140,7 +140,7 @@ public static void invokeFunctionPointerAsyncIteratively(BFunctionPointer Strand parent = Scheduler.getStrand(); blockStrand(parent); AtomicInteger callCount = new AtomicInteger(0); - BFunctionType funcType = (BFunctionType) func.getType(); + BFunctionType funcType = (BFunctionType) TypeUtils.getReferredType(func.getType()); scheduleNextFunction(func, funcType, parent, strandName, metadata, noOfIterations, callCount, argsSupplier, futureResultConsumer, returnValueSupplier, scheduler); @@ -165,7 +165,7 @@ public static void getArgsWithDefaultValues(Scheduler scheduler, BObject object, private static void getArgsWithDefaultValues(Scheduler scheduler, BFunctionPointer func, Callback callback, Object... args) { - FunctionType functionType = (FunctionType) func.getType(); + FunctionType functionType = (FunctionType) TypeUtils.getReferredType(func.getType()); Module module = functionType.getPackage(); if (args.length == 0 || module == null) { callback.notifySuccess(args); @@ -327,4 +327,7 @@ public void accept(Object returnValue, Throwable throwable) { } } } + + private AsyncUtils() { + } } From a9e7d04c5cce21d7a069b2b912055afbc7786381 Mon Sep 17 00:00:00 2001 From: gabilang Date: Tue, 15 Nov 2022 15:44:39 +0530 Subject: [PATCH 059/450] Disallow float and decimal suffixes in CLI args --- .../runtime/internal/TypeConverter.java | 7 +++++-- .../runtime/internal/cli/CliUtil.java | 17 +++++++++-------- .../ballerina/runtime/internal/cli/Option.java | 2 +- .../langlib/floatingpoint/FromString.java | 7 +------ .../function/ArgumentParserNegativeTest.java | 18 +++++++++++++++--- 5 files changed, 31 insertions(+), 20 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeConverter.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeConverter.java index fefa319ff0e2..3d051af330a2 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeConverter.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeConverter.java @@ -27,7 +27,6 @@ import io.ballerina.runtime.api.utils.StringUtils; import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.utils.XmlUtils; -import io.ballerina.runtime.api.values.BDecimal; import io.ballerina.runtime.api.values.BError; import io.ballerina.runtime.api.values.BString; import io.ballerina.runtime.api.values.BXml; @@ -923,6 +922,10 @@ public static int stringToByte(String value) throws NumberFormatException, BErro } public static Double stringToFloat(String value) throws NumberFormatException { + String upperCaseValue = value.toUpperCase(); + if (upperCaseValue.endsWith("F") || upperCaseValue.endsWith("D")) { + throw new NumberFormatException(); + } return Double.parseDouble(value); } @@ -935,7 +938,7 @@ public static Boolean stringToBoolean(String value) throws NumberFormatException throw new NumberFormatException(); } - public static BDecimal stringToDecimal(String value) throws NumberFormatException { + public static DecimalValue stringToDecimal(String value) throws NumberFormatException { return new DecimalValue(value); } diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/CliUtil.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/CliUtil.java index 9b3b256d535c..a771eeab3952 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/CliUtil.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/CliUtil.java @@ -25,6 +25,7 @@ import io.ballerina.runtime.api.types.UnionType; import io.ballerina.runtime.api.utils.StringUtils; import io.ballerina.runtime.api.values.BError; +import io.ballerina.runtime.internal.TypeConverter; import io.ballerina.runtime.internal.values.DecimalValue; import java.util.List; @@ -105,20 +106,15 @@ private static long getIntegerValue(String argument, String parameterName) { if (isHexValueString(argument)) { return Long.parseLong(argument.toUpperCase().replace(HEX_PREFIX, ""), 16); } - return Long.parseLong(argument); + return TypeConverter.stringToInt(argument); } catch (NumberFormatException e) { throw getInvalidArgumentError(argument, parameterName, "integer"); } } - private static boolean isHexValueString(String value) { - String upperCaseVal = value.toUpperCase(); - return upperCaseVal.startsWith("0X") || upperCaseVal.startsWith("-0X"); - } - private static double getFloatValue(String argument, String parameterName) { try { - return Double.parseDouble(argument); + return TypeConverter.stringToFloat(argument); } catch (NumberFormatException e) { throw getInvalidArgumentError(argument, parameterName, "float"); } @@ -126,12 +122,17 @@ private static double getFloatValue(String argument, String parameterName) { private static DecimalValue getDecimalValue(String argument, String parameterName) { try { - return new DecimalValue(argument); + return TypeConverter.stringToDecimal(argument); } catch (NumberFormatException | BError e) { throw getInvalidArgumentError(argument, parameterName, "decimal"); } } + private static boolean isHexValueString(String value) { + String upperCaseVal = value.toUpperCase(); + return upperCaseVal.startsWith("0X") || upperCaseVal.startsWith("-0X"); + } + private static BError getInvalidArgumentError(String argument, String parameterName, String type) { return ErrorCreator.createError( StringUtils.fromString(String.format(INVALID_ARGUMENT_ERROR, argument, parameterName, type))); diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java index 50a45fdbf738..23752d60d7cc 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java @@ -99,7 +99,7 @@ private boolean isNumeric(String stringVal) { if (upperCaseValue.endsWith("F") || upperCaseValue.endsWith("D")) { stringVal = upperCaseValue.substring(0, stringVal.length() - 1); } - return HEX_LITERAL.matcher(stringVal).matches() || NUMBER_PATTERN.matcher(stringVal).matches(); + return NUMBER_PATTERN.matcher(stringVal).matches() || HEX_LITERAL.matcher(stringVal).matches(); } private void validateConfigOption(String arg) { diff --git a/langlib/lang.float/src/main/java/org/ballerinalang/langlib/floatingpoint/FromString.java b/langlib/lang.float/src/main/java/org/ballerinalang/langlib/floatingpoint/FromString.java index d4960d5faebe..9bc58729ed3b 100644 --- a/langlib/lang.float/src/main/java/org/ballerinalang/langlib/floatingpoint/FromString.java +++ b/langlib/lang.float/src/main/java/org/ballerinalang/langlib/floatingpoint/FromString.java @@ -48,13 +48,8 @@ public class FromString { public static Object fromString(BString s) { String decimalFloatingPointNumber = s.getValue(); - String upperCaseValue = decimalFloatingPointNumber.toUpperCase(); - if (upperCaseValue.endsWith("F") || upperCaseValue.endsWith("D")) { - return getTypeConversionError(decimalFloatingPointNumber); - } - try { - return TypeConverter.stringToFloat(s.getValue()); + return TypeConverter.stringToFloat(decimalFloatingPointNumber); } catch (NumberFormatException e) { return getTypeConversionError(decimalFloatingPointNumber); } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/main/function/ArgumentParserNegativeTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/main/function/ArgumentParserNegativeTest.java index 588686b0d0dc..c253a66da225 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/main/function/ArgumentParserNegativeTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/main/function/ArgumentParserNegativeTest.java @@ -137,7 +137,10 @@ public Object[][] intValues() { {"0b2101"}, {"0B11015"}, {"0xkef"}, - {"0XFSF1"} + {"0XFSF1"}, + {"12d"}, + {"-128D"}, + {""} }; } @@ -150,7 +153,12 @@ public Object[] floatValues() { "2.0d", "-2d", "-4.5f", - "0x23dfp-2d" + "0x23dfp-2d", + "124.56f", + "-345.34F", + "-4.235E34f", + "-5.278e-45D", + "" }; } @@ -165,7 +173,11 @@ public Object[] decimalValues() { "2.0d", "-2d", "4.5f", - "0x23dfp-2d" + "0x23dfp-2d", + "42.46D", + "-456.678d", + "-1.34e-6145f", + "" }; } } From acfb4e6b407d7cce90ef7c925938b627171001ca Mon Sep 17 00:00:00 2001 From: Kanushka Gayan Date: Wed, 16 Nov 2022 11:21:41 +0530 Subject: [PATCH 060/450] add class level endpoints to visibleEndpoint list --- .../diagramutil/SyntaxTreeMapGenerator.java | 41 ++--- .../diagramutil/SyntaxTreeGenTest.java | 145 +++++++++++++----- .../multiLevelEndpoints/external.bal | 2 +- .../resources/multiLevelEndpoints/main.bal | 83 ++++++---- 4 files changed, 187 insertions(+), 84 deletions(-) diff --git a/misc/diagram-util/src/main/java/org/ballerinalang/diagramutil/SyntaxTreeMapGenerator.java b/misc/diagram-util/src/main/java/org/ballerinalang/diagramutil/SyntaxTreeMapGenerator.java index 05b56b381d93..e669f6a700bf 100644 --- a/misc/diagram-util/src/main/java/org/ballerinalang/diagramutil/SyntaxTreeMapGenerator.java +++ b/misc/diagram-util/src/main/java/org/ballerinalang/diagramutil/SyntaxTreeMapGenerator.java @@ -41,6 +41,7 @@ import io.ballerina.compiler.syntax.tree.Node; import io.ballerina.compiler.syntax.tree.NodeTransformer; import io.ballerina.compiler.syntax.tree.NonTerminalNode; +import io.ballerina.compiler.syntax.tree.ObjectFieldNode; import io.ballerina.compiler.syntax.tree.RemoteMethodCallActionNode; import io.ballerina.compiler.syntax.tree.RequiredParameterNode; import io.ballerina.compiler.syntax.tree.SimpleNameReferenceNode; @@ -198,8 +199,9 @@ protected JsonElement transformSyntaxNode(Node node) { nodeJson.add("typeData", symbolJson); - if ((node.kind() == SyntaxKind.BLOCK_STATEMENT || node.kind() == SyntaxKind.FUNCTION_BODY_BLOCK) - && (this.visibleEpsForEachBlock.size() > 0 || this.visibleEpsForModule.size() > 0)) { + if ((node.kind() == SyntaxKind.BLOCK_STATEMENT || node.kind() == SyntaxKind.FUNCTION_BODY_BLOCK || + node.kind() == SyntaxKind.SERVICE_DECLARATION) && (this.visibleEpsForEachBlock.size() > 0 || + this.visibleEpsForModule.size() > 0)) { JsonArray blockEndpoints = new JsonArray(); // Add module level endpoints @@ -209,7 +211,7 @@ protected JsonElement transformSyntaxNode(Node node) { int epStartLine = endpoint.get("position").getAsJsonObject().get("startLine").getAsInt(); int epEndLine = endpoint.get("position").getAsJsonObject().get("endLine").getAsInt(); - Optional parentFunctionBlock = getParentFunctionBlock(node); + Optional parentFunctionBlock = getParentBlock(node); if (parentFunctionBlock.isPresent() && epStartLine >= parentFunctionBlock.get().lineRange().startLine().line() && epEndLine < node.lineRange().startLine().line() @@ -232,13 +234,13 @@ protected JsonElement transformSyntaxNode(Node node) { return nodeJson; } - protected Optional getParentFunctionBlock(Node node) { + protected Optional getParentBlock(Node node) { try { - if (node.kind() == SyntaxKind.FUNCTION_DEFINITION - || node.kind() == SyntaxKind.RESOURCE_ACCESSOR_DEFINITION) { + if (node.kind() == SyntaxKind.FUNCTION_DEFINITION || + node.kind() == SyntaxKind.SERVICE_DECLARATION) { return Optional.of(node); } - return getParentFunctionBlock(node.parent()); + return getParentBlock(node.parent()); } catch (NullPointerException ex) { return Optional.empty(); } @@ -291,7 +293,8 @@ private JsonObject updateVisibleEP(Node node, TypeSymbol typeSymbol, boolean isR Optional paramName = requiredParameterNode.paramName(); String symbolName = paramName.isPresent() ? paramName.get().text() : ""; symbolMetaInfo = getModuleMetaInfo(typeSymbol, symbolName, requiredParameterNode.lineRange(), - false, true, true); + false, true); + symbolMetaInfo.addProperty("isParameter", true); if (!isAvailableAsEndpoint(symbolName)) { this.visibleEpsForEachBlock.add(symbolMetaInfo); } @@ -308,6 +311,16 @@ private JsonObject updateVisibleEP(Node node, TypeSymbol typeSymbol, boolean isR } } break; + case OBJECT_FIELD: + ObjectFieldNode objectFieldNode = (ObjectFieldNode) node; + String fieldName = objectFieldNode.fieldName().text(); + symbolMetaInfo = getModuleMetaInfo(typeSymbol, fieldName, objectFieldNode.lineRange(), + false, true); + symbolMetaInfo.addProperty("isClassField", true); + if (!isAvailableAsEndpoint(fieldName)) { + this.visibleEpsForEachBlock.add(symbolMetaInfo); + } + break; case LOCAL_VAR_DECL: VariableDeclarationNode variableDeclarationNode = (VariableDeclarationNode) node; if (variableDeclarationNode.typedBindingPattern().bindingPattern().kind() == @@ -374,18 +387,6 @@ private JsonObject getModuleMetaInfo(TypeSymbol typeSymbol, String name, LineRan return metaInfo; } - private JsonObject getModuleMetaInfo(TypeSymbol typeSymbol, String name, LineRange lineRange, - Boolean isModuleVar, Boolean isExternal, Boolean isParam) { - if (!typeSymbol.getModule().isPresent()) { - return new JsonObject(); - } - - JsonObject metaInfo = getModuleMetaInfo(typeSymbol, name, lineRange, isModuleVar, isExternal); - metaInfo.addProperty("isParameter", isParam); - - return metaInfo; - } - private boolean isAvailableAsEndpoint(String name) { for (JsonObject ep : this.visibleEpsForEachBlock) { if (ep.get("name").getAsString().equals(name) && ep.get("innerBlock") == null) { diff --git a/misc/diagram-util/src/test/java/org/ballerinalang/diagramutil/SyntaxTreeGenTest.java b/misc/diagram-util/src/test/java/org/ballerinalang/diagramutil/SyntaxTreeGenTest.java index 450104630c8c..93888dec0cee 100644 --- a/misc/diagram-util/src/test/java/org/ballerinalang/diagramutil/SyntaxTreeGenTest.java +++ b/misc/diagram-util/src/test/java/org/ballerinalang/diagramutil/SyntaxTreeGenTest.java @@ -364,7 +364,7 @@ public void testVisibleEndpoints() throws IOException { Assert.assertEquals(stJson.getAsJsonObject().get("kind").getAsString(), "ModulePart"); Assert.assertTrue(stJson.getAsJsonObject().get("members").isJsonArray()); - Assert.assertTrue(stJson.getAsJsonObject().get("members").getAsJsonArray().size() == 6); + Assert.assertTrue(stJson.getAsJsonObject().get("members").getAsJsonArray().size() == 9); JsonArray members = stJson.getAsJsonObject().get("members").getAsJsonArray(); // Verify main function @@ -386,8 +386,8 @@ public void testVisibleEndpoints() throws IOException { Assert.assertEquals(exEp0.get("isModuleVar").getAsBoolean(), true); Assert.assertEquals(exEp0.get("isExternal").getAsBoolean(), true); JsonObject exEp0Position = exEp0.get("position").getAsJsonObject(); - Assert.assertEquals(exEp0Position.get("startLine").getAsInt(), 12); - Assert.assertEquals(exEp0Position.get("endLine").getAsInt(), 12); + Assert.assertEquals(exEp0Position.get("startLine").getAsInt(), 14); + Assert.assertEquals(exEp0Position.get("endLine").getAsInt(), 14); JsonObject exEp1 = mainFunctionVEp.get(1).getAsJsonObject(); Assert.assertEquals(exEp1.get("name").getAsString(), "exEp1"); @@ -399,13 +399,13 @@ public void testVisibleEndpoints() throws IOException { Assert.assertEquals(exEp1.get("isModuleVar").getAsBoolean(), false); Assert.assertEquals(exEp1.get("isExternal").getAsBoolean(), false); JsonObject exEp1Position = exEp1.get("position").getAsJsonObject(); - Assert.assertEquals(exEp1Position.get("startLine").getAsInt(), 15); - Assert.assertEquals(exEp1Position.get("endLine").getAsInt(), 15); + Assert.assertEquals(exEp1Position.get("startLine").getAsInt(), 17); + Assert.assertEquals(exEp1Position.get("endLine").getAsInt(), 17); // Verify main function if block - Assert.assertEquals(mainFunctionBody.get("statements").getAsJsonArray().get(4).getAsJsonObject().get("ifBody") + Assert.assertEquals(mainFunctionBody.get("statements").getAsJsonArray().get(3).getAsJsonObject().get("ifBody") .getAsJsonObject().get("kind").getAsString(), "BlockStatement"); - JsonObject mainFunctionIfBody = mainFunctionBody.get("statements").getAsJsonArray().get(4).getAsJsonObject() + JsonObject mainFunctionIfBody = mainFunctionBody.get("statements").getAsJsonArray().get(3).getAsJsonObject() .get("ifBody").getAsJsonObject(); JsonArray mainFunctionIfBodyVEp = mainFunctionIfBody.get("VisibleEndpoints").getAsJsonArray(); Assert.assertTrue(mainFunctionIfBodyVEp.size() == 3); @@ -429,10 +429,10 @@ public void testVisibleEndpoints() throws IOException { Assert.assertEquals(exEp2Position.get("endLine").getAsInt(), 22); // Verify main function anonymous function block - Assert.assertEquals(mainFunctionBody.get("statements").getAsJsonArray().get(5).getAsJsonObject() + Assert.assertEquals(mainFunctionBody.get("statements").getAsJsonArray().get(4).getAsJsonObject() .get("initializer").getAsJsonObject().get("functionBody").getAsJsonObject().get("kind") .getAsString(), "FunctionBodyBlock"); - JsonObject mainFunctionAnonBody = mainFunctionBody.get("statements").getAsJsonArray().get(5) + JsonObject mainFunctionAnonBody = mainFunctionBody.get("statements").getAsJsonArray().get(4) .getAsJsonObject().get("initializer").getAsJsonObject().get("functionBody").getAsJsonObject(); JsonArray mainFunctionAnonVEp = mainFunctionAnonBody.get("VisibleEndpoints").getAsJsonArray(); Assert.assertTrue(mainFunctionAnonVEp.size() == 3); @@ -495,9 +495,9 @@ public void testVisibleEndpoints() throws IOException { Assert.assertEquals(exEp6Position.get("endLine").getAsInt(), 41); // Verify secondFunc function while block - Assert.assertEquals(secondFunctionBody.get("statements").getAsJsonArray().get(0).getAsJsonObject() + Assert.assertEquals(secondFunctionBody.get("statements").getAsJsonArray().get(1).getAsJsonObject() .get("whileBody").getAsJsonObject().get("kind").getAsString(), "BlockStatement"); - JsonObject secondFunctionWhileBody = secondFunctionBody.get("statements").getAsJsonArray().get(0) + JsonObject secondFunctionWhileBody = secondFunctionBody.get("statements").getAsJsonArray().get(1) .getAsJsonObject().get("whileBody").getAsJsonObject(); JsonArray secondFunctionWhileBodyVEp = secondFunctionWhileBody.get("VisibleEndpoints").getAsJsonArray(); Assert.assertTrue(secondFunctionWhileBodyVEp.size() == 3); @@ -521,9 +521,9 @@ public void testVisibleEndpoints() throws IOException { Assert.assertEquals(exEp4Position.get("endLine").getAsInt(), 34); // Verify secondFunc function do block - Assert.assertEquals(secondFunctionBody.get("statements").getAsJsonArray().get(1).getAsJsonObject() + Assert.assertEquals(secondFunctionBody.get("statements").getAsJsonArray().get(2).getAsJsonObject() .get("blockStatement").getAsJsonObject().get("kind").getAsString(), "BlockStatement"); - JsonObject secondFunctionDoBody = secondFunctionBody.get("statements").getAsJsonArray().get(1) + JsonObject secondFunctionDoBody = secondFunctionBody.get("statements").getAsJsonArray().get(2) .getAsJsonObject().get("blockStatement").getAsJsonObject(); JsonArray secondFunctionDoBodyVEp = secondFunctionDoBody.get("VisibleEndpoints").getAsJsonArray(); Assert.assertTrue(secondFunctionDoBodyVEp.size() == 3); @@ -547,10 +547,10 @@ public void testVisibleEndpoints() throws IOException { Assert.assertEquals(exEp5Position.get("endLine").getAsInt(), 38); // Verify secondFunc function else block - Assert.assertEquals(secondFunctionBody.get("statements").getAsJsonArray().get(3).getAsJsonObject() + Assert.assertEquals(secondFunctionBody.get("statements").getAsJsonArray().get(4).getAsJsonObject() .get("elseBody").getAsJsonObject().get("elseBody").getAsJsonObject().get("kind").getAsString(), "BlockStatement"); - JsonObject secondFunctionElseBody = secondFunctionBody.get("statements").getAsJsonArray().get(3) + JsonObject secondFunctionElseBody = secondFunctionBody.get("statements").getAsJsonArray().get(4) .getAsJsonObject().get("elseBody").getAsJsonObject().get("elseBody").getAsJsonObject(); JsonArray secondFunctionElseBodyVEp = secondFunctionElseBody.get("VisibleEndpoints").getAsJsonArray(); Assert.assertTrue(secondFunctionElseBodyVEp.size() == 4); @@ -582,7 +582,7 @@ public void testVisibleEndpoints() throws IOException { "thirdFunc"); JsonObject thirdFunctionBody = thirdFunction.get("functionBody").getAsJsonObject(); JsonArray thirdFunctionVEp = thirdFunctionBody.get("VisibleEndpoints").getAsJsonArray(); - Assert.assertTrue(thirdFunctionVEp.size() == 2); + Assert.assertTrue(thirdFunctionVEp.size() == 3); // Verify thirdFunc function visible endpoints Assert.assertEquals(thirdFunctionVEp.get(0).getAsJsonObject().get("name").getAsString(), "exEp0"); @@ -600,6 +600,19 @@ public void testVisibleEndpoints() throws IOException { Assert.assertEquals(exEp8Position.get("startLine").getAsInt(), 53); Assert.assertEquals(exEp8Position.get("endLine").getAsInt(), 53); + JsonObject exEp6Copy = thirdFunctionVEp.get(2).getAsJsonObject(); + Assert.assertEquals(exEp6Copy.get("name").getAsString(), "exEp6"); + Assert.assertEquals(exEp6Copy.get("typeName").getAsString(), "ExternalClient"); + Assert.assertEquals(exEp6Copy.get("orgName").getAsString(), "gayanOrg"); + Assert.assertEquals(exEp6Copy.get("packageName").getAsString(), "testEps"); + Assert.assertEquals(exEp6Copy.get("moduleName").getAsString(), "testEps"); + Assert.assertEquals(exEp6Copy.get("version").getAsString(), "0.1.0"); + Assert.assertEquals(exEp6Copy.get("isModuleVar").getAsBoolean(), false); + Assert.assertEquals(exEp6Copy.get("isExternal").getAsBoolean(), false); + JsonObject exEp6CopyPosition = exEp6Copy.get("position").getAsJsonObject(); + Assert.assertEquals(exEp6CopyPosition.get("startLine").getAsInt(), 57); + Assert.assertEquals(exEp6CopyPosition.get("endLine").getAsInt(), 57); + // Verify fourthFunc function Assert.assertEquals(members.get(5).getAsJsonObject().get("kind").getAsString(), "FunctionDefinition"); JsonObject fourthFunction = members.get(5).getAsJsonObject(); @@ -636,10 +649,23 @@ public void testVisibleEndpoints() throws IOException { Assert.assertEquals(exEpP2.get("isExternal").getAsBoolean(), true); Assert.assertEquals(exEpP2.get("isParameter").getAsBoolean(), true); JsonObject exEpP2Position = exEpP2.get("position").getAsJsonObject(); - Assert.assertEquals(exEpP2Position.get("startLine").getAsInt(), 61); - Assert.assertEquals(exEpP2Position.get("endLine").getAsInt(), 61); - - JsonObject exEp10 = fourthFunctionVEp.get(3).getAsJsonObject(); + Assert.assertEquals(exEpP2Position.get("startLine").getAsInt(), 62); + Assert.assertEquals(exEpP2Position.get("endLine").getAsInt(), 62); + + JsonObject tempVar = fourthFunctionVEp.get(3).getAsJsonObject(); + Assert.assertEquals(tempVar.get("name").getAsString(), "temp"); + Assert.assertEquals(tempVar.get("typeName").getAsString(), "ExternalClient"); + Assert.assertEquals(tempVar.get("orgName").getAsString(), "gayanOrg"); + Assert.assertEquals(tempVar.get("packageName").getAsString(), "testEps"); + Assert.assertEquals(tempVar.get("moduleName").getAsString(), "testEps"); + Assert.assertEquals(tempVar.get("version").getAsString(), "0.1.0"); + Assert.assertEquals(tempVar.get("isModuleVar").getAsBoolean(), false); + Assert.assertEquals(tempVar.get("isExternal").getAsBoolean(), false); + JsonObject tempVarPosition = tempVar.get("position").getAsJsonObject(); + Assert.assertEquals(tempVarPosition.get("startLine").getAsInt(), 63); + Assert.assertEquals(tempVarPosition.get("endLine").getAsInt(), 63); + + JsonObject exEp10 = fourthFunctionVEp.get(4).getAsJsonObject(); Assert.assertEquals(exEp10.get("name").getAsString(), "exEp10"); Assert.assertEquals(exEp10.get("typeName").getAsString(), "ExternalClient"); Assert.assertEquals(exEp10.get("orgName").getAsString(), "gayanOrg"); @@ -649,21 +675,8 @@ public void testVisibleEndpoints() throws IOException { Assert.assertEquals(exEp10.get("isModuleVar").getAsBoolean(), false); Assert.assertEquals(exEp10.get("isExternal").getAsBoolean(), false); JsonObject exEp10Position = exEp10.get("position").getAsJsonObject(); - Assert.assertEquals(exEp10Position.get("startLine").getAsInt(), 65); - Assert.assertEquals(exEp10Position.get("endLine").getAsInt(), 65); - - JsonObject exEp82 = fourthFunctionVEp.get(4).getAsJsonObject(); - Assert.assertEquals(exEp82.get("name").getAsString(), "exEp8"); - Assert.assertEquals(exEp82.get("typeName").getAsString(), "ExternalClient"); - Assert.assertEquals(exEp82.get("orgName").getAsString(), "gayanOrg"); - Assert.assertEquals(exEp82.get("packageName").getAsString(), "testEps"); - Assert.assertEquals(exEp82.get("moduleName").getAsString(), "testEps"); - Assert.assertEquals(exEp82.get("version").getAsString(), "0.1.0"); - Assert.assertEquals(exEp82.get("isModuleVar").getAsBoolean(), false); - Assert.assertEquals(exEp82.get("isExternal").getAsBoolean(), false); - JsonObject exEp82Position = exEp82.get("position").getAsJsonObject(); - Assert.assertEquals(exEp82Position.get("startLine").getAsInt(), 67); - Assert.assertEquals(exEp82Position.get("endLine").getAsInt(), 67); + Assert.assertEquals(exEp10Position.get("startLine").getAsInt(), 64); + Assert.assertEquals(exEp10Position.get("endLine").getAsInt(), 64); JsonObject inEp1 = fourthFunctionVEp.get(5).getAsJsonObject(); Assert.assertEquals(inEp1.get("name").getAsString(), "inEp1"); @@ -675,7 +688,65 @@ public void testVisibleEndpoints() throws IOException { Assert.assertEquals(inEp1.get("isModuleVar").getAsBoolean(), false); Assert.assertEquals(inEp1.get("isExternal").getAsBoolean(), false); JsonObject inEp1Position = inEp1.get("position").getAsJsonObject(); - Assert.assertEquals(inEp1Position.get("startLine").getAsInt(), 69); - Assert.assertEquals(inEp1Position.get("endLine").getAsInt(), 69); + Assert.assertEquals(inEp1Position.get("startLine").getAsInt(), 70); + Assert.assertEquals(inEp1Position.get("endLine").getAsInt(), 70); + + // Verify service declaration + Assert.assertEquals(members.get(6).getAsJsonObject().get("kind").getAsString(), "ServiceDeclaration"); + JsonObject serviceDec = members.get(6).getAsJsonObject(); + JsonArray serviceMembers = serviceDec.get("members").getAsJsonArray(); + Assert.assertTrue(serviceMembers.size() == 4); + JsonArray serviceVEp = serviceDec.get("VisibleEndpoints").getAsJsonArray(); + Assert.assertTrue(serviceVEp.size() == 3); + + // Verify service declaration visible endpoints + Assert.assertEquals(serviceVEp.get(0).getAsJsonObject().get("name").getAsString(), "exEp0"); + + Assert.assertEquals(serviceVEp.get(1).getAsJsonObject().get("name").getAsString(), "exEpOut"); + + JsonObject inEp2 = serviceVEp.get(2).getAsJsonObject(); + Assert.assertEquals(inEp2.get("name").getAsString(), "inEp2"); + Assert.assertEquals(inEp2.get("typeName").getAsString(), "InternalClient"); + Assert.assertEquals(inEp2.get("orgName").getAsString(), "gayanOrg"); + Assert.assertEquals(inEp2.get("packageName").getAsString(), "testEps"); + Assert.assertEquals(inEp2.get("moduleName").getAsString(), "testEps"); + Assert.assertEquals(inEp2.get("version").getAsString(), "0.1.0"); + Assert.assertEquals(inEp2.get("isModuleVar").getAsBoolean(), false); + Assert.assertEquals(inEp2.get("isExternal").getAsBoolean(), true); + Assert.assertEquals(inEp2.get("isClassField").getAsBoolean(), true); + JsonObject inEp2Position = inEp2.get("position").getAsJsonObject(); + Assert.assertEquals(inEp2Position.get("startLine").getAsInt(), 78); + Assert.assertEquals(inEp2Position.get("endLine").getAsInt(), 78); + + // Verify resource definitions + JsonArray getResourceVEps = serviceMembers.get(2).getAsJsonObject().get("functionBody").getAsJsonObject() + .get("VisibleEndpoints").getAsJsonArray(); + Assert.assertTrue(getResourceVEps.size() == 3); + + Assert.assertEquals(getResourceVEps.get(0).getAsJsonObject().get("name").getAsString(), "exEp0"); + Assert.assertEquals(getResourceVEps.get(1).getAsJsonObject().get("name").getAsString(), "exEpOut"); + Assert.assertEquals(getResourceVEps.get(2).getAsJsonObject().get("name").getAsString(), "inEp2"); + + JsonArray postResourceVEps = serviceMembers.get(3).getAsJsonObject().get("functionBody").getAsJsonObject() + .get("VisibleEndpoints").getAsJsonArray(); + Assert.assertTrue(postResourceVEps.size() == 4); + + Assert.assertEquals(postResourceVEps.get(0).getAsJsonObject().get("name").getAsString(), "exEp0"); + Assert.assertEquals(postResourceVEps.get(1).getAsJsonObject().get("name").getAsString(), "exEpOut"); + Assert.assertEquals(postResourceVEps.get(2).getAsJsonObject().get("name").getAsString(), "inEp2"); + + JsonObject exEp11 = postResourceVEps.get(3).getAsJsonObject(); + Assert.assertEquals(exEp11.get("name").getAsString(), "exEp11"); + Assert.assertEquals(exEp11.get("typeName").getAsString(), "ExternalClient"); + Assert.assertEquals(exEp11.get("orgName").getAsString(), "gayanOrg"); + Assert.assertEquals(exEp11.get("packageName").getAsString(), "testEps"); + Assert.assertEquals(exEp11.get("moduleName").getAsString(), "testEps"); + Assert.assertEquals(exEp11.get("version").getAsString(), "0.1.0"); + Assert.assertEquals(exEp11.get("isModuleVar").getAsBoolean(), false); + Assert.assertEquals(exEp11.get("isExternal").getAsBoolean(), false); + JsonObject exEp11Position = exEp11.get("position").getAsJsonObject(); + Assert.assertEquals(exEp11Position.get("startLine").getAsInt(), 90); + Assert.assertEquals(exEp11Position.get("endLine").getAsInt(), 90); + } } diff --git a/misc/diagram-util/src/test/resources/multiLevelEndpoints/external.bal b/misc/diagram-util/src/test/resources/multiLevelEndpoints/external.bal index 2d92be820d87..b214e176a4ca 100644 --- a/misc/diagram-util/src/test/resources/multiLevelEndpoints/external.bal +++ b/misc/diagram-util/src/test/resources/multiLevelEndpoints/external.bal @@ -10,4 +10,4 @@ public client class ExternalClient { } } -ExternalClient exEpOut = new ("http://example.com/0"); +ExternalClient exEpOut = check new ("http://example.com/0"); diff --git a/misc/diagram-util/src/test/resources/multiLevelEndpoints/main.bal b/misc/diagram-util/src/test/resources/multiLevelEndpoints/main.bal index 5fcbbef427a9..810d5bc2b7e0 100644 --- a/misc/diagram-util/src/test/resources/multiLevelEndpoints/main.bal +++ b/misc/diagram-util/src/test/resources/multiLevelEndpoints/main.bal @@ -1,3 +1,5 @@ +import ballerina/http; + public client class InternalClient { public string url; @@ -10,67 +12,96 @@ public client class InternalClient { } } -ExternalClient exEp0 = new ("http://example.com/0"); +ExternalClient|error exEp0 = new ("http://example.com/0"); public function main() returns error? { - ExternalClient exEp1 = new ("http://example.com/1"); - + ExternalClient exEp1 = check new ("http://example.com/1"); var localRes = check exEp1->getAll(""); - var moduleRes = check exEp0->getAll(""); - boolean status = secondFunc(exEp1); + boolean|error status = secondFunc(exEp1); if true { - ExternalClient exEp2 = new ("http://example.com/2"); + ExternalClient exEp2 = check new ("http://example.com/2"); } any functionResult = function() { - ExternalClient exEp3 = new ("http://example.com/3"); + ExternalClient|error exEp3 = new ("http://example.com/3"); return (); }; } -function secondFunc(ExternalClient exEpP1) returns boolean { - - while exEp { - ExternalClient exEp4 = new ("http://example.com/4"); +function secondFunc(ExternalClient exEpP1) returns boolean|error { + int count = 0; + while count > 5 { + ExternalClient exEp4 = check new ("http://example.com/4"); } do { - ExternalClient exEp5 = new ("http://example.com/5"); + ExternalClient exEp5 = check new ("http://example.com/5"); } - ExternalClient exEp6 = new ("http://example.com/6"); + ExternalClient exEp6 = check new ("http://example.com/6"); - if false { - string localRes2 = check exEp4->getAll("4"); + if count == 5 { + _ = check exEp6->getAll("4"); } else { - ExternalClient exEp7 = new ("http://example.com/7"); + ExternalClient exEp7 = check new ("http://example.com/7"); } return true; } -function thirdFunc() returns boolean { - ExternalClient exEp8 = new ("http://example.com/7"); +function thirdFunc() returns boolean|error { + ExternalClient exEp8 = check new ("http://example.com/8"); if true { - ExternalClient exEp9 = new ("http://example.com/9"); + ExternalClient exEp9 = check new ("http://example.com/9"); } + ExternalClient exEp6 = check new ("http://example.com/6/copy"); return true; } -function fourthFunc(ExternalClient exEpP2) returns boolean { - var temp; - temp = exEpP2; - +function fourthFunc(ExternalClient exEpP2) returns boolean|error { + ExternalClient temp = exEpP2; ExternalClient|error exEp10 = new ("http://example.com/10"); - ExternalClient exEp8 = new ("http://example.com/8"); + if exEp10 is ExternalClient { + temp = exEp10; + } - InternalClient inEp1 = new ("http://example.com/1"); + InternalClient inEp1 = check new ("http://example.com/internal/1"); var localRes1 = check inEp1->getAll(""); - var localRes2 = check exEpOut->getAll(""); return true; } + +service / on new http:Listener(9090) { + InternalClient inEp2; + + function init() returns error? { + self.inEp2 = check new InternalClient("http://example.com/internal/1"); + } + + resource function get repos(string orgName, int max = 5) returns string|error? { + string|error? inRes = self.inEp2->getAll("service"); + return inRes; + } + + resource function post repos(string orgName) returns string|error? { + ExternalClient exEp11 = check new ("http://example.com/11"); + int count = 0; + if count > 5 {} + } +} + +function fifthFunc() { + +} + +service /next on new http:Listener(9090) { + + resource function get repos(string url) returns string|error? { + return url; + } + +} From b3cbe6ccd494c60a082ff8da9ff86d413038b868 Mon Sep 17 00:00:00 2001 From: HindujaB Date: Wed, 16 Nov 2022 17:20:23 +0530 Subject: [PATCH 061/450] Fix table with multiple keys --- .../runtime/internal/TypeChecker.java | 2 +- .../runtime/internal/cli/Option.java | 3 +-- .../internal/values/TableValueImpl.java | 3 +-- .../jvm/runtime/api/tests/TypeReference.java | 16 +++++++++++++ .../api/types/modules/typeref/typeAPIs.bal | 23 +++++++++++++++++++ .../api/types/modules/typeref/typeref.bal | 1 + 6 files changed, 43 insertions(+), 5 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java index 54f6b796f3aa..2bb06c4ab211 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeChecker.java @@ -2959,7 +2959,7 @@ private static boolean checkValueEquals(Object lhsValue, Object rhsValue, List keyTypes = new ArrayList<>(); - Type constraintType = ((ReferenceType) tableType.getConstrainedType()).getReferredType(); + Type constraintType = TypeUtils.getReferredType(tableType.getConstrainedType()); if (constraintType.getTag() == TypeTags.RECORD_TYPE_TAG) { BRecordType recordType = (BRecordType) constraintType; Arrays.stream(fieldNames) diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java index 4cc56460c99b..ab735a47281d 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java @@ -32,6 +32,7 @@ import io.ballerina.runtime.api.values.BMap; import io.ballerina.runtime.api.values.BObject; import io.ballerina.runtime.api.values.BStream; +import io.ballerina.runtime.api.values.BTable; import io.ballerina.runtime.api.values.BTypedesc; import io.ballerina.runtime.internal.TypeChecker; import io.ballerina.runtime.internal.types.BArrayType; @@ -316,4 +317,19 @@ public static boolean validateUnionTypeNarrowing(Object value, BTypedesc typedes return true; } + public static boolean validateTableKeys(BTable table) { + BError error = ErrorCreator.createError(StringUtils.fromString("Table keys does not provide type-reference " + + "type.")); + if (table.getType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw error; + } + if (table.size() != 1) { + throw error; + } + if (table.getKeyType().getTag() != TypeTags.TUPLE_TAG) { + throw error; + } + return true; + } + } diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal index ea78a6907246..839b4a56c577 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeAPIs.bal @@ -213,6 +213,29 @@ function validateValueWithUnion() { test:assertTrue(result); } + +type Sample record { + readonly int id; + readonly int depId; + string name; +}; + +type RecordRef Sample; + +type RecordRef2 RecordRef; + +type RecordTable table key(id, depId); + +function validateTableMultipleKey() { + RecordTable recTab = table [{id: 101, depId: 99, name: "aaa"}]; + boolean result = validateTableKeys(recTab); + test:assertTrue(result); +} + +function validateTableKeys(any value) returns boolean = @java:Method { + 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" +} external; + public function validateGetDetailType(any value) returns boolean = @java:Method { 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.TypeReference" } external; diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeref.bal b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeref.bal index 47b054fdc6d2..40177574aac2 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeref.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/types/modules/typeref/typeref.bal @@ -86,6 +86,7 @@ public function validateTypeRef() { validateFunctionParameters(); validateRuntimeAPIs(); validateValueWithUnion(); + validateTableMultipleKey(); } function validateFunctionParameters() { From 4ecc6164dbb65107f205f0940f2243458f3ff0b1 Mon Sep 17 00:00:00 2001 From: gabilang Date: Wed, 16 Nov 2022 17:42:29 +0530 Subject: [PATCH 062/450] Disallow hexadecimal values as integer CLI arguments --- .../runtime/internal/cli/CliUtil.java | 9 ------ .../function/ArgumentParserNegativeTest.java | 28 +++++++++++-------- .../function/ArgumentParserPositiveTest.java | 6 +--- 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/CliUtil.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/CliUtil.java index a771eeab3952..21f787ddfc33 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/CliUtil.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/CliUtil.java @@ -35,7 +35,6 @@ */ public class CliUtil { - private static final String HEX_PREFIX = "0X"; private static final String INVALID_ARGUMENT_ERROR = "invalid argument '%s' for parameter '%s', expected %s value"; @@ -103,9 +102,6 @@ static boolean isUnionWithNil(List unionMemberTypes) { private static long getIntegerValue(String argument, String parameterName) { try { - if (isHexValueString(argument)) { - return Long.parseLong(argument.toUpperCase().replace(HEX_PREFIX, ""), 16); - } return TypeConverter.stringToInt(argument); } catch (NumberFormatException e) { throw getInvalidArgumentError(argument, parameterName, "integer"); @@ -128,11 +124,6 @@ private static DecimalValue getDecimalValue(String argument, String parameterNam } } - private static boolean isHexValueString(String value) { - String upperCaseVal = value.toUpperCase(); - return upperCaseVal.startsWith("0X") || upperCaseVal.startsWith("-0X"); - } - private static BError getInvalidArgumentError(String argument, String parameterName, String type) { return ErrorCreator.createError( StringUtils.fromString(String.format(INVALID_ARGUMENT_ERROR, argument, parameterName, type))); diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/main/function/ArgumentParserNegativeTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/main/function/ArgumentParserNegativeTest.java index c253a66da225..4db6a17f4a3a 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/main/function/ArgumentParserNegativeTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/main/function/ArgumentParserNegativeTest.java @@ -130,17 +130,23 @@ public void testInvalidFloatArrayArg() { } @DataProvider(name = "intValues") - public Object[][] intValues() { - return new Object[][]{ - {"5ss"}, - {"0c10"}, - {"0b2101"}, - {"0B11015"}, - {"0xkef"}, - {"0XFSF1"}, - {"12d"}, - {"-128D"}, - {""} + public Object[] intValues() { + return new Object[]{ + "10.0", + "142.5", + "5ss", + "0c10", + "0b2101", + "0B11015", + "0x1efa2", + "-0x1efa2", + "0XFAF1", + "-0XFAF1", + "0xkef", + "0XFSF1", + "12d", + "-128D", + "" }; } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/main/function/ArgumentParserPositiveTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/main/function/ArgumentParserPositiveTest.java index ed9c6c645b27..f2bba47c573a 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/main/function/ArgumentParserPositiveTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/main/function/ArgumentParserPositiveTest.java @@ -155,11 +155,7 @@ public Object[][] mainFunctionArgsAndResult() { public Object[][] intValues() { return new Object[][]{ {"10", "10"}, - {"-10", "-10"}, - {"0x1efa2", "126882"}, - {"-0x1efa2", "-126882"}, - {"0XFAF1", "64241"}, - {"-0XFAF1", "-64241"} + {"-10", "-10"} }; } From baf30e1573f93a74ce12f1e3c67b6c7692cc69b4 Mon Sep 17 00:00:00 2001 From: aneeshafedo Date: Mon, 14 Nov 2022 11:17:34 +0530 Subject: [PATCH 063/450] Add support for anonymous arrays --- .../projectdesign/ComponentModel.java | 6 ++-- .../entity/EntityModelGenerator.java | 33 +++++++++++-------- .../projectdesign/model/entity/Entity.java | 8 ++++- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModel.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModel.java index 90edbe818501..07515e7e0bee 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModel.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModel.java @@ -32,12 +32,12 @@ public class ComponentModel { private final PackageId packageId; + private final boolean hasDiagnosticErrors; private final Map services; private final Map entities; - private boolean hasDiagnosticErrors; - - public ComponentModel(PackageId packageId, Map services, Map entities, boolean hasDiagnosticErrors) { + public ComponentModel(PackageId packageId, Map services, Map entities, + boolean hasDiagnosticErrors) { this.packageId = packageId; this.services = services; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/entity/EntityModelGenerator.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/entity/EntityModelGenerator.java index 1603b3a42104..6e380b9b3ca4 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/entity/EntityModelGenerator.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/entity/EntityModelGenerator.java @@ -43,6 +43,7 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.stream.Collectors; @@ -80,14 +81,15 @@ public Map generate() { String entityName = getEntityName(packageId, typeDefinitionSymbol.moduleQualifiedName()); RecordTypeSymbol recordTypeSymbol = (RecordTypeSymbol) typeDefinitionSymbol.typeDescriptor(); this.types.put(entityName, getType(recordTypeSymbol, entityName, - getLineRange(typeDefinitionSymbol))); + getLineRange(typeDefinitionSymbol), false)); } } } return types; } - private Entity getType(RecordTypeSymbol recordTypeSymbol, String entityName, LineRange lineRange) { + private Entity getType(RecordTypeSymbol recordTypeSymbol, String entityName, LineRange lineRange, + boolean isAnonymous) { List attributeList = new ArrayList<>(); List inclusionList = new ArrayList<>(); Map recordFieldSymbolMap = @@ -95,7 +97,7 @@ private Entity getType(RecordTypeSymbol recordTypeSymbol, String entityName, Lin for (Map.Entry fieldEntry : recordFieldSymbolMap.entrySet()) { attributeList.add(getAttribute(fieldEntry.getValue(), entityName)); } - return new Entity(attributeList, inclusionList, lineRange); + return new Entity(attributeList, inclusionList, lineRange, isAnonymous); } private Attribute getAttribute(RecordFieldSymbol recordFieldSymbol, String entityName) { @@ -104,41 +106,44 @@ private Attribute getAttribute(RecordFieldSymbol recordFieldSymbol, String entit String fieldName = recordFieldSymbol.getName().get(); // need to handle String fieldType = recordFieldSymbol.typeDescriptor().signature(); - List associations = new LinkedList<>(); + List associations; boolean optional = recordFieldSymbol.isOptional(); String defaultValue = ""; //need to address boolean nillable = isNillable(recordFieldSymbol.typeDescriptor()); if (fieldTypeDescKind.equals(TypeDescKind.RECORD)) { RecordTypeSymbol inlineRecordTypeSymbol = (RecordTypeSymbol) fieldTypeSymbol; - fieldType = entityName + fieldName.substring(0,1).toUpperCase() + + fieldType = TypeDescKind.RECORD.getName(); + String inlineRecordName = entityName + fieldName.substring(0, 1).toUpperCase(Locale.ROOT) + fieldName.substring(1); - this.types.put(fieldType, getType(inlineRecordTypeSymbol, fieldType, - getLineRange(recordFieldSymbol))); + this.types.put(inlineRecordName, getType(inlineRecordTypeSymbol, inlineRecordName, + getLineRange(recordFieldSymbol), true)); String associateCardinality = optional ? CardinalityValue.ZERO_OR_ONE.getValue() : CardinalityValue.ONE_AND_ONLY_ONE.getValue(); - Association association = new Association(fieldType, new Association.Cardinality( + Association association = new Association(inlineRecordName, new Association.Cardinality( CardinalityValue.ONE_AND_ONLY_ONE.getValue(), associateCardinality)); associations = new LinkedList<>(List.of(association)); } else if (fieldTypeDescKind.equals(TypeDescKind.ARRAY) && ((ArrayTypeSymbol) fieldTypeSymbol).memberTypeDescriptor().typeKind().equals(TypeDescKind.RECORD)) { - RecordTypeSymbol inlineRecordTypeSymbol = (RecordTypeSymbol) ((ArrayTypeSymbol) fieldTypeSymbol).memberTypeDescriptor(); - String inlineRecordName = fieldType; - fieldType = entityName + fieldName.substring(0,1).toUpperCase() + - fieldName.substring(1) + ARRAY; + RecordTypeSymbol inlineRecordTypeSymbol = (RecordTypeSymbol) ((ArrayTypeSymbol) + fieldTypeSymbol).memberTypeDescriptor(); + String inlineRecordName = entityName + fieldName.substring(0, 1).toUpperCase(Locale.ROOT) + + fieldName.substring(1); + fieldType = TypeDescKind.RECORD.getName() + ARRAY; String associateCardinality = optional ? CardinalityValue.ZERO_OR_MANY.getValue() : CardinalityValue.ONE_OR_MANY.getValue(); - Association association = new Association(fieldType, new Association.Cardinality( + Association association = new Association(inlineRecordName, new Association.Cardinality( CardinalityValue.ONE_AND_ONLY_ONE.getValue(), associateCardinality)); associations = new LinkedList<>(List.of(association)); this.types.put(inlineRecordName, getType(inlineRecordTypeSymbol, inlineRecordName, - getLineRange(recordFieldSymbol))); + getLineRange(recordFieldSymbol), true)); } else { associations = getAssociations(recordFieldSymbol.typeDescriptor(), entityName, optional, nillable); } + // todo: address when union types has anonymous records return new Attribute(fieldName, fieldType, optional, nillable, defaultValue, associations, getLineRange(recordFieldSymbol)); } diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Entity.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Entity.java index 6db8bac99b1c..cbab7e74d211 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Entity.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Entity.java @@ -32,13 +32,15 @@ public class Entity extends ComponentModelItem { private List attributes; private final List inclusions; + private final boolean isAnonymous; // todo : send the location - public Entity(List attributes, List inclusions, LineRange lineRange) { + public Entity(List attributes, List inclusions, LineRange lineRange, boolean isAnonymous) { super(lineRange); this.attributes = attributes; this.inclusions = inclusions; + this.isAnonymous = isAnonymous; } public List getAttributes() { @@ -52,5 +54,9 @@ public void setAttributes(List attributes) { public List getInclusions() { return inclusions; } + + public boolean isAnonymous() { + return isAnonymous; + } } From b74f45eb60885fc7a82f45592a861651ccb50b41 Mon Sep 17 00:00:00 2001 From: azinneera Date: Fri, 11 Nov 2022 14:27:17 +0530 Subject: [PATCH 064/450] Remove IDL client gen support from Project API --- .../io/ballerina/cli/task/CompileTask.java | 2 - .../io/ballerina/projects/BalaWriter.java | 25 -- .../ballerina/projects/DocumentContext.java | 331 +---------------- .../io/ballerina/projects/IDLClientEntry.java | 84 ----- .../projects/IDLClientGeneratorResult.java | 61 ---- .../projects/IDLPluginContextImpl.java | 43 --- .../ballerina/projects/IDLPluginManager.java | 254 ------------- .../ballerina/projects/JBallerinaBackend.java | 3 +- .../java/io/ballerina/projects/Module.java | 6 +- .../ballerina/projects/ModuleCompilation.java | 3 +- .../io/ballerina/projects/ModuleConfig.java | 24 +- .../io/ballerina/projects/ModuleContext.java | 30 +- .../io/ballerina/projects/ModuleKind.java | 31 -- .../java/io/ballerina/projects/Package.java | 89 +---- .../projects/PackageCompilation.java | 3 +- .../io/ballerina/projects/PackageContext.java | 46 +-- .../ballerina/projects/PackageResolution.java | 61 +--- .../java/io/ballerina/projects/Project.java | 4 - .../java/io/ballerina/projects/Utils.java | 84 ----- .../ballerina/projects/bala/BalaProject.java | 12 - .../projects/directory/BuildProject.java | 4 - .../projects/internal/IDLClients.java | 65 ---- .../projects/internal/PackageDiagnostic.java | 11 +- .../projects/util/DependencyUtils.java | 13 - .../compiler/semantics/model/SymbolTable.java | 3 +- .../commons/workspace/WorkspaceManager.java | 9 - .../workspace/BallerinaWorkspaceManager.java | 25 +- .../test/plugins/IDLClientCompilerTests.java | 334 ------------------ .../test/plugins/IDLClientGenPluginTests.java | 252 ------------- .../package_test_idl_plugin_1/Ballerina.toml | 7 - .../package_test_idl_plugin_1/main.bal | 23 -- .../package_test_idl_plugin_2/Ballerina.toml | 7 - ...ser-package_test_idl_plugin-any-0.1.0.bala | Bin 2323 -> 0 bytes .../package_test_idl_plugin_2/main.bal | 21 -- .../package_test_idl_plugin_3/Ballerina.toml | 7 - .../package_test_idl_plugin_3/main.bal | 23 -- .../Ballerina.toml | 7 - .../main.bal | 23 -- .../Ballerina.toml | 7 - .../main.bal | 42 --- .../modules/mod1/Module.md | 6 - .../modules/mod1/mod1.bal | 23 -- .../projectapiclientplugin.json | 10 - .../Ballerina.toml | 7 - .../exception.bal | 24 -- .../package_test_idl_plugin_negative/main.bal | 23 -- .../Ballerina.toml | 7 - .../main.bal | 27 -- .../simpleclientnegativetest/Ballerina.toml | 4 - .../simpleclientnegativetest/main.bal | 44 --- .../Ballerina.toml | 4 - .../simpleclientnegativetestfive/main.bal | 26 -- .../Ballerina.toml | 4 - .../simpleclientnegativetestfour/main.bal | 29 -- .../Ballerina.toml | 4 - .../simpleclientnegativetestsix/main.bal | 32 -- .../modules/foo/foo.bal | 19 - .../simpleclientnegativetestsix/oth.bal | 24 -- .../Ballerina.toml | 4 - .../simpleclientnegativetestthree/main.bal | 148 -------- .../Ballerina.toml | 4 - .../unused_prefix.bal | 45 --- .../simpleclienttest/Ballerina.toml | 4 - .../simpleclienttest/main.bal | 106 ------ 64 files changed, 39 insertions(+), 2668 deletions(-) delete mode 100644 compiler/ballerina-lang/src/main/java/io/ballerina/projects/IDLClientEntry.java delete mode 100644 compiler/ballerina-lang/src/main/java/io/ballerina/projects/IDLClientGeneratorResult.java delete mode 100644 compiler/ballerina-lang/src/main/java/io/ballerina/projects/IDLPluginContextImpl.java delete mode 100644 compiler/ballerina-lang/src/main/java/io/ballerina/projects/IDLPluginManager.java delete mode 100644 compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleKind.java delete mode 100644 compiler/ballerina-lang/src/main/java/io/ballerina/projects/Utils.java delete mode 100644 compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/IDLClients.java delete mode 100644 project-api/project-api-test/src/test/java/io/ballerina/projects/test/plugins/IDLClientCompilerTests.java delete mode 100644 project-api/project-api-test/src/test/java/io/ballerina/projects/test/plugins/IDLClientGenPluginTests.java delete mode 100644 project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_1/Ballerina.toml delete mode 100644 project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_1/main.bal delete mode 100644 project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_2/Ballerina.toml delete mode 100644 project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_2/idl-dependency-bala/user-package_test_idl_plugin-any-0.1.0.bala delete mode 100644 project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_2/main.bal delete mode 100644 project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_3/Ballerina.toml delete mode 100644 project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_3/main.bal delete mode 100644 project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_for_edits/Ballerina.toml delete mode 100644 project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_for_edits/main.bal delete mode 100644 project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_local_test/Ballerina.toml delete mode 100644 project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_local_test/main.bal delete mode 100644 project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_local_test/modules/mod1/Module.md delete mode 100644 project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_local_test/modules/mod1/mod1.bal delete mode 100644 project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_local_test/projectapiclientplugin.json delete mode 100644 project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_negative/Ballerina.toml delete mode 100644 project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_negative/exception.bal delete mode 100644 project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_negative/main.bal delete mode 100644 project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_repeat_client_url/Ballerina.toml delete mode 100644 project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_repeat_client_url/main.bal delete mode 100644 project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetest/Ballerina.toml delete mode 100644 project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetest/main.bal delete mode 100644 project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestfive/Ballerina.toml delete mode 100644 project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestfive/main.bal delete mode 100644 project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestfour/Ballerina.toml delete mode 100644 project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestfour/main.bal delete mode 100644 project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestsix/Ballerina.toml delete mode 100644 project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestsix/main.bal delete mode 100644 project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestsix/modules/foo/foo.bal delete mode 100644 project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestsix/oth.bal delete mode 100644 project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestthree/Ballerina.toml delete mode 100644 project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestthree/main.bal delete mode 100644 project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetesttwo/Ballerina.toml delete mode 100644 project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetesttwo/unused_prefix.bal delete mode 100644 project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclienttest/Ballerina.toml delete mode 100644 project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclienttest/main.bal diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/CompileTask.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/CompileTask.java index 0df648308fd8..51ad84d6cca2 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/CompileTask.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/CompileTask.java @@ -84,8 +84,6 @@ public void execute(Project project) { System.setProperty(CentralClientConstants.ENABLE_OUTPUT_STREAM, "true"); - // Run IDL generator plugins - project.currentPackage().runIDLGeneratorPlugins(); List diagnostics = new ArrayList<>(); try { diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/BalaWriter.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/BalaWriter.java index 62d551b324cd..f30f55519dc0 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/BalaWriter.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/BalaWriter.java @@ -22,10 +22,8 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonArray; import io.ballerina.projects.environment.PackageCache; -import io.ballerina.projects.internal.IDLClients; import io.ballerina.projects.internal.bala.BalaJson; import io.ballerina.projects.internal.bala.DependencyGraphJson; -import io.ballerina.projects.internal.bala.IDLClientsJson; import io.ballerina.projects.internal.bala.ModuleDependency; import io.ballerina.projects.internal.bala.PackageJson; import io.ballerina.projects.internal.bala.adaptors.JsonCollectionsAdaptor; @@ -34,11 +32,8 @@ import io.ballerina.projects.internal.model.Dependency; import io.ballerina.projects.util.ProjectConstants; import io.ballerina.projects.util.ProjectUtils; -import io.ballerina.tools.text.LineRange; import org.apache.commons.compress.utils.IOUtils; import org.ballerinalang.compiler.BLangCompilerException; -import org.ballerinalang.model.elements.PackageID; -import org.wso2.ballerinalang.compiler.util.CompilerContext; import org.wso2.ballerinalang.util.RepoUtils; import java.io.ByteArrayInputStream; @@ -56,7 +51,6 @@ import java.util.Collection; import java.util.Collections; import java.util.List; -import java.util.Map; import java.util.Optional; import java.util.zip.ZipEntry; import java.util.zip.ZipException; @@ -65,7 +59,6 @@ import static io.ballerina.projects.util.ProjectConstants.BALA_DOCS_DIR; import static io.ballerina.projects.util.ProjectConstants.BALA_JSON; import static io.ballerina.projects.util.ProjectConstants.DEPENDENCY_GRAPH_JSON; -import static io.ballerina.projects.util.ProjectConstants.IDL_CLIENTS_JSON; import static io.ballerina.projects.util.ProjectConstants.PACKAGE_JSON; import static io.ballerina.projects.util.ProjectUtils.getBalaName; @@ -135,24 +128,6 @@ private void populateBalaArchive(ZipOutputStream balaOutputStream) addCompilerPlugin(balaOutputStream); addDependenciesJson(balaOutputStream); - addIDLClientsJson(balaOutputStream); - } - - private void addIDLClientsJson(ZipOutputStream balaOutputStream) { - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - IDLClients idlClients = IDLClients.getInstance( - packageContext.project().projectEnvironmentContext().getService(CompilerContext.class)); - Map>>> idlClientMap = idlClients.idlClientMap(); - if (idlClientMap.isEmpty()) { - return; - } - String idlClientsJson = gson.toJson(IDLClientsJson.from(idlClientMap)); - try { - putZipEntry(balaOutputStream, Paths.get(IDL_CLIENTS_JSON), - new ByteArrayInputStream(idlClientsJson.getBytes(Charset.defaultCharset()))); - } catch (IOException e) { - throw new ProjectException("Failed to write '" + IDL_CLIENTS_JSON + "' file: " + e.getMessage(), e); - } } private void addBalaJson(ZipOutputStream balaOutputStream) { diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/DocumentContext.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/DocumentContext.java index 188c669d3167..a304ee0f9f11 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/DocumentContext.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/DocumentContext.java @@ -17,30 +17,14 @@ */ package io.ballerina.projects; -import io.ballerina.compiler.syntax.tree.AnnotationNode; -import io.ballerina.compiler.syntax.tree.ClientDeclarationNode; import io.ballerina.compiler.syntax.tree.IdentifierToken; import io.ballerina.compiler.syntax.tree.ImportDeclarationNode; -import io.ballerina.compiler.syntax.tree.ModuleClientDeclarationNode; import io.ballerina.compiler.syntax.tree.ModulePartNode; -import io.ballerina.compiler.syntax.tree.Node; -import io.ballerina.compiler.syntax.tree.NodeList; -import io.ballerina.compiler.syntax.tree.NodeVisitor; import io.ballerina.compiler.syntax.tree.SeparatedNodeList; import io.ballerina.compiler.syntax.tree.SyntaxTree; import io.ballerina.projects.environment.ModuleLoadRequest; -import io.ballerina.projects.internal.IDLClients; -import io.ballerina.projects.internal.ProjectDiagnosticErrorCode; import io.ballerina.projects.internal.TransactionImportValidator; -import io.ballerina.projects.internal.plugins.CompilerPlugins; -import io.ballerina.projects.plugins.IDLClientGenerator; -import io.ballerina.projects.util.ProjectConstants; import io.ballerina.tools.diagnostics.Diagnostic; -import io.ballerina.tools.diagnostics.DiagnosticFactory; -import io.ballerina.tools.diagnostics.DiagnosticInfo; -import io.ballerina.tools.diagnostics.DiagnosticSeverity; -import io.ballerina.tools.diagnostics.Location; -import io.ballerina.tools.text.LineRange; import io.ballerina.tools.text.TextDocument; import io.ballerina.tools.text.TextDocuments; import org.ballerinalang.model.elements.PackageID; @@ -50,22 +34,9 @@ import org.wso2.ballerinalang.compiler.parser.NodeCloner; import org.wso2.ballerinalang.compiler.tree.BLangCompilationUnit; import org.wso2.ballerinalang.compiler.util.CompilerContext; -import org.wso2.ballerinalang.compiler.util.Name; import org.wso2.ballerinalang.compiler.util.Names; -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Comparator; import java.util.LinkedHashSet; -import java.util.List; -import java.util.Optional; import java.util.Set; import java.util.StringJoiner; @@ -143,24 +114,17 @@ BLangCompilationUnit compilationUnit(CompilerContext compilerContext, PackageID return nodeCloner.cloneCUnit(compilationUnit); } - Set moduleLoadRequests(ModuleDescriptor currentModuleDesc, PackageDependencyScope scope, - IDLPluginManager idlPluginManager, CompilationOptions compilationOptions, - Package currentPkg, List pluginDiagnosticList) { + Set moduleLoadRequests(ModuleDescriptor currentModuleDesc, PackageDependencyScope scope) { if (this.moduleLoadRequests != null) { return this.moduleLoadRequests; } - this.moduleLoadRequests = getModuleLoadRequests( - currentModuleDesc, scope, idlPluginManager, compilationOptions, currentPkg, pluginDiagnosticList); + this.moduleLoadRequests = getModuleLoadRequests(currentModuleDesc, scope); return this.moduleLoadRequests; } private Set getModuleLoadRequests(ModuleDescriptor currentModuleDesc, - PackageDependencyScope scope, - IDLPluginManager idlPluginManager, - CompilationOptions compilationOptions, - Package currentPkg, - List pluginDiagnosticList) { + PackageDependencyScope scope) { Set moduleLoadRequests = new LinkedHashSet<>(); ModulePartNode modulePartNode = syntaxTree().rootNode(); for (ImportDeclarationNode importDcl : modulePartNode.imports()) { @@ -179,29 +143,9 @@ private Set getModuleLoadRequests(ModuleDescriptor currentMod moduleName, scope, DependencyResolutionType.PLATFORM_PROVIDED); moduleLoadRequests.add(ballerinaiLoadReq); } - generateIDLClients(currentModuleDesc, syntaxTree, idlPluginManager, compilationOptions, currentPkg, - moduleLoadRequests, pluginDiagnosticList); return moduleLoadRequests; } - private void generateIDLClients(ModuleDescriptor currentModuleDesc, SyntaxTree syntaxTree, - IDLPluginManager idlPluginManager, CompilationOptions compilationOptions, - Package currentPkg, Set moduleLoadRequests, - List pluginDiagnosticList) { - - CompilerContext compilerContext = currentPkg.project().projectEnvironmentContext() - .getService(CompilerContext.class); - IDLClients idlClients = IDLClients.getInstance(compilerContext); - - // Remove the client entries generated from the previous edit - if (idlClients.idlClientMap().containsKey(currentModuleDesc.moduleCompilationId())) { - idlClients.idlClientMap().get(currentModuleDesc.moduleCompilationId()).remove(name); - } - syntaxTree.rootNode().accept(new ClientNodeVisitor( - idlPluginManager, compilationOptions, currentPkg, idlClients, moduleLoadRequests, - pluginDiagnosticList, currentModuleDesc, name, documentId)); - } - private ModuleLoadRequest getModuleLoadRequest(ImportDeclarationNode importDcl, PackageDependencyScope scope) { // TODO We need to handle syntax errors in importDcl // Get organization name @@ -240,273 +184,4 @@ DocumentContext duplicate() { return new DocumentContext(this.documentId, this.name, syntaxTree().toSourceCode()); } - private static class ClientNodeVisitor extends NodeVisitor { - - private final IDLPluginManager idlPluginManager; - private final CompilationOptions compilationOptions; - private final Package currentPkg; - private final IDLClients idlClients; - private final Set moduleLoadRequests; - private final List pluginDiagnosticList; - private final ModuleDescriptor currentModuleDesc; - private final String docName; - private final DocumentId documentId; - - public ClientNodeVisitor(IDLPluginManager idlPluginManager, - CompilationOptions compilationOptions, - Package currentPkg, IDLClients idlClients, - Set moduleLoadRequests, - List pluginDiagnosticList, - ModuleDescriptor moduleDescriptor, String docName, DocumentId documentId) { - this.idlPluginManager = idlPluginManager; - this.compilationOptions = compilationOptions; - this.currentPkg = currentPkg; - this.idlClients = idlClients; - this.moduleLoadRequests = moduleLoadRequests; - this.pluginDiagnosticList = pluginDiagnosticList; - this.currentModuleDesc = moduleDescriptor; - this.docName = docName; - this.documentId = documentId; - } - - @Override - public void visit(ModuleClientDeclarationNode moduleClientDeclarationNode) { - // report unsupported project error for single file - if (this.currentPkg.project().kind() == ProjectKind.SINGLE_FILE_PROJECT) { - ProjectDiagnosticErrorCode errorCode = - ProjectDiagnosticErrorCode.CLIENT_DECL_IN_UNSUPPORTED_PROJECT_KIND; - Location location = moduleClientDeclarationNode.location(); - String message = "client declaration is not supported with standalone Ballerina file"; - pluginDiagnosticList.add(createDiagnostic(errorCode, location, message)); - return; - } - - if (loadExistingModule(moduleClientDeclarationNode, moduleClientDeclarationNode.annotations(), - moduleClientDeclarationNode.clientPrefix().location().lineRange())) { - return; - } - - // client declaration is in a BuildProject - executeIDLPlugin(moduleClientDeclarationNode, moduleClientDeclarationNode.location(), - moduleClientDeclarationNode.clientPrefix().location().lineRange()); - } - - @Override - public void visit(ClientDeclarationNode clientDeclarationNode) { - // report unsupported project error for single file - if (this.currentPkg.project().kind() == ProjectKind.SINGLE_FILE_PROJECT) { - ProjectDiagnosticErrorCode errorCode = - ProjectDiagnosticErrorCode.CLIENT_DECL_IN_UNSUPPORTED_PROJECT_KIND; - Location location = clientDeclarationNode.location(); - String message = "client declaration is not supported with standalone Ballerina file"; - pluginDiagnosticList.add(createDiagnostic(errorCode, location, message)); - return; - } - - if (loadExistingModule(clientDeclarationNode, clientDeclarationNode.annotations(), - clientDeclarationNode.clientPrefix().location().lineRange())) { - return; - } - - // client declaration is in a BuildProject - executeIDLPlugin(clientDeclarationNode, clientDeclarationNode.location(), - clientDeclarationNode.clientPrefix().location().lineRange()); - } - - private boolean loadExistingModule( - Node clientNode, NodeList annotationsList, LineRange lineRange) { - String uri = CompilerPlugins.getUri(clientNode); - try { - if (!isRemoteUrl(uri)) { - uri = getNormalizedUriPath(uri).toString(); - } - } catch (MalformedURLException e) { - // ignore since we only need to check if the uri is local - } - for (IDLClientEntry cachedPlugin : idlPluginManager.cachedClientEntries()) { - String cachedUrl = cachedPlugin.url(); - try { - if (!isRemoteUrl(cachedUrl)) { - cachedUrl = cachedPlugin.filePath(); - } - } catch (MalformedURLException e) { - // ignore since we only need to check if the uri is local - } - if (cachedUrl.equals(uri)) { - cachedPlugin.annotations().sort(Comparator.naturalOrder()); - if (!cachedPlugin.annotations().equals( - CompilerPlugins.annotationsAsStr(annotationsList))) { - continue; - } - if (idlPluginManager.generatedModuleConfigs().stream().noneMatch(moduleConfig -> - moduleConfig.moduleDescriptor().name().moduleNamePart() - .equals(cachedPlugin.generatedModuleName()))) { - - File specFile = new File(cachedPlugin.filePath()); - if (specFile.exists()) { - if (cachedPlugin.lastModifiedTime() != specFile.lastModified()) { - // the idl resource file has been modified - return false; - } - } - if (!CompilerPlugins.moduleExists(cachedPlugin.generatedModuleName(), currentPkg.project())) { - // user has deleted the module - return false; - } - } - - getGeneratedModuleEntry(cachedPlugin, lineRange); - return true; - } - } - return false; - } - - private void executeIDLPlugin(Node clientNode, Location location, LineRange lineRange) { - if (!compilationOptions.withIDLGenerators()) { - return; - } - - for (IDLPluginContextImpl idlPluginContext : idlPluginManager.idlPluginContexts()) { - for (IDLClientGenerator idlClientGenerator : idlPluginContext.idlClientGenerators()) { - Path idlPath; - try { - idlPath = getIdlPath(clientNode); - } catch (IOException e) { - ProjectDiagnosticErrorCode errorCode = ProjectDiagnosticErrorCode.INVALID_IDL_URI; - String message = "unable to get resource from uri, reason: " + e.getMessage(); - pluginDiagnosticList.add(createDiagnostic(errorCode, location, message)); - return; - } catch (ProjectException e) { - ProjectDiagnosticErrorCode errorCode = ProjectDiagnosticErrorCode.INVALID_IDL_URI; - pluginDiagnosticList.add(createDiagnostic(errorCode, location, e.getMessage())); - return; - } - IDLPluginManager.IDLSourceGeneratorContextImpl idlSourceGeneratorContext = - new IDLPluginManager.IDLSourceGeneratorContextImpl( - clientNode, currentModuleDesc.moduleCompilationId(), docName, - currentPkg, idlPath, idlClients, moduleLoadRequests, - idlPluginManager.generatedModuleConfigs(), idlPluginManager.cachedClientEntries(), - idlPluginManager.aliasNameCounter()); - try { - if (idlClientGenerator.canHandle(idlSourceGeneratorContext)) { - idlClientGenerator.perform(idlSourceGeneratorContext); - pluginDiagnosticList.addAll(idlSourceGeneratorContext.reportedDiagnostics()); - return; - } - } catch (Exception e) { - ProjectDiagnosticErrorCode errorCode = ProjectDiagnosticErrorCode.UNEXPECTED_IDL_EXCEPTION; - String message = "unexpected exception thrown from plugin class: " - + idlClientGenerator.getClass().getName() + ", exception: " + e.getMessage(); - pluginDiagnosticList.add(createDiagnostic(errorCode, location, message)); - return; - } - } - } - ProjectDiagnosticErrorCode errorCode = ProjectDiagnosticErrorCode.MATCHING_PLUGIN_NOT_FOUND; - String message = "no matching plugin found for client declaration"; - pluginDiagnosticList.add(createDiagnostic(errorCode, location, message)); - idlClients.addEntry(currentModuleDesc.moduleCompilationId(), docName, lineRange, null); - } - - private void getGeneratedModuleEntry(IDLClientEntry cachedPlugin, LineRange lineRange) { - String generatedModuleName = this.currentPkg.descriptor().name().value() + - ProjectConstants.DOT + cachedPlugin.generatedModuleName(); - PackageID packageID = new PackageID(new Name(this.currentPkg.descriptor().org().value()), - new Name(this.currentPkg.descriptor().name().value()), - new Name(generatedModuleName), - new Name(this.currentPkg.descriptor().version().toString()), null); - idlClients.addEntry(currentModuleDesc.moduleCompilationId(), docName, lineRange, - packageID); - moduleLoadRequests.add(new ModuleLoadRequest( - PackageOrg.from(packageID.orgName.getValue()), - packageID.name.getValue(), - PackageDependencyScope.DEFAULT, - DependencyResolutionType.SOURCE)); - idlPluginManager.addModuleToLoadFromCache(cachedPlugin.generatedModuleName()); - } - - private Diagnostic createDiagnostic(ProjectDiagnosticErrorCode errorCode, Location location, String message) { - DiagnosticInfo diagnosticInfo = new DiagnosticInfo( - errorCode.diagnosticId(), message, DiagnosticSeverity.ERROR); - return DiagnosticFactory.createDiagnostic(diagnosticInfo, location); - } - - private boolean isRemoteUrl(String uri) throws MalformedURLException { - URL url; - try { - url = new URL(uri); - } catch (MalformedURLException e) { - if (uri.matches("(?!file\\b)\\w+?://.*")) { - // Remote file - throw e; - } - return false; - } - return !url.getProtocol().equals("file"); - } - - private Path getIdlPath(Node clientNode) throws IOException { - String uri = CompilerPlugins.getUri(clientNode); - if (!isRemoteUrl(uri)) { - return resolveLocalPath(uri); - } - return resolveRemoteUrl(uri); - } - - private Path resolveRemoteUrl(String uri) throws IOException { - URL url = new URL(uri); - String[] split = url.getFile().split("[~?=#@*+%{}<>/\\[\\]|\"^]"); - String fileName = split[split.length - 1]; - Path resourceName = Paths.get(fileName).getFileName(); - Path absResourcePath = this.currentPkg.project().sourceRoot().resolve(resourceName); - - if (Files.exists(absResourcePath)) { - Files.delete(absResourcePath); - } - Files.createFile(absResourcePath); - - try (BufferedInputStream in = new BufferedInputStream(url.openStream()); - FileOutputStream fileOutputStream = new FileOutputStream(absResourcePath.toFile())) { - byte[] dataBuffer = new byte[1024]; - int bytesRead; - while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) { - fileOutputStream.write(dataBuffer, 0, bytesRead); - } - } - return resourceName; - } - - private Path getNormalizedUriPath(String uri) { - Path documentParent = Optional.of(this.currentPkg.project().documentPath(this.documentId) - .orElseThrow().getParent()).get(); - Path uriPath = Paths.get(uri); - if (uriPath.isAbsolute()) { - return Paths.get(uri); - } - return this.currentPkg.project().sourceRoot().relativize(documentParent.resolve(uri)); - } - - private Path resolveLocalPath(String uri) { - Path localFilePath = getNormalizedUriPath(uri); - Path absLocalFilePath = localFilePath; - if (!absLocalFilePath.isAbsolute()) { - absLocalFilePath = this.currentPkg.project().sourceRoot().resolve(localFilePath); - } - - if (!Files.exists(absLocalFilePath)) { - String message = "could not locate the file: " + uri; - throw new ProjectException(message); - } - if (!Files.isRegularFile(absLocalFilePath)) { - String message = "provided file is not a regular file: " + uri; - throw new ProjectException(message); - } - if (!absLocalFilePath.toFile().canRead()) { - String message = "provided file does not have read permission: " + uri; - throw new ProjectException(message); - } - return localFilePath; - } - } } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/IDLClientEntry.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/IDLClientEntry.java deleted file mode 100644 index 7f04bce1c5dd..000000000000 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/IDLClientEntry.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.projects; - -import java.nio.file.Path; -import java.util.List; -import java.util.Objects; - -/** - * IDL client entry loaded from the file system cache. - * - * @since 2201.3.0 - */ -class IDLClientEntry { - private final String url; - private final List annotations; - private final String generatedModuleName; - private final String filePath; - private final long lastModifiedTime; - - public IDLClientEntry(String url, Path filePath, List annotations, String generatedModuleName, - long lastModifiedTime) { - this.url = url; - this.annotations = annotations; - this.generatedModuleName = generatedModuleName; - this.filePath = filePath.toString(); - this.lastModifiedTime = lastModifiedTime; - } - - public String url() { - return url; - } - - public List annotations() { - return annotations; - } - - public String filePath() { - return filePath; - } - - public String generatedModuleName() { - return generatedModuleName; - } - - public long lastModifiedTime() { - return lastModifiedTime; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - IDLClientEntry that = (IDLClientEntry) o; - return Objects.equals(url, that.url) && - Objects.equals(annotations, that.annotations) && - Objects.equals(generatedModuleName, that.generatedModuleName); - } - - @Override - public int hashCode() { - return Objects.hash(url, annotations, generatedModuleName); - } -} diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/IDLClientGeneratorResult.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/IDLClientGeneratorResult.java deleted file mode 100644 index ffcb7ee98bc9..000000000000 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/IDLClientGeneratorResult.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package io.ballerina.projects; - -import io.ballerina.projects.internal.DefaultDiagnosticResult; -import io.ballerina.tools.diagnostics.Diagnostic; - -import java.util.Collection; -import java.util.Optional; - -/** - * Represents the package with generated idl client modules and a - * collection of diagnostics generated during IDL plugin execution. - * - * @since 2201.3.0 - */ -public class IDLClientGeneratorResult { - private final Package updatedPkg; - private final DiagnosticResult diagnostics; - - IDLClientGeneratorResult(Package updatedPkg, Collection diagnostics) { - this.updatedPkg = updatedPkg; - this.diagnostics = new DefaultDiagnosticResult(diagnostics); - } - - /** - * Returns the updated package that contains the generated IDL clients modules. - *

- * This method does not modify the current package. It returns a new package instance - * with generated idl client modules. - * - * @return the updated package - */ - public Optional updatedPackage() { - return Optional.ofNullable(updatedPkg); - } - - /** - * Returns the diagnostics reported during IDL client generation. - * - * @return a collected of diagnostics - */ - public DiagnosticResult reportedDiagnostics() { - return diagnostics; - } -} diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/IDLPluginContextImpl.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/IDLPluginContextImpl.java deleted file mode 100644 index d217bbe2e13e..000000000000 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/IDLPluginContextImpl.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.projects; - -import io.ballerina.projects.plugins.IDLClientGenerator; -import io.ballerina.projects.plugins.IDLPluginContext; - -import java.util.ArrayList; -import java.util.List; - -/** - * The default implementation of the {@code IDLPluginContext}. - * - * @since 2.3.0 - */ -public class IDLPluginContextImpl implements IDLPluginContext { - List idlClientGenerators = new ArrayList<>(); - - @Override - public void addCodeGenerator(IDLClientGenerator codeGenerator) { - idlClientGenerators.add(codeGenerator); - } - - public List idlClientGenerators() { - return idlClientGenerators; - } -} diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/IDLPluginManager.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/IDLPluginManager.java deleted file mode 100644 index f383f03236fd..000000000000 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/IDLPluginManager.java +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.projects; - -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; -import io.ballerina.compiler.syntax.tree.AnnotationNode; -import io.ballerina.compiler.syntax.tree.BasicLiteralNode; -import io.ballerina.compiler.syntax.tree.ClientDeclarationNode; -import io.ballerina.compiler.syntax.tree.ModuleClientDeclarationNode; -import io.ballerina.compiler.syntax.tree.Node; -import io.ballerina.compiler.syntax.tree.NodeList; -import io.ballerina.compiler.syntax.tree.SyntaxKind; -import io.ballerina.projects.environment.ModuleLoadRequest; -import io.ballerina.projects.internal.IDLClients; -import io.ballerina.projects.internal.plugins.CompilerPlugins; -import io.ballerina.projects.plugins.IDLGeneratorPlugin; -import io.ballerina.projects.plugins.IDLSourceGeneratorContext; -import io.ballerina.projects.util.ProjectConstants; -import io.ballerina.tools.diagnostics.Diagnostic; -import io.ballerina.tools.text.LineRange; -import org.ballerinalang.model.elements.PackageID; - -import java.io.IOException; -import java.lang.reflect.Type; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -class IDLPluginManager { - private List idlPluginContexts; - private final List moduleConfigs; - private final Path target; - private final List cachedClientEntries; - private final Set cachedModuleNames; - private final Map aliasNameCounter; - - private IDLPluginManager(Path target, List cachedPlugins) { - this.target = target; - this.moduleConfigs = new ArrayList<>(); - this.cachedClientEntries = cachedPlugins; - this.cachedModuleNames = new HashSet<>(); - this.aliasNameCounter = new HashMap<>(); - } - - static IDLPluginManager from(Path sourceRoot) { - List cache = new ArrayList<>(); - Path idlCacheJson = sourceRoot.resolve(ProjectConstants.GENERATED_MODULES_ROOT) - .resolve(ProjectConstants.IDL_CACHE_FILE); - if (Files.exists(idlCacheJson)) { - try { - String readString = Files.readString(idlCacheJson); - Type cacheMapType = new TypeToken>() { - }.getType(); - cache = new Gson().fromJson(readString, cacheMapType); - } catch (IOException e) { - // ignore e - } - } - return new IDLPluginManager(sourceRoot, cache); - - } - - private static List initializePlugins(List builtInIDLPlugins) { - List compilerPluginContexts = new ArrayList<>(builtInIDLPlugins.size()); - for (IDLGeneratorPlugin plugin : builtInIDLPlugins) { - IDLPluginContextImpl idlPluginContextImpl = new IDLPluginContextImpl(); - plugin.init(idlPluginContextImpl); - compilerPluginContexts.add(idlPluginContextImpl); - } - return compilerPluginContexts; - } - - public List idlPluginContexts() { - if (this.idlPluginContexts == null) { - idlPluginContexts = initializePlugins(CompilerPlugins.getBuiltInIDLPlugins()); - } - return idlPluginContexts; - } - - public List generatedModuleConfigs() { - return moduleConfigs; - } - - public Path target() { - return target; - } - - public List cachedClientEntries() { - return cachedClientEntries; - } - - public Set cachedModuleNames() { - return cachedModuleNames; - } - - public void addModuleToLoadFromCache(String generatedModuleName) { - this.cachedModuleNames.add(generatedModuleName); - } - - public Map aliasNameCounter() { - return aliasNameCounter; - } - - public static class IDLSourceGeneratorContextImpl implements IDLSourceGeneratorContext { - private final PackageID sourcePkgId; - private final String sourceDoc; - private final Package currentPackage; - private final IDLClients idlClients; - private final Node clientNode; - private final Set moduleLoadRequests; - private final List moduleConfigs; - private final List diagnostics = new ArrayList<>(); - private final Path resourcePath; - private final List cachedClientEntries; - private final Map aliasNameCounter; - - public IDLSourceGeneratorContextImpl(Node clientNode, PackageID sourcePkgId, String sourceDoc, - Package currentPackage, Path resourcePath, - IDLClients idlClients, - Set moduleLoadRequests, - List moduleConfigs, - List cachedPlugins, - Map aliasNameCounter) { - this.sourcePkgId = sourcePkgId; - this.sourceDoc = sourceDoc; - this.currentPackage = currentPackage; - this.resourcePath = resourcePath; - this.idlClients = idlClients; - this.clientNode = clientNode; - this.moduleLoadRequests = moduleLoadRequests; - this.moduleConfigs = moduleConfigs; - this.cachedClientEntries = cachedPlugins; - this.aliasNameCounter = aliasNameCounter; - } - - @Override - public Node clientNode() { - return clientNode; - } - - @Override - public Package currentPackage() { - return currentPackage; - } - - @Override - public Path resourcePath() { - if (resourcePath.isAbsolute()) { - return resourcePath; - } else { - return currentPackage.project().sourceRoot().resolve(resourcePath); - } - } - - @Override - public void reportDiagnostic(Diagnostic diagnostic) { - diagnostics.add(diagnostic); - } - - Collection reportedDiagnostics() { - return diagnostics; - } - - @Override - public void addClient(ModuleConfig moduleConfig, NodeList supportedAnnotations) { - ModuleConfig newModuleConfig = createModuleConfigWithRandomName(moduleConfig); - LineRange lineRange; - if (this.clientNode.kind().equals(SyntaxKind.MODULE_CLIENT_DECLARATION)) { - ModuleClientDeclarationNode moduleClientNode = (ModuleClientDeclarationNode) this.clientNode; - lineRange = moduleClientNode.clientPrefix().location().lineRange(); - } else { - ClientDeclarationNode clientDeclarationNode = (ClientDeclarationNode) this.clientNode; - lineRange = clientDeclarationNode.clientPrefix().location().lineRange(); - } - idlClients.addEntry(sourcePkgId, sourceDoc, lineRange, - newModuleConfig.moduleDescriptor().moduleCompilationId()); - this.moduleLoadRequests.add(new ModuleLoadRequest( - PackageOrg.from(newModuleConfig.moduleDescriptor().moduleCompilationId().orgName.getValue()), - newModuleConfig.moduleDescriptor().moduleCompilationId().name.getValue(), - PackageDependencyScope.DEFAULT, - DependencyResolutionType.SOURCE)); - this.moduleConfigs.add(newModuleConfig); - - // Generate id to cache plugins for subsequent compilations - List annotations = CompilerPlugins.annotationsAsStr(supportedAnnotations); - String uri = getUri(this.clientNode); - - IDLClientEntry idlCacheInfo = new IDLClientEntry(uri, resourcePath, annotations, - newModuleConfig.moduleDescriptor().name().moduleNamePart(), - this.currentPackage.project().sourceRoot().resolve(resourcePath).toFile().lastModified()); - this.cachedClientEntries.add(idlCacheInfo); - } - - private String getUri(Node clientNode) { - BasicLiteralNode clientUri; - - if (clientNode.kind() == SyntaxKind.MODULE_CLIENT_DECLARATION) { - clientUri = ((ModuleClientDeclarationNode) clientNode).clientUri(); - } else { - clientUri = ((ClientDeclarationNode) clientNode).clientUri(); - } - - String text = clientUri.literalToken().text(); - return text.substring(1, text.length() - 1); - } - - private ModuleConfig createModuleConfigWithRandomName(ModuleConfig moduleConfig) { - ModuleName randomModuleName; - String alias = moduleConfig.moduleDescriptor().name().moduleNamePart(); - String moduleNameStr = alias; - if (aliasNameCounter.containsKey(alias)) { - moduleNameStr += aliasNameCounter.get(alias); - aliasNameCounter.put(alias, aliasNameCounter.get(alias) + 1); - } else { - aliasNameCounter.put(alias, 1); - } - if (moduleConfig.moduleDescriptor().name() == null) { - // Module name is mandatory since this will be added as a non-default module - throw new ProjectException("module name cannot be null"); - } else { - randomModuleName = ModuleName.from(moduleConfig.moduleDescriptor().packageName(), moduleNameStr); - } - ModuleDescriptor newModuleDescriptor = ModuleDescriptor.from(randomModuleName, - this.currentPackage.descriptor()); - return ModuleConfig.from( - moduleConfig.moduleId(), newModuleDescriptor, moduleConfig.sourceDocs(), - moduleConfig.testSourceDocs(), moduleConfig.moduleMd().orElse(null), moduleConfig.dependencies(), - ModuleKind.COMPILER_GENERATED); - } - } -} diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/JBallerinaBackend.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/JBallerinaBackend.java index 9c9a41c74a02..22b9b7359ad8 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/JBallerinaBackend.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/JBallerinaBackend.java @@ -171,8 +171,7 @@ private void performCodeGen() { } for (Diagnostic diagnostic : moduleContext.diagnostics()) { moduleDiagnostics.add( - new PackageDiagnostic(diagnostic, moduleContext.descriptor(), moduleContext.project(), - moduleContext.isGenerated())); + new PackageDiagnostic(diagnostic, moduleContext.descriptor(), moduleContext.project())); } } // add compilation diagnostics diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Module.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Module.java index 401f990176e8..3fa6f71beef8 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Module.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Module.java @@ -188,7 +188,6 @@ public static class Modifier { private MdDocumentContext moduleMdContext; private final Map resourceContextMap; private final Map testResourceContextMap; - private final ModuleKind kind; private Modifier(Module oldModule) { moduleId = oldModule.moduleId(); @@ -202,7 +201,6 @@ private Modifier(Module oldModule) { moduleMdContext = oldModule.moduleContext.moduleMdContext().orElse(null); resourceContextMap = copyResources(oldModule, oldModule.moduleContext.resourceIds()); testResourceContextMap = copyResources(oldModule, oldModule.moduleContext.testResourceIds()); - kind = oldModule.moduleContext.kind(); } Modifier updateDocument(DocumentContext newDocContext) { @@ -338,7 +336,7 @@ private Module createNewModule(Map srcDocContextMap ModuleContext newModuleContext = new ModuleContext(this.project, this.moduleId, this.moduleDescriptor, this.isDefaultModule, srcDocContextMap, testDocContextMap, this.moduleMdContext, this.dependencies, this.resourceContextMap, - this.testResourceContextMap, this.kind); + this.testResourceContextMap); moduleContextSet.add(newModuleContext); // add dependant modules including transitives @@ -351,7 +349,7 @@ private Module createNewModule(Map srcDocContextMap moduleContextSet.add(new ModuleContext(this.project, module.moduleId, dependentDescriptor, module.isDefaultModule, module.srcDocContextMap, module.testDocContextMap, module.moduleMdContext, module.dependencies, - module.resourceContextMap, module.testResourceContextMap, module.kind)); + module.resourceContextMap, module.testResourceContextMap)); } Package newPackage = this.packageInstance.modify().updateModules(moduleContextSet).apply(); diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleCompilation.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleCompilation.java index 8f7beca11be1..2d7730f0bcfc 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleCompilation.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleCompilation.java @@ -114,8 +114,7 @@ private void compile() { ModuleContext moduleContext = pkg.get().module(sortedModuleDescriptor.name()).moduleContext(); moduleContext.compile(compilerContext); for (Diagnostic diagnostic : moduleContext.diagnostics()) { - diagnostics.add(new PackageDiagnostic(diagnostic, moduleContext.descriptor(), moduleContext.project(), - moduleContext.isGenerated())); + diagnostics.add(new PackageDiagnostic(diagnostic, moduleContext.descriptor(), moduleContext.project())); } } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleConfig.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleConfig.java index b8d9d0072fb9..b5935a4a50f4 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleConfig.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleConfig.java @@ -36,7 +36,6 @@ public class ModuleConfig { private final DocumentConfig moduleMd; private final List resources; private final List testResources; - private final ModuleKind kind; private ModuleConfig(ModuleId moduleId, ModuleDescriptor moduleDescriptor, @@ -45,8 +44,7 @@ private ModuleConfig(ModuleId moduleId, DocumentConfig moduleMd, List dependencies, List resources, - List testResources, - ModuleKind kind) { + List testResources) { this.moduleId = moduleId; this.moduleDescriptor = moduleDescriptor; this.srcDocs = srcDocs; @@ -55,17 +53,6 @@ private ModuleConfig(ModuleId moduleId, this.moduleMd = moduleMd; this.resources = resources; this.testResources = testResources; - this.kind = kind; - } - - static ModuleConfig from(ModuleId moduleId, - ModuleDescriptor moduleDescriptor, - List srcDocs, - List testSrcDocs, - DocumentConfig moduleMd, - List dependencies, ModuleKind kind) { - return new ModuleConfig(moduleId, moduleDescriptor, srcDocs, testSrcDocs, moduleMd, dependencies, - Collections.emptyList(), Collections.emptyList(), kind); } public static ModuleConfig from(ModuleId moduleId, @@ -75,7 +62,7 @@ public static ModuleConfig from(ModuleId moduleId, DocumentConfig moduleMd, List dependencies) { return new ModuleConfig(moduleId, moduleDescriptor, srcDocs, testSrcDocs, moduleMd, dependencies, - Collections.emptyList(), Collections.emptyList(), ModuleKind.USER_PROVIDED); + Collections.emptyList(), Collections.emptyList()); } public static ModuleConfig from(ModuleId moduleId, @@ -86,8 +73,8 @@ public static ModuleConfig from(ModuleId moduleId, List dependencies, List resources, List testResources) { - return new ModuleConfig(moduleId, moduleDescriptor, srcDocs, testSrcDocs, moduleMd, dependencies, - resources, testResources, ModuleKind.USER_PROVIDED); + return new ModuleConfig( + moduleId, moduleDescriptor, srcDocs, testSrcDocs, moduleMd, dependencies, resources, testResources); } public ModuleId moduleId() { @@ -126,7 +113,4 @@ public List testResources() { return testResources; } - public ModuleKind kind() { - return kind; - } } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleContext.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleContext.java index c697dae948fe..ef4f12d08771 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleContext.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleContext.java @@ -91,7 +91,6 @@ class ModuleContext { private ModuleCompilationState moduleCompState; private Set allModuleLoadRequests = null; private Set allTestModuleLoadRequests = null; - private final ModuleKind kind; private List idlPluginDiagnostics; ModuleContext(Project project, @@ -103,8 +102,7 @@ class ModuleContext { MdDocumentContext moduleMd, List moduleDescDependencies, Map resourceContextMap, - Map testResourceContextMap, - ModuleKind kind) { + Map testResourceContextMap) { this.project = project; this.moduleId = moduleId; this.moduleDescriptor = moduleDescriptor; @@ -119,7 +117,6 @@ class ModuleContext { this.testResourceContextMap = testResourceContextMap; this.resourceIds = Collections.unmodifiableCollection(resourceContextMap.keySet()); this.testResourceIds = Collections.unmodifiableCollection(testResourceContextMap.keySet()); - this.kind = kind; ProjectEnvironment projectEnvironment = project.projectEnvironmentContext(); this.bootstrap = new Bootstrap(projectEnvironment.getService(PackageResolver.class)); @@ -151,7 +148,7 @@ static ModuleContext from(Project project, ModuleConfig moduleConfig) { return new ModuleContext(project, moduleConfig.moduleId(), moduleConfig.moduleDescriptor(), moduleConfig.isDefaultModule(), srcDocContextMap, testDocContextMap, moduleConfig.moduleMd().map(c ->MdDocumentContext.from(c)).orElse(null), - moduleConfig.dependencies(), resourceContextMap, testResourceContextMap, moduleConfig.kind()); + moduleConfig.dependencies(), resourceContextMap, testResourceContextMap); } ModuleId moduleId() { @@ -219,32 +216,27 @@ List moduleDescDependencies() { return moduleDescDependencies; } - Set populateModuleLoadRequests(IDLPluginManager idlPluginManager, - CompilationOptions compilationOptions, Package currentPkg) { + Set populateModuleLoadRequests() { if (allModuleLoadRequests != null) { return allModuleLoadRequests; } allModuleLoadRequests = new OverwritableLinkedHashSet(); for (DocumentContext docContext : srcDocContextMap.values()) { allModuleLoadRequests.addAll(docContext.moduleLoadRequests(moduleDescriptor, - PackageDependencyScope.DEFAULT, idlPluginManager, compilationOptions, currentPkg, - idlPluginDiagnostics)); + PackageDependencyScope.DEFAULT)); } return allModuleLoadRequests; } - Set populateTestSrcModuleLoadRequests(IDLPluginManager idlPluginManager, - CompilationOptions compilationOptions, - Package currentPkg) { + Set populateTestSrcModuleLoadRequests() { if (allTestModuleLoadRequests != null) { return allTestModuleLoadRequests; } allTestModuleLoadRequests = new OverwritableLinkedHashSet(); for (DocumentContext docContext : testDocContextMap.values()) { allTestModuleLoadRequests.addAll( - docContext.moduleLoadRequests(moduleDescriptor, PackageDependencyScope.TEST_ONLY, - idlPluginManager, compilationOptions, currentPkg, idlPluginDiagnostics)); + docContext.moduleLoadRequests(moduleDescriptor, PackageDependencyScope.TEST_ONLY)); } return allTestModuleLoadRequests; @@ -258,14 +250,6 @@ ModuleCompilationState compilationState() { return moduleCompState; } - ModuleKind kind() { - return this.kind; - } - - boolean isGenerated() { - return this.kind.equals(ModuleKind.COMPILER_GENERATED); - } - private BLangPackage getBLangPackageOrThrow() { if (bLangPackage == null) { throw new IllegalStateException("Compile the module first!"); @@ -593,7 +577,7 @@ ModuleContext duplicate(Project project) { } return new ModuleContext(project, this.moduleId, this.moduleDescriptor, this.isDefaultModule, srcDocContextMap, testDocContextMap, this.moduleMdContext().orElse(null), - this.moduleDescDependencies, this.resourceContextMap, this.testResourceContextMap, this.kind); + this.moduleDescDependencies, this.resourceContextMap, this.testResourceContextMap); } /** diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleKind.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleKind.java deleted file mode 100644 index edcdc8d647b2..000000000000 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleKind.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package io.ballerina.projects; - -/** - * Represents the kind of the {@code Module} instance. - *

- * There are two known kinds of module at the moment: {user-provided, compiler-generated}, - * - * @since 2.3.0 - */ -enum ModuleKind { - COMPILER_GENERATED, - USER_PROVIDED, - ; -} diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Package.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Package.java index b9d0f5fb0cd5..5cb4a4592486 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Package.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Package.java @@ -1,21 +1,14 @@ package io.ballerina.projects; -import com.google.gson.Gson; -import io.ballerina.projects.environment.ResolutionOptions; import io.ballerina.projects.internal.DefaultDiagnosticResult; import io.ballerina.projects.internal.DependencyManifestBuilder; import io.ballerina.projects.internal.ManifestBuilder; import io.ballerina.projects.internal.model.CompilerPluginDescriptor; -import io.ballerina.projects.util.ProjectConstants; -import io.ballerina.projects.util.ProjectUtils; import io.ballerina.tools.diagnostics.Diagnostic; import org.ballerinalang.model.elements.PackageID; import org.wso2.ballerinalang.compiler.PackageCache; import org.wso2.ballerinalang.compiler.util.CompilerContext; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -30,7 +23,6 @@ import java.util.Spliterator; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Function; -import java.util.stream.Collectors; /** * {@code Package} represents a Ballerina Package. @@ -225,75 +217,6 @@ Package duplicate(Project project) { return new Package(packageContext.duplicate(project), project); } - public IDLClientGeneratorResult runIDLGeneratorPlugins() { - ResolutionOptions resolutionOptions = ResolutionOptions.builder() - .setOffline(this.packageContext.compilationOptions().offlineBuild()) - .setSticky(this.packageContext.compilationOptions().sticky()).build(); - return runIDLGeneratorPlugins(resolutionOptions); - } - - public IDLClientGeneratorResult runIDLGeneratorPlugins(ResolutionOptions resolutionOptions) { - if (this.project.kind().equals(ProjectKind.BALA_PROJECT)) { - throw new ProjectException( - "IDL plugin generation is not supported for project kind: " + ProjectKind.BALA_PROJECT); - } - - // Clear existing module and document contexts. - // Otherwise the cached compilations will be reused skipping the IDL client generator plugins. - Package updatedPackage = resetIfCompiled(); - this.project.setCurrentPackage(updatedPackage); - - // Generate IDL client modules - CompilationOptions newCompilationOptions = this.packageContext.compilationOptions().acceptTheirs( - CompilationOptions.builder() - .withIDLGenerators(true) - .setOffline(resolutionOptions.offline()) - .setSticky(resolutionOptions.sticky()) - .build()); - PackageResolution packageResolution = updatedPackage.getResolution(newCompilationOptions); - - // Save the generated client modules - try { - saveGeneratedModules(packageResolution); - } catch (IOException e) { - throw new ProjectException("failed to save generated IDL client modules: " + e.getMessage(), e); - } - return new IDLClientGeneratorResult(updatedPackage, packageResolution.pluginDiagnosticList()); - } - - private Package resetIfCompiled() { - if (this.packageContext.cachedCompilation() == null) { - return this; - } - return duplicate(this.project); - } - - private void saveGeneratedModules(PackageResolution resolution) throws IOException { - Path modulesRoot = this.project().sourceRoot().resolve(ProjectConstants.GENERATED_MODULES_ROOT); - List unusedModules = new ArrayList<>(); - if (Files.exists(modulesRoot)) { - unusedModules.addAll(Files.list(modulesRoot).map(path -> - Optional.of(path.getFileName()).get().toString()).collect(Collectors.toList())); - } - for (ModuleId moduleId : resolution.packageContext().moduleIds()) { - if (resolution.packageContext().moduleContext(moduleId).isGenerated()) { - Utils.writeModule(project.currentPackage().module(moduleId), modulesRoot); - unusedModules.remove(resolution.packageContext().moduleContext(moduleId).moduleName().moduleNamePart()); - } - } - - // Delete unused generated module directories - for (String unusedModule : unusedModules) { - ProjectUtils.deleteDirectory(modulesRoot.resolve(unusedModule)); - } - - if (!resolution.clientsToCache().isEmpty()) { - String json = new Gson().toJson(resolution.clientsToCache()); - Files.writeString(this.project.sourceRoot().resolve(ProjectConstants.GENERATED_MODULES_ROOT) - .resolve(ProjectConstants.IDL_CACHE_FILE), json); - } - } - /** * Run {@code CodeGenerator} and {@code CodeModifier} tasks in engaged {@code CompilerPlugin}s. *

@@ -342,6 +265,7 @@ public DiagnosticResult runCodeGenAndModifyPlugins() { } if (compilerPluginManager.engagedCodeModifierCount() > 0) { + compilerPluginManager = pkg.getCompilation(compOptions).compilerPluginManager(); CodeModifierManager codeModifierManager = compilerPluginManager.getCodeModifierManager(); CodeModifierResult codeModifierResult = codeModifierManager.runCodeModifiers(pkg); diagnostics.addAll(codeModifierResult.reportedDiagnostics().allDiagnostics); @@ -500,11 +424,6 @@ Modifier updateModules(Set newModuleContexts) { return this; } - Modifier withCompilationOptions(CompilationOptions compilationOptions) { - this.compilationOptions = this.compilationOptions.acceptTheirs(compilationOptions); - return this; - } - /** * Adds a new module in a new package that is copied from the existing. * @@ -658,8 +577,7 @@ private Package createNewPackage() { PackageContext newPackageContext = new PackageContext(this.project, this.packageId, this.packageManifest, this.dependencyManifest, this.ballerinaTomlContext, this.dependenciesTomlContext, this.cloudTomlContext, this.compilerPluginTomlContext, this.packageMdContext, - this.compilationOptions, this.moduleContextMap, DependencyGraph.emptyGraph(), - this.oldPackageContext.idlPluginManager()); + this.compilationOptions, this.moduleContextMap, DependencyGraph.emptyGraph()); this.project.setCurrentPackage(new Package(newPackageContext, this.project)); if (oldPackageContext.cachedCompilation() != null) { @@ -778,8 +696,7 @@ private void updateModules() { moduleContextSet.add(new ModuleContext(this.project, moduleId, moduleDescriptor, oldModuleContext.isDefaultModule(), srcDocContextMap, testDocContextMap, oldModuleContext.moduleMdContext().orElse(null), - oldModuleContext.moduleDescDependencies(), resourceMap, testResourceMap, - oldModuleContext.kind())); + oldModuleContext.moduleDescDependencies(), resourceMap, testResourceMap)); } updateModules(moduleContextSet); } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/PackageCompilation.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/PackageCompilation.java index d0e4ed4c0fda..2c345825958f 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/PackageCompilation.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/PackageCompilation.java @@ -196,14 +196,13 @@ private void compileModulesInternal() { diagnostics.addAll(packageContext().packageManifest().diagnostics().allDiagnostics); // add dependency manifest diagnostics diagnostics.addAll(packageContext().dependencyManifest().diagnostics().allDiagnostics); - diagnostics.addAll(packageResolution.pluginDiagnosticList()); // add compilation diagnostics if (!packageResolution.diagnosticResult().hasErrors()) { for (ModuleContext moduleContext : packageResolution.topologicallySortedModuleList()) { moduleContext.compile(compilerContext); for (Diagnostic diagnostic : moduleContext.diagnostics()) { diagnostics.add(new PackageDiagnostic(diagnostic, moduleContext.descriptor(), - moduleContext.project(), moduleContext.isGenerated())); + moduleContext.project())); } } } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/PackageContext.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/PackageContext.java index e2878d1ed880..244a442ae73a 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/PackageContext.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/PackageContext.java @@ -61,7 +61,6 @@ class PackageContext { private DependencyGraph moduleDependencyGraph; private PackageResolution packageResolution; private PackageCompilation packageCompilation; - private final IDLPluginManager idlPluginManager; // TODO Try to reuse the unaffected compilations if possible private final Map moduleCompilationMap; @@ -77,8 +76,7 @@ class PackageContext { MdDocumentContext packageMdContext, CompilationOptions compilationOptions, Map moduleContextMap, - DependencyGraph pkgDescDependencyGraph, - IDLPluginManager idlPluginManager) { + DependencyGraph pkgDescDependencyGraph) { this.project = project; this.packageId = packageId; this.packageManifest = packageManifest; @@ -91,7 +89,6 @@ class PackageContext { this.compilationOptions = compilationOptions; this.moduleIds = Collections.unmodifiableCollection(moduleContextMap.keySet()); this.moduleContextMap = moduleContextMap; - this.idlPluginManager = idlPluginManager; // TODO Try to reuse previous unaffected compilations this.moduleCompilationMap = new HashMap<>(); this.packageDependencies = Collections.emptySet(); @@ -104,12 +101,7 @@ static PackageContext from(Project project, PackageConfig packageConfig, Compila for (ModuleConfig moduleConfig : packageConfig.otherModules()) { moduleContextMap.put(moduleConfig.moduleId(), ModuleContext.from(project, moduleConfig)); } - IDLPluginManager idlPluginManager; - if (project.kind() == ProjectKind.BALA_PROJECT) { - idlPluginManager = null; - } else { - idlPluginManager = IDLPluginManager.from(project.sourceRoot); - } + return new PackageContext(project, packageConfig.packageId(), packageConfig.packageManifest(), packageConfig.dependencyManifest(), packageConfig.ballerinaToml().map(c -> TomlDocumentContext.from(c)).orElse(null), @@ -117,8 +109,7 @@ static PackageContext from(Project project, PackageConfig packageConfig, Compila packageConfig.cloudToml().map(c -> TomlDocumentContext.from(c)).orElse(null), packageConfig.compilerPluginToml().map(c -> TomlDocumentContext.from(c)).orElse(null), packageConfig.packageMd().map(c -> MdDocumentContext.from(c)).orElse(null), - compilationOptions, moduleContextMap, packageConfig.packageDescDependencyGraph(), - idlPluginManager); + compilationOptions, moduleContextMap, packageConfig.packageDescDependencyGraph()); } PackageId packageId() { @@ -248,35 +239,15 @@ PackageCompilation cachedCompilation() { PackageResolution getResolution() { if (packageResolution == null) { - packageResolution = PackageResolution.from(this, this.compilationOptions, this.idlPluginManager); - if (packageResolution.generatedModules().size() == 0) { - return packageResolution; - } - Package.Modifier modifier = project.currentPackage().modify(); - for (ModuleConfig generatedModule : packageResolution.generatedModules()) { - modifier.addModule(generatedModule); - } - Package newPackage = modifier.apply(); - packageResolution = newPackage.packageContext().getResolution(); + packageResolution = PackageResolution.from(this, this.compilationOptions); } return packageResolution; } PackageResolution getResolution(CompilationOptions compilationOptions) { - packageResolution = PackageResolution.from(this, compilationOptions, this.idlPluginManager); - if (packageResolution.generatedModules().size() == 0) { - return packageResolution; - } - - Package.Modifier modifier = project.currentPackage().modify(); - for (ModuleConfig generatedModule : packageResolution.generatedModules()) { - modifier.addModule(generatedModule); - } - Package newPackage = modifier.apply(); - packageResolution = newPackage.packageContext().getResolution(compilationOptions); + packageResolution = PackageResolution.from(this, compilationOptions); return packageResolution; } - Collection packageDependencies() { return packageDependencies; } @@ -289,10 +260,6 @@ DependencyGraph dependencyGraph() { return pkgDescDependencyGraph; } - IDLPluginManager idlPluginManager() { - return idlPluginManager; - } - void resolveDependencies(DependencyResolution dependencyResolution) { // This method mutate the internal state of the moduleContext instance. This is considered as lazy loading // TODO Figure out a way to handle concurrent modifications @@ -337,7 +304,6 @@ PackageContext duplicate(Project project) { return new PackageContext(project, this.packageId, this.packageManifest, this.dependencyManifest, this.ballerinaTomlContext, this.dependenciesTomlContext, this.cloudTomlContext, this.compilerPluginTomlContext, this.packageMdContext, - this.compilationOptions, duplicatedModuleContextMap, this.pkgDescDependencyGraph, - this.idlPluginManager); + this.compilationOptions, duplicatedModuleContextMap, this.pkgDescDependencyGraph); } } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/PackageResolution.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/PackageResolution.java index bce54c0118c1..942b23f38fae 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/PackageResolution.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/PackageResolution.java @@ -54,11 +54,9 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Optional; -import java.util.Set; import java.util.stream.Collectors; import static io.ballerina.projects.util.ProjectConstants.BUILD_FILE; @@ -71,14 +69,12 @@ */ public class PackageResolution { private final PackageContext rootPackageContext; - private final IDLPluginManager idlPluginManager; private final BlendedManifest blendedManifest; private final DependencyGraph dependencyGraph; private final CompilationOptions compilationOptions; private final PackageResolver packageResolver; private final ModuleResolver moduleResolver; private final List diagnosticList; - private final List pluginDiagnosticList; private DiagnosticResult diagnosticResult; private boolean autoUpdate; private String dependencyGraphDump; @@ -86,17 +82,12 @@ public class PackageResolution { private List topologicallySortedModuleList; private Collection dependenciesWithTransitives; private final List generatedModules; - private final Set clientsToCache; - private PackageResolution(PackageContext rootPackageContext, CompilationOptions compilationOptions, - IDLPluginManager idlPluginManager) { + private PackageResolution(PackageContext rootPackageContext, CompilationOptions compilationOptions) { this.rootPackageContext = rootPackageContext; - this.idlPluginManager = idlPluginManager; this.diagnosticList = new ArrayList<>(); - this.pluginDiagnosticList = new ArrayList<>(); this.compilationOptions = compilationOptions; this.generatedModules = new ArrayList<>(); - this.clientsToCache = new HashSet<>(); ResolutionOptions resolutionOptions = getResolutionOptions(rootPackageContext, compilationOptions); ProjectEnvironment projectEnvContext = rootPackageContext.project().projectEnvironmentContext(); this.packageResolver = projectEnvContext.getService(PackageResolver.class); @@ -111,9 +102,8 @@ private PackageResolution(PackageContext rootPackageContext, CompilationOptions resolveDependencies(dependencyResolution); } - static PackageResolution from(PackageContext rootPackageContext, CompilationOptions compilationOptions, - IDLPluginManager idlPluginManager) { - return new PackageResolution(rootPackageContext, compilationOptions, idlPluginManager); + static PackageResolution from(PackageContext rootPackageContext, CompilationOptions compilationOptions) { + return new PackageResolution(rootPackageContext, compilationOptions); } /** @@ -171,8 +161,7 @@ void reportDiagnostic(String message, String diagnosticErrorCode, DiagnosticSeve ModuleDescriptor moduleDescriptor) { var diagnosticInfo = new DiagnosticInfo(diagnosticErrorCode, message, severity); var diagnostic = DiagnosticFactory.createDiagnostic(diagnosticInfo, location); - var packageDiagnostic = new PackageDiagnostic(diagnostic, moduleDescriptor, rootPackageContext.project(), - false); + var packageDiagnostic = new PackageDiagnostic(diagnostic, moduleDescriptor, rootPackageContext.project()); this.diagnosticList.add(packageDiagnostic); this.diagnosticResult = new DefaultDiagnosticResult(this.diagnosticList); } @@ -181,18 +170,6 @@ public boolean autoUpdate() { return autoUpdate; } - List generatedModules() { - return generatedModules; - } - - Set clientsToCache() { - return clientsToCache; - } - - public List pluginDiagnosticList() { - return pluginDiagnosticList; - } - private boolean getSticky(PackageContext rootPackageContext) { boolean sticky = rootPackageContext.project().buildOptions().sticky(); if (sticky) { @@ -256,39 +233,13 @@ private LinkedHashSet getModuleLoadRequestsOfDirectDependenci LinkedHashSet allModuleLoadRequests = new ModuleContext.OverwritableLinkedHashSet(); for (ModuleId moduleId : rootPackageContext.moduleIds()) { ModuleContext moduleContext = rootPackageContext.moduleContext(moduleId); - allModuleLoadRequests.addAll(moduleContext.populateModuleLoadRequests( - idlPluginManager, compilationOptions, rootPackageContext.project().currentPackage())); + allModuleLoadRequests.addAll(moduleContext.populateModuleLoadRequests()); } for (ModuleId moduleId : rootPackageContext.moduleIds()) { ModuleContext moduleContext = rootPackageContext.moduleContext(moduleId); - allModuleLoadRequests.addAll(moduleContext.populateTestSrcModuleLoadRequests( - idlPluginManager, compilationOptions, rootPackageContext.project().currentPackage())); - } - for (ModuleId moduleId : rootPackageContext.moduleIds()) { - ModuleContext moduleContext = rootPackageContext.moduleContext(moduleId); - this.pluginDiagnosticList.addAll(moduleContext.idlPluginDiagnostics()); - } - - for (String moduleName : idlPluginManager.cachedModuleNames()) { - if (rootPackageContext.moduleContext( - ModuleName.from(rootPackageContext.packageName(), moduleName)) == null) { - Optional config = idlPluginManager.generatedModuleConfigs().stream().filter( - moduleConfig -> moduleConfig.moduleDescriptor().name().moduleNamePart() - .equals(moduleName)).findFirst(); - if (config.isEmpty()) { - idlPluginManager.generatedModuleConfigs().add( - Utils.createModuleConfig(moduleName, rootPackageContext.project())); - } - } - } - for (ModuleConfig generatedModuleConfig : idlPluginManager.generatedModuleConfigs()) { - if (!rootPackageContext.moduleIds().contains(generatedModuleConfig.moduleId())) { - this.generatedModules.add(generatedModuleConfig); - } + allModuleLoadRequests.addAll(moduleContext.populateTestSrcModuleLoadRequests()); } - this.clientsToCache.addAll(idlPluginManager.cachedClientEntries()); - // TODO: Move to compiler extension once new Compiler Extension model is introduced if (compilationOptions.observabilityIncluded()) { diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Project.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Project.java index 1113ef63857e..c539eb65b357 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Project.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Project.java @@ -85,10 +85,6 @@ protected void setCurrentPackage(Package currentPackage) { this.currentPackage = currentPackage; } - protected boolean isGeneratedModule(Module module) { - return module.moduleContext().isGenerated(); - } - public ProjectEnvironment projectEnvironmentContext() { return this.projectEnvironment; } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Utils.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Utils.java deleted file mode 100644 index f2c3492b7efe..000000000000 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Utils.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.projects; - -import io.ballerina.projects.internal.DocumentData; -import io.ballerina.projects.internal.ModuleData; -import io.ballerina.projects.internal.ProjectFiles; -import io.ballerina.projects.util.ProjectConstants; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.List; - -/** - * Compiler plugin related util methods. We have to introduce this due to the - * usage of package-private methods from ModuleContext - * - * @since 2.3.0 - */ -class Utils { - - static void writeModule(Module module, Path modulesRoot) throws IOException { - Path moduleDirPath = modulesRoot.resolve(module.descriptor().name().moduleNamePart()); - Files.createDirectories(moduleDirPath); - for (DocumentId documentId : module.documentIds()) { - Document document = module.document(documentId); - Files.writeString(moduleDirPath.resolve(document.name()), document.syntaxTree().toString()); - } - - Path moduleTestDirPath = moduleDirPath.resolve(ProjectConstants.TEST_DIR_NAME); - for (DocumentId documentId : module.testDocumentIds()) { - Files.createDirectories(moduleTestDirPath); - Document document = module.document(documentId); - Files.writeString(moduleTestDirPath.resolve(document.name()), document.syntaxTree().toString()); - } - - Path moduleResourcesDirPath = moduleDirPath.resolve(ProjectConstants.RESOURCE_DIR_NAME); - for (DocumentId resourceId : module.resourceIds()) { - Files.createDirectories(moduleTestDirPath); - Resource resource = module.resource(resourceId); - Files.write(moduleResourcesDirPath.resolve(resource.name()), resource.content()); - } - } - - static ModuleConfig createModuleConfig (String moduleName, Project project) { - ModuleData moduleData = ProjectFiles.loadModule( - project.sourceRoot().resolve(ProjectConstants.GENERATED_MODULES_ROOT).resolve(moduleName)); - ModuleId moduleId = ModuleId.create(moduleName, project.currentPackage().packageId()); - List documentConfigs = new ArrayList<>(); - List testDocumentConfigs = new ArrayList<>(); - for (DocumentData sourceDoc : moduleData.sourceDocs()) { - DocumentId documentId = DocumentId.create(sourceDoc.name(), moduleId); - documentConfigs.add(DocumentConfig.from(documentId, sourceDoc.content(), sourceDoc.name())); - } - for (DocumentData sourceDoc : moduleData.testSourceDocs()) { - DocumentId documentId = DocumentId.create(sourceDoc.name(), moduleId); - testDocumentConfigs.add(DocumentConfig.from(documentId, sourceDoc.content(), sourceDoc.name())); - } - ModuleDescriptor moduleDescriptor = ModuleDescriptor.from( - ModuleName.from(project.currentPackage().packageName(), moduleName), - project.currentPackage().descriptor()); - return ModuleConfig.from( - moduleId, moduleDescriptor, documentConfigs, testDocumentConfigs, null, new ArrayList<>(), - ModuleKind.COMPILER_GENERATED); - } -} diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/bala/BalaProject.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/bala/BalaProject.java index 8b08e4619a68..81febf8d9c61 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/bala/BalaProject.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/bala/BalaProject.java @@ -28,18 +28,13 @@ import io.ballerina.projects.ProjectException; import io.ballerina.projects.ProjectKind; import io.ballerina.projects.internal.BalaFiles; -import io.ballerina.projects.internal.IDLClients; import io.ballerina.projects.internal.PackageConfigCreator; import io.ballerina.projects.repos.TempDirCompilationCache; import io.ballerina.projects.util.ProjectConstants; import io.ballerina.projects.util.ProjectPaths; -import io.ballerina.tools.text.LineRange; -import org.ballerinalang.model.elements.PackageID; -import org.wso2.ballerinalang.compiler.util.CompilerContext; import java.nio.file.Files; import java.nio.file.Path; -import java.util.Map; import java.util.Optional; /** @@ -60,13 +55,6 @@ public static BalaProject loadProject(ProjectEnvironmentBuilder environmentBuild PackageConfig packageConfig = PackageConfigCreator.createBalaProjectConfig(balaPath); BalaProject balaProject = new BalaProject(environmentBuilder, balaPath); balaProject.addPackage(packageConfig); - Map>>> idlClientMap = - PackageConfigCreator.getIDLClientMap(balaPath); - if (!idlClientMap.isEmpty()) { - IDLClients idlClients = IDLClients.getInstance(balaProject.projectEnvironmentContext() - .getService(CompilerContext.class)); - idlClients.idlClientMap().putAll(idlClientMap); - } return balaProject; } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/directory/BuildProject.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/directory/BuildProject.java index a988355f653e..6e59aa527cd0 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/directory/BuildProject.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/directory/BuildProject.java @@ -127,10 +127,6 @@ private BuildProject(ProjectEnvironmentBuilder environmentBuilder, Path projectP } private Optional modulePath(ModuleId moduleId) { - if (isGeneratedModule(currentPackage().module(moduleId))) { - return Optional.of(sourceRoot.resolve(ProjectConstants.GENERATED_MODULES_ROOT).resolve( - currentPackage().module(moduleId).moduleName().moduleNamePart())); - } if (currentPackage().moduleIds().contains(moduleId)) { if (currentPackage().getDefaultModule().moduleId() == moduleId) { return Optional.of(sourceRoot); diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/IDLClients.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/IDLClients.java deleted file mode 100644 index f5512e03336b..000000000000 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/IDLClients.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.projects.internal; - -import io.ballerina.tools.text.LineRange; -import org.ballerinalang.model.elements.PackageID; -import org.wso2.ballerinalang.compiler.util.CompilerContext; - -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; - -/** - * A data holder for the generated IDL clients. - * - * @since 2.3.0 - */ -public class IDLClients { - public static final CompilerContext.Key IDL_CLIENT_MAP_KEY = new CompilerContext.Key<>(); - private final Map>>> idlClientMap; - - private IDLClients(CompilerContext context) { - context.put(IDL_CLIENT_MAP_KEY, this); - this.idlClientMap = new HashMap<>(); - } - - public static IDLClients getInstance(CompilerContext context) { - IDLClients idlClients = context.get(IDL_CLIENT_MAP_KEY); - if (idlClients == null) { - idlClients = new IDLClients(context); - } - - return idlClients; - } - - public Map>>> idlClientMap() { - return idlClientMap; - } - - public void addEntry(PackageID sourcePkgID, String sourceDoc, LineRange lineRange, PackageID clientPkgID) { - if (!this.idlClientMap.containsKey(sourcePkgID)) { - this.idlClientMap.put(sourcePkgID, new HashMap<>()); - } - if (!this.idlClientMap.get(sourcePkgID).containsKey(sourceDoc)) { - this.idlClientMap.get(sourcePkgID).put(sourceDoc, new HashMap<>()); - } - this.idlClientMap.get(sourcePkgID).get(sourceDoc).put(lineRange, Optional.ofNullable(clientPkgID)); - } -} diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageDiagnostic.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageDiagnostic.java index 09024d2fb32e..dc451abd0448 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageDiagnostic.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageDiagnostic.java @@ -55,8 +55,7 @@ protected PackageDiagnostic(DiagnosticInfo diagnosticInfo, Location location) { this.location = location; } - public PackageDiagnostic(Diagnostic diagnostic, ModuleDescriptor moduleDescriptor, Project project, - boolean isGenerated) { + public PackageDiagnostic(Diagnostic diagnostic, ModuleDescriptor moduleDescriptor, Project project) { String filePath; ModuleName moduleName = moduleDescriptor.name(); if (project.kind().equals(ProjectKind.BALA_PROJECT)) { @@ -65,13 +64,7 @@ public PackageDiagnostic(Diagnostic diagnostic, ModuleDescriptor moduleDescripto diagnostic.location().lineRange().filePath()).toString(); } else { if (!moduleName.isDefaultModuleName()) { - Path modulePath; - if (isGenerated) { - modulePath = Paths.get(ProjectConstants.GENERATED_MODULES_ROOT) - .resolve(moduleName.moduleNamePart()); - } else { - modulePath = Paths.get(ProjectConstants.MODULES_ROOT).resolve(moduleName.moduleNamePart()); - } + Path modulePath = Paths.get(ProjectConstants.MODULES_ROOT).resolve(moduleName.moduleNamePart()); filePath = modulePath.resolve(diagnostic.location().lineRange().filePath()).toString(); } else { filePath = diagnostic.location().lineRange().filePath(); diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/DependencyUtils.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/DependencyUtils.java index fdcd45ef2f3d..41a637b7a96d 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/DependencyUtils.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/DependencyUtils.java @@ -18,9 +18,7 @@ package io.ballerina.projects.util; import io.ballerina.projects.CompilationOptions; -import io.ballerina.projects.IDLClientGeneratorResult; import io.ballerina.projects.Project; -import io.ballerina.projects.environment.ResolutionOptions; /** * Project dependencies related util methods. @@ -44,15 +42,4 @@ public static void pullMissingDependencies(Project project) { project.currentPackage().getResolution(compilationOptionsBuilder.build()); } - /** - * Generate missing IDL client modules. - * - * @param project project - * @return IDLClientGeneratorResult idl generation result containing diagnostics and the updated package - */ - public static IDLClientGeneratorResult generateIDLClientModules(Project project) { - CompilationOptions.CompilationOptionsBuilder compilationOptionsBuilder = CompilationOptions.builder(); - compilationOptionsBuilder.setOffline(false); - return project.currentPackage().runIDLGeneratorPlugins(ResolutionOptions.builder().setOffline(false).build()); - } } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/SymbolTable.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/SymbolTable.java index a303c30d22ba..738209d072db 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/SymbolTable.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/SymbolTable.java @@ -17,7 +17,6 @@ */ package org.wso2.ballerinalang.compiler.semantics.model; -import io.ballerina.projects.internal.IDLClients; import io.ballerina.tools.diagnostics.Location; import io.ballerina.tools.text.LineRange; import org.ballerinalang.model.TreeBuilder; @@ -327,7 +326,7 @@ private SymbolTable(CompilerContext context) { defineReadonlyCompoundType(); - this.clientDeclarations = IDLClients.getInstance(context).idlClientMap(); + this.clientDeclarations = new HashMap<>(); } private void defineReadonlyCompoundType() { diff --git a/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/workspace/WorkspaceManager.java b/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/workspace/WorkspaceManager.java index bf6cb028c532..0110814cb607 100644 --- a/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/workspace/WorkspaceManager.java +++ b/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/workspace/WorkspaceManager.java @@ -20,7 +20,6 @@ import io.ballerina.compiler.api.SemanticModel; import io.ballerina.compiler.syntax.tree.SyntaxTree; import io.ballerina.projects.Document; -import io.ballerina.projects.IDLClientGeneratorResult; import io.ballerina.projects.Module; import io.ballerina.projects.ModuleCompilation; import io.ballerina.projects.PackageCompilation; @@ -236,12 +235,4 @@ public interface WorkspaceManager { */ String uriScheme(); - /** - * Run IDLGenerator plugins. - * - * @param filePath filepath. - * @param project project. - * @return {@link IDLClientGeneratorResult} - */ - Optional waitAndRunIDLGeneratorPlugins(Path filePath, Project project); } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/workspace/BallerinaWorkspaceManager.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/workspace/BallerinaWorkspaceManager.java index 85fda6411da7..c22a41e39155 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/workspace/BallerinaWorkspaceManager.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/workspace/BallerinaWorkspaceManager.java @@ -29,7 +29,6 @@ import io.ballerina.projects.Document; import io.ballerina.projects.DocumentConfig; import io.ballerina.projects.DocumentId; -import io.ballerina.projects.IDLClientGeneratorResult; import io.ballerina.projects.Module; import io.ballerina.projects.ModuleCompilation; import io.ballerina.projects.Package; @@ -40,7 +39,6 @@ import io.ballerina.projects.directory.BuildProject; import io.ballerina.projects.directory.ProjectLoader; import io.ballerina.projects.directory.SingleFileProject; -import io.ballerina.projects.environment.ResolutionOptions; import io.ballerina.projects.util.ProjectConstants; import io.ballerina.projects.util.ProjectPaths; import org.apache.commons.lang3.tuple.ImmutablePair; @@ -71,6 +69,8 @@ import org.eclipse.lsp4j.TextDocumentIdentifier; import org.eclipse.lsp4j.jsonrpc.CancelChecker; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -88,9 +88,6 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - import static io.ballerina.projects.util.ProjectConstants.BALLERINA_TOML; /** @@ -1031,24 +1028,6 @@ public void didClose(Path filePath, DidCloseTextDocumentParams params) { } } - @Override - public Optional waitAndRunIDLGeneratorPlugins(Path filePath, Project project) { - Optional projectPair = projectPair(projectRoot(filePath)); - if (projectPair.isEmpty()) { - return Optional.empty(); - } - - // Lock Project Instance - Lock lock = projectPair.get().lockAndGet(); - try { - return Optional.of(project.currentPackage() - .runIDLGeneratorPlugins(ResolutionOptions.builder().setOffline(false).build())); - } finally { - // Unlock Project Instance - lock.unlock(); - } - } - // ============================================================================================================== // private Path computeProjectRoot(Path path) { diff --git a/project-api/project-api-test/src/test/java/io/ballerina/projects/test/plugins/IDLClientCompilerTests.java b/project-api/project-api-test/src/test/java/io/ballerina/projects/test/plugins/IDLClientCompilerTests.java deleted file mode 100644 index 4c1cb4ca3050..000000000000 --- a/project-api/project-api-test/src/test/java/io/ballerina/projects/test/plugins/IDLClientCompilerTests.java +++ /dev/null @@ -1,334 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.projects.test.plugins; - -import io.ballerina.projects.BuildOptions; -import io.ballerina.projects.DiagnosticResult; -import io.ballerina.projects.IDLClientGeneratorResult; -import io.ballerina.projects.JBallerinaBackend; -import io.ballerina.projects.JvmTarget; -import io.ballerina.projects.PackageCompilation; -import io.ballerina.projects.Project; -import io.ballerina.projects.test.TestUtils; -import io.ballerina.projects.util.ProjectUtils; -import io.ballerina.tools.diagnostics.Diagnostic; -import io.ballerina.tools.diagnostics.DiagnosticSeverity; -import org.ballerinalang.model.symbols.AnnotationAttachmentSymbol; -import org.ballerinalang.model.tree.ClientDeclarationNode; -import org.ballerinalang.model.tree.FunctionNode; -import org.ballerinalang.test.BRunUtil; -import org.ballerinalang.test.CompileResult; -import org.testng.Assert; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import org.wso2.ballerinalang.compiler.semantics.model.symbols.BAnnotationAttachmentSymbol; -import org.wso2.ballerinalang.compiler.semantics.model.symbols.BClientDeclarationSymbol; -import org.wso2.ballerinalang.compiler.tree.BLangBlockFunctionBody; -import org.wso2.ballerinalang.compiler.tree.BLangClientDeclaration; -import org.wso2.ballerinalang.compiler.tree.BLangConstantValue; -import org.wso2.ballerinalang.compiler.tree.BLangFunction; -import org.wso2.ballerinalang.compiler.tree.statements.BLangClientDeclarationStatement; -import org.wso2.ballerinalang.compiler.tree.statements.BLangStatement; - -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.List; -import java.util.Map; - -/** - * Compiler test cases for IDL clients. - * - * @since 2201.3.0 - */ -public class IDLClientCompilerTests { - - private static final Path RESOURCE_DIRECTORY = Paths.get( - "src/test/resources/idl_client_compiler_tests").toAbsolutePath(); - private static final String CARRIAGE_RETURN_CHAR = "\\r"; - private static final String EMPTY_STRING = ""; - - private static final String UNSUPPORTED_EXPOSURE_OF_PUBLIC_CONSTRUCT_ERROR = - "exposing a construct from a module generated for a client declaration is not yet supported"; - private static final String NO_CLIENT_OBJECT_NAMED_CLIENT_IN_GENERATED_MODULE_ERROR = - "a module generated for a client declaration must have an object type or class named 'client'"; - private static final String MUTABLE_STATE_IN_GENERATED_MODULE_ERROR = - "a module generated for a client declaration cannot have mutable state"; - private static final String INVALID_USAGE_OF_UNQUOTED_CLIENT_KEYWORD_ERROR = - "invalid usage of the 'client' keyword as an unquoted identifier in a qualified identifier: " + - "allowed only with client declarations"; - - private CompileResult result; - - @BeforeSuite - public void setup() { - Project project = loadPackage("simpleclienttest"); - IDLClientGeneratorResult idlClientGeneratorResult = project.currentPackage().runIDLGeneratorPlugins(); - DiagnosticResult diagnosticResult = idlClientGeneratorResult.reportedDiagnostics(); - Assert.assertEquals(diagnosticResult.diagnostics().size(), 0, - TestUtils.getDiagnosticsAsString(diagnosticResult)); - - PackageCompilation compilation = project.currentPackage().getCompilation(); - Assert.assertEquals(compilation.diagnosticResult().diagnostics().size(), 0, - TestUtils.getDiagnosticsAsString(compilation.diagnosticResult())); - - JBallerinaBackend jBallerinaBackend = JBallerinaBackend.from(compilation, JvmTarget.JAVA_11); - result = new CompileResult(project.currentPackage(), jBallerinaBackend); - try { - BRunUtil.runInit(result); - } catch (ClassNotFoundException e) { - throw new RuntimeException("error while invoking init method"); - } - } - - @Test(dataProvider = "testFuncNames") - public void testModuleClientDecl(String testFuncName) { - BRunUtil.invoke(result, testFuncName); - } - - @DataProvider - public Object[] testFuncNames() { - return new Object[] { - "testModuleClientDecl", - "testClientDeclStmt", - "testClientDeclScoping1", - "testClientDeclModuleWithClientObjectType" - }; - } - - @Test - public void testClientDeclUndefinedSymbolsAndNoGeneratedModulesNegative() { - Project project = loadPackage("simpleclientnegativetest"); - IDLClientGeneratorResult idlClientGeneratorResult = project.currentPackage().runIDLGeneratorPlugins(); - - // Expected to get 2 'no matching plugin found' errors - Assert.assertEquals(idlClientGeneratorResult.reportedDiagnostics().diagnostics().size(), 2, - TestUtils.getDiagnosticsAsString(idlClientGeneratorResult.reportedDiagnostics())); - Assert.assertEquals(TestUtils.getDiagnosticsAsString(idlClientGeneratorResult.reportedDiagnostics()), - "ERROR [main.bal:(40:1,40:82)] no matching plugin found for client declaration\n" + - "ERROR [main.bal:(43:5,43:87)] no matching plugin found for client declaration\n"); - PackageCompilation compilation = project.currentPackage().getCompilation(); - - Diagnostic[] diagnostics = compilation.diagnosticResult().diagnostics().toArray(new Diagnostic[0]); - int index = 0; - validateError(diagnostics, index++, "no matching plugin found for client declaration", 40, 1); - validateError(diagnostics, index++, "no matching plugin found for client declaration", 43, 5); - validateError(diagnostics, index++, "unknown type 'Config'", 19, 1); - validateError(diagnostics, index++, "unknown type 'Client'", 20, 1); - validateError(diagnostics, index++, "unknown type 'ClientConfig'", 23, 5); - validateError(diagnostics, index++, "unknown type 'Client'", 24, 5); - validateError(diagnostics, index++, "unknown type 'ClientConfiguratin'", 29, 5); - validateError(diagnostics, index++, "unknown type 'clients'", 30, 5); - validateError(diagnostics, index++, "unknown type 'ClientConfiguration'", 36, 5); - validateError(diagnostics, index++, "unknown type 'Config'", 37, 5); - Assert.assertEquals(diagnostics.length, index); - } - - @Test - public void testUnusedClientDeclPrefixNegative() { - Project project = loadPackage("simpleclientnegativetesttwo"); - IDLClientGeneratorResult idlClientGeneratorResult = project.currentPackage().runIDLGeneratorPlugins(); - Assert.assertTrue(idlClientGeneratorResult.reportedDiagnostics().diagnostics().isEmpty(), - TestUtils.getDiagnosticsAsString(idlClientGeneratorResult.reportedDiagnostics())); - PackageCompilation compilation = project.currentPackage().getCompilation(); - - Diagnostic[] diagnostics = compilation.diagnosticResult().diagnostics().toArray(new Diagnostic[0]); - int index = 0; - validateError(diagnostics, index++, "unused client declaration prefix 'foo'", 17, 69); - validateError(diagnostics, index++, "unused client declaration prefix 'bar'", 20, 74); - validateError(diagnostics, index++, "unused client declaration prefix 'baz'", 23, 78); - validateError(diagnostics, index++, "unused client declaration prefix 'p2'", 30, 70); - validateError(diagnostics, index++, "unused client declaration prefix 'p1'", 38, 74); - validateError(diagnostics, index++, "unused client declaration prefix 'p3'", 40, 74); - validateError(diagnostics, index++, "unused client declaration prefix 'p4'", 43, 70); - validateError(diagnostics, index++, "unused client declaration prefix 'p5'", 45, 70); - Assert.assertEquals(diagnostics.length, index); - } - - @Test - public void testExposingConstructFromGeneratedModuleNegative() { - Project project = loadPackage("simpleclientnegativetestthree"); - IDLClientGeneratorResult idlClientGeneratorResult = project.currentPackage().runIDLGeneratorPlugins(); - Assert.assertTrue(idlClientGeneratorResult.reportedDiagnostics().diagnostics().isEmpty(), - TestUtils.getDiagnosticsAsString(idlClientGeneratorResult.reportedDiagnostics())); - PackageCompilation compilation = project.currentPackage().getCompilation(); - - Diagnostic[] diagnostics = compilation.diagnosticResult().diagnostics().toArray(new Diagnostic[0]); - int index = 0; - validateError(diagnostics, index++, UNSUPPORTED_EXPOSURE_OF_PUBLIC_CONSTRUCT_ERROR, 20, 1); - validateError(diagnostics, index++, UNSUPPORTED_EXPOSURE_OF_PUBLIC_CONSTRUCT_ERROR, 23, 1); - validateError(diagnostics, index++, UNSUPPORTED_EXPOSURE_OF_PUBLIC_CONSTRUCT_ERROR, 37, 1); - validateError(diagnostics, index++, UNSUPPORTED_EXPOSURE_OF_PUBLIC_CONSTRUCT_ERROR, 45, 1); - validateError(diagnostics, index++, UNSUPPORTED_EXPOSURE_OF_PUBLIC_CONSTRUCT_ERROR, 51, 1); - validateError(diagnostics, index++, UNSUPPORTED_EXPOSURE_OF_PUBLIC_CONSTRUCT_ERROR, 54, 1); - validateError(diagnostics, index++, UNSUPPORTED_EXPOSURE_OF_PUBLIC_CONSTRUCT_ERROR, 57, 1); - validateError(diagnostics, index++, UNSUPPORTED_EXPOSURE_OF_PUBLIC_CONSTRUCT_ERROR, 63, 1); - validateError(diagnostics, index++, UNSUPPORTED_EXPOSURE_OF_PUBLIC_CONSTRUCT_ERROR, 72, 1); - validateError(diagnostics, index++, UNSUPPORTED_EXPOSURE_OF_PUBLIC_CONSTRUCT_ERROR, 78, 1); - validateError(diagnostics, index++, UNSUPPORTED_EXPOSURE_OF_PUBLIC_CONSTRUCT_ERROR, 81, 1); - validateError(diagnostics, index++, UNSUPPORTED_EXPOSURE_OF_PUBLIC_CONSTRUCT_ERROR, 84, 1); - validateError(diagnostics, index++, UNSUPPORTED_EXPOSURE_OF_PUBLIC_CONSTRUCT_ERROR, 87, 1); - validateError(diagnostics, index++, UNSUPPORTED_EXPOSURE_OF_PUBLIC_CONSTRUCT_ERROR, 90, 1); - validateError(diagnostics, index++, UNSUPPORTED_EXPOSURE_OF_PUBLIC_CONSTRUCT_ERROR, 93, 1); - validateError(diagnostics, index++, UNSUPPORTED_EXPOSURE_OF_PUBLIC_CONSTRUCT_ERROR, 96, 1); - validateError(diagnostics, index++, UNSUPPORTED_EXPOSURE_OF_PUBLIC_CONSTRUCT_ERROR, 99, 1); - validateError(diagnostics, index++, UNSUPPORTED_EXPOSURE_OF_PUBLIC_CONSTRUCT_ERROR, 102, 1); - validateError(diagnostics, index++, UNSUPPORTED_EXPOSURE_OF_PUBLIC_CONSTRUCT_ERROR, 105, 1); - validateError(diagnostics, index++, UNSUPPORTED_EXPOSURE_OF_PUBLIC_CONSTRUCT_ERROR, 108, 1); - validateError(diagnostics, index++, UNSUPPORTED_EXPOSURE_OF_PUBLIC_CONSTRUCT_ERROR, 114, 1); - validateError(diagnostics, index++, UNSUPPORTED_EXPOSURE_OF_PUBLIC_CONSTRUCT_ERROR, 123, 1); - validateError(diagnostics, index++, UNSUPPORTED_EXPOSURE_OF_PUBLIC_CONSTRUCT_ERROR, 127, 1); - validateError(diagnostics, index++, UNSUPPORTED_EXPOSURE_OF_PUBLIC_CONSTRUCT_ERROR, 138, 1); - validateError(diagnostics, index++, UNSUPPORTED_EXPOSURE_OF_PUBLIC_CONSTRUCT_ERROR, 141, 1); - validateError(diagnostics, index++, UNSUPPORTED_EXPOSURE_OF_PUBLIC_CONSTRUCT_ERROR, 143, 1); - validateError(diagnostics, index++, UNSUPPORTED_EXPOSURE_OF_PUBLIC_CONSTRUCT_ERROR, 148, 1); - Assert.assertEquals(diagnostics.length, index); - } - - @Test - public void testInvalidGeneratedModuleNegative() { - Project project = loadPackage("simpleclientnegativetestfour"); - IDLClientGeneratorResult idlClientGeneratorResult = project.currentPackage().runIDLGeneratorPlugins(); - Assert.assertTrue(idlClientGeneratorResult.reportedDiagnostics().diagnostics().isEmpty(), - TestUtils.getDiagnosticsAsString(idlClientGeneratorResult.reportedDiagnostics())); - PackageCompilation compilation = project.currentPackage().getCompilation(); - - Diagnostic[] diagnostics = compilation.diagnosticResult().diagnostics().toArray(new Diagnostic[0]); - int index = 0; - validateError(diagnostics, index++, NO_CLIENT_OBJECT_NAMED_CLIENT_IN_GENERATED_MODULE_ERROR, 1, 1); - validateError(diagnostics, index++, NO_CLIENT_OBJECT_NAMED_CLIENT_IN_GENERATED_MODULE_ERROR, 1, 1); - validateError(diagnostics, index++, NO_CLIENT_OBJECT_NAMED_CLIENT_IN_GENERATED_MODULE_ERROR, 1, 1); - validateError(diagnostics, index++, MUTABLE_STATE_IN_GENERATED_MODULE_ERROR, 9, 1); - validateError(diagnostics, index++, MUTABLE_STATE_IN_GENERATED_MODULE_ERROR, 11, 1); - validateError(diagnostics, index++, MUTABLE_STATE_IN_GENERATED_MODULE_ERROR, 13, 1); - validateError(diagnostics, index++, MUTABLE_STATE_IN_GENERATED_MODULE_ERROR, 15, 1); - validateError(diagnostics, index++, MUTABLE_STATE_IN_GENERATED_MODULE_ERROR, 19, 1); - Assert.assertEquals(diagnostics.length, index); - } - - @Test - public void testInvalidImportOfGeneratedModuleNegative() { - Project project = loadPackage("simpleclientnegativetestfive"); - IDLClientGeneratorResult idlClientGeneratorResult = project.currentPackage().runIDLGeneratorPlugins(); - Assert.assertTrue(idlClientGeneratorResult.reportedDiagnostics().diagnostics().isEmpty(), - TestUtils.getDiagnosticsAsString(idlClientGeneratorResult.reportedDiagnostics())); - PackageCompilation compilation = project.currentPackage().getCompilation(); - - Diagnostic[] diagnostics = compilation.diagnosticResult().diagnostics().toArray(new Diagnostic[0]); - int index = 0; - validateError(diagnostics, index++, "a module generated for a client declaration cannot be imported", 17, 1); - validateError(diagnostics, index++, "a module generated for a client declaration cannot be imported", 18, 1); - validateError(diagnostics, index++, "undefined module 'client1'", 24, 5); - validateError(diagnostics, index++, "unknown type 'ClientConfiguration'", 24, 5); - validateError(diagnostics, index++, "undefined module 'bar'", 25, 5); - validateError(diagnostics, index++, "unknown type 'ClientConfiguration'", 25, 5); - Assert.assertEquals(diagnostics.length, index); - } - - @Test - public void testInvalidUsageOfUnquotedClientKeywordNegative() { - Project project = loadPackage("simpleclientnegativetestsix"); - IDLClientGeneratorResult idlClientGeneratorResult = project.currentPackage().runIDLGeneratorPlugins(); - Assert.assertTrue(idlClientGeneratorResult.reportedDiagnostics().diagnostics().isEmpty(), - TestUtils.getDiagnosticsAsString(idlClientGeneratorResult.reportedDiagnostics())); - PackageCompilation compilation = project.currentPackage().getCompilation(); - - Diagnostic[] diagnostics = compilation.diagnosticResult().diagnostics().toArray(new Diagnostic[0]); - int index = 0; - // main.bal - validateError(diagnostics, index++, INVALID_USAGE_OF_UNQUOTED_CLIENT_KEYWORD_ERROR, 21, 1); - validateError(diagnostics, index++, INVALID_USAGE_OF_UNQUOTED_CLIENT_KEYWORD_ERROR, 25, 5); - validateError(diagnostics, index++, INVALID_USAGE_OF_UNQUOTED_CLIENT_KEYWORD_ERROR, 26, 5); - validateError(diagnostics, index++, INVALID_USAGE_OF_UNQUOTED_CLIENT_KEYWORD_ERROR, 26, 27); - validateError(diagnostics, index++, INVALID_USAGE_OF_UNQUOTED_CLIENT_KEYWORD_ERROR, 31, 9); - // oth.bal - validateError(diagnostics, index++, INVALID_USAGE_OF_UNQUOTED_CLIENT_KEYWORD_ERROR, 20, 5); - validateError(diagnostics, index++, INVALID_USAGE_OF_UNQUOTED_CLIENT_KEYWORD_ERROR, 21, 9); - Assert.assertEquals(diagnostics.length, index); - } - - @Test - public void testAnnotationOnClientDeclaration() { - List clientDeclarations = result.getAST().getClientDeclarations(); - - ClientDeclarationNode clientDeclarationNode = clientDeclarations.stream() - .filter(cl -> "foo".equals(cl.getPrefix().getValue())).findFirst().get(); - List attachments = - ((BClientDeclarationSymbol) ((BLangClientDeclaration) clientDeclarationNode).symbol).getAnnotations(); - Assert.assertEquals(attachments.size(), 0); - - clientDeclarationNode = clientDeclarations.stream() - .filter(cl -> "bar".equals(cl.getPrefix().getValue())).findFirst().get(); - attachments = - ((BClientDeclarationSymbol) ((BLangClientDeclaration) clientDeclarationNode).symbol).getAnnotations(); - Assert.assertEquals(attachments.size(), 1); - assertAttachmentSymbol(attachments.get(0), 123L); - } - - @Test - public void testAnnotationOnClientDeclarationStmt() { - FunctionNode functionNode = result.getAST().getFunctions().stream() - .filter(fn -> "testClientDeclAnnotSymbols".equals(((BLangFunction) fn).name.value)).findFirst().get(); - - BLangStatement stmt = ((BLangBlockFunctionBody) ((BLangFunction) functionNode).body).stmts.get(0); - List attachments = - ((BClientDeclarationSymbol) ((BLangClientDeclarationStatement) stmt).clientDeclaration.symbol) - .getAnnotations(); - Assert.assertEquals(attachments.size(), 2); - assertAttachmentSymbol(attachments.get(0), 12L); - assertAttachmentSymbol(attachments.get(1), 13L); - - stmt = ((BLangBlockFunctionBody) ((BLangFunction) functionNode).body).stmts.get(2); - attachments = ((BClientDeclarationSymbol) ((BLangClientDeclarationStatement) stmt).clientDeclaration.symbol) - .getAnnotations(); - Assert.assertEquals(attachments.size(), 0); - } - - private Project loadPackage(String path) { - Path projectDirPath = RESOURCE_DIRECTORY.resolve(path); - BuildOptions buildOptions = BuildOptions.builder().targetDir(ProjectUtils.getTemporaryTargetPath()).build(); - return TestUtils.loadBuildProject(projectDirPath, buildOptions); - } - - private static void validateError(Diagnostic[] diagnostics, int errorIndex, String expectedErrMsg, - int expectedErrLine, int expectedErrCol) { - Diagnostic diag = diagnostics[errorIndex]; - Assert.assertEquals(diag.diagnosticInfo().severity(), DiagnosticSeverity.ERROR, "incorrect diagnostic type"); - Assert.assertEquals(diag.message().replace(CARRIAGE_RETURN_CHAR, EMPTY_STRING), - expectedErrMsg.replace(CARRIAGE_RETURN_CHAR, EMPTY_STRING), "incorrect error message:"); - Assert.assertEquals(diag.location().lineRange().startLine().line() + 1, expectedErrLine, - "incorrect line number:"); - Assert.assertEquals(diag.location().lineRange().startLine().offset() + 1, expectedErrCol, - "incorrect column position:"); - } - - private void assertAttachmentSymbol(AnnotationAttachmentSymbol attachmentSymbol, Object value) { - BAnnotationAttachmentSymbol annotationAttachmentSymbol = (BAnnotationAttachmentSymbol) attachmentSymbol; - Assert.assertEquals(annotationAttachmentSymbol.annotTag.value, "ClientAnnot"); - Assert.assertTrue(annotationAttachmentSymbol.isConstAnnotation()); - - Object constValue = - ((BAnnotationAttachmentSymbol.BConstAnnotationAttachmentSymbol) annotationAttachmentSymbol) - .attachmentValueSymbol.value.value; - - Map mapConst = (Map) constValue; - Assert.assertEquals(mapConst.size(), 1); - Assert.assertEquals(mapConst.get("i").value, value); - } -} diff --git a/project-api/project-api-test/src/test/java/io/ballerina/projects/test/plugins/IDLClientGenPluginTests.java b/project-api/project-api-test/src/test/java/io/ballerina/projects/test/plugins/IDLClientGenPluginTests.java deleted file mode 100644 index c38c98545276..000000000000 --- a/project-api/project-api-test/src/test/java/io/ballerina/projects/test/plugins/IDLClientGenPluginTests.java +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.projects.test.plugins; - -import io.ballerina.projects.DiagnosticResult; -import io.ballerina.projects.DocumentId; -import io.ballerina.projects.IDLClientGeneratorResult; -import io.ballerina.projects.Project; -import io.ballerina.projects.ProjectEnvironmentBuilder; -import io.ballerina.projects.directory.BuildProject; -import io.ballerina.projects.environment.Environment; -import io.ballerina.projects.environment.EnvironmentBuilder; -import io.ballerina.projects.test.TestUtils; -import org.ballerinalang.test.BCompileUtil; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import java.io.IOException; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.regex.Matcher; - -import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; - -/** - * Test cases for IDL Client generation. - * - * @since 2201.3.0 - */ -public class IDLClientGenPluginTests { - - private Path testResourceDir; - - @BeforeClass - public void setup() throws IOException { - - Path testSourceDir = Paths.get( - "src/test/resources/compiler_plugin_tests/idl_plugin_packages").toAbsolutePath(); - testResourceDir = Files.createTempDirectory("idl-plugin-tests" + System.currentTimeMillis()); - Files.walk(testSourceDir).forEach(source -> { - try { - Files.copy(source, testResourceDir.resolve(testSourceDir.relativize(source)), REPLACE_EXISTING); - } catch (IOException e) { - Assert.fail(e.getMessage()); - } - }); - } - - @Test - public void testIdlPluginBuildProject() { - assertIdlPluginProject("package_test_idl_plugin_1", 2); - } - - @Test - public void testIdlPluginLocalPaths() throws IOException { - String projectName = "package_test_idl_plugin_local_test"; - Path projectDir = testResourceDir.resolve(projectName); - Path mainPath = projectDir.resolve("main.bal"); - String originalContent = writeBalFile(projectDir, mainPath); - - assertIdlPluginProject(projectName, 4); - - undoBalFile(mainPath, originalContent); - } - - private String writeBalFile(Path projectDir, Path balPath) throws IOException { - String mainContent = Files.readString(balPath); - - Path path = projectDir.resolve("projectapiclientplugin.json").toAbsolutePath().normalize(); - - String absPath = Matcher.quoteReplacement(path.toString()); - absPath = absPath.replace("\\", "\\\\"); - - String newMainContent = mainContent.replaceAll("<>", absPath); - - URL fileProtocol = path.toUri().toURL(); - newMainContent = newMainContent.replaceAll("<>", - Matcher.quoteReplacement(fileProtocol.toString())); - - Files.write(balPath, newMainContent.getBytes(StandardCharsets.UTF_8)); - return mainContent; - } - - private void undoBalFile(Path balPath, String oldContent) throws IOException { - Files.write(balPath, oldContent.getBytes(StandardCharsets.UTF_8)); - } - - private void assertIdlPluginProject(String projectName, int expectedModules) { - Path projectDir = testResourceDir.resolve(projectName); - Project project = TestUtils.loadBuildProject(projectDir); - IDLClientGeneratorResult idlClientGeneratorResult = project.currentPackage().runIDLGeneratorPlugins(); - Assert.assertTrue(idlClientGeneratorResult.reportedDiagnostics().diagnostics().isEmpty(), - TestUtils.getDiagnosticsAsString(idlClientGeneratorResult.reportedDiagnostics())); - - // Check whether there are any diagnostics - DiagnosticResult diagnosticResult = project.currentPackage().getCompilation().diagnosticResult(); - Assert.assertEquals(diagnosticResult.diagnosticCount(), 0, - TestUtils.getDiagnosticsAsString(diagnosticResult)); - - Assert.assertEquals(project.currentPackage().moduleIds().size(), expectedModules); - } - - @Test(dependsOnMethods = "testIdlPluginBuildProject") - public void testIdlPluginBuildProjectLoadExistingRemote() { - Project project = TestUtils.loadBuildProject(testResourceDir.resolve("package_test_idl_plugin_1")); - - // Check whether there are any diagnostics - DiagnosticResult diagnosticResult = project.currentPackage().getCompilation().diagnosticResult(); - Assert.assertEquals(diagnosticResult.diagnosticCount(), 0, - TestUtils.getDiagnosticsAsString(diagnosticResult)); - Assert.assertEquals(project.currentPackage().moduleIds().size(), 2); - } - - @Test(dependsOnMethods = "testIdlPluginLocalPaths") - public void testIdlPluginBuildProjectLoadExistingLocal() throws IOException { - String projectName = "package_test_idl_plugin_local_test"; - Path projectDir = testResourceDir.resolve(projectName); - Path mainPath = projectDir.resolve("main.bal"); - String originalContent = writeBalFile(projectDir, mainPath); - Project project = TestUtils.loadBuildProject(projectDir); - undoBalFile(mainPath, originalContent); - - // Check whether there are any diagnostics - DiagnosticResult diagnosticResult = project.currentPackage().getCompilation().diagnosticResult(); - Assert.assertEquals(diagnosticResult.diagnosticCount(), 0, - TestUtils.getDiagnosticsAsString(diagnosticResult)); - Assert.assertEquals(project.currentPackage().moduleIds().size(), 4); - - } - - @Test - public void testIdlPluginBuildProjectRepeatCompilation() { - Project project = TestUtils.loadBuildProject(testResourceDir.resolve("package_test_idl_plugin_3")); - Assert.assertEquals(project.currentPackage().getCompilation().diagnosticResult().errors().size(), 6, - TestUtils.getDiagnosticsAsString(project.currentPackage().getCompilation().diagnosticResult())); - Assert.assertEquals(project.currentPackage().moduleIds().size(), 1); - IDLClientGeneratorResult idlClientGeneratorResult = project.currentPackage().runIDLGeneratorPlugins(); - - Assert.assertTrue(idlClientGeneratorResult.reportedDiagnostics().diagnostics().isEmpty(), - TestUtils.getDiagnosticsAsString(idlClientGeneratorResult.reportedDiagnostics())); - Assert.assertEquals(project.currentPackage().getCompilation().diagnosticResult().errors().size(), 0, - TestUtils.getDiagnosticsAsString(project.currentPackage().getCompilation().diagnosticResult())); - Assert.assertEquals(project.currentPackage().moduleIds().size(), 2); - } - - @Test - public void testIdlPluginBuildProjectRepeatEditsWithCompilation() { - Project project = TestUtils.loadBuildProject(testResourceDir.resolve("package_test_idl_plugin_for_edits")); - Assert.assertEquals(project.currentPackage().getCompilation().diagnosticResult().errors().size(), 6, - TestUtils.getDiagnosticsAsString(project.currentPackage().getCompilation().diagnosticResult())); - - DocumentId documentId = project.currentPackage().getDefaultModule().documentIds() - .stream().findFirst().orElseThrow(); - String sourceCode = project.currentPackage().getDefaultModule() - .document(documentId).syntaxTree().toSourceCode(); - - // Edit, compile and check diagnostics - for (int i = 1; i < 6; i++) { - sourceCode += ("int a" + i + " = " + i + "\n"); - project.currentPackage().getDefaultModule().document(documentId).modify().withContent(sourceCode).apply(); - Assert.assertEquals( - project.currentPackage().getCompilation().diagnosticResult().diagnostics().size(), 6 + i, - TestUtils.getDiagnosticsAsString(project.currentPackage().getCompilation().diagnosticResult())); - } - Assert.assertEquals(project.currentPackage().moduleIds().size(), 1); - - // Run IDL client generator plugins - IDLClientGeneratorResult idlClientGeneratorResult = project.currentPackage().runIDLGeneratorPlugins(); - Assert.assertTrue(idlClientGeneratorResult.reportedDiagnostics().diagnostics().isEmpty()); - Assert.assertEquals(project.currentPackage().getCompilation().diagnosticResult().errors().size(), 5, - TestUtils.getDiagnosticsAsString(project.currentPackage().getCompilation().diagnosticResult())); - Assert.assertEquals(project.currentPackage().moduleIds().size(), 2); - - // Repeat: Edit, compile and check diagnostics - for (int i = 6; i < 11; i++) { - sourceCode += ("int a" + i + " = " + i + "\n"); - project.currentPackage().getDefaultModule().document(documentId).modify().withContent(sourceCode).apply(); - Assert.assertEquals(project.currentPackage().getCompilation().diagnosticResult().diagnostics().size(), i, - TestUtils.getDiagnosticsAsString(project.currentPackage().getCompilation().diagnosticResult())); - } - - Assert.assertEquals(project.currentPackage().moduleIds().size(), 2); - } - - @Test - public void testIdlDeclarationInBala() throws IOException { - Path projectPath = testResourceDir.resolve("package_test_idl_plugin_2"); - Path customUserHome = Paths.get(System.getProperty("user.dir")).resolve("build/user-home"); - Path customHomeRepo = customUserHome.resolve("repositories/central.ballerina.io"); - Environment environment = EnvironmentBuilder.getBuilder().setUserHome(customUserHome).build(); - ProjectEnvironmentBuilder projectEnvironmentBuilder = ProjectEnvironmentBuilder.getBuilder(environment); - - Path balaPath = projectPath.resolve("idl-dependency-bala/user-package_test_idl_plugin-any-0.1.0.bala"); - BCompileUtil.copyBalaToExtractedDist(balaPath, "user", "package_test_idl_plugin", "0.1.0", customHomeRepo); - - BuildProject buildProject = TestUtils.loadBuildProject(projectEnvironmentBuilder, projectPath); - Assert.assertFalse(buildProject.currentPackage().getCompilation().diagnosticResult().hasErrors(), - TestUtils.getDiagnosticsAsString(buildProject.currentPackage().getCompilation().diagnosticResult())); - } - - @Test - public void testIdlPluginRepeatClientUrl() { - Path projectPath = testResourceDir.resolve("package_test_idl_plugin_repeat_client_url"); - Project project = TestUtils.loadBuildProject(projectPath); - Assert.assertEquals(project.currentPackage().getCompilation().diagnosticResult().errors().size(), 7); - Assert.assertEquals(project.currentPackage().moduleIds().size(), 1); - IDLClientGeneratorResult idlClientGeneratorResult = project.currentPackage().runIDLGeneratorPlugins(); - - Assert.assertTrue(idlClientGeneratorResult.reportedDiagnostics().diagnostics().isEmpty(), - TestUtils.getDiagnosticsAsString(idlClientGeneratorResult.reportedDiagnostics())); - Assert.assertEquals(project.currentPackage().getCompilation().diagnosticResult().errors().size(), 1, - TestUtils.getDiagnosticsAsString(project.currentPackage().getCompilation().diagnosticResult())); - Assert.assertEquals(project.currentPackage().moduleIds().size(), 2); - } - - @Test - public void testIdlPluginUnhandledEx() { - Path projectPath = testResourceDir.resolve("package_test_idl_plugin_negative"); - Project project = TestUtils.loadBuildProject(projectPath); - IDLClientGeneratorResult idlClientGeneratorResult = project.currentPackage().runIDLGeneratorPlugins(); - Assert.assertEquals(idlClientGeneratorResult.reportedDiagnostics().diagnostics().size(), 3, - TestUtils.getDiagnosticsAsString(idlClientGeneratorResult.reportedDiagnostics())); - - // Check whether there are any diagnostics - DiagnosticResult diagnosticResult = project.currentPackage().getCompilation().diagnosticResult(); - Assert.assertEquals(diagnosticResult.diagnosticCount(), 6, - TestUtils.getDiagnosticsAsString(diagnosticResult)); - - Assert.assertEquals(project.currentPackage().moduleIds().size(), 2); - - } -} diff --git a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_1/Ballerina.toml b/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_1/Ballerina.toml deleted file mode 100644 index 7e9365f15757..000000000000 --- a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_1/Ballerina.toml +++ /dev/null @@ -1,7 +0,0 @@ -[package] -org = "user" -name = "package_test_idl_plugin" -version = "0.1.0" - -[build-options] -observabilityIncluded = false diff --git a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_1/main.bal b/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_1/main.bal deleted file mode 100644 index 90a8fd0dc421..000000000000 --- a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_1/main.bal +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -// -// WSO2 Inc. licenses this file to you under the Apache License, -// Version 2.0 (the "License"); you may not use this file except -// in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -client "https://postman-echo.com/get?name=projectapiclientplugin" as foo; - -public function testModuleClientDecl() returns string { - foo:ClientConfiguration config = {specVersion : "3.0.0"}; - foo:client cl = new (config); - return cl->getSpecVersion(); -} diff --git a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_2/Ballerina.toml b/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_2/Ballerina.toml deleted file mode 100644 index 701e80af302e..000000000000 --- a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_2/Ballerina.toml +++ /dev/null @@ -1,7 +0,0 @@ -[package] -org = "user" -name = "package_test_idl_plugin_2" -version = "0.1.0" - -[build-options] -observabilityIncluded = false diff --git a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_2/idl-dependency-bala/user-package_test_idl_plugin-any-0.1.0.bala b/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_2/idl-dependency-bala/user-package_test_idl_plugin-any-0.1.0.bala deleted file mode 100644 index f66ae06c5fe0a17ffbc5b93afdd06b3a85cbef05..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2323 zcmWIWW@Zs#;Nak3m?>f#%76qof$XHjoJ75>;{3eT&w>I1yu8kM_UL=-YMncCK6q15 zfYBx63&sJL7`>;aJ)3ewJ+!IiaP!~ZDLb+l1H9Qej7rU4>jTX&2I2smwm1Q0bMsS5 zb5e`-3lfvF6Vp@UOHzwV;xkin;tO(0(=+q*l5;Xs^GXcO%uI|eEsYE;%}p%zLDCR$ zJ)k3V`yBb23Hd`(a+Obr|0Ee-CV(rvde$Yoc>)u>-{W| z6WLA~ri$L#6$=Wt&7F|AVMWi|hp`S7emWmH@|;SYUmx15SraT0JZXaQF5x$hu7N+S zowno-S9bB91 zvNJCulGP#Ybl%XBp$S(4X# z0=MW+oA_v>ivPQrW|5Pg|FK@Y&1=%PCxY8fEe_LFlz8LY?w5b!)c7WPLLE@pA@0 zpBEnf-CU_tA7uwly~-+g`s(+ihq?NX7Db*3e;V6*RA}?jKiguac3Xzu4>&Vl>9f1# z{=E!^2{v7EYr54UR(2(RYHRFzAJKHYINH3ZddvMZiP5JGw zBA>M7AM;}sOp;yszw-1XmrpLT6OO&HZO`xJw_d34ndf`#^;v1I_$@as_Le>~KdG?B zsvzgKsn>FW8pEEQenPj`T2@_|JFQTK>F0;bIlHE%F+ZG^VlDM~o73}%gq|s;`_&$_ zTgS)-7%$GgT9P;6?040$9S5_&)b838?qQ!gIcL(o*#D{Wy(gv}oK^Mj7~88K4Hi64 zFP}c2v*Ona)1(8@pZGv&Z@1uoKQ$%>hI!2R(jE^m?Ll)SxCkiix8(=sv9|I$*2J)& zRg-7Wo-AQlXwWvNVA8Q~x3(PpA^3my6ss2xD$f5dEI+T}Yn*GX@R32^B(>Y*wd}1N zArYq5Mu`l)3yE(p{*2nP$!ybm7T3$7Yk#Xm#y!yq+9R3!mx2HAlz;0bt~{2oXq=M4 z>i9SGgr)YU$aBlCR_$CF_Ec{gcdCk(iv2wsmK9gcetZu-x!9Gdv^L@ekD2|{p3iS> zX7#YtUkhX9E9t+mn9Ihdj_svEt`qV@--_6w0@u0w86|RI@x*sB?;%0EDu561=5f2a{tTU;`?}!jz>kl#6Iz5 zp9Kz?o{ita(EI*H;(3nJ!+CSPM8l5svbFw=oU(;wx!-jo=36OqI@gH#9()>gqv_I~ zN$bpb7AeHYE?#lv&WCHJRY40AH%eSlkUTM`-{Iw>DWcg&RQRIuzaP9870)u`pg)I^ z-Jg}g6S(;oEB)$Nk8vWY#?!g>>#t_hen>Rp3`7UV89pNZ_h9Vrw59 zD%l$Nh4of}YHqoNi=#)?s+(u^>mD(kGYUU^cv=7JUnN^$xnJ$axJ^h9ChJ)Di_U@Cy diff --git a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_2/main.bal b/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_2/main.bal deleted file mode 100644 index dd2257a865ad..000000000000 --- a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_2/main.bal +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -// -// WSO2 Inc. licenses this file to you under the Apache License, -// Version 2.0 (the "License"); you may not use this file except -// in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -import user/package_test_idl_plugin as foo; - -function testModuleClientDecl() returns string { - return foo:testModuleClientDecl(); -} diff --git a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_3/Ballerina.toml b/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_3/Ballerina.toml deleted file mode 100644 index 7e9365f15757..000000000000 --- a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_3/Ballerina.toml +++ /dev/null @@ -1,7 +0,0 @@ -[package] -org = "user" -name = "package_test_idl_plugin" -version = "0.1.0" - -[build-options] -observabilityIncluded = false diff --git a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_3/main.bal b/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_3/main.bal deleted file mode 100644 index 90a8fd0dc421..000000000000 --- a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_3/main.bal +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -// -// WSO2 Inc. licenses this file to you under the Apache License, -// Version 2.0 (the "License"); you may not use this file except -// in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -client "https://postman-echo.com/get?name=projectapiclientplugin" as foo; - -public function testModuleClientDecl() returns string { - foo:ClientConfiguration config = {specVersion : "3.0.0"}; - foo:client cl = new (config); - return cl->getSpecVersion(); -} diff --git a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_for_edits/Ballerina.toml b/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_for_edits/Ballerina.toml deleted file mode 100644 index 7e9365f15757..000000000000 --- a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_for_edits/Ballerina.toml +++ /dev/null @@ -1,7 +0,0 @@ -[package] -org = "user" -name = "package_test_idl_plugin" -version = "0.1.0" - -[build-options] -observabilityIncluded = false diff --git a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_for_edits/main.bal b/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_for_edits/main.bal deleted file mode 100644 index 90a8fd0dc421..000000000000 --- a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_for_edits/main.bal +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -// -// WSO2 Inc. licenses this file to you under the Apache License, -// Version 2.0 (the "License"); you may not use this file except -// in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -client "https://postman-echo.com/get?name=projectapiclientplugin" as foo; - -public function testModuleClientDecl() returns string { - foo:ClientConfiguration config = {specVersion : "3.0.0"}; - foo:client cl = new (config); - return cl->getSpecVersion(); -} diff --git a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_local_test/Ballerina.toml b/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_local_test/Ballerina.toml deleted file mode 100644 index 7e9365f15757..000000000000 --- a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_local_test/Ballerina.toml +++ /dev/null @@ -1,7 +0,0 @@ -[package] -org = "user" -name = "package_test_idl_plugin" -version = "0.1.0" - -[build-options] -observabilityIncluded = false diff --git a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_local_test/main.bal b/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_local_test/main.bal deleted file mode 100644 index e4d538c23efd..000000000000 --- a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_local_test/main.bal +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -// -// WSO2 Inc. licenses this file to you under the Apache License, -// Version 2.0 (the "License"); you may not use this file except -// in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -import package_test_idl_plugin.mod1 as mod1; - -public function main() { - _ = mod1:testModuleClientDecl(); -} - -client "<>" as foo; -//client "<>" as bar; -client "./projectapiclientplugin.json" as baz; - -function testModuleClientDecl() returns string { - foo:ClientConfiguration config = {specVersion : "3.0.0"}; - foo:client cl = new (config); - return cl->getSpecVersion(); -} - -//function testModuleClientDecl1() returns string { -// bar:ClientConfiguration config = {specVersion : "3.0.0"}; -// bar:client cl = new (config); -// return cl->getSpecVersion(); -//} - -function testModuleClientDecl2() returns string { - baz:ClientConfiguration config = {specVersion : "3.0.0"}; - baz:client cl = new (config); - return cl->getSpecVersion(); -} diff --git a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_local_test/modules/mod1/Module.md b/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_local_test/modules/mod1/Module.md deleted file mode 100644 index 8a69f51930aa..000000000000 --- a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_local_test/modules/mod1/Module.md +++ /dev/null @@ -1,6 +0,0 @@ -Prints "Hello, World!" with a main function. -[//]: # (above is the module summary) - -# Module Overview -Provides an overview about the module when generating the API documentations. -For example, refer to https://lib.ballerina.io/ballerina/io/latest diff --git a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_local_test/modules/mod1/mod1.bal b/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_local_test/modules/mod1/mod1.bal deleted file mode 100644 index b3a79b5c6a9b..000000000000 --- a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_local_test/modules/mod1/mod1.bal +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -// -// WSO2 Inc. licenses this file to you under the Apache License, -// Version 2.0 (the "License"); you may not use this file except -// in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -client "./../../projectapiclientplugin.json" as foo; - -public function testModuleClientDecl() returns string { - foo:ClientConfiguration config = {specVersion : "3.0.0"}; - foo:client cl = new (config); - return cl->getSpecVersion(); -} diff --git a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_local_test/projectapiclientplugin.json b/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_local_test/projectapiclientplugin.json deleted file mode 100644 index 34c2ba607f28..000000000000 --- a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_local_test/projectapiclientplugin.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "args": { - "name": "projectapiclientplugin" - }, - "headers": { - "x-forwarded-proto": "https", - "x-forwarded-port": "443" - }, - "url": "/home/anjana/compiler_plugin_tests/package_test_idl_plugin_local/projectapiclientplugin.json" -} diff --git a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_negative/Ballerina.toml b/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_negative/Ballerina.toml deleted file mode 100644 index 3f317e3b84b7..000000000000 --- a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_negative/Ballerina.toml +++ /dev/null @@ -1,7 +0,0 @@ -[package] -org = "user" -name = "package_test_idl_plugin_neg" -version = "0.1.0" - -[build-options] -observabilityIncluded = false diff --git a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_negative/exception.bal b/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_negative/exception.bal deleted file mode 100644 index bc7f25401d16..000000000000 --- a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_negative/exception.bal +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -// -// WSO2 Inc. licenses this file to you under the Apache License, -// Version 2.0 (the "License"); you may not use this file except -// in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -client "https://postman-echo.com/get?name=projectapiclientplugin_throwNPE" as bar1; - -client "https://postman-echo.com/get?name=projectapiclientplugin_throwUnhandledExInPerform" as bar2; - -public function testSameClientUri() { - client "https://postman-echo.com/get?name=projectapiclientplugin_throwRuntimeEx" as bar3; -} - diff --git a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_negative/main.bal b/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_negative/main.bal deleted file mode 100644 index 90a8fd0dc421..000000000000 --- a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_negative/main.bal +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -// -// WSO2 Inc. licenses this file to you under the Apache License, -// Version 2.0 (the "License"); you may not use this file except -// in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -client "https://postman-echo.com/get?name=projectapiclientplugin" as foo; - -public function testModuleClientDecl() returns string { - foo:ClientConfiguration config = {specVersion : "3.0.0"}; - foo:client cl = new (config); - return cl->getSpecVersion(); -} diff --git a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_repeat_client_url/Ballerina.toml b/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_repeat_client_url/Ballerina.toml deleted file mode 100644 index 7e9365f15757..000000000000 --- a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_repeat_client_url/Ballerina.toml +++ /dev/null @@ -1,7 +0,0 @@ -[package] -org = "user" -name = "package_test_idl_plugin" -version = "0.1.0" - -[build-options] -observabilityIncluded = false diff --git a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_repeat_client_url/main.bal b/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_repeat_client_url/main.bal deleted file mode 100644 index 9fc20ee51599..000000000000 --- a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/idl_plugin_packages/package_test_idl_plugin_repeat_client_url/main.bal +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -// -// WSO2 Inc. licenses this file to you under the Apache License, -// Version 2.0 (the "License"); you may not use this file except -// in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -client "https://postman-echo.com/get?name=projectapiclientplugin" as foo; - -public function testModuleClientDecl() returns string { - foo:ClientConfiguration config = {specVersion : "3.0.0"}; - foo:client cl = new (config); - return cl->getSpecVersion(); -} - -public function testSameClientUri() { - client "https://postman-echo.com/get?name=projectapiclientplugin" as bar; -} diff --git a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetest/Ballerina.toml b/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetest/Ballerina.toml deleted file mode 100644 index ffb6fd03cfc3..000000000000 --- a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetest/Ballerina.toml +++ /dev/null @@ -1,4 +0,0 @@ -[package] -org = "idl_clients" -name = "simpleclientnegative" -version = "0.1.0" diff --git a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetest/main.bal b/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetest/main.bal deleted file mode 100644 index 791615318358..000000000000 --- a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetest/main.bal +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -// -// WSO2 Inc. licenses this file to you under the Apache License, -// Version 2.0 (the "License"); you may not use this file except -// in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -client "https://postman-echo.com/get?name=simpleclienttest.yaml" as foo; - -foo:Config config = 1; -foo:Client cl; - -function testModuleClientDeclNegative() { - foo:ClientConfig config = 1; - foo:Client cl; -} - -function testClientDeclStmtNegative1() { - client "https://postman-echo.com/get?name=simpleclienttest.yaml" as bar; - bar:ClientConfiguratin config; - bar:clients cl; -} - -function testClientDeclStmtNegative2() { - client "https://postman-echo.com/get?name=simpleclienttest.yaml" as bar; - client "https://postman-echo.com/get?name=simpleclienttest2.yaml" as baz; - baz:ClientConfiguration c1; - bar:Config c2; -} - -client "https://postman-echo.com/get?name=simpleclienttest-disallow.yaml" as qux; - -function testClientDeclStmtWithNoGeneratedModuleNegative() { - client "https://postman-echo.com/get?name=simpleclienttest-disallow2.yaml" as bar; -} diff --git a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestfive/Ballerina.toml b/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestfive/Ballerina.toml deleted file mode 100644 index 41cdc9747dae..000000000000 --- a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestfive/Ballerina.toml +++ /dev/null @@ -1,4 +0,0 @@ -[package] -org = "idl_clients" -name = "simpleclientnegativefive" -version = "0.1.0" diff --git a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestfive/main.bal b/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestfive/main.bal deleted file mode 100644 index e1fca55f75ef..000000000000 --- a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestfive/main.bal +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -// -// WSO2 Inc. licenses this file to you under the Apache License, -// Version 2.0 (the "License"); you may not use this file except -// in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -import simpleclientnegativefive.client1; -import simpleclientnegativefive.client1 as bar; - -client "https://postman-echo.com/get?name=simpleclienttest.yaml" as foo; - -function testModuleClientDecl() { - foo:ClientConfiguration _ = {'limit: 5}; - client1:ClientConfiguration _ = {'limit: 5}; - bar:ClientConfiguration _ = {'limit: 5}; -} diff --git a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestfour/Ballerina.toml b/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestfour/Ballerina.toml deleted file mode 100644 index 13aa29851d85..000000000000 --- a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestfour/Ballerina.toml +++ /dev/null @@ -1,4 +0,0 @@ -[package] -org = "idl_clients" -name = "simpleclientnegativefour" -version = "0.1.0" diff --git a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestfour/main.bal b/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestfour/main.bal deleted file mode 100644 index 4af5fa095946..000000000000 --- a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestfour/main.bal +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -// -// WSO2 Inc. licenses this file to you under the Apache License, -// Version 2.0 (the "License"); you may not use this file except -// in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -client "https://postman-echo.com/get?name=simpleclienttest-invalidgeneratedcode-one.yaml" as foo; -foo:MyClientClass a = new; - -client "https://postman-echo.com/get?name=simpleclienttest-invalidgeneratedcode-two.yaml" as bar; -bar:'client b = new; - -function fn() { - client "https://postman-echo.com/get?name=simpleclienttest-invalidgeneratedcode-three.yaml" as baz; - baz:'client? _ = (); - - client "https://postman-echo.com/get?name=simpleclienttest-invalidgeneratedcode-four.yaml" as qux; - qux:client _ = new; -} diff --git a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestsix/Ballerina.toml b/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestsix/Ballerina.toml deleted file mode 100644 index c195237d46db..000000000000 --- a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestsix/Ballerina.toml +++ /dev/null @@ -1,4 +0,0 @@ -[package] -org = "idl_clients" -name = "simpleclientnegativesix" -version = "0.1.0" diff --git a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestsix/main.bal b/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestsix/main.bal deleted file mode 100644 index e4438169b938..000000000000 --- a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestsix/main.bal +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -// -// WSO2 Inc. licenses this file to you under the Apache License, -// Version 2.0 (the "License"); you may not use this file except -// in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -import simpleclientnegativesix.foo; - -client "https://postman-echo.com/get?name=simpleclienttest.yaml" as bar; - -foo:client a = new; // error -bar:client b = new ({'limit: 5}); // OK - -function testUnquotedClientKeywordUsage() { - foo:client _ = new; // error - foo:client[] _ = [new foo:client()]; // error - bar:client _ = new ({'limit: 5}); // OK - bar:client[] _ = [new bar:client({'limit: 5})]; // OK - - xmlns "xmlns" as baz; - _ = baz:client; // error -} diff --git a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestsix/modules/foo/foo.bal b/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestsix/modules/foo/foo.bal deleted file mode 100644 index 5e12181201d0..000000000000 --- a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestsix/modules/foo/foo.bal +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -// -// WSO2 Inc. licenses this file to you under the Apache License, -// Version 2.0 (the "License"); you may not use this file except -// in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -public client class 'client { - public int i = 1; -} diff --git a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestsix/oth.bal b/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestsix/oth.bal deleted file mode 100644 index 756392c41b77..000000000000 --- a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestsix/oth.bal +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -// -// WSO2 Inc. licenses this file to you under the Apache License, -// Version 2.0 (the "License"); you may not use this file except -// in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -import simpleclientnegativesix.foo; - -function testUnquotedClientKeywordUsageInDifferentFile() { - foo:client _ = new; // error - _ = foo:client; // error - bar:client _ = new ({'limit: 5}); // OK - _ = bar:client; // OK -} diff --git a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestthree/Ballerina.toml b/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestthree/Ballerina.toml deleted file mode 100644 index bf0f957adb29..000000000000 --- a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestthree/Ballerina.toml +++ /dev/null @@ -1,4 +0,0 @@ -[package] -org = "idl_clients" -name = "simpleclientnegativethree" -version = "0.1.0" diff --git a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestthree/main.bal b/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestthree/main.bal deleted file mode 100644 index 0d74c0d47eaf..000000000000 --- a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetestthree/main.bal +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -// -// WSO2 Inc. licenses this file to you under the Apache License, -// Version 2.0 (the "License"); you may not use this file except -// in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -client "https://postman-echo.com/get?name=simpleclienttest.yaml" as foo; - -const foo:IntMap C1 = {a: 1}; // OK -public const foo:IntMap C2 = {a: 1}; // error - -foo:IntMap v1 = {a: 1}; // OK -public foo:IntMap v2 = {a: 1}; // error - -public function main() { - foo:ClientConfiguration x; // OK -} - -class Class1 { // OK - foo:IntMap a; - - function init(foo:IntMap a) { - self.a = a; - } -} - -public class Class2 { // error - foo:IntMap a; - - function init(foo:IntMap a) { - self.a = a; - } -} - -public class Class3 { // error - public function fn() returns foo:ClientConfiguration => {'limit: 5}; // error -} - -function fn(foo:ClientConfiguration x, foo:ClientConfiguration y = {'limit: 5}, foo:ClientConfiguration... z) returns foo:ClientConfiguration => x; // OK - -public function fn2(foo:ClientConfiguration x, foo:ClientConfiguration y = {'limit: 5}, foo:ClientConfiguration... z) returns foo:ClientConfiguration => x; // errors - -foo:IntMap[] v3 = []; // OK -public foo:IntMap[] v4 = []; // error - -error v5 = error("e1"); // OK -public error v6 = error("e2"); // error - -function (foo:IntMap) v7 = function (foo:IntMap a) { // OK - -}; - -public function (foo:IntMap) v8 = function (foo:IntMap a) { // error - -}; - -function (foo:IntMap a, foo:IntMap b = {}, foo:IntMap... c) returns foo:IntMap v9 = // OK -function (foo:IntMap a, foo:IntMap b = {}, foo:IntMap... c) returns foo:IntMap { - return a; -}; - -public function (foo:IntMap a, foo:IntMap b = {}, foo:IntMap... c) returns foo:IntMap v10 = // error -function (foo:IntMap a, foo:IntMap b = {}, foo:IntMap... c) returns foo:IntMap { - return a; -}; - -map v11 = {}; // OK -public map v12 = {}; // error - -stream v31 = new; // OK -public stream v32 = new; // error - -stream?> v13 = new; // OK -public stream?> v14 = new; // error - -typedesc v15 = foo:IntMap; // OK -public typedesc v16 = foo:IntMap; // error - -type T1 foo:IntMap; // OK -public type T2 foo:IntMap; // error - -[foo:IntMap] v17 = [{}]; // OK -public [foo:IntMap] v18 = [{}]; // error - -[foo:IntMap, foo:IntMap...] v19 = [{}]; // OK -public [foo:IntMap, foo:IntMap...] v20 = [{}]; // error - -foo:IntMap|int v21 = 1; // OK -public foo:IntMap|int v22 = 1; // error - -foo:IntMap & readonly v23 = {}; // OK -public foo:IntMap & readonly v24 = {}; // error - -xml v25 = xml ``; // OK -public xml v26 = xml ``; // error - -table v27 = table []; // OK -public table v28 = table []; // error - -type T3 record {| // OK - foo:IntMap a; -|}; - -public type T4 record {| // error - foo:IntMap a; - int b; -|}; - -type T5 object { // OK - foo:IntMap a; -}; - -public type T6 object { // error - foo:IntMap a; -}; - -public type T7 object { // error - public function fn() returns foo:ClientConfiguration; -}; - -function testFn() returns future { - function () returns foo:IntMap f = () => {}; - future ft = start f(); - return ft; -} - -future v29 = testFn(); // OK -public future v30 = testFn(); // error - -type T8 foo:IntMap|map; // OK -public type T9 foo:IntMap|map; // error - -public function testFn2() returns T8 { // error - return {a: 1}; -} - -never|foo:IntMap v33 = {}; // OK -public never|foo:IntMap v34 = {}; // error diff --git a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetesttwo/Ballerina.toml b/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetesttwo/Ballerina.toml deleted file mode 100644 index a10ede7d0b76..000000000000 --- a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetesttwo/Ballerina.toml +++ /dev/null @@ -1,4 +0,0 @@ -[package] -org = "idl_clients" -name = "simpleclientnegativetwo" -version = "0.1.0" diff --git a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetesttwo/unused_prefix.bal b/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetesttwo/unused_prefix.bal deleted file mode 100644 index ec8e11eaf89f..000000000000 --- a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclientnegativetesttwo/unused_prefix.bal +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -// -// WSO2 Inc. licenses this file to you under the Apache License, -// Version 2.0 (the "License"); you may not use this file except -// in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -client "https://postman-echo.com/get?name=simpleclienttest.yaml" as foo; - -function testUnusedClientDeclStmtPrefix(boolean b) { - client "https://postman-echo.com/get?name=simpleclienttest2.yaml" as bar; - - if b { - client "https://postman-echo.com/get?name=simpleclienttest3.yaml" as baz; - } -} - -client "https://postman-echo.com/get?name=simpleclienttest4.yaml" as p1; - -// should result in an error even though p1 is the same module and is used -client "https://postman-echo.com/get?name=simpleclienttest4.yaml" as p2; - -public function useModuleClientDeclPrefix() { - p1:Config _ = {url: ""}; -} - -public function testUnusedModuleClientDeclPrefixWithSameGeneratedModule() { - // should result in an error even though the module-level p1 is used and is the same module - client "https://postman-echo.com/get?name=simpleclienttest4.yaml" as p1; - - client "https://postman-echo.com/get?name=simpleclienttest4.yaml" as p3; -} - -client "https://postman-echo.com/get?name=simpleclienttest5.yaml" as p4; - -client "https://postman-echo.com/get?name=simpleclienttest5.yaml" as p5; diff --git a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclienttest/Ballerina.toml b/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclienttest/Ballerina.toml deleted file mode 100644 index 8b284275d98a..000000000000 --- a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclienttest/Ballerina.toml +++ /dev/null @@ -1,4 +0,0 @@ -[package] -org = "idl_clients" -name = "simpleclient" -version = "0.1.0" diff --git a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclienttest/main.bal b/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclienttest/main.bal deleted file mode 100644 index 2ba7c341d3fe..000000000000 --- a/project-api/project-api-test/src/test/resources/idl_client_compiler_tests/simpleclienttest/main.bal +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -// -// WSO2 Inc. licenses this file to you under the Apache License, -// Version 2.0 (the "License"); you may not use this file except -// in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -client "https://postman-echo.com/get?name=simpleclienttest.yaml" as foo; - -function testModuleClientDecl() { - foo:ClientConfiguration config = {'limit: 5}; - foo:client cl = new (config); - int 'limit = cl->getLimit(); - assertEquals(5, 'limit); - cl->setLimit(10);'limit = cl->getLimit(); - assertEquals(10, 'limit); -} - -function testClientDeclStmt() { - client "https://postman-echo.com/get?name=simpleclienttest.yaml" as bar; - bar:ClientConfiguration config = {'limit: 5}; - bar:client cl = new (config); - int 'limit = cl->getLimit(); - assertEquals(5, 'limit); - cl->setLimit(10);'limit = cl->getLimit(); - assertEquals(10, 'limit); - - client "https://postman-echo.com/get?name=simpleclienttest2.yaml" as baz; - baz:Config config2 = {url: "http://www.example.com"}; - baz:client cl2 = new (config2); - string url = cl2->getUrl(); - assertEquals("http://www.example.com", url); -} - -public const annotation record { int i; }[] ClientAnnot on source client; - -@ClientAnnot { - i: 123 -} -client "https://postman-echo.com/get?name=simpleclienttest.yaml" as bar; - -bar:ClientConfiguration clientConfig = {'limit: 15}; - -function testClientDeclAnnotSymbols() { - @ClientAnnot { - i: 12 - } - @ClientAnnot { - i: 13 - } - client "https://postman-echo.com/get?name=simpleclienttest2.yaml" as qux; - qux:Config _ = {url: "http://www.example.com/one"}; - - client "https://postman-echo.com/get?name=simpleclienttest3.yaml" as quux; - quux:Config _ = {url: "http://www.example.com/two"}; -} - -function testClientDeclScoping1() { - client "https://postman-echo.com/get?name=simpleclienttest2.yaml" as foo; // OK, shadows the module-level prefix - foo:Config config2 = {url: "http://www.examples.com"}; - foo:client cl2 = new (config2); - string url = cl2->getUrl(); - assertEquals("http://www.examples.com", url); -} - -function testClientDeclScoping2(boolean b) { // no assertion, validates absence of errors - if b { - client "https://postman-echo.com/get?name=simpleclienttest.yaml" as bar; // OK, different scope - bar:ClientConfiguration _ = {'limit: 5}; - } else { - client "https://postman-echo.com/get?name=simpleclienttest2.yaml" as bar; // OK, different scope - bar:Config _ = {url: "http://www.examples.com"}; - } - - if !b { - client "https://postman-echo.com/get?name=simpleclienttest2.yaml" as bar; // OK, different scope - bar:Config _ = {url: "http://www.examples.com"}; - return; - } - client "https://postman-echo.com/get?name=simpleclienttest.yaml" as bar; // OK, different scope - bar:ClientConfiguration _ = {'limit: 5}; -} - -function testClientDeclModuleWithClientObjectType() { - client "https://postman-echo.com/get?name=simpleclienttest-clientobjecttype.yaml" as foo2; // OK, shadows the module-level prefix - foo2:client cl = foo2:fn(); - int index = cl->getIndex(); - assertEquals(10, index); -} - -function assertEquals(anydata expected, anydata actual) { - if expected == actual { - return; - } - - panic error(string `expected ${expected.toBalString()}, found ${actual.toBalString()}`); -} From e58043dd5617625bb3eec47a36e425024fd06a7a Mon Sep 17 00:00:00 2001 From: azinneera Date: Fri, 11 Nov 2022 18:20:45 +0530 Subject: [PATCH 065/450] Remove unused variable and fix typos --- .../src/main/java/io/ballerina/projects/PackageResolution.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/PackageResolution.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/PackageResolution.java index 942b23f38fae..5e398bd281bc 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/PackageResolution.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/PackageResolution.java @@ -81,13 +81,11 @@ public class PackageResolution { private List topologicallySortedModuleList; private Collection dependenciesWithTransitives; - private final List generatedModules; private PackageResolution(PackageContext rootPackageContext, CompilationOptions compilationOptions) { this.rootPackageContext = rootPackageContext; this.diagnosticList = new ArrayList<>(); this.compilationOptions = compilationOptions; - this.generatedModules = new ArrayList<>(); ResolutionOptions resolutionOptions = getResolutionOptions(rootPackageContext, compilationOptions); ProjectEnvironment projectEnvContext = rootPackageContext.project().projectEnvironmentContext(); this.packageResolver = projectEnvContext.getService(PackageResolver.class); From fd3daaffbe2986b3145a0d74b1bd161fd3be5876 Mon Sep 17 00:00:00 2001 From: azinneera Date: Sat, 12 Nov 2022 01:37:26 +0530 Subject: [PATCH 066/450] Remove failing parser idl client test --- .../test/symbols/ClientDeclSymbolTest.java | 107 ------------------ .../src/test/resources/testng.xml | 1 - 2 files changed, 108 deletions(-) delete mode 100644 tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/symbols/ClientDeclSymbolTest.java diff --git a/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/symbols/ClientDeclSymbolTest.java b/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/symbols/ClientDeclSymbolTest.java deleted file mode 100644 index 995db14a46e6..000000000000 --- a/tests/ballerina-compiler-api-test/src/test/java/io/ballerina/semantic/api/test/symbols/ClientDeclSymbolTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.semantic.api.test.symbols; - -import io.ballerina.compiler.api.ModuleID; -import io.ballerina.compiler.api.SemanticModel; -import io.ballerina.compiler.api.symbols.AnnotationSymbol; -import io.ballerina.compiler.api.symbols.ClientDeclSymbol; -import io.ballerina.compiler.api.symbols.SymbolKind; -import io.ballerina.compiler.api.symbols.TypeDescKind; -import io.ballerina.compiler.api.symbols.TypeSymbol; -import io.ballerina.projects.Document; -import io.ballerina.projects.Project; -import org.ballerinalang.test.BCompileUtil; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -import java.util.Optional; - -import static io.ballerina.semantic.api.test.util.SemanticAPITestUtils.assertBasicsAndGetSymbol; -import static io.ballerina.semantic.api.test.util.SemanticAPITestUtils.getDefaultModulesSemanticModel; -import static io.ballerina.semantic.api.test.util.SemanticAPITestUtils.getDocumentForSingleSource; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -/** - * Test cases for client declaration symbols. - * - * @since 2201.3.0 - */ -public class ClientDeclSymbolTest { - - private SemanticModel model; - private Document srcFile; - - @BeforeClass - public void setup() { - Project project = BCompileUtil.loadProject("test-src/symbols/client_decl_proj"); - // Generate IDL to access the module associated with client-decl - project.currentPackage().runIDLGeneratorPlugins(); - model = getDefaultModulesSemanticModel(project); - srcFile = getDocumentForSingleSource(project); - } - - @Test(dataProvider = "ClientDeclarationSymbolInfoProvider") - public void testClientDeclarations(int line, int col, String modPrefix, String serviceUri) { - ClientDeclSymbol symbol = (ClientDeclSymbol) assertBasicsAndGetSymbol(model, srcFile, line, col, - modPrefix, SymbolKind.CLIENT_DECLARATION); - assertEquals(symbol.serviceUri(), serviceUri); - ModuleID id = symbol.moduleSymbol().id(); - assertEquals(id.orgName(), "testorg"); - assertEquals(id.packageName(), "clientdecl"); - if (serviceUri.endsWith("projectapiclientplugin")) { - assertEquals(id.moduleName(), "clientdecl.myapi"); - } else { - assertEquals(id.moduleName(), "clientdecl.client1"); - } - - // Annotations - assertEquals(symbol.annotations().size(), 1); - AnnotationSymbol annotSymbol = symbol.annotations().get(0); - assertTrue(annotSymbol.getName().isPresent()); - assertEquals(annotSymbol.getName().get(), "ClientAnnot"); - Optional typeSymbol = annotSymbol.typeDescriptor(); - assertTrue(typeSymbol.isPresent()); - assertEquals(typeSymbol.get().typeKind(), TypeDescKind.ARRAY); - } - - @DataProvider(name = "ClientDeclarationSymbolInfoProvider") - public Object[][] getClientDeclInfo() { - return new Object[][]{ - {19, 69, "myapi", "https://postman-echo.com/get?name=projectapiclientplugin"}, - {29, 67, "bar", "https://postman-echo.com/get?name=simpleclienttest"}, - }; - } - - // TODO: Add test with constant references -// @Test(dataProvider = "ClientDeclarationWithConstRefProvider") -// public void testConstRef(int line, int col, String expName) { -// ConstantSymbol symbol = (ConstantSymbol) assertBasicsAndGetSymbol(model, srcFile, line, col, expName, -// SymbolKind.CONSTANT); -// assertEquals(symbol.typeDescriptor().typeKind(), TypeDescKind.SINGLETON); -// } -// -// @DataProvider(name = "ClientDeclarationWithConstRefProvider") -// public Object[][] getConstRefInfo() { -// return new Object[][]{ -// }; -// } -} diff --git a/tests/ballerina-compiler-api-test/src/test/resources/testng.xml b/tests/ballerina-compiler-api-test/src/test/resources/testng.xml index b6c66e4ed69a..a29af2470604 100644 --- a/tests/ballerina-compiler-api-test/src/test/resources/testng.xml +++ b/tests/ballerina-compiler-api-test/src/test/resources/testng.xml @@ -139,7 +139,6 @@ - From ea01d78d0224596cfe41e629ad701af678990a26 Mon Sep 17 00:00:00 2001 From: azinneera Date: Sat, 12 Nov 2022 13:54:34 +0530 Subject: [PATCH 067/450] Remove invalid client tests --- .../workspace/BallerinaWorkspaceManager.java | 5 +- .../declarations/ClientDeclarationTest.java | 96 ------------------- 2 files changed, 3 insertions(+), 98 deletions(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/workspace/BallerinaWorkspaceManager.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/workspace/BallerinaWorkspaceManager.java index c22a41e39155..10e0ca5b0353 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/workspace/BallerinaWorkspaceManager.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/workspace/BallerinaWorkspaceManager.java @@ -69,8 +69,6 @@ import org.eclipse.lsp4j.TextDocumentIdentifier; import org.eclipse.lsp4j.jsonrpc.CancelChecker; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -88,6 +86,9 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + import static io.ballerina.projects.util.ProjectConstants.BALLERINA_TOML; /** diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/module/declarations/ClientDeclarationTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/module/declarations/ClientDeclarationTest.java index 5802ae25687c..ae019fee527c 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/module/declarations/ClientDeclarationTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/module/declarations/ClientDeclarationTest.java @@ -37,63 +37,6 @@ public class ClientDeclarationTest { private static final String REDECLARED_PREFIX_ERROR = "redeclared symbol '%s'"; - private static final String NO_MODULE_GENERATED_ERROR = "no module generated for the client declaration"; - private static final String NOT_SUPPORTED_IN_SINGLE_FILE_ERROR = - "client declaration is not supported with standalone Ballerina file"; - - @Test - public void testInvalidRedeclaredPrefixNegative() { - CompileResult result = BCompileUtil.compile( - "test-src/module.declarations/client-decl/client_decl_redeclared_prefix_negative_test.bal"); - int index = 0; - BAssertUtil.validateError(result, index++, NOT_SUPPORTED_IN_SINGLE_FILE_ERROR, 21, 1); - BAssertUtil.validateError(result, index++, NOT_SUPPORTED_IN_SINGLE_FILE_ERROR, 23, 1); - BAssertUtil.validateError(result, index++, NOT_SUPPORTED_IN_SINGLE_FILE_ERROR, 24, 1); - BAssertUtil.validateError(result, index++, NOT_SUPPORTED_IN_SINGLE_FILE_ERROR, 26, 1); - BAssertUtil.validateError(result, index++, NOT_SUPPORTED_IN_SINGLE_FILE_ERROR, 29, 1); - BAssertUtil.validateError(result, index++, NOT_SUPPORTED_IN_SINGLE_FILE_ERROR, 30, 1); - BAssertUtil.validateError(result, index++, NOT_SUPPORTED_IN_SINGLE_FILE_ERROR, 33, 1); - BAssertUtil.validateError(result, index++, NOT_SUPPORTED_IN_SINGLE_FILE_ERROR, 34, 1); - BAssertUtil.validateError(result, index++, NOT_SUPPORTED_IN_SINGLE_FILE_ERROR, 37, 1); - - BAssertUtil.validateError(result, index++, NO_MODULE_GENERATED_ERROR, 21, 1); - BAssertUtil.validateError(result, index++, getRedeclaredSymbolError("foo"), 21, 50); - BAssertUtil.validateError(result, index++, NO_MODULE_GENERATED_ERROR, 23, 1); - BAssertUtil.validateError(result, index++, getRedeclaredSymbolError("bar"), 23, 50); - BAssertUtil.validateError(result, index++, NO_MODULE_GENERATED_ERROR, 24, 1); - BAssertUtil.validateError(result, index++, getRedeclaredSymbolError("bar"), 24, 52); - BAssertUtil.validateError(result, index++, NO_MODULE_GENERATED_ERROR, 26, 1); - BAssertUtil.validateError(result, index++, getRedeclaredSymbolError("baz"), 26, 51); - BAssertUtil.validateError(result, index++, getRedeclaredSymbolError("baz"), 27, 1); - BAssertUtil.validateError(result, index++, NO_MODULE_GENERATED_ERROR, 29, 1); - BAssertUtil.validateError(result, index++, NO_MODULE_GENERATED_ERROR, 30, 1); - BAssertUtil.validateError(result, index++, getRedeclaredSymbolError("qux"), 30, 52); - BAssertUtil.validateError(result, index++, getRedeclaredSymbolError("qux"), 31, 31); - BAssertUtil.validateError(result, index++, NO_MODULE_GENERATED_ERROR, 33, 1); - BAssertUtil.validateError(result, index++, NO_MODULE_GENERATED_ERROR, 34, 1); - BAssertUtil.validateError(result, index++, getRedeclaredSymbolError("quux"), 34, 50); - // Symbols for module client declarations are defined at symbol enter because they are required to resolve - // constructs from the corresponding module, whereas for module XMLNS declarations symbols are defined at - // semantic analysis. Therefore, the error is always logged for the XMLNS declaration even though it is defined - // after the client declaration in the source. - BAssertUtil.validateError(result, index++, getRedeclaredSymbolError("corge"), 36, 31); - BAssertUtil.validateError(result, index++, NO_MODULE_GENERATED_ERROR, 37, 1); - Assert.assertEquals(result.getErrorCount(), index); - } - - @Test - public void testClientDeclPrefixAsXmlnsPrefixNegative() { - CompileResult result = BCompileUtil.compile( - "test-src/module.declarations/client-decl/client_decl_client_prefix_as_xmlns_prefix_negative_test.bal"); - int index = 0; - BAssertUtil.validateError(result, index++, NOT_SUPPORTED_IN_SINGLE_FILE_ERROR, 17, 1); - BAssertUtil.validateError(result, index++, NO_MODULE_GENERATED_ERROR, 17, 1); - BAssertUtil.validateError(result, index++, "cannot find xml namespace prefix 'foo'", 20, 19); - BAssertUtil.validateError(result, index++, "cannot find xml namespace prefix 'foo'", 21, 16); - BAssertUtil.validateError(result, index++, "cannot find xml namespace prefix 'foo'", 22, 24); - Assert.assertEquals(result.getErrorCount(), index); - } - @Test public void testUndefinedPrefixNegative() { CompileResult result = BCompileUtil.compile( @@ -103,17 +46,6 @@ public void testUndefinedPrefixNegative() { Assert.assertEquals(result.getErrorCount(), index); } - @Test - public void testUnderscoreAsPrefixNegative() { - CompileResult result = BCompileUtil.compile( - "test-src/module.declarations/client-decl/client_decl_underscore_as_prefix_negative_test.bal"); - int index = 0; - BAssertUtil.validateError(result, index++, NOT_SUPPORTED_IN_SINGLE_FILE_ERROR, 17, 1); - BAssertUtil.validateError(result, index++, NO_MODULE_GENERATED_ERROR, 17, 1); - BAssertUtil.validateError(result, index++, "'_' is a keyword, and may not be used as an identifier", 17, 50); - Assert.assertEquals(result.getErrorCount(), index); - } - @Test public void testClientDecl() { CompileResult result = BCompileUtil.compile( @@ -137,34 +69,6 @@ public void testClientDecl() { } } - @Test - public void testClientAnnotationsNegative() { - CompileResult result = BCompileUtil.compile( - "test-src/module.declarations/client-decl/client_decl_annotations_negative_test.bal"); - int index = 0; - BAssertUtil.validateError(result, index++, NOT_SUPPORTED_IN_SINGLE_FILE_ERROR, 48, 1); - BAssertUtil.validateError(result, index++, "annotation declaration with 'source' attach point(s) should be a " + - "'const' declaration", 19, 1); - BAssertUtil.validateError(result, index++, "missing source keyword", 19, 18); - BAssertUtil.validateError(result, index++, "annotation declaration with 'source' attach point(s) should be a " + - "'const' declaration", 21, 1); - BAssertUtil.validateError(result, index++, "missing source keyword", 23, 24); - BAssertUtil.validateError(result, index++, "invalid type 'map' for " + - "annotation with 'client' attachment point: expected a subtype of 'anydata'", 25, 18); - BAssertUtil.validateError(result, index++, "annotation 'A5' is not allowed on function", 33, 1); - BAssertUtil.validateError(result, index++, "annotation 'A6' is not allowed on function", 36, 1); - BAssertUtil.validateError(result, index++, "annotation 'A5' is not allowed on var", 42, 1); - BAssertUtil.validateError(result, index++, "annotation 'A6' is not allowed on var", 45, 1); - BAssertUtil.validateError(result, index++, "annotation 'A7' is not allowed on client", 48, 1); - BAssertUtil.validateError(result, index++, NO_MODULE_GENERATED_ERROR, 48, 1); - BAssertUtil.validateError(result, index++, "annotation value expected for annotation of record type 'record " + - "{| int i; |}' with required fields", 49, 1); - BAssertUtil.validateError(result, index++, "cannot specify more than one annotation value for annotation " + - "'A5'", 49, 1); - BAssertUtil.validateError(result, index++, "missing non-defaultable required record field 'i'", 50, 5); - Assert.assertEquals(result.getErrorCount(), index); - } - private String getRedeclaredSymbolError(String prefix) { return String.format(REDECLARED_PREFIX_ERROR, prefix); } From 21e6cf039ac8180cc0c9db62d4387982ce10db21 Mon Sep 17 00:00:00 2001 From: Thevakumar-Luheerathan Date: Mon, 21 Nov 2022 15:41:46 +0530 Subject: [PATCH 068/450] Fix reflection config --- .../io/ballerina/cli/utils/NativeUtils.java | 133 +++++++++--------- 1 file changed, 66 insertions(+), 67 deletions(-) diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java index 84cde675a65c..cfd44b5d8548 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java @@ -36,6 +36,7 @@ import java.util.Map; import static io.ballerina.identifier.Utils.encodeNonFunctionIdentifier; +import static io.ballerina.runtime.api.constants.RuntimeConstants.FILE_NAME_PERIOD_SEPARATOR; import static org.ballerinalang.test.runtime.util.TesterinaConstants.ANON_ORG; import static org.ballerinalang.test.runtime.util.TesterinaConstants.DOT; @@ -57,82 +58,80 @@ public static void createReflectConfig(Path nativeConfigPath, Package currentPac Gson gson = new GsonBuilder().setPrettyPrinting().create(); List classList = new ArrayList<>(); - int tally = 1; + for (Module module : currentPackage.modules()) { - String name = module.moduleName().toString(); - String moduleName = ProjectUtils.getJarFileName(module); - - ReflectConfigClass testInitRefConfClz = new ReflectConfigClass(getQualifiedClassName(org, name, version, - MODULE_INIT_CLASS_NAME)); - - testInitRefConfClz.addReflectConfigClassMethod( - new ReflectConfigClassMethod( - "$moduleInit", - new String[]{"io.ballerina.runtime.internal.scheduling.Strand"} - ) - ); - - testInitRefConfClz.addReflectConfigClassMethod( - new ReflectConfigClassMethod( - "$moduleStart", - new String[]{"io.ballerina.runtime.internal.scheduling.Strand"} - ) - ); - - testInitRefConfClz.addReflectConfigClassMethod( - new ReflectConfigClassMethod( - "$moduleStop", - new String[]{"io.ballerina.runtime.internal.scheduling.RuntimeRegistry"} - ) - ); - - ReflectConfigClass testConfigurationMapperRefConfClz = new ReflectConfigClass( - getQualifiedClassName(org, name, version, MODULE_CONFIGURATION_MAPPER)); - - testConfigurationMapperRefConfClz.addReflectConfigClassMethod( - new ReflectConfigClassMethod( - "$configureInit", - new String[]{"java.lang.String[]", "java.nio.file.Path[]", "java.lang.String"} - ) - ); - ReflectConfigClass testTestExecuteGeneratedRefConfClz = new ReflectConfigClass(""); - if (testSuiteMap.containsKey(moduleName)) { - testTestExecuteGeneratedRefConfClz = new ReflectConfigClass(testSuiteMap.get(moduleName) - .getTestUtilityFunctions().get("__execute__")); - testTestExecuteGeneratedRefConfClz.addReflectConfigClassMethod( + if (module.testDocumentIds().size() != 0) { + String name = module.moduleName().toString(); + String moduleName = ProjectUtils.getJarFileName(module); + + ReflectConfigClass testInitRefConfClz = new ReflectConfigClass(getQualifiedClassName(org, name, version, + MODULE_INIT_CLASS_NAME)); + + testInitRefConfClz.addReflectConfigClassMethod( new ReflectConfigClassMethod( - "__execute__", - new String[]{ - "io.ballerina.runtime.internal.scheduling.Strand", - "io.ballerina.runtime.api.values.BString", - "io.ballerina.runtime.api.values.BString", - "io.ballerina.runtime.api.values.BString", - "io.ballerina.runtime.api.values.BString", - "io.ballerina.runtime.api.values.BString", - "io.ballerina.runtime.api.values.BString", - "io.ballerina.runtime.api.values.BString", - "io.ballerina.runtime.api.values.BString", - "io.ballerina.runtime.api.values.BString", - "io.ballerina.runtime.api.values.BString" - } + "$moduleInit", + new String[]{"io.ballerina.runtime.internal.scheduling.Strand"} + ) + ); + + testInitRefConfClz.addReflectConfigClassMethod( + new ReflectConfigClassMethod( + "$moduleStart", + new String[]{"io.ballerina.runtime.internal.scheduling.Strand"} ) ); - } - ReflectConfigClass testNameZeroNameRefConfClz = - new ReflectConfigClass(getQualifiedClassName(org, name, version, name)); - testNameZeroNameRefConfClz.setQueryAllDeclaredMethods(true); + testInitRefConfClz.addReflectConfigClassMethod( + new ReflectConfigClassMethod( + "$moduleStop", + new String[]{"io.ballerina.runtime.internal.scheduling.RuntimeRegistry"} + ) + ); + + ReflectConfigClass testConfigurationMapperRefConfClz = new ReflectConfigClass( + getQualifiedClassName(org, name, version, MODULE_CONFIGURATION_MAPPER)); - // Add all class values to the array - classList.add(testInitRefConfClz); - classList.add(testConfigurationMapperRefConfClz); - classList.add(testTestExecuteGeneratedRefConfClz); + testConfigurationMapperRefConfClz.addReflectConfigClassMethod( + new ReflectConfigClassMethod( + "$configureInit", + new String[]{"java.lang.String[]", "java.nio.file.Path[]", "java.lang.String"} + ) + ); + ReflectConfigClass testTestExecuteGeneratedRefConfClz = new ReflectConfigClass( + testSuiteMap.get(moduleName).getTestUtilityFunctions().get("__execute__")); + testTestExecuteGeneratedRefConfClz.addReflectConfigClassMethod( + new ReflectConfigClassMethod( + "__execute__", + new String[]{ + "io.ballerina.runtime.internal.scheduling.Strand", + "io.ballerina.runtime.api.values.BString", + "io.ballerina.runtime.api.values.BString", + "io.ballerina.runtime.api.values.BString", + "io.ballerina.runtime.api.values.BString", + "io.ballerina.runtime.api.values.BString", + "io.ballerina.runtime.api.values.BString", + "io.ballerina.runtime.api.values.BString", + "io.ballerina.runtime.api.values.BString", + "io.ballerina.runtime.api.values.BString", + "io.ballerina.runtime.api.values.BString" + } + ) + ); + if (!testSuiteMap.get(moduleName).getMockFunctionNamesMap().isEmpty()) { + ReflectConfigClass testNameZeroNameRefConfClz = new ReflectConfigClass(getQualifiedClassName( + org, name, version, name.replace(DOT, FILE_NAME_PERIOD_SEPARATOR))); + testNameZeroNameRefConfClz.setQueryAllDeclaredMethods(true); + classList.add(testNameZeroNameRefConfClz); + } + + // Add all class values to the array + classList.add(testInitRefConfClz); + classList.add(testConfigurationMapperRefConfClz); + classList.add(testTestExecuteGeneratedRefConfClz); - classList.add(testNameZeroNameRefConfClz); + } - // Increment tally to cover executable_ class - tally += 1; } ReflectConfigClass runtimeEntityTestSuiteRefConfClz = new ReflectConfigClass( From 391536884b4f1f1b53a4923ca66df1fde68c8d6f Mon Sep 17 00:00:00 2001 From: Thevakumar-Luheerathan Date: Mon, 21 Nov 2022 18:01:09 +0530 Subject: [PATCH 069/450] Add call,callOriginal function support --- .../cli/task/RunNativeImageTestTask.java | 323 ++++++++++-------- .../io/ballerina/cli/utils/NativeUtils.java | 112 +++++- .../testerina-compiler-plugin/build.gradle | 1 + .../src/main/java/module-info.java | 1 + .../compiler/TestExecutionGenerationTask.java | 82 ++++- .../TesterinaCompilerPluginUtils.java | 36 ++ .../testerina/natives/mock/FunctionMock.java | 8 +- 7 files changed, 414 insertions(+), 149 deletions(-) diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java index 5555d8c17235..ecb8884887c4 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java @@ -109,6 +109,7 @@ public class RunNativeImageTestTask implements Task { private final PrintStream out; private final String includesInCoverage; + TestReport testReport; private String groupList; private String disableGroupList; private boolean report; @@ -119,11 +120,9 @@ public class RunNativeImageTestTask implements Task { private Map coverageModules; private boolean listGroups; - TestReport testReport; - public RunNativeImageTestTask(PrintStream out, boolean rerunTests, String groupList, - String disableGroupList, String testList, String includes, String coverageFormat, - Map modules, boolean listGroups) { + String disableGroupList, String testList, String includes, String coverageFormat, + Map modules, boolean listGroups) { this.out = out; this.isRerunTestExecution = rerunTests; @@ -142,6 +141,136 @@ public RunNativeImageTestTask(PrintStream out, boolean rerunTests, String groupL this.listGroups = listGroups; } + public static byte[] getModifiedClassBytes(String className, List functionNames, TestSuite suite, + ClassLoader classLoader) { + Class functionToMockClass; + try { + functionToMockClass = classLoader.loadClass(className); + } catch (Throwable e) { + throw createLauncherException("failed to load class: " + className); + } + + byte[] classFile = new byte[0]; + boolean readFromBytes = false; + for (Method method1 : functionToMockClass.getDeclaredMethods()) { + if (functionNames.contains(MOCK_FN_DELIMITER + method1.getName())) { + String desugaredMockFunctionName = MOCK_FUNC_NAME_PREFIX + method1.getName(); + String testClassName = TesterinaUtils.getQualifiedClassName(suite.getOrgName(), + suite.getTestPackageID(), suite.getVersion(), + suite.getPackageID().replace(DOT, FILE_NAME_PERIOD_SEPARATOR)); + Class testClass; + try { + testClass = classLoader.loadClass(testClassName); + } catch (Throwable e) { + throw createLauncherException("failed to load class :" + testClassName); + } + for (Method method2 : testClass.getDeclaredMethods()) { + if (method2.getName().equals(desugaredMockFunctionName)) { + if (!readFromBytes) { + classFile = replaceMethodBody(method1, method2); + readFromBytes = true; + } else { + classFile = replaceMethodBody(classFile, method1, method2); + } + } + } + } else if (functionNames.contains(MOCK_LEGACY_DELIMITER + method1.getName())) { + String key = className + MOCK_LEGACY_DELIMITER + method1.getName(); + String mockFunctionName = suite.getMockFunctionNamesMap().get(key); + if (mockFunctionName != null) { + String mockFunctionClassName = suite.getTestUtilityFunctions().get(mockFunctionName); + Class mockFunctionClass; + try { + mockFunctionClass = classLoader.loadClass(mockFunctionClassName); + } catch (ClassNotFoundException e) { + throw createLauncherException("failed to load class: " + mockFunctionClassName); + } + for (Method method2 : mockFunctionClass.getDeclaredMethods()) { + if (method2.getName().equals(mockFunctionName)) { + if (!readFromBytes) { + classFile = replaceMethodBody(method1, method2); + readFromBytes = true; + } else { + classFile = replaceMethodBody(classFile, method1, method2); + } + } + } + } else { + continue; + } + } + } + return classFile; + } + + private static byte[] replaceMethodBody(Method method, Method mockMethod) { + Class clazz = method.getDeclaringClass(); + ClassReader cr; + try { + InputStream ins; + ins = clazz.getResourceAsStream(clazz.getSimpleName() + CLASS_EXTENSION); + cr = new ClassReader(requireNonNull(ins)); + } catch (IOException e) { + throw createLauncherException("failed to get the class reader object for the class " + + clazz.getSimpleName()); + } + ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); + ClassVisitor cv = new MockFunctionReplaceVisitor(Opcodes.ASM7, cw, method.getName(), + Type.getMethodDescriptor(method), mockMethod); + cr.accept(cv, 0); + return cw.toByteArray(); + } + + private static byte[] replaceMethodBody(byte[] classFile, Method method, Method mockMethod) { + ClassReader cr = new ClassReader(classFile); + ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); + ClassVisitor cv = new MockFunctionReplaceVisitor(Opcodes.ASM7, cw, method.getName(), + Type.getMethodDescriptor(method), mockMethod); + cr.accept(cv, 0); + return cw.toByteArray(); + } + + public static List getURLList(List jarFilePaths) { + List urlList = new ArrayList<>(); + + for (String jarFilePath : jarFilePaths) { + try { + urlList.add(Paths.get(jarFilePath).toUri().toURL()); + } catch (MalformedURLException e) { + // This path cannot get executed + throw new RuntimeException("Failed to create classloader with all jar files", e); + } + } + return urlList; + } + + private static void populateClassNameVsFunctionToMockMap(Map> classVsMockFunctionsMap, + Map mockFunctionMap) { + for (Map.Entry entry : mockFunctionMap.entrySet()) { + String key = entry.getKey(); + String functionToMockClassName; + String functionToMock; + if (key.indexOf(MOCK_LEGACY_DELIMITER) == -1) { + functionToMockClassName = key.substring(0, key.indexOf(MOCK_FN_DELIMITER)); + functionToMock = key.substring(key.indexOf(MOCK_FN_DELIMITER)); + } else if (key.indexOf(MOCK_FN_DELIMITER) == -1) { + functionToMockClassName = key.substring(0, key.indexOf(MOCK_LEGACY_DELIMITER)); + functionToMock = key.substring(key.indexOf(MOCK_LEGACY_DELIMITER)); + } else { + if (key.indexOf(MOCK_FN_DELIMITER) < key.indexOf(MOCK_LEGACY_DELIMITER)) { + functionToMockClassName = key.substring(0, key.indexOf(MOCK_FN_DELIMITER)); + functionToMock = key.substring(key.indexOf(MOCK_FN_DELIMITER)); + } else { + functionToMockClassName = key.substring(0, key.indexOf(MOCK_LEGACY_DELIMITER)); + functionToMock = key.substring(key.indexOf(MOCK_LEGACY_DELIMITER)); + } + } + functionToMock = functionToMock.replaceAll("\\\\", ""); + classVsMockFunctionsMap.computeIfAbsent(functionToMockClassName, + k -> new ArrayList<>()).add(functionToMock); + } + } + @Override public void execute(Project project) { long start = 0; @@ -210,22 +339,36 @@ public void execute(Project project) { } suite.setReportRequired(report || coverage); try { - isMockFuncExist = modifyJarForFunctionMock(suite, target, moduleName.toString(), + modifyJarForFunctionMock(suite, target, moduleName.toString(), functionMockModuleMapping); } catch (IOException e) { throw createLauncherException("error occurred while running tests", e); } - if (isMockFuncExist) { - suite.removeAllMockFunctions(); - } + String resolvedModuleName = module.isDefaultModule() ? moduleName.toString() : module.moduleName().moduleNamePart(); testSuiteMap.put(resolvedModuleName, suite); moduleNamesList.add(resolvedModuleName); } + try { + Path nativeConfigPath = target.getNativeConfigPath(); + createReflectConfig(nativeConfigPath, project.currentPackage(), testSuiteMap); + } catch (IOException e) { + throw createLauncherException("error while generating the necessary graalvm reflection config ", e); + } + + for (Map.Entry testSuiteEntry : testSuiteMap.entrySet()) { + TestSuite testSuite = testSuiteEntry.getValue(); + if (!testSuite.getMockFunctionNamesMap().isEmpty()) { + testSuite.removeAllMockFunctions(); + } + } + TestUtils.writeToTestSuiteJson(testSuiteMap, testsCachePath); + + if (hasTests) { int testResult = 1; try { @@ -271,9 +414,35 @@ public void execute(Project project) { } } +// private void mapClassWithMethodForCallOrigFuncMock(TestSuite suite, Map> +// balFileClassOrigMockFuncMapping, ClassLoader classLoader) { +// Map mockFunctionNamesMap = suite.getMockFunctionNamesMap(); +// for (Map.Entry mockFunctionNameEntry : mockFunctionNamesMap.entrySet()) { +// String classWithFunctionMock = ((mockFunctionNameEntry.getKey()).split("#"))[0]; +// balFileClassOrigMockFuncMapping.put(classWithFunctionMock, new ArrayList()); +// } +// +// for (Map.Entry> balFileClassOrigMockFuncEntry : +// balFileClassOrigMockFuncMapping.entrySet()) { +// Class loadClass; +// String className = balFileClassOrigMockFuncEntry.getKey(); +// try { +// loadClass = classLoader.loadClass(className); +// } catch (Throwable e) { +// throw createLauncherException("failed to load class: " + className); +// } +// for (Method method : loadClass.getDeclaredMethods()) { +// String methodName = method.getName(); +// if (methodName.startsWith("$ORIG")) { +// balFileClassOrigMockFuncMapping.get(className).add(methodName); +// } +// } +// } +// } + private int runTestSuiteWithNativeImage(Package currentPackage, JBallerinaBackend jBallerinaBackend, Target target, Map functionMockModuleMappings) - throws IOException, InterruptedException { + throws IOException, InterruptedException { String packageName = currentPackage.packageName().toString(); String classPath = getClassPath(jBallerinaBackend, currentPackage); String modClassPath; @@ -352,8 +521,6 @@ private int runTestSuiteWithNativeImage(Package currentPackage, JBallerinaBacken Path nativeConfigPath = target.getNativeConfigPath(); // target/cache/test_cache/native-config Path nativeTargetPath = target.getNativePath(); // target/native - // Create Configs - createReflectConfig(nativeConfigPath, currentPackage); // Run native-image command with generated configs cmdArgs.addAll(Lists.of("-cp", classPath)); @@ -421,7 +588,7 @@ private String getClassPath(JBallerinaBackend jBallerinaBackend, Package current return classPath.toString(); } - private boolean modifyJarForFunctionMock(TestSuite testSuite, Target target, String moduleName, + private void modifyJarForFunctionMock(TestSuite testSuite, Target target, String moduleName, Map functionMockModuleMapping) throws IOException { String mainJarName = testSuite.getOrgName() + HYPHEN + moduleName + HYPHEN + testSuite.getVersion() + JAR_EXTENSION; @@ -430,7 +597,7 @@ private boolean modifyJarForFunctionMock(TestSuite testSuite, Target target, Str String modifiedJar = testSuite.getOrgName() + HYPHEN + moduleName + HYPHEN + testSuite.getVersion() + HYPHEN + MODIFIED + JAR_EXTENSION; if (testSuite.getMockFunctionNamesMap().isEmpty()) { - return false; + return; } functionMockModuleMapping.put(mainJarName, modifiedJar); List testExecutionDependencies = testSuite.getTestExecutionDependencies(); @@ -462,7 +629,6 @@ private boolean modifyJarForFunctionMock(TestSuite testSuite, Target target, Str (testSuite.getPackageName()).resolve(testSuite.getVersion()).resolve(JAVA_11_DIR)).toString() + PATH_SEPARATOR + modifiedJar; dumpJar(modifiedClassDef, unmodifiedFiles, modifiedJarPath); - return true; } private void dumpJar(Map modifiedClassDefs, Map unmodifiedFiles, @@ -492,135 +658,6 @@ private void dumpJar(Map modifiedClassDefs, Map } - public static byte[] getModifiedClassBytes(String className, List functionNames, TestSuite suite, - ClassLoader classLoader) { - Class functionToMockClass; - try { - functionToMockClass = classLoader.loadClass(className); - } catch (Throwable e) { - throw createLauncherException("failed to load class: " + className); - } - - byte[] classFile = new byte[0]; - boolean readFromBytes = false; - for (Method method1 : functionToMockClass.getDeclaredMethods()) { - if (functionNames.contains(MOCK_FN_DELIMITER + method1.getName())) { - String desugaredMockFunctionName = MOCK_FUNC_NAME_PREFIX + method1.getName(); - String testClassName = TesterinaUtils.getQualifiedClassName(suite.getOrgName(), - suite.getTestPackageID(), suite.getVersion(), - suite.getPackageID().replace(DOT, FILE_NAME_PERIOD_SEPARATOR)); - Class testClass; - try { - testClass = classLoader.loadClass(testClassName); - } catch (Throwable e) { - throw createLauncherException("failed to load class :" + testClassName); - } - for (Method method2 : testClass.getDeclaredMethods()) { - if (method2.getName().equals(desugaredMockFunctionName)) { - if (!readFromBytes) { - classFile = replaceMethodBody(method1, method2); - readFromBytes = true; - } else { - classFile = replaceMethodBody(classFile, method1, method2); - } - } - } - } else if (functionNames.contains(MOCK_LEGACY_DELIMITER + method1.getName())) { - String key = className + MOCK_LEGACY_DELIMITER + method1.getName(); - String mockFunctionName = suite.getMockFunctionNamesMap().get(key); - if (mockFunctionName != null) { - String mockFunctionClassName = suite.getTestUtilityFunctions().get(mockFunctionName); - Class mockFunctionClass; - try { - mockFunctionClass = classLoader.loadClass(mockFunctionClassName); - } catch (ClassNotFoundException e) { - throw createLauncherException("failed to load class: " + mockFunctionClassName); - } - for (Method method2 : mockFunctionClass.getDeclaredMethods()) { - if (method2.getName().equals(mockFunctionName)) { - if (!readFromBytes) { - classFile = replaceMethodBody(method1, method2); - readFromBytes = true; - } else { - classFile = replaceMethodBody(classFile, method1, method2); - } - } - } - } else { - continue; - } - } - } - return classFile; - } - - private static byte[] replaceMethodBody(Method method, Method mockMethod) { - Class clazz = method.getDeclaringClass(); - ClassReader cr; - try { - InputStream ins; - ins = clazz.getResourceAsStream(clazz.getSimpleName() + CLASS_EXTENSION); - cr = new ClassReader(requireNonNull(ins)); - } catch (IOException e) { - throw createLauncherException("failed to get the class reader object for the class " - + clazz.getSimpleName()); - } - ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); - ClassVisitor cv = new MockFunctionReplaceVisitor(Opcodes.ASM7, cw, method.getName(), - Type.getMethodDescriptor(method), mockMethod); - cr.accept(cv, 0); - return cw.toByteArray(); - } - - private static byte[] replaceMethodBody(byte[] classFile, Method method, Method mockMethod) { - ClassReader cr = new ClassReader(classFile); - ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); - ClassVisitor cv = new MockFunctionReplaceVisitor(Opcodes.ASM7, cw, method.getName(), - Type.getMethodDescriptor(method), mockMethod); - cr.accept(cv, 0); - return cw.toByteArray(); - } - public static List getURLList(List jarFilePaths) { - List urlList = new ArrayList<>(); - - for (String jarFilePath : jarFilePaths) { - try { - urlList.add(Paths.get(jarFilePath).toUri().toURL()); - } catch (MalformedURLException e) { - // This path cannot get executed - throw new RuntimeException("Failed to create classloader with all jar files", e); - } - } - return urlList; - } - - private static void populateClassNameVsFunctionToMockMap(Map> classVsMockFunctionsMap, - Map mockFunctionMap) { - for (Map.Entry entry : mockFunctionMap.entrySet()) { - String key = entry.getKey(); - String functionToMockClassName; - String functionToMock; - if (key.indexOf(MOCK_LEGACY_DELIMITER) == -1) { - functionToMockClassName = key.substring(0, key.indexOf(MOCK_FN_DELIMITER)); - functionToMock = key.substring(key.indexOf(MOCK_FN_DELIMITER)); - } else if (key.indexOf(MOCK_FN_DELIMITER) == -1) { - functionToMockClassName = key.substring(0, key.indexOf(MOCK_LEGACY_DELIMITER)); - functionToMock = key.substring(key.indexOf(MOCK_LEGACY_DELIMITER)); - } else { - if (key.indexOf(MOCK_FN_DELIMITER) < key.indexOf(MOCK_LEGACY_DELIMITER)) { - functionToMockClassName = key.substring(0, key.indexOf(MOCK_FN_DELIMITER)); - functionToMock = key.substring(key.indexOf(MOCK_FN_DELIMITER)); - } else { - functionToMockClassName = key.substring(0, key.indexOf(MOCK_LEGACY_DELIMITER)); - functionToMock = key.substring(key.indexOf(MOCK_LEGACY_DELIMITER)); - } - } - functionToMock = functionToMock.replaceAll("\\\\", ""); - classVsMockFunctionsMap.computeIfAbsent(functionToMockClassName, - k -> new ArrayList<>()).add(functionToMock); - } - } - private Map loadUnmodifiedFilesWithinJar(List codeGeneratedJarPaths, String mainJarName) throws IOException { String mainJarPath = null; diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java index d31d2971a5f9..fe3334f28aa0 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java @@ -20,19 +20,28 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.reflect.TypeToken; import io.ballerina.projects.Module; import io.ballerina.projects.Package; import io.ballerina.runtime.internal.util.RuntimeUtils; +import org.ballerinalang.test.runtime.entity.TestSuite; +import java.io.BufferedReader; +import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.Writer; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import static io.ballerina.identifier.Utils.encodeNonFunctionIdentifier; +import static io.ballerina.runtime.api.constants.RuntimeConstants.FILE_NAME_PERIOD_SEPARATOR; import static org.ballerinalang.test.runtime.util.TesterinaConstants.ANON_ORG; import static org.ballerinalang.test.runtime.util.TesterinaConstants.DOT; @@ -46,7 +55,8 @@ public class NativeUtils { private static final String MODULE_CONFIGURATION_MAPPER = "$configurationMapper"; private static final String MODULE_EXECUTE_GENERATED = "tests.test_execute-generated_"; - public static void createReflectConfig(Path nativeConfigPath, Package currentPackage) throws IOException { + public static void createReflectConfig(Path nativeConfigPath, Package currentPackage, Map + testSuiteMap) throws IOException { String org = currentPackage.packageOrg().toString(); String version = currentPackage.packageVersion().toString(); @@ -114,9 +124,12 @@ public static void createReflectConfig(Path nativeConfigPath, Package currentPac ) ); - ReflectConfigClass testNameZeroName = - new ReflectConfigClass(getQualifiedClassName(org, name, version, name)); + ReflectConfigClass testNameZeroName = new ReflectConfigClass( + getQualifiedClassName(org, name, version, name.replace(DOT, FILE_NAME_PERIOD_SEPARATOR))); testNameZeroName.setQueryAllDeclaredMethods(true); + testNameZeroName.setAllDeclaredFields(true); + testNameZeroName.setUnsafeAllocated(true); + // Add all class values to the array classList.add(testInitClass); @@ -127,8 +140,82 @@ public static void createReflectConfig(Path nativeConfigPath, Package currentPac // Increment tally to cover executable_ class tally += 1; + } + Path mockedFunctionClassPath = nativeConfigPath.resolve("mocked-func-class-map.json"); + File mockedFunctionClassFile = new File(mockedFunctionClassPath.toString()); + if (mockedFunctionClassFile.isFile()) { + try (BufferedReader br = Files.newBufferedReader(mockedFunctionClassPath, StandardCharsets.UTF_8)) { + Gson gsonRead = new Gson(); + Map testFileMockedFunctionMapping = gsonRead.fromJson(br, + new TypeToken>() { + }.getType()); + if (!testFileMockedFunctionMapping.isEmpty()) { + ReflectConfigClass originalTestFileRefConfClz; + for (Map.Entry testFileMockedFunctionMappingEntry : + testFileMockedFunctionMapping.entrySet()) { + String moduleName = testFileMockedFunctionMappingEntry.getKey().split("-")[0]; + String testFile = testFileMockedFunctionMappingEntry.getKey().split("-")[1]; + String[] mockedFunctions = testFileMockedFunctionMappingEntry.getValue(); + if (mockedFunctions.length > 0) { + originalTestFileRefConfClz = new ReflectConfigClass(getQualifiedClassName(org, moduleName, + version, testFile)); + for (int i = 0; i < mockedFunctions.length; i++) { + originalTestFileRefConfClz.addReflectConfigClassMethod( + new ReflectConfigClassMethod(mockedFunctions[i])); + originalTestFileRefConfClz.setUnsafeAllocated(true); + originalTestFileRefConfClz.setAllDeclaredFields(true); + originalTestFileRefConfClz.setQueryAllDeclaredMethods(true); + } + classList.add(originalTestFileRefConfClz); + } + } + } + } + } + ReflectConfigClass originalBalFileRefConfClz = new ReflectConfigClass(""); + Map> mockFunctionClassMapping = new HashMap<>(); + extractMockFunctionClassMapping(testSuiteMap, mockFunctionClassMapping); + for (Map.Entry> mockFunctionClassMapEntry : mockFunctionClassMapping.entrySet()) { + String mockFunctionClass = mockFunctionClassMapEntry.getKey(); + originalBalFileRefConfClz = new ReflectConfigClass(mockFunctionClass); + for (String originalMockFunction : mockFunctionClassMapEntry.getValue()) { + originalBalFileRefConfClz.addReflectConfigClassMethod( + new ReflectConfigClassMethod(originalMockFunction)); + } + originalBalFileRefConfClz.setQueryAllDeclaredMethods(true); + originalBalFileRefConfClz.setQueryAllDeclaredMethods(true); + originalBalFileRefConfClz.setUnsafeAllocated(true); + classList.add(originalBalFileRefConfClz); + } + + + +// ReflectConfigClass originalBalFileRefConfClz; +// for (Map.Entry> balFileClassOrigMockFuncEntry : +// balFileClassOrigMockFuncMapping.entrySet()) { +// if (balFileClassOrigMockFuncEntry.getValue().size() > 0) { +// originalBalFileRefConfClz = new ReflectConfigClass(balFileClassOrigMockFuncEntry.getKey()); +// for (String methodName : balFileClassOrigMockFuncEntry.getValue()) { +// originalBalFileRefConfClz.addReflectConfigClassMethod(new ReflectConfigClassMethod(methodName)); +// } +// originalBalFileRefConfClz.setQueryAllDeclaredMethods(true); +// originalBalFileRefConfClz.setQueryAllDeclaredMethods(true); +// originalBalFileRefConfClz.setUnsafeAllocated(true); +// } +// } + +// ReflectConfigClass originalFunctionRefConfClz; + +// for (String classWithFunctionMock : balFileClassOrigMockFuncMapping) { +// originalFunctionRefConfClz = new ReflectConfigClass(classWithFunctionMock); +// originalFunctionRefConfClz.setQueryAllDeclaredMethods(true); +// originalFunctionRefConfClz.setQueryAllDeclaredMethods(true); +// originalFunctionRefConfClz.setUnsafeAllocated(true); +// classList.add(originalFunctionRefConfClz); +// } + ReflectConfigClass runtimeEntityTestSuite = new ReflectConfigClass("org.ballerinalang.test.runtime.entity" + ".TestSuite"); runtimeEntityTestSuite.setAllDeclaredFields(true); @@ -136,6 +223,7 @@ public static void createReflectConfig(Path nativeConfigPath, Package currentPac classList.add(runtimeEntityTestSuite); + // Write the array to the config file try (Writer writer = new FileWriter(nativeConfigPath.resolve("reflect-config.json").toString(), Charset.defaultCharset())) { @@ -144,6 +232,24 @@ public static void createReflectConfig(Path nativeConfigPath, Package currentPac } } + private static void extractMockFunctionClassMapping(Map testSuiteMap, Map> mockFunctionClassMapping) { + for (Map.Entry testSuiteEntry : testSuiteMap.entrySet()) { + TestSuite suite = testSuiteEntry.getValue(); + for (Map.Entry mockFunctionEntry : suite.getMockFunctionNamesMap().entrySet()) { + String mockFunctionId = mockFunctionEntry.getKey(); + String mockFunctionClass = mockFunctionId.split("#")[0]; + String mockFunction = mockFunctionId.split("#")[1]; + if (mockFunctionClassMapping.containsKey(mockFunctionClass)) { + mockFunctionClassMapping.get(mockFunctionClass).add("$ORIG_" + mockFunction); + } else { + List mockFunctionList = new ArrayList<>(); + mockFunctionList.add("$ORIG_" + mockFunction); + mockFunctionClassMapping.put(mockFunctionClass, mockFunctionList); + } + } + } + } + public static void createResourceConfig(Path nativeConfigPath) throws IOException { // { // "resources": { diff --git a/misc/testerina/modules/testerina-compiler-plugin/build.gradle b/misc/testerina/modules/testerina-compiler-plugin/build.gradle index ae630ce5e401..abb52d3a3089 100644 --- a/misc/testerina/modules/testerina-compiler-plugin/build.gradle +++ b/misc/testerina/modules/testerina-compiler-plugin/build.gradle @@ -21,6 +21,7 @@ description = 'Compiler Plugin - Testerina' version = '0.1.0' dependencies { + implementation "com.google.code.gson:gson:${project.gsonVersion}" implementation project(':ballerina-lang') implementation project(':ballerina-parser') implementation project(':ballerina-tools-api') diff --git a/misc/testerina/modules/testerina-compiler-plugin/src/main/java/module-info.java b/misc/testerina/modules/testerina-compiler-plugin/src/main/java/module-info.java index 772e0378c89e..7e61d9bc82e8 100644 --- a/misc/testerina/modules/testerina-compiler-plugin/src/main/java/module-info.java +++ b/misc/testerina/modules/testerina-compiler-plugin/src/main/java/module-info.java @@ -1,5 +1,6 @@ module io.ballerina.testerina.compiler { exports org.ballerinalang.testerina.compiler; + requires com.google.gson; requires io.ballerina.lang; requires io.ballerina.parser; requires io.ballerina.tools.api; diff --git a/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/TestExecutionGenerationTask.java b/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/TestExecutionGenerationTask.java index e099fa84677e..23dbd233debd 100644 --- a/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/TestExecutionGenerationTask.java +++ b/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/TestExecutionGenerationTask.java @@ -18,12 +18,21 @@ package org.ballerinalang.testerina.compiler; +import io.ballerina.compiler.syntax.tree.ExpressionNode; +import io.ballerina.compiler.syntax.tree.ExpressionStatementNode; +import io.ballerina.compiler.syntax.tree.FunctionBodyBlockNode; +import io.ballerina.compiler.syntax.tree.FunctionBodyNode; +import io.ballerina.compiler.syntax.tree.FunctionCallExpressionNode; +import io.ballerina.compiler.syntax.tree.FunctionDefinitionNode; import io.ballerina.compiler.syntax.tree.ImportDeclarationNode; +import io.ballerina.compiler.syntax.tree.MethodCallExpressionNode; import io.ballerina.compiler.syntax.tree.ModuleMemberDeclarationNode; import io.ballerina.compiler.syntax.tree.ModulePartNode; +import io.ballerina.compiler.syntax.tree.NameReferenceNode; import io.ballerina.compiler.syntax.tree.Node; import io.ballerina.compiler.syntax.tree.NodeFactory; import io.ballerina.compiler.syntax.tree.NodeList; +import io.ballerina.compiler.syntax.tree.QualifiedNameReferenceNode; import io.ballerina.compiler.syntax.tree.StatementNode; import io.ballerina.compiler.syntax.tree.SyntaxKind; import io.ballerina.compiler.syntax.tree.Token; @@ -31,13 +40,17 @@ import io.ballerina.projects.DocumentId; import io.ballerina.projects.Module; import io.ballerina.projects.ModuleId; +import io.ballerina.projects.Package; import io.ballerina.projects.plugins.GeneratorTask; import io.ballerina.projects.plugins.SourceGeneratorContext; import io.ballerina.tools.text.TextDocument; import io.ballerina.tools.text.TextDocuments; +import java.nio.file.Path; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; /** @@ -49,7 +62,8 @@ public class TestExecutionGenerationTask implements GeneratorTask> testFileMockedFunctionMapping = new HashMap<>(); + for (ModuleId moduleId : pack.moduleIds()) { + Module module = pack.module(moduleId); + String moduleName = module.moduleName().toString(); + for (DocumentId documentId : module.testDocumentIds()) { + Document document = module.document(documentId); + String documentName = moduleName + "-" + document.name().replace(".bal", "") + .replace("/", "."); + List mockedFunctionList = new ArrayList<>(); + Node node = document.syntaxTree().rootNode(); + TestFunctionVisitor testFunctionVisitor = new TestFunctionVisitor(); + node.accept(testFunctionVisitor); + for (FunctionDefinitionNode func : testFunctionVisitor.getTestStaticFunctions()) { + FunctionBodyNode functionBodyNode = func.functionBody(); + NodeList statements = ((FunctionBodyBlockNode) functionBodyNode).statements(); + for (int i = 0; i < statements.size(); i++) { + StatementNode functionBodyContent = (StatementNode) statements.get(i); + if (functionBodyContent instanceof ExpressionStatementNode) { + ExpressionNode methodCallNode = ((ExpressionStatementNode) functionBodyContent) + .expression(); + if (methodCallNode instanceof MethodCallExpressionNode) { + ExpressionNode expression = ((MethodCallExpressionNode) methodCallNode).expression(); + if (expression instanceof FunctionCallExpressionNode) { + gatherMockedFunctions(mockedFunctionList, (MethodCallExpressionNode) + methodCallNode, (FunctionCallExpressionNode) expression); + } else if (expression instanceof MethodCallExpressionNode) { + expression = ((MethodCallExpressionNode) expression).expression(); + if (expression instanceof FunctionCallExpressionNode) { + gatherMockedFunctions(mockedFunctionList, (MethodCallExpressionNode) + methodCallNode, (FunctionCallExpressionNode) expression); + } + } + } + } + } + } + testFileMockedFunctionMapping.put(documentName, mockedFunctionList); + } + } + Path cachePath = pack.project().targetDir().resolve("cache").resolve("tests_cache") + .resolve("native-config"); + TesterinaCompilerPluginUtils.writeCacheMapAsJson(testFileMockedFunctionMapping, cachePath, + "mocked-func-class-map.json"); + } + + private static void gatherMockedFunctions(List mockedFunctionList, MethodCallExpressionNode methodCallNode, + FunctionCallExpressionNode expression) { + NameReferenceNode functionName = expression.functionName(); + if (functionName instanceof QualifiedNameReferenceNode) { + String modulePrefix = ((QualifiedNameReferenceNode) functionName). + modulePrefix().text(); + String identifier = ((QualifiedNameReferenceNode) functionName). + identifier().text(); + String methodName = methodCallNode.methodName() + .toString().strip(); + if ("test".equals(modulePrefix) && "call".equals(methodName) + && "when".equals(identifier)) { + String mockedFunction = methodCallNode.arguments() + .get(0).toString().replaceAll("\"", ""); + mockedFunctionList.add(mockedFunction); + } + } + } } diff --git a/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/TesterinaCompilerPluginUtils.java b/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/TesterinaCompilerPluginUtils.java index 5c74e29cec32..62410808d24d 100644 --- a/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/TesterinaCompilerPluginUtils.java +++ b/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/TesterinaCompilerPluginUtils.java @@ -18,6 +18,7 @@ package org.ballerinalang.testerina.compiler; +import com.google.gson.Gson; import io.ballerina.compiler.syntax.tree.ExpressionNode; import io.ballerina.compiler.syntax.tree.FunctionArgumentNode; import io.ballerina.compiler.syntax.tree.FunctionBodyBlockNode; @@ -35,9 +36,20 @@ import io.ballerina.compiler.syntax.tree.SimpleNameReferenceNode; import io.ballerina.compiler.syntax.tree.StatementNode; import io.ballerina.compiler.syntax.tree.SyntaxKind; +import org.ballerinalang.testerina.compiler.exceptions.CacheGenException; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.Writer; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; /** @@ -277,4 +289,28 @@ public static PositionalArgumentNode getPositionalArg(String argName) { return NodeFactory.createPositionalArgumentNode( NodeFactory.createSimpleNameReferenceNode(NodeFactory.createIdentifierToken(argName))); } + + public static void writeCacheMapAsJson(Map map, Path path, String fileName) { + if (!Files.exists(path)) { + try { + Files.createDirectories(path); + } catch (IOException e) { + throw new CacheGenException("couldn't create cache directories : " + e.toString()); + } + } + + Path jsonFilePath = Paths.get(path.toString(), fileName); + File jsonFile = new File(jsonFilePath.toString()); + try (FileOutputStream fileOutputStream = new FileOutputStream(jsonFile)) { + try (Writer writer = new OutputStreamWriter(fileOutputStream, StandardCharsets.UTF_8)) { + Gson gson = new Gson(); + String json = gson.toJson(map); + writer.write(new String(json.getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8)); + } catch (IOException e) { + throw new CacheGenException("couldn't write cache data to the file : " + e.toString()); + } + } catch (IOException e) { + throw new CacheGenException("couldn't write cache data to the file : " + e.toString()); + } + } } diff --git a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/natives/mock/FunctionMock.java b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/natives/mock/FunctionMock.java index 8e1f9a6f82ef..649f14303cef 100644 --- a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/natives/mock/FunctionMock.java +++ b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/natives/mock/FunctionMock.java @@ -112,7 +112,11 @@ private static Object callMockFunction(String originalFunction, String originalC String version; if (Thread.currentThread().getStackTrace().length >= 5) { - String[] projectInfo = Thread.currentThread().getStackTrace()[4].getClassName().split(Pattern.quote(".")); + String classname = Thread.currentThread().getStackTrace()[4].getClassName(); + if (classname.contains("/")) { + classname = classname.replaceAll("/", "."); + } + String[] projectInfo = classname.split(Pattern.quote(".")); // Set project info try { orgName = projectInfo[0]; @@ -170,7 +174,7 @@ private static Method getMockMethod(String orgName, String packageName, String v return mockMethod; } - + //Identify the class with the mockMethod(method within call) private static String resolveMockClass(String mockMethodName, String[] mockFunctionClasses, String orgName, String packageName, String version, ClassLoader classLoader) throws ClassNotFoundException { From 46a3a88ba81c9dccca6cd5919e844069d3525586 Mon Sep 17 00:00:00 2001 From: Nadeeshan96 Date: Mon, 21 Nov 2022 18:09:13 +0530 Subject: [PATCH 070/450] Generate anonymous error type constants --- .../compiler/bir/codegen/JvmConstants.java | 3 + .../compiler/bir/codegen/JvmSignatures.java | 2 + .../compiler/bir/codegen/JvmTypeGen.java | 12 +- .../bir/codegen/split/JvmConstantsGen.java | 13 ++ .../bir/codegen/split/JvmCreateTypeGen.java | 4 + .../constants/JvmErrorTypeConstantsGen.java | 150 ++++++++++++++++++ 6 files changed, 180 insertions(+), 4 deletions(-) create mode 100644 compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmErrorTypeConstantsGen.java diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java index 7eeaa922f298..c9f971ecfadc 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java @@ -177,6 +177,7 @@ public class JvmConstants { public static final String LARGE_STRING_VAR_PREFIX = "$stringChunk"; public static final String GET_SURROGATE_ARRAY_METHOD_PREFIX = "getSurrogateArray"; public static final String UNION_TYPE_VAR_PREFIX = "$unionType"; + public static final String ERROR_TYPE_VAR_PREFIX = "$errorType"; public static final String TYPEREF_TYPE_VAR_PREFIX = "$typeRefType$"; public static final String TUPLE_TYPE_VAR_PREFIX = "$tupleType"; public static final String ARRAY_TYPE_VAR_PREFIX = "$arrayType"; @@ -293,6 +294,7 @@ public class JvmConstants { // code generation related constants. public static final String MODULE_INIT_CLASS_NAME = "$_init"; public static final String UNION_TYPE_CONSTANT_CLASS_NAME = "constants/$_bunion_type_constants"; + public static final String ERROR_TYPE_CONSTANT_CLASS_NAME = "constants/$_berror_type_constants"; public static final String TUPLE_TYPE_CONSTANT_CLASS_NAME = "constants/$_tuple_type_constants"; public static final String ARRAY_TYPE_CONSTANT_CLASS_NAME = "constants/$_array_type_constants"; public static final String TYPEREF_TYPE_CONSTANT_CLASS_NAME = "constants/$_typeref_type_constants"; @@ -314,6 +316,7 @@ public class JvmConstants { public static final String MODULE_ANNOTATIONS_CLASS_NAME = "annotations/$_annotations"; public static final String B_STRING_INIT_METHOD_PREFIX = "$string_init"; public static final String B_UNION_TYPE_INIT_METHOD_PREFIX = "$union_type_init"; + public static final String B_ERROR_TYPE_INIT_METHOD_PREFIX = "$error_type_init"; public static final String B_TUPLE_TYPE_INIT_METHOD_PREFIX = "$tuple_type_init"; public static final String B_ARRAY_TYPE_INIT_METHOD_PREFIX = "$array_type_init"; public static final String B_TYPEREF_TYPE_INIT_METHOD_PREFIX = "$typeref_type_init"; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java index 5d893d1aa283..8675ebe0548c 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java @@ -44,6 +44,7 @@ import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.DECIMAL_VALUE; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.DOUBLE_VALUE; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.ERROR_TYPE; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.ERROR_TYPE_IMPL; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.ERROR_VALUE; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.FLOAT_TYPE; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.FUNCTION; @@ -257,6 +258,7 @@ public class JvmSignatures { public static final String GET_TYPEDESC = "L" + TYPEDESC_VALUE + ";"; public static final String GET_TYPEDESC_OF_OBJECT = "(L" + OBJECT + ";)L" + TYPEDESC_VALUE + ";"; public static final String GET_UNION_TYPE_IMPL = "L" + UNION_TYPE_IMPL + ";"; + public static final String GET_ERROR_TYPE_IMPL = "L" + ERROR_TYPE_IMPL + ";"; public static final String GET_TYPE_REF_TYPE_IMPL = "L" + TYPE_REF_TYPE_IMPL + ";"; public static final String GET_WD_CHANNELS = "L" + WD_CHANNELS + ";"; public static final String GET_WORKER_DATA_CHANNEL = "(L" + STRING_VALUE + ";)L" + WORKER_DATA_CHANNEL + ";"; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeGen.java index 3220052c25a6..7a3164312cd6 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeGen.java @@ -694,10 +694,14 @@ private void loadErrorType(MethodVisitor mv, BErrorType errorType) { mv.visitFieldInsn(GETSTATIC, PREDEFINED_TYPES, TYPES_ERROR, GET_ERROR_TYPE); return; } - String typeOwner = - JvmCodeGenUtil.getPackageName(pkgID) + MODULE_INIT_CLASS_NAME; - String fieldName = getTypeFieldName(toNameString(errorType)); - mv.visitFieldInsn(GETSTATIC, typeOwner, fieldName, GET_TYPE); + + if (Symbols.isFlagOn(errorType.flags, Flags.ANONYMOUS)) { + jvmConstantsGen.generateGetBErrorType(mv, jvmConstantsGen.getTypeConstantsVar(errorType, symbolTable)); + } else { + String typeOwner = JvmCodeGenUtil.getPackageName(pkgID) + MODULE_INIT_CLASS_NAME; + String fieldName = getTypeFieldName(toNameString(errorType)); + mv.visitFieldInsn(GETSTATIC, typeOwner, fieldName, GET_TYPE); + } } public boolean loadUnionName(MethodVisitor mv, BUnionType unionType) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmConstantsGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmConstantsGen.java index 3551c00c35d4..373593ae42e2 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmConstantsGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmConstantsGen.java @@ -23,6 +23,7 @@ import org.wso2.ballerinalang.compiler.bir.codegen.split.constants.JvmArrayTypeConstantsGen; import org.wso2.ballerinalang.compiler.bir.codegen.split.constants.JvmBStringConstantsGen; import org.wso2.ballerinalang.compiler.bir.codegen.split.constants.JvmBallerinaConstantsGen; +import org.wso2.ballerinalang.compiler.bir.codegen.split.constants.JvmErrorTypeConstantsGen; import org.wso2.ballerinalang.compiler.bir.codegen.split.constants.JvmModuleConstantsGen; import org.wso2.ballerinalang.compiler.bir.codegen.split.constants.JvmRefTypeConstantsGen; import org.wso2.ballerinalang.compiler.bir.codegen.split.constants.JvmTupleTypeConstantsGen; @@ -32,6 +33,7 @@ import org.wso2.ballerinalang.compiler.semantics.analyzer.Types; import org.wso2.ballerinalang.compiler.semantics.model.SymbolTable; import org.wso2.ballerinalang.compiler.semantics.model.types.BArrayType; +import org.wso2.ballerinalang.compiler.semantics.model.types.BErrorType; import org.wso2.ballerinalang.compiler.semantics.model.types.BTupleType; import org.wso2.ballerinalang.compiler.semantics.model.types.BType; import org.wso2.ballerinalang.compiler.semantics.model.types.BTypeReferenceType; @@ -51,6 +53,8 @@ public class JvmConstantsGen { private final JvmUnionTypeConstantsGen unionTypeConstantsGen; + private final JvmErrorTypeConstantsGen errorTypeConstantsGen; + private final JvmBStringConstantsGen stringConstantsGen; private final JvmModuleConstantsGen moduleConstantsGen; @@ -70,6 +74,7 @@ public JvmConstantsGen(BIRNode.BIRPackage module, String moduleInitClass, Types this.moduleConstantsGen = new JvmModuleConstantsGen(module); this.jvmBallerinaConstantsGen = new JvmBallerinaConstantsGen(module, moduleInitClass, this); this.unionTypeConstantsGen = new JvmUnionTypeConstantsGen(module.packageID, bTypeHashComparator); + this.errorTypeConstantsGen = new JvmErrorTypeConstantsGen(module.packageID, bTypeHashComparator); this.tupleTypeConstantsGen = new JvmTupleTypeConstantsGen(module.packageID, bTypeHashComparator); this.arrayTypeConstantsGen = new JvmArrayTypeConstantsGen(module.packageID, bTypeHashComparator, types); this.refTypeConstantsGen = new JvmRefTypeConstantsGen(module.packageID, bTypeHashComparator); @@ -85,6 +90,7 @@ public String getModuleConstantVar(PackageID packageID) { public void setJvmCreateTypeGen(JvmCreateTypeGen jvmCreateTypeGen) { unionTypeConstantsGen.setJvmUnionTypeGen(jvmCreateTypeGen.getJvmUnionTypeGen()); + errorTypeConstantsGen.setJvmErrorTypeGen(jvmCreateTypeGen.getJvmErrorTypeGen()); tupleTypeConstantsGen.setJvmTupleTypeGen(jvmCreateTypeGen.getJvmTupleTypeGen()); arrayTypeConstantsGen.setJvmArrayTypeGen(jvmCreateTypeGen.getJvmArrayTypeGen()); refTypeConstantsGen.setJvmRefTypeGen(jvmCreateTypeGen.getJvmRefTypeGen()); @@ -93,6 +99,7 @@ public void setJvmCreateTypeGen(JvmCreateTypeGen jvmCreateTypeGen) { public void generateConstants(Map jarEntries) { jvmBallerinaConstantsGen.generateConstantInit(jarEntries); unionTypeConstantsGen.generateClass(jarEntries); + errorTypeConstantsGen.generateClass(jarEntries); moduleConstantsGen.generateConstantInit(jarEntries); stringConstantsGen.generateConstantInit(jarEntries); tupleTypeConstantsGen.generateClass(jarEntries); @@ -100,6 +107,10 @@ public void generateConstants(Map jarEntries) { refTypeConstantsGen.generateClass(jarEntries); } + public void generateGetBErrorType(MethodVisitor mv, String varName) { + errorTypeConstantsGen.generateGetBErrorType(mv, varName); + } + public void generateGetBUnionType(MethodVisitor mv, String varName) { unionTypeConstantsGen.generateGetBUnionType(mv, varName); } @@ -114,6 +125,8 @@ public void generateGetBTypeRefType(MethodVisitor mv, String varName) { public String getTypeConstantsVar(BType type, SymbolTable symbolTable) { switch (type.tag) { + case TypeTags.ERROR: + return errorTypeConstantsGen.add((BErrorType) type); case TypeTags.ARRAY: return arrayTypeConstantsGen.add((BArrayType) type); case TypeTags.TUPLE: diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmCreateTypeGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmCreateTypeGen.java index 07c4fefeb19b..a690d6797869 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmCreateTypeGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmCreateTypeGen.java @@ -671,6 +671,10 @@ public JvmUnionTypeGen getJvmUnionTypeGen() { return jvmUnionTypeGen; } + public JvmErrorTypeGen getJvmErrorTypeGen() { + return jvmErrorTypeGen; + } + public JvmTupleTypeGen getJvmTupleTypeGen() { return jvmTupleTypeGen; } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmErrorTypeConstantsGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmErrorTypeConstantsGen.java new file mode 100644 index 000000000000..94117c3df3ca --- /dev/null +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmErrorTypeConstantsGen.java @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com) All Rights Reserved. + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.ballerinalang.compiler.bir.codegen.split.constants; + +import org.ballerinalang.model.elements.PackageID; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.FieldVisitor; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; +import org.wso2.ballerinalang.compiler.bir.codegen.BallerinaClassWriter; +import org.wso2.ballerinalang.compiler.bir.codegen.JvmCodeGenUtil; +import org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants; +import org.wso2.ballerinalang.compiler.bir.codegen.internal.BTypeHashComparator; +import org.wso2.ballerinalang.compiler.bir.codegen.split.types.JvmErrorTypeGen; +import org.wso2.ballerinalang.compiler.semantics.model.types.BErrorType; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +import static org.objectweb.asm.ClassWriter.COMPUTE_FRAMES; +import static org.objectweb.asm.Opcodes.ACC_FINAL; +import static org.objectweb.asm.Opcodes.ACC_PUBLIC; +import static org.objectweb.asm.Opcodes.ACC_STATIC; +import static org.objectweb.asm.Opcodes.GETSTATIC; +import static org.objectweb.asm.Opcodes.INVOKESTATIC; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_ERROR_TYPE_INIT_METHOD_PREFIX; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_ERROR_TYPE_IMPL; +import static org.wso2.ballerinalang.compiler.bir.codegen.split.constants.JvmConstantGenCommons.genMethodReturn; +import static org.wso2.ballerinalang.compiler.bir.codegen.split.constants.JvmConstantGenCommons.generateConstantsClassInit; + +/** + * Generates the JVM class for the ballerina error types as constants for a given module. + * Anonymous distinct error types are generated in this class. + * + * @since 2201.4.0 + */ +public class JvmErrorTypeConstantsGen { + + private final String errorVarConstantsClass; + private int constantIndex = 0; + private JvmErrorTypeGen jvmErrorTypeGen; + private final ClassWriter cw; + private MethodVisitor mv; + private int methodCount; + private final List funcNames; + private final Map errorTypeVarMap; + + public JvmErrorTypeConstantsGen(PackageID packageID, BTypeHashComparator bTypeHashComparator) { + errorVarConstantsClass = JvmCodeGenUtil.getModuleLevelClassName(packageID, + JvmConstants.ERROR_TYPE_CONSTANT_CLASS_NAME); + cw = new BallerinaClassWriter(COMPUTE_FRAMES); + generateConstantsClassInit(cw, errorVarConstantsClass); + visitErrorTypeInitMethod(); + funcNames = new ArrayList<>(); + errorTypeVarMap = new TreeMap<>(bTypeHashComparator); + } + + public void setJvmErrorTypeGen(JvmErrorTypeGen jvmErrorTypeGen) { + this.jvmErrorTypeGen = jvmErrorTypeGen; + } + + public String add(BErrorType type) { + String varName = errorTypeVarMap.get(type); + if (varName == null) { + varName = generateBErrorInits(type); + errorTypeVarMap.put(type, varName); + } + return varName; + } + + private void visitErrorTypeInitMethod() { + mv = cw.visitMethod(ACC_STATIC, B_ERROR_TYPE_INIT_METHOD_PREFIX + methodCount++, + "()V", null, null); + } + + private String generateBErrorInits(BErrorType type) { + String varName = JvmConstants.ERROR_TYPE_VAR_PREFIX + constantIndex++; + visitBErrorField(varName); + createBErrorType(mv, type, varName); + genPopulateMethod(type, varName); + return varName; + } + + private void genPopulateMethod(BErrorType type, String varName) { + String methodName = "$populate" + varName; + funcNames.add(methodName); + MethodVisitor methodVisitor = cw.visitMethod(ACC_STATIC, methodName, "()V", null, null); + methodVisitor.visitCode(); + generateGetBErrorType(methodVisitor, varName); + jvmErrorTypeGen.populateError(methodVisitor, type); + genMethodReturn(methodVisitor); + } + + private void createBErrorType(MethodVisitor mv, BErrorType errorType, String varName) { + jvmErrorTypeGen.createErrorType(mv, errorType, errorType.tsymbol.name.value); + mv.visitFieldInsn(Opcodes.PUTSTATIC, errorVarConstantsClass, varName, + GET_ERROR_TYPE_IMPL); + } + + private void visitBErrorField(String varName) { + FieldVisitor fv = cw.visitField(ACC_PUBLIC + ACC_FINAL + ACC_STATIC, varName, + GET_ERROR_TYPE_IMPL, null, null); + fv.visitEnd(); + } + + public void generateGetBErrorType(MethodVisitor mv, String varName) { + mv.visitFieldInsn(GETSTATIC, errorVarConstantsClass, varName, + GET_ERROR_TYPE_IMPL); + } + + public void generateClass(Map jarEntries) { + genMethodReturn(mv); + visitErrorTypeInitMethod(); + for (String funcName : funcNames) { + mv.visitMethodInsn(INVOKESTATIC, errorVarConstantsClass, funcName, "()V", false); + } + genMethodReturn(mv); + generateStaticInitializer(cw); + cw.visitEnd(); + jarEntries.put(errorVarConstantsClass + ".class", cw.toByteArray()); + } + + private void generateStaticInitializer(ClassWriter cw) { + MethodVisitor methodVisitor = cw.visitMethod(ACC_STATIC, "", "()V", null, null); + for (int i = 0; i < methodCount; i++) { + methodVisitor.visitMethodInsn(INVOKESTATIC, errorVarConstantsClass, + B_ERROR_TYPE_INIT_METHOD_PREFIX + i, + "()V", false); + } + genMethodReturn(methodVisitor); + } +} From b859a5eb2844fea9caf9739bdf3fd4e501740fd4 Mon Sep 17 00:00:00 2001 From: azinneera Date: Mon, 21 Nov 2022 20:13:15 +0530 Subject: [PATCH 071/450] Revert "Add client decl stmt tests" This reverts commit 365725f3be8b6d6090d8c91f465a4b19d008dda2. --- .../declarations/ClientDeclarationTest.java | 2 +- .../ClientDeclarationStatementTest.java | 164 ------------------ ...nt_decl_undefined_prefix_negative_test.bal | 4 +- ...t_prefix_as_xmlns_prefix_negative_test.bal | 23 --- ...l_stmt_redeclared_prefix_negative_test.bal | 49 ------ .../clientdeclstmt/client_decl_stmt_test.bal | 23 --- ...cl_stmt_undefined_prefix_negative_test.bal | 19 -- .../src/test/resources/testng.xml | 1 - 8 files changed, 4 insertions(+), 281 deletions(-) delete mode 100644 tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/clientdeclstmt/ClientDeclarationStatementTest.java delete mode 100644 tests/jballerina-unit-test/src/test/resources/test-src/statements/clientdeclstmt/client_decl_stmt_client_prefix_as_xmlns_prefix_negative_test.bal delete mode 100644 tests/jballerina-unit-test/src/test/resources/test-src/statements/clientdeclstmt/client_decl_stmt_redeclared_prefix_negative_test.bal delete mode 100644 tests/jballerina-unit-test/src/test/resources/test-src/statements/clientdeclstmt/client_decl_stmt_test.bal delete mode 100644 tests/jballerina-unit-test/src/test/resources/test-src/statements/clientdeclstmt/client_decl_stmt_undefined_prefix_negative_test.bal diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/module/declarations/ClientDeclarationTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/module/declarations/ClientDeclarationTest.java index ae019fee527c..f587f9a58cc0 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/module/declarations/ClientDeclarationTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/module/declarations/ClientDeclarationTest.java @@ -42,7 +42,7 @@ public void testUndefinedPrefixNegative() { CompileResult result = BCompileUtil.compile( "test-src/module.declarations/client-decl/client_decl_undefined_prefix_negative_test.bal"); int index = 0; - BAssertUtil.validateError(result, index++, "undefined module 'foo'", 17, 11); + BAssertUtil.validateError(result, index++, "undefined module 'foo'", 18, 15); Assert.assertEquals(result.getErrorCount(), index); } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/clientdeclstmt/ClientDeclarationStatementTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/clientdeclstmt/ClientDeclarationStatementTest.java deleted file mode 100644 index 4cad42a56037..000000000000 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/clientdeclstmt/ClientDeclarationStatementTest.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.ballerinalang.test.statements.clientdeclstmt; - -import org.ballerinalang.test.BAssertUtil; -import org.ballerinalang.test.BCompileUtil; -import org.ballerinalang.test.CompileResult; -import org.testng.Assert; -import org.testng.annotations.Test; -import org.wso2.ballerinalang.compiler.tree.BLangBlockFunctionBody; -import org.wso2.ballerinalang.compiler.tree.BLangClientDeclaration; -import org.wso2.ballerinalang.compiler.tree.statements.BLangClientDeclarationStatement; -import org.wso2.ballerinalang.compiler.tree.statements.BLangStatement; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * Tests for client declaration statements. - * - * @since 2201.3.0 - */ -public class ClientDeclarationStatementTest { - - private static final String REDECLARED_PREFIX_ERROR = "redeclared symbol '%s'"; - private static final String NO_MODULE_GENERATED_ERROR = "no module generated for the client declaration"; - private static final String NOT_SUPPORTED_IN_SINGLE_FILE_ERROR = - "client declaration is not supported with standalone Ballerina file"; - - @Test - public void testInvalidRedeclaredPrefixNegative() { - CompileResult result = BCompileUtil.compile( - "test-src/statements/clientdeclstmt/client_decl_stmt_redeclared_prefix_negative_test.bal"); - int index = 0; - BAssertUtil.validateError(result, index++, NOT_SUPPORTED_IN_SINGLE_FILE_ERROR, 22, 5); - BAssertUtil.validateError(result, index++, NOT_SUPPORTED_IN_SINGLE_FILE_ERROR, 24, 5); - BAssertUtil.validateError(result, index++, NOT_SUPPORTED_IN_SINGLE_FILE_ERROR, 25, 5); - BAssertUtil.validateError(result, index++, NOT_SUPPORTED_IN_SINGLE_FILE_ERROR, 27, 5); - BAssertUtil.validateError(result, index++, NOT_SUPPORTED_IN_SINGLE_FILE_ERROR, 30, 5); - BAssertUtil.validateError(result, index++, NOT_SUPPORTED_IN_SINGLE_FILE_ERROR, 31, 5); - BAssertUtil.validateError(result, index++, NOT_SUPPORTED_IN_SINGLE_FILE_ERROR, 34, 5); - BAssertUtil.validateError(result, index++, NOT_SUPPORTED_IN_SINGLE_FILE_ERROR, 35, 5); - BAssertUtil.validateError(result, index++, NOT_SUPPORTED_IN_SINGLE_FILE_ERROR, 38, 5); - BAssertUtil.validateError(result, index++, NOT_SUPPORTED_IN_SINGLE_FILE_ERROR, 40, 5); - BAssertUtil.validateError(result, index++, NOT_SUPPORTED_IN_SINGLE_FILE_ERROR, 44, 9); - - BAssertUtil.validateError(result, index++, NO_MODULE_GENERATED_ERROR, 22, 5); - BAssertUtil.validateError(result, index++, getRedeclaredSymbolError("foo"), 22, 54); - BAssertUtil.validateError(result, index++, NO_MODULE_GENERATED_ERROR, 24, 5); - BAssertUtil.validateError(result, index++, getRedeclaredSymbolError("bar"), 24, 54); - BAssertUtil.validateError(result, index++, NO_MODULE_GENERATED_ERROR, 25, 5); - BAssertUtil.validateError(result, index++, getRedeclaredSymbolError("bar"), 25, 56); - BAssertUtil.validateError(result, index++, NO_MODULE_GENERATED_ERROR, 27, 5); - BAssertUtil.validateError(result, index++, getRedeclaredSymbolError("baz"), 27, 55); - BAssertUtil.validateError(result, index++, getRedeclaredSymbolError("baz"), 28, 5); - BAssertUtil.validateError(result, index++, NO_MODULE_GENERATED_ERROR, 30, 5); - BAssertUtil.validateError(result, index++, NO_MODULE_GENERATED_ERROR, 31, 5); - BAssertUtil.validateError(result, index++, getRedeclaredSymbolError("qux"), 31, 56); - BAssertUtil.validateError(result, index++, getRedeclaredSymbolError("qux"), 32, 35); - BAssertUtil.validateError(result, index++, NO_MODULE_GENERATED_ERROR, 34, 5); - BAssertUtil.validateError(result, index++, NO_MODULE_GENERATED_ERROR, 35, 5); - BAssertUtil.validateError(result, index++, getRedeclaredSymbolError("quux"), 35, 54); - BAssertUtil.validateError(result, index++, NO_MODULE_GENERATED_ERROR, 38, 5); - BAssertUtil.validateError(result, index++, getRedeclaredSymbolError("corge"), 38, 54); - BAssertUtil.validateError(result, index++, NO_MODULE_GENERATED_ERROR, 40, 5); - BAssertUtil.validateError(result, index++, NO_MODULE_GENERATED_ERROR, 44, 9); - BAssertUtil.validateError(result, index++, getRedeclaredSymbolError("foobar"), 44, 56); - Assert.assertEquals(result.getErrorCount(), index); - } - - @Test - public void testClientDeclPrefixAsXmlnsPrefixNegative() { - CompileResult result = BCompileUtil.compile( - "test-src/statements/clientdeclstmt/client_decl_stmt_client_prefix_as_xmlns_prefix_negative_test.bal"); - int index = 0; - BAssertUtil.validateError(result, index++, NOT_SUPPORTED_IN_SINGLE_FILE_ERROR, 18, 5); - BAssertUtil.validateError(result, index++, NO_MODULE_GENERATED_ERROR, 18, 5); - BAssertUtil.validateError(result, index++, "cannot find xml namespace prefix 'foo'", 20, 19); - BAssertUtil.validateError(result, index++, "cannot find xml namespace prefix 'foo'", 21, 16); - BAssertUtil.validateError(result, index++, "cannot find xml namespace prefix 'foo'", 22, 24); - Assert.assertEquals(result.getErrorCount(), index); - } - - @Test - public void testUndefinedPrefixNegative() { - CompileResult result = BCompileUtil.compile( - "test-src/statements/clientdeclstmt/client_decl_stmt_undefined_prefix_negative_test.bal"); - int index = 0; - BAssertUtil.validateError(result, index++, "undefined module 'foo'", 18, 15); - Assert.assertEquals(result.getErrorCount(), index); - } - - @Test - public void testUnderscoreAsPrefixNegative() { - CompileResult result = BCompileUtil.compile( - "test-src/statements/clientdeclstmt/client_decl_stmt_underscore_as_prefix_negative_test.bal"); - int index = 0; - BAssertUtil.validateError(result, index++, NOT_SUPPORTED_IN_SINGLE_FILE_ERROR, 18, 5); - BAssertUtil.validateError(result, index++, NO_MODULE_GENERATED_ERROR, 18, 5); - BAssertUtil.validateError(result, index++, "'_' is a keyword, and may not be used as an identifier", 18, 54); - Assert.assertEquals(result.getErrorCount(), index); - } - - @Test - public void testClientDeclStmt() { - CompileResult result = BCompileUtil.compile( - "test-src/statements/clientdeclstmt/client_decl_stmt_test.bal"); - List stmts = ((BLangBlockFunctionBody) result.getAST().getFunctions().get(0).getBody()).stmts; - Assert.assertEquals(stmts.size(), 3); - - final Map expectedDeclDetails = Map.ofEntries( - Map.entry("foo", "http://www.example.com/apis/one.yaml"), - Map.entry("bar", "http://www.example.com/apis/two.yaml"), - Map.entry("baz", "http://www.example.com/apis/two.yaml") - ); - final Set expectedPrefixes = expectedDeclDetails.keySet(); - - for (int i = 0; i < 3; i++) { - BLangStatement statement = stmts.get(i); - Assert.assertTrue(statement instanceof BLangClientDeclarationStatement); - - BLangClientDeclaration clientDeclaration = ((BLangClientDeclarationStatement) statement).clientDeclaration; - String prefix = clientDeclaration.prefix.value; - Assert.assertTrue(expectedPrefixes.contains(prefix)); - Assert.assertEquals(clientDeclaration.uri.value, expectedDeclDetails.get(prefix)); - } - } - - @Test - public void testClientAnnotationsNegative() { - CompileResult result = BCompileUtil.compile( - "test-src/statements/clientdeclstmt/client_decl_stmt_annotations_negative_test.bal"); - int index = 0; - BAssertUtil.validateError(result, index++, NOT_SUPPORTED_IN_SINGLE_FILE_ERROR, 22, 5); - BAssertUtil.validateError(result, index++, "annotation 'A7' is not allowed on client", 22, 5); - BAssertUtil.validateError(result, index++, NO_MODULE_GENERATED_ERROR, 22, 5); - BAssertUtil.validateError(result, index++, "annotation value expected for annotation of record type 'record " + - "{| int i; |}' with required fields", 23, 5); - BAssertUtil.validateError(result, index++, "cannot specify more than one annotation value for annotation " + - "'A5'", 23, 5); - BAssertUtil.validateError(result, index++, "missing non-defaultable required record field 'i'", 24, 9); - Assert.assertEquals(result.getErrorCount(), index); - } - - private String getRedeclaredSymbolError(String prefix) { - return String.format(REDECLARED_PREFIX_ERROR, prefix); - } -} diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/module.declarations/client-decl/client_decl_undefined_prefix_negative_test.bal b/tests/jballerina-unit-test/src/test/resources/test-src/module.declarations/client-decl/client_decl_undefined_prefix_negative_test.bal index 1a69f74e770b..8c87fb423ecc 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/module.declarations/client-decl/client_decl_undefined_prefix_negative_test.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/module.declarations/client-decl/client_decl_undefined_prefix_negative_test.bal @@ -14,4 +14,6 @@ // specific language governing permissions and limitations // under the License. -int[] _ = foo:x; +public function main() { + int[] _ = foo:x; +} diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/statements/clientdeclstmt/client_decl_stmt_client_prefix_as_xmlns_prefix_negative_test.bal b/tests/jballerina-unit-test/src/test/resources/test-src/statements/clientdeclstmt/client_decl_stmt_client_prefix_as_xmlns_prefix_negative_test.bal deleted file mode 100644 index c2d985065677..000000000000 --- a/tests/jballerina-unit-test/src/test/resources/test-src/statements/clientdeclstmt/client_decl_stmt_client_prefix_as_xmlns_prefix_negative_test.bal +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -// -// WSO2 Inc. licenses this file to you under the Apache License, -// Version 2.0 (the "License"); you may not use this file except -// in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -public function main() { - client "http://www.example.com/apis/one.yaml" as foo; - - xml x = xml ``; - xml _ = x.; - string _ = check x.foo:m; -} diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/statements/clientdeclstmt/client_decl_stmt_redeclared_prefix_negative_test.bal b/tests/jballerina-unit-test/src/test/resources/test-src/statements/clientdeclstmt/client_decl_stmt_redeclared_prefix_negative_test.bal deleted file mode 100644 index 1c4b4e971d27..000000000000 --- a/tests/jballerina-unit-test/src/test/resources/test-src/statements/clientdeclstmt/client_decl_stmt_redeclared_prefix_negative_test.bal +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -// -// WSO2 Inc. licenses this file to you under the Apache License, -// Version 2.0 (the "License"); you may not use this file except -// in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -import ballerina/lang.'int as foo; -import ballerina/lang.'string as bar; -import ballerina/lang.'float as baz; - -public function main() { - client "http://www.example.com/apis/one.yaml" as foo; - - client "http://www.example.com/apis/two.yaml" as bar; - client "http://www.example.com/apis/three.yaml" as bar; - - client "http://www.example.com/apis/four.yaml" as baz; - xmlns "http://example.com" as baz; - - client "http://www.example.com/apis/six.yaml" as qux; - client "http://www.example.com/apis/seven.yaml" as qux; - xmlns "http://example.com" as qux; - - client "http://www.example.com/apis/nigth.yaml" as quux; - client "http://www.example.com/apis/ten.yaml" as quux; - - xmlns "http://example.com" as corge; - client "http://www.example.com/apis/ten.yaml" as corge; - - client "http://www.example.com/apis/ten.yaml" as foobar; - - boolean b = true; - if b { - client "http://example.com/apis/three.yaml" as foobar; - } - - foo:Signed8 _ = 1; - bar:Char _ = "a"; -} diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/statements/clientdeclstmt/client_decl_stmt_test.bal b/tests/jballerina-unit-test/src/test/resources/test-src/statements/clientdeclstmt/client_decl_stmt_test.bal deleted file mode 100644 index c4758ed0baa5..000000000000 --- a/tests/jballerina-unit-test/src/test/resources/test-src/statements/clientdeclstmt/client_decl_stmt_test.bal +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -// -// WSO2 Inc. licenses this file to you under the Apache License, -// Version 2.0 (the "License"); you may not use this file except -// in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -function fn() { - client "http://www.example.com/apis/one.yaml" as foo; - - client "http://www.example.com/apis/two.yaml" as bar; - - client "http://www.example.com/apis/two.yaml" as baz; -} diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/statements/clientdeclstmt/client_decl_stmt_undefined_prefix_negative_test.bal b/tests/jballerina-unit-test/src/test/resources/test-src/statements/clientdeclstmt/client_decl_stmt_undefined_prefix_negative_test.bal deleted file mode 100644 index 8c87fb423ecc..000000000000 --- a/tests/jballerina-unit-test/src/test/resources/test-src/statements/clientdeclstmt/client_decl_stmt_undefined_prefix_negative_test.bal +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -// -// WSO2 Inc. licenses this file to you under the Apache License, -// Version 2.0 (the "License"); you may not use this file except -// in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -public function main() { - int[] _ = foo:x; -} diff --git a/tests/jballerina-unit-test/src/test/resources/testng.xml b/tests/jballerina-unit-test/src/test/resources/testng.xml index 1e48bc9a37ea..831fd4ea2737 100644 --- a/tests/jballerina-unit-test/src/test/resources/testng.xml +++ b/tests/jballerina-unit-test/src/test/resources/testng.xml @@ -95,7 +95,6 @@ - From b21a05b42e58a46f82fc5d52e1df8465ff06c0ef Mon Sep 17 00:00:00 2001 From: Gayal Dassanayake Date: Tue, 22 Nov 2022 05:53:14 +0530 Subject: [PATCH 072/450] Break at error diag in MockAnnotationProcessor --- .../ballerinalang/testerina/core/MockAnnotationProcessor.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java index 434930447682..b5f1900f1ea2 100644 --- a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java +++ b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java @@ -208,6 +208,7 @@ public void process(FunctionNode functionNode, List an if (functionToMockID == null) { diagnosticLog.logDiagnostic(DiagnosticSeverity.ERROR, attachmentNode.getPosition(), "could not find module specified "); + break; } BType functionToMockType = getFunctionType(packageEnvironmentMap, functionToMockID, vals[1]); @@ -219,10 +220,12 @@ public void process(FunctionNode functionNode, List an diagnosticLog.logDiagnostic(DiagnosticSeverity.ERROR, ((BLangFunction) functionNode).pos, "incompatible types: expected " + functionToMockType.toString() + " but found " + mockFunctionType.toString()); + break; } } else { diagnosticLog.logDiagnostic(DiagnosticSeverity.ERROR, attachmentNode.getPosition(), "could not find functions in module"); + break; } //Creating a bLangTestablePackage to add a mock function From 94f15867c923001aaef9a2e8c0d7293096dc51e8 Mon Sep 17 00:00:00 2001 From: Nadeeshan96 Date: Tue, 22 Nov 2022 11:51:49 +0530 Subject: [PATCH 073/450] Add tests for type testing distinct types --- .../binaryoperations/TypeTestExprTest.java | 3 +- .../binaryoperations/type-test-expr.bal | 174 ++++++++++++++++++ 2 files changed, 176 insertions(+), 1 deletion(-) diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/binaryoperations/TypeTestExprTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/binaryoperations/TypeTestExprTest.java index afd327ebf822..fa9c126b066c 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/binaryoperations/TypeTestExprTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/binaryoperations/TypeTestExprTest.java @@ -769,7 +769,8 @@ public Object[] dataToTypeTestExpressions() { "testRecordsWithOptionalFields", "testReadOnlyArrays", "testTypeTestExprWithSingletons", - "testResourceMethodTyping" + "testResourceMethodTyping", + "testIsExpressionWithDistinctErrors" }; } } diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/expressions/binaryoperations/type-test-expr.bal b/tests/jballerina-unit-test/src/test/resources/test-src/expressions/binaryoperations/type-test-expr.bal index e88e423b69c0..73afce23d6b3 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/expressions/binaryoperations/type-test-expr.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/expressions/binaryoperations/type-test-expr.bal @@ -1808,3 +1808,177 @@ function testResourceMethodTyping() { test:assertTrue(result); } + +// ========================== distinct types ========================== + +type ListenerError distinct error; + +type ClientError distinct error; + +type DistictListenerError distinct ListenerError; + +type ErrType error; + +distinct error err1 = error("err1"); +distinct error err2 = error("err2"); +ErrType errtype1 = error("errtype1"); +error err3 = error("error!"); +ListenerError listerr1 = error("listerr1"); +ListenerError listerr2 = error("listerr2"); +ClientError clierr1 = error("clierr1"); +distinct ListenerError distlisterr1 = error("distlisterr1"); +distinct ListenerError distlisterr2 = error("distlisterr2"); +distinct ClientError distclierr1 = error("distclierr1"); + +function testIsExpressionWithDistinctErrors() { + distinct error err11 = error("err11"); + distinct error err21 = error("err21"); + ErrType errtype11 = error("errtype11"); + error err31 = error("error1!"); + ListenerError listerr11 = error("listerr11"); + ListenerError listerr21 = error("listerr21"); + ClientError clierr11 = error("clierr11"); + distinct ListenerError distlisterr11 = error("distlisterr11"); + distinct ListenerError distlisterr21 = error("distlisterr21"); + distinct ClientError distclierr11 = error("distclierr11"); + + // global variables + test:assertEquals(err1 is distinct error, false); + test:assertEquals(err1 is ErrType, true); + test:assertEquals(err1 is error, true); + test:assertEquals(err1 is ListenerError, false); + test:assertEquals(err1 is distinct ListenerError, false); + test:assertEquals(err1 is DistictListenerError, false); + + test:assertEquals(errtype1 is distinct error, false); + test:assertEquals(errtype1 is ErrType, true); + test:assertEquals(errtype1 is error, true); + test:assertEquals(errtype1 is ListenerError, false); + test:assertEquals(errtype1 is distinct ListenerError, false); + test:assertEquals(errtype1 is DistictListenerError, false); + + test:assertEquals(err3 is distinct error, false); + test:assertEquals(err3 is ErrType, true); + test:assertEquals(err3 is error, true); + test:assertEquals(err3 is ListenerError, false); + test:assertEquals(err3 is distinct ListenerError, false); + test:assertEquals(err3 is DistictListenerError, false); + + test:assertEquals(listerr1 is distinct error, false); + test:assertEquals(listerr1 is ErrType, true); + test:assertEquals(listerr1 is error, true); + test:assertEquals(listerr1 is ListenerError, true); + // https://github.com/ballerina-platform/ballerina-lang/issues/38130 + // test:assertEquals(listerr1 is distinct ListenerError, false); + test:assertEquals(listerr1 is ClientError, false); + test:assertEquals(listerr1 is distinct ClientError, false); + test:assertEquals(listerr1 is DistictListenerError, false); + + test:assertEquals(distlisterr1 is distinct error, false); + test:assertEquals(distlisterr1 is ErrType, true); + test:assertEquals(distlisterr1 is error, true); + test:assertEquals(distlisterr1 is ListenerError, true); + // https://github.com/ballerina-platform/ballerina-lang/issues/38130 + // test:assertEquals(distlisterr1 is distinct ListenerError, false); + test:assertEquals(distlisterr1 is ClientError, false); + test:assertEquals(distlisterr1 is distinct ClientError, false); + test:assertEquals(distlisterr1 is DistictListenerError, false); + + // local variables + test:assertEquals(err11 is distinct error, false); + test:assertEquals(err11 is ErrType, true); + test:assertEquals(err11 is error, true); + test:assertEquals(err11 is ListenerError, false); + test:assertEquals(err11 is distinct ListenerError, false); + test:assertEquals(err11 is DistictListenerError, false); + + test:assertEquals(errtype11 is distinct error, false); + test:assertEquals(errtype11 is ErrType, true); + test:assertEquals(errtype11 is error, true); + test:assertEquals(errtype11 is ListenerError, false); + test:assertEquals(errtype11 is distinct ListenerError, false); + test:assertEquals(errtype11 is DistictListenerError, false); + + test:assertEquals(err31 is distinct error, false); + test:assertEquals(err31 is ErrType, true); + test:assertEquals(err31 is error, true); + test:assertEquals(err31 is ListenerError, false); + test:assertEquals(err31 is distinct ListenerError, false); + test:assertEquals(err31 is DistictListenerError, false); + + test:assertEquals(listerr11 is distinct error, false); + test:assertEquals(listerr11 is ErrType, true); + test:assertEquals(listerr11 is error, true); + test:assertEquals(listerr11 is ListenerError, true); + // https://github.com/ballerina-platform/ballerina-lang/issues/38130 + // test:assertEquals(listerr11 is distinct ListenerError, false); + test:assertEquals(listerr11 is ClientError, false); + test:assertEquals(listerr11 is distinct ClientError, false); + test:assertEquals(listerr11 is DistictListenerError, false); + + test:assertEquals(distlisterr11 is distinct error, false); + test:assertEquals(distlisterr11 is ErrType, true); + test:assertEquals(distlisterr11 is error, true); + test:assertEquals(distlisterr11 is ListenerError, true); + // https://github.com/ballerina-platform/ballerina-lang/issues/38130 + // test:assertEquals(distlisterr11 is distinct ListenerError, false); + test:assertEquals(distlisterr11 is ClientError, false); + test:assertEquals(distlisterr11 is distinct ClientError, false); + test:assertEquals(distlisterr11 is DistictListenerError, false); + + testIsExpressionWithDistinctErrors2(); +} + +function testIsExpressionWithDistinctErrors2() { + distinct error err12 = error("err12"); + distinct error err22 = error("err22"); + ErrType errtype12 = error("errtype12"); + error err32 = error("error2!"); + ListenerError listerr12 = error("listerr12"); + ListenerError listerr22 = error("listerr22"); + ClientError clierr12 = error("clierr12"); + distinct ListenerError distlisterr12 = error("distlisterr12"); + distinct ListenerError distlisterr22 = error("distlisterr22"); + distinct ClientError distclierr12 = error("distclierr12"); + + test:assertEquals(err12 is distinct error, false); + test:assertEquals(err12 is ErrType, true); + test:assertEquals(err12 is error, true); + test:assertEquals(err12 is ListenerError, false); + test:assertEquals(err12 is distinct ListenerError, false); + test:assertEquals(err12 is DistictListenerError, false); + + test:assertEquals(errtype12 is distinct error, false); + test:assertEquals(errtype12 is ErrType, true); + test:assertEquals(errtype12 is error, true); + test:assertEquals(errtype12 is ListenerError, false); + test:assertEquals(errtype12 is distinct ListenerError, false); + test:assertEquals(errtype12 is DistictListenerError, false); + + test:assertEquals(err32 is distinct error, false); + test:assertEquals(err32 is ErrType, true); + test:assertEquals(err32 is error, true); + test:assertEquals(err32 is ListenerError, false); + test:assertEquals(err32 is distinct ListenerError, false); + test:assertEquals(err32 is DistictListenerError, false); + + test:assertEquals(listerr12 is distinct error, false); + test:assertEquals(listerr12 is ErrType, true); + test:assertEquals(listerr12 is error, true); + test:assertEquals(listerr12 is ListenerError, true); + // https://github.com/ballerina-platform/ballerina-lang/issues/38130 + // test:assertEquals(listerr12 is distinct ListenerError, false); + test:assertEquals(listerr12 is ClientError, false); + test:assertEquals(listerr12 is distinct ClientError, false); + test:assertEquals(listerr12 is DistictListenerError, false); + + test:assertEquals(distlisterr12 is distinct error, false); + test:assertEquals(distlisterr12 is ErrType, true); + test:assertEquals(distlisterr12 is error, true); + test:assertEquals(distlisterr12 is ListenerError, true); + // https://github.com/ballerina-platform/ballerina-lang/issues/38130 + // test:assertEquals(distlisterr12 is distinct ListenerError, false); + test:assertEquals(distlisterr12 is ClientError, false); + test:assertEquals(distlisterr12 is distinct ClientError, false); + test:assertEquals(distlisterr12 is DistictListenerError, false); +} From b497deda2cc9b6889cda532881e59629f3311658 Mon Sep 17 00:00:00 2001 From: mohan Date: Tue, 22 Nov 2022 12:06:47 +0530 Subject: [PATCH 074/450] Add initial impl on Add documentation code action for enums and const --- .../codeaction/CodeActionNodeAnalyzer.java | 2 + .../docs/AddAllDocumentationCodeAction.java | 4 +- .../docs/AddDocumentationCodeAction.java | 4 +- .../command/docs/DocumentationGenerator.java | 44 +++++++++++++++++++ .../codeaction/AddDocumentationTest.java | 2 + .../config/singleDocGeneration11.json | 40 +++++++++++++++++ .../config/singleDocGeneration12.json | 40 +++++++++++++++++ .../source/singleDocGeneration.bal | 10 ++++- 8 files changed, 143 insertions(+), 3 deletions(-) create mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/add-documentation/config/singleDocGeneration11.json create mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/add-documentation/config/singleDocGeneration12.json diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/CodeActionNodeAnalyzer.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/CodeActionNodeAnalyzer.java index aeb6627b8b03..96423f5fc11b 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/CodeActionNodeAnalyzer.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/CodeActionNodeAnalyzer.java @@ -286,6 +286,7 @@ public void visit(ModuleVariableDeclarationNode node) { @Override public void visit(ConstantDeclarationNode node) { checkAndSetCodeActionNode(node); + checkAndSetSyntaxKind(node.kind()); Optional visibilityQualifier = node.visibilityQualifier(); int startOffset = visibilityQualifier.map(token -> token.textRange().startOffset()) @@ -307,6 +308,7 @@ public void visit(ConstantDeclarationNode node) { @Override public void visit(EnumDeclarationNode node) { checkAndSetCodeActionNode(node); + checkAndSetSyntaxKind(node.kind()); int startOffset = node.qualifier().map(token -> token.textRange().startOffset()) .orElseGet(() -> node.enumKeywordToken().textRange().startOffset()); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/docs/AddAllDocumentationCodeAction.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/docs/AddAllDocumentationCodeAction.java index 64615d8ec301..739a606e089c 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/docs/AddAllDocumentationCodeAction.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/docs/AddAllDocumentationCodeAction.java @@ -52,7 +52,9 @@ public List getSyntaxKinds() { SyntaxKind.RECORD_TYPE_DESC, SyntaxKind.METHOD_DECLARATION, SyntaxKind.ANNOTATION_DECLARATION, - SyntaxKind.OBJECT_METHOD_DEFINITION); + SyntaxKind.OBJECT_METHOD_DEFINITION, + SyntaxKind.ENUM_DECLARATION, + SyntaxKind.CONST_DECLARATION); } /** diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/docs/AddDocumentationCodeAction.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/docs/AddDocumentationCodeAction.java index b053f8738beb..083e15f8e7b4 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/docs/AddDocumentationCodeAction.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/docs/AddDocumentationCodeAction.java @@ -57,7 +57,9 @@ public List getSyntaxKinds() { SyntaxKind.METHOD_DECLARATION, SyntaxKind.OBJECT_METHOD_DEFINITION, SyntaxKind.ANNOTATION_DECLARATION, - SyntaxKind.MODULE_VAR_DECL); + SyntaxKind.MODULE_VAR_DECL, + SyntaxKind.ENUM_DECLARATION, + SyntaxKind.CONST_DECLARATION); } @Override diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/command/docs/DocumentationGenerator.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/command/docs/DocumentationGenerator.java index 3f910ebdf341..7f85e170e213 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/command/docs/DocumentationGenerator.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/command/docs/DocumentationGenerator.java @@ -20,7 +20,9 @@ import io.ballerina.compiler.syntax.tree.AnnotationDeclarationNode; import io.ballerina.compiler.syntax.tree.AnnotationNode; import io.ballerina.compiler.syntax.tree.ClassDefinitionNode; +import io.ballerina.compiler.syntax.tree.ConstantDeclarationNode; import io.ballerina.compiler.syntax.tree.DefaultableParameterNode; +import io.ballerina.compiler.syntax.tree.EnumDeclarationNode; import io.ballerina.compiler.syntax.tree.FunctionDefinitionNode; import io.ballerina.compiler.syntax.tree.FunctionSignatureNode; import io.ballerina.compiler.syntax.tree.MetadataNode; @@ -119,6 +121,12 @@ public static Optional getDocumentationEditForNode(NonTermina case CLASS_DEFINITION: { return Optional.of(generateClassDocumentation((ClassDefinitionNode) node, syntaxTree)); } + case CONST_DECLARATION: { + return Optional.of(generateConstantDocumentation((ConstantDeclarationNode) node, syntaxTree)); + } + case ENUM_DECLARATION: { + return Optional.of(generateEnumDocumentation((EnumDeclarationNode) node, syntaxTree)); + } case MODULE_VAR_DECL: { return Optional.of(generateModuleVarDocumentation((ModuleVariableDeclarationNode) node, syntaxTree)); } @@ -171,6 +179,42 @@ private static DocAttachmentInfo generateServiceDocumentation(ServiceDeclaration return new DocAttachmentInfo(desc, docStart, getPadding(serviceDeclrNode, syntaxTree)); } + /** + * Generate documentation for constant declaration node. + * + * @param constantDeclarationNode constant declaration node + * @param syntaxTree syntaxTree {@link SyntaxTree} + * @return generated doc attachment + */ + private static DocAttachmentInfo generateConstantDocumentation(ConstantDeclarationNode constantDeclarationNode, + SyntaxTree syntaxTree) { + Optional metadata = constantDeclarationNode.metadata(); + Position docStart = PositionUtil.toRange(constantDeclarationNode.lineRange()).getStart(); + if (metadata.isPresent() && !metadata.get().annotations().isEmpty()) { + docStart = PositionUtil.toRange(metadata.get().annotations().get(0).lineRange()).getStart(); + } + String desc = String.format("Description%n"); + return new DocAttachmentInfo(desc, docStart, getPadding(constantDeclarationNode, syntaxTree)); + } + + /** + * Generate documentation for enum declaration node. + * + * @param enumDeclarationNode enum declaration node + * @param syntaxTree syntaxTree {@link SyntaxTree} + * @return generated doc attachment + */ + private static DocAttachmentInfo generateEnumDocumentation(EnumDeclarationNode enumDeclarationNode, + SyntaxTree syntaxTree) { + Optional metadata = enumDeclarationNode.metadata(); + Position docStart = PositionUtil.toRange(enumDeclarationNode.lineRange()).getStart(); + if (metadata.isPresent() && !metadata.get().annotations().isEmpty()) { + docStart = PositionUtil.toRange(metadata.get().annotations().get(0).lineRange()).getStart(); + } + String desc = String.format("Description%n"); + return new DocAttachmentInfo(desc, docStart, getPadding(enumDeclarationNode, syntaxTree)); + } + /** * Generate documentation for service node. * diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/AddDocumentationTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/AddDocumentationTest.java index a5c1d87d1105..98e63b05a8ab 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/AddDocumentationTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/AddDocumentationTest.java @@ -62,6 +62,8 @@ public Object[][] dataProvider() { {"singleDocGeneration8.json"}, {"singleDocGeneration9.json"}, {"singleDocGeneration10.json"}, + {"singleDocGeneration11.json"}, + {"singleDocGeneration12.json"}, // Within Service {"serviceDocumentation1.json"}, // Already documented nodes diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/add-documentation/config/singleDocGeneration11.json b/language-server/modules/langserver-core/src/test/resources/codeaction/add-documentation/config/singleDocGeneration11.json new file mode 100644 index 000000000000..5704547751ee --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/add-documentation/config/singleDocGeneration11.json @@ -0,0 +1,40 @@ +{ + "position": { + "line": 89, + "character": 3 + }, + "source": "singleDocGeneration.bal", + "expected": [ + { + "title": "Document this", + "command": { + "title": "Document this", + "command": "ADD_DOC", + "arguments": [ + { + "key": "node.range", + "value": { + "start": { + "line": 89, + "character": 0 + }, + "end": { + "line": 89, + "character": 35 + } + } + } + ] + } + }, + { + "title": "Document all", + "kind": "source", + "command": { + "title": "Document all", + "command": "ADD_ALL_DOC", + "arguments": [] + } + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/add-documentation/config/singleDocGeneration12.json b/language-server/modules/langserver-core/src/test/resources/codeaction/add-documentation/config/singleDocGeneration12.json new file mode 100644 index 000000000000..fe88f0071f37 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/add-documentation/config/singleDocGeneration12.json @@ -0,0 +1,40 @@ +{ + "position": { + "line": 91, + "character": 3 + }, + "source": "singleDocGeneration.bal", + "expected": [ + { + "title": "Document this", + "command": { + "title": "Document this", + "command": "ADD_DOC", + "arguments": [ + { + "key": "node.range", + "value": { + "start": { + "line": 91, + "character": 0 + }, + "end": { + "line": 91, + "character": 10 + } + } + } + ] + } + }, + { + "title": "Document all", + "kind": "source", + "command": { + "title": "Document all", + "command": "ADD_ALL_DOC", + "arguments": [] + } + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/add-documentation/source/singleDocGeneration.bal b/language-server/modules/langserver-core/src/test/resources/codeaction/add-documentation/source/singleDocGeneration.bal index d7be291dec86..97b2b48608cf 100644 --- a/language-server/modules/langserver-core/src/test/resources/codeaction/add-documentation/source/singleDocGeneration.bal +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/add-documentation/source/singleDocGeneration.bal @@ -85,4 +85,12 @@ final int testModuleVar2 = 10; @varAnnotation final int testModuleVar1 = 10; -annotation varAnnotation; \ No newline at end of file +annotation varAnnotation; + +const string constString = "Hello"; + +enum Color { + RED, + GREEN, + BLUE +} From f5665c308047ec5f873404c9b732bb797ebeeedc Mon Sep 17 00:00:00 2001 From: gabilang Date: Tue, 22 Nov 2022 13:10:11 +0530 Subject: [PATCH 075/450] Add support typedesc for tuples --- .../internal/values/TupleValueImpl.java | 35 +++++++++++-------- .../internal/values/TypedescValueImpl.java | 4 +++ .../ballerinalang/compiler/bir/BIRGen.java | 14 ++++++-- .../bir/codegen/JvmInstructionGen.java | 11 +++--- .../compiler/bir/model/BIRNonTerminator.java | 9 +++++ .../compiler/bir/optimizer/BIROptimizer.java | 3 ++ .../bir/writer/BIRInstructionWriter.java | 3 ++ 7 files changed, 56 insertions(+), 23 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TupleValueImpl.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TupleValueImpl.java index 4090872e17da..a8531e6a0899 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TupleValueImpl.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TupleValueImpl.java @@ -71,21 +71,11 @@ public class TupleValueImpl extends AbstractArrayValue { private BTypedesc typedesc; // ------------------------ Constructors ------------------------------------------------------------------- - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (o == null || getClass() != o.getClass()) { - return false; + public TupleValueImpl(TypedescValue typedescValue) { + this((TupleType) typedescValue.getDescribingType()); + if (!tupleType.isReadOnly()) { + this.typedesc = typedescValue; } - - TupleValueImpl that = (TupleValueImpl) o; - return minSize == that.minSize && - hasRestElement == that.hasRestElement && - tupleType.equals(that.tupleType) && - Arrays.equals(refValues, that.refValues); } public TupleValueImpl(Object[] values, TupleType type) { @@ -390,6 +380,23 @@ public void add(long index, BString value) { // ------------------------------------------------------------------------------------------------------------- + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + + if (o == null || getClass() != o.getClass()) { + return false; + } + + TupleValueImpl that = (TupleValueImpl) o; + return minSize == that.minSize && + hasRestElement == that.hasRestElement && + tupleType.equals(that.tupleType) && + Arrays.equals(refValues, that.refValues); + } + /** * Append value to the existing array. * diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TypedescValueImpl.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TypedescValueImpl.java index 6c5aafb82583..478ccec667b5 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TypedescValueImpl.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TypedescValueImpl.java @@ -18,9 +18,11 @@ package io.ballerina.runtime.internal.values; import io.ballerina.runtime.api.TypeTags; +import io.ballerina.runtime.api.types.TupleType; import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.values.BInitialValueEntry; import io.ballerina.runtime.api.values.BLink; +import io.ballerina.runtime.api.values.BListInitialValueEntry; import io.ballerina.runtime.api.values.BMapInitialValueEntry; import io.ballerina.runtime.api.values.BTypedesc; import io.ballerina.runtime.internal.scheduling.Strand; @@ -88,6 +90,8 @@ public Object instantiate(Strand s, BInitialValueEntry[] initialValues) { Type referredType = getReferredType(this.describingType); if (referredType.getTag() == TypeTags.MAP_TAG) { return new MapValueImpl(referredType, (BMapInitialValueEntry[]) initialValues); + } else if (referredType.getTag() == TypeTags.TUPLE_TAG) { + return new TupleValueImpl((TupleType) referredType, (BListInitialValueEntry[]) initialValues); } // This method will be overridden for user-defined types, therefor this line shouldn't be reached. throw new BallerinaException("Given type can't be instantiated at runtime : " + this.describingType); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java index a0552c05481a..f99a65284b7f 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java @@ -1652,6 +1652,7 @@ public void visit(BLangArrayLiteral astArrayLiteralExpr) { @Override public void visit(BLangTupleLiteral tupleLiteral) { + visitTypedesc(tupleLiteral.pos, tupleLiteral.getBType(), Collections.emptyList()); generateListConstructorExpr(tupleLiteral); } @@ -2661,6 +2662,7 @@ private void generateListConstructorExpr(BLangListConstructorExpr listConstructo size = exprs.size(); } + BIROperand rhsOp = this.env.targetOperand; BLangLiteral literal = new BLangLiteral(); literal.pos = listConstructorExpr.pos; literal.value = size; @@ -2681,9 +2683,15 @@ private void generateListConstructorExpr(BLangListConstructorExpr listConstructo } } - setScopeAndEmit( - new BIRNonTerminator.NewArray(listConstructorExpr.pos, listConstructorExprType, toVarRef, sizeOp, - initialValues)); + if (listConstructorExprType.tag == TypeTags.TUPLE) { + setScopeAndEmit( + new BIRNonTerminator.NewArray(listConstructorExpr.pos, listConstructorExprType, toVarRef, rhsOp, + sizeOp, initialValues)); + } else { + setScopeAndEmit( + new BIRNonTerminator.NewArray(listConstructorExpr.pos, listConstructorExprType, toVarRef, sizeOp, + initialValues)); + } this.env.targetOperand = toVarRef; } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java index e087d195e067..3466511ec679 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java @@ -1514,7 +1514,7 @@ void generateStringLoadIns(BIRNonTerminator.FieldAccess stringLoadIns) { this.storeToVar(stringLoadIns.lhsOp.variableDcl); } - void generateArrayNewIns(BIRNonTerminator.NewArray inst) { + void generateArrayNewIns(BIRNonTerminator.NewArray inst, int localVarOffset) { BType instType = JvmCodeGenUtil.getReferredType(inst.type); if (instType.tag == TypeTags.ARRAY) { this.mv.visitTypeInsn(NEW, ARRAY_VALUE_IMPL); @@ -1532,11 +1532,10 @@ void generateArrayNewIns(BIRNonTerminator.NewArray inst) { } this.storeToVar(inst.lhsOp.variableDcl); } else { - this.mv.visitTypeInsn(NEW, TUPLE_VALUE_IMPL); - this.mv.visitInsn(DUP); - jvmTypeGen.loadType(this.mv, instType); + this.loadVar(inst.rhsOp.variableDcl); + this.mv.visitVarInsn(ALOAD, localVarOffset); loadListInitialValues(inst); - this.mv.visitMethodInsn(INVOKESPECIAL, TUPLE_VALUE_IMPL, JVM_INIT_METHOD, INIT_TUPLE, false); + this.mv.visitMethodInsn(INVOKEINTERFACE, TYPEDESC_VALUE, "instantiate", INSTANTIATE, true); this.storeToVar(inst.lhsOp.variableDcl); } } @@ -2232,7 +2231,7 @@ void generateInstructions(int localVarOffset, BIRInstruction inst) { generateTableLoadIns((FieldAccess) inst); break; case NEW_ARRAY: - generateArrayNewIns((BIRNonTerminator.NewArray) inst); + generateArrayNewIns((BIRNonTerminator.NewArray) inst, localVarOffset); break; case ARRAY_STORE: generateArrayStoreIns((FieldAccess) inst); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/model/BIRNonTerminator.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/model/BIRNonTerminator.java index 977a02bfd87e..0f08f1fd1b2a 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/model/BIRNonTerminator.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/model/BIRNonTerminator.java @@ -287,6 +287,7 @@ public static class NewArray extends BIRNonTerminator { public BIROperand sizeOp; public BType type; public List values; + public BIROperand rhsOp; public NewArray(Location location, BType type, BIROperand lhsOp, BIROperand sizeOp, List values) { @@ -297,6 +298,12 @@ public NewArray(Location location, BType type, BIROperand lhsOp, BIROperand size this.values = values; } + public NewArray(Location location, BType type, BIROperand lhsOp, BIROperand rhsOp, BIROperand sizeOp, + List values) { + this(location, type, lhsOp, sizeOp, values); + this.rhsOp = rhsOp; + } + @Override public void accept(BIRVisitor visitor) { visitor.visit(this); @@ -306,10 +313,12 @@ public void accept(BIRVisitor visitor) { public BIROperand[] getRhsOperands() { BIROperand[] operands = new BIROperand[values.size() + 1]; int i = 0; + operands[i++] = rhsOp; operands[i++] = sizeOp; for (BIRListConstructorEntry listValueEntry : values) { operands[i++] = listValueEntry.exprOp; } + operands = Arrays.copyOf(operands, i); return operands; } } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/optimizer/BIROptimizer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/optimizer/BIROptimizer.java index b5fa55873fe1..c329fed2c0c6 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/optimizer/BIROptimizer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/optimizer/BIROptimizer.java @@ -525,6 +525,9 @@ public void visit(BIRNonTerminator.NewArray birNewArray) { for (BIRNode.BIRListConstructorEntry listValueEntry : birNewArray.values) { this.optimizeNode(listValueEntry.exprOp, this.env); } + if (birNewArray.rhsOp != null) { + birNewArray.rhsOp.accept(this); + } } @Override diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/writer/BIRInstructionWriter.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/writer/BIRInstructionWriter.java index 085506f7908a..1a58d5ad829e 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/writer/BIRInstructionWriter.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/writer/BIRInstructionWriter.java @@ -386,6 +386,9 @@ public void visit(BIRNonTerminator.NewInstance newInstance) { public void visit(NewArray birNewArray) { writeType(birNewArray.type); + if (birNewArray.rhsOp != null) { + birNewArray.rhsOp.accept(this); + } birNewArray.lhsOp.accept(this); birNewArray.sizeOp.accept(this); buf.writeInt(birNewArray.values.size()); From 24f1a5d35b74f9ae65f6b648f73097270c1f1543 Mon Sep 17 00:00:00 2001 From: gayalkuruppu Date: Tue, 22 Nov 2022 13:53:39 +0530 Subject: [PATCH 076/450] Prioritize named arg completions --- ...ErrorConstructorExpressionNodeContext.java | 28 +- .../error_constructor_expr_ctx_config12.json | 130 +-- .../error_constructor_expr_ctx_config14.json | 741 ++++++++++++++++++ .../error_constructor_expr_ctx_config15.json | 741 ++++++++++++++++++ .../error_constructor_expr_ctx_config16.json | 707 +++++++++++++++++ .../error_constructor_expr_ctx_config9.json | 128 +-- .../error_constructor_expr_ctx_source14.bal | 10 + .../error_constructor_expr_ctx_source15.bal | 10 + .../error_constructor_expr_ctx_source16.bal | 10 + 9 files changed, 2362 insertions(+), 143 deletions(-) create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config14.json create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config15.json create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config16.json create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/expression_context/source/error_constructor_expr_ctx_source14.bal create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/expression_context/source/error_constructor_expr_ctx_source15.bal create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/expression_context/source/error_constructor_expr_ctx_source16.bal diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ErrorConstructorExpressionNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ErrorConstructorExpressionNodeContext.java index cfd3781dddd2..c37bc7105953 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ErrorConstructorExpressionNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ErrorConstructorExpressionNodeContext.java @@ -165,7 +165,7 @@ public void sort(BallerinaCompletionContext context, ErrorConstructorExpressionN return; } - if (isInErrorCauseArgContext(context, node)) { + if (isInErrorCauseArgContext(context, node) || node.typeReference().isPresent()) { /* Covers the following. error(arg1, ) @@ -173,23 +173,23 @@ public void sort(BallerinaCompletionContext context, ErrorConstructorExpressionN UnionTypeSymbol optionalErrorTypeSymbol = types.builder().UNION_TYPE .withMemberTypes(types.ERROR, types.NIL).build(); for (LSCompletionItem completionItem : completionItems) { - completionItem.getCompletionItem().setSortText(SortingUtil - .genSortTextByAssignability(context, completionItem, optionalErrorTypeSymbol)); + String sortText; + if (completionItem.getType() == LSCompletionItem.CompletionItemType.NAMED_ARG) { + if (isInErrorCauseArgContext(context, node)) { + sortText = SortingUtil.genSortText(1) + + SortingUtil.genSortText(SortingUtil.toRank(context, completionItem)); + } else { + sortText = SortingUtil.genSortText(1); + } + } else { + sortText = SortingUtil.genSortTextByAssignability(context, completionItem, optionalErrorTypeSymbol); + } + completionItem.getCompletionItem().setSortText(sortText); } return; } - for (LSCompletionItem completionItem : completionItems) { - String sortText; - if (completionItem.getType() == LSCompletionItem.CompletionItemType.NAMED_ARG) { - sortText = SortingUtil.genSortText(1) + - SortingUtil.genSortText(SortingUtil.toRank(context, completionItem)); - } else { - sortText = SortingUtil.genSortText(2) + - SortingUtil.genSortText(SortingUtil.toRank(context, completionItem)); - } - completionItem.getCompletionItem().setSortText(sortText); - } + super.sort(context, node, completionItems); } private boolean withinArgs(BallerinaCompletionContext context, ErrorConstructorExpressionNode node) { diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config12.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config12.json index 02460ca75c5c..87c496464861 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config12.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config12.json @@ -9,7 +9,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -33,7 +33,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -57,7 +57,7 @@ "label": "ballerina/module1", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet", @@ -81,7 +81,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -105,7 +105,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -129,7 +129,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -153,7 +153,7 @@ "label": "boolean", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "boolean", "insertTextFormat": "Snippet" }, @@ -161,7 +161,7 @@ "label": "decimal", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "decimal", "insertTextFormat": "Snippet" }, @@ -169,7 +169,7 @@ "label": "error", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "error", "insertTextFormat": "Snippet" }, @@ -177,7 +177,7 @@ "label": "float", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "float", "insertTextFormat": "Snippet" }, @@ -185,7 +185,7 @@ "label": "future", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "future", "insertTextFormat": "Snippet" }, @@ -193,7 +193,7 @@ "label": "int", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "int", "insertTextFormat": "Snippet" }, @@ -201,7 +201,7 @@ "label": "map", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "map", "insertTextFormat": "Snippet" }, @@ -209,7 +209,7 @@ "label": "object", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "object", "insertTextFormat": "Snippet" }, @@ -217,7 +217,7 @@ "label": "stream", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "stream", "insertTextFormat": "Snippet" }, @@ -225,7 +225,7 @@ "label": "string", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "string", "insertTextFormat": "Snippet" }, @@ -233,7 +233,7 @@ "label": "table", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "table", "insertTextFormat": "Snippet" }, @@ -241,7 +241,7 @@ "label": "transaction", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "transaction", "insertTextFormat": "Snippet" }, @@ -249,7 +249,7 @@ "label": "typedesc", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "typedesc", "insertTextFormat": "Snippet" }, @@ -257,7 +257,7 @@ "label": "xml", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "xml", "insertTextFormat": "Snippet" }, @@ -265,7 +265,7 @@ "label": "service", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "service", "insertText": "service", "insertTextFormat": "Snippet" @@ -274,7 +274,7 @@ "label": "new", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "new", "insertText": "new ", "insertTextFormat": "Snippet" @@ -283,7 +283,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -292,7 +292,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -301,7 +301,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -310,7 +310,7 @@ "label": "let", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "let", "insertText": "let", "insertTextFormat": "Snippet" @@ -319,7 +319,7 @@ "label": "typeof", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "typeof", "insertText": "typeof ", "insertTextFormat": "Snippet" @@ -328,7 +328,7 @@ "label": "trap", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "trap", "insertText": "trap", "insertTextFormat": "Snippet" @@ -337,7 +337,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -346,7 +346,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -355,7 +355,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -364,7 +364,7 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" @@ -373,7 +373,7 @@ "label": "check", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "check", "insertText": "check ", "insertTextFormat": "Snippet" @@ -382,7 +382,7 @@ "label": "checkpanic", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "checkpanic", "insertText": "checkpanic ", "insertTextFormat": "Snippet" @@ -391,7 +391,7 @@ "label": "is", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "is", "insertText": "is", "insertTextFormat": "Snippet" @@ -400,7 +400,7 @@ "label": "error constructor", "kind": "Snippet", "detail": "Snippet", - "sortText": "BP", + "sortText": "T", "filterText": "error", "insertText": "error(\"${1}\")", "insertTextFormat": "Snippet" @@ -409,7 +409,7 @@ "label": "object constructor", "kind": "Snippet", "detail": "Snippet", - "sortText": "BP", + "sortText": "T", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -418,7 +418,7 @@ "label": "base16", "kind": "Snippet", "detail": "Snippet", - "sortText": "BP", + "sortText": "T", "filterText": "base16", "insertText": "base16 `${1}`", "insertTextFormat": "Snippet" @@ -427,7 +427,7 @@ "label": "base64", "kind": "Snippet", "detail": "Snippet", - "sortText": "BP", + "sortText": "T", "filterText": "base64", "insertText": "base64 `${1}`", "insertTextFormat": "Snippet" @@ -436,7 +436,7 @@ "label": "from", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "from", "insertText": "from ", "insertTextFormat": "Snippet" @@ -445,7 +445,7 @@ "label": "ce", "kind": "Variable", "detail": "ERR", - "sortText": "BB", + "sortText": "AB", "insertText": "ce", "insertTextFormat": "Snippet" }, @@ -453,7 +453,7 @@ "label": "ERR", "kind": "Event", "detail": "Error", - "sortText": "BL", + "sortText": "AL", "insertText": "ERR", "insertTextFormat": "Snippet" }, @@ -461,7 +461,7 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "BN", + "sortText": "R", "insertText": "Thread", "insertTextFormat": "Snippet" }, @@ -475,7 +475,7 @@ "value": "**Package:** _._ \n \n \n" } }, - "sortText": "BC", + "sortText": "AC", "filterText": "name", "insertText": "name()", "insertTextFormat": "Snippet" @@ -487,7 +487,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "BM", + "sortText": "Q", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -495,7 +495,7 @@ "label": "ErrorData", "kind": "Struct", "detail": "Record", - "sortText": "BM", + "sortText": "Q", "insertText": "ErrorData", "insertTextFormat": "Snippet" }, @@ -503,7 +503,7 @@ "label": "readonly", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "readonly", "insertTextFormat": "Snippet" }, @@ -511,7 +511,7 @@ "label": "handle", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "handle", "insertTextFormat": "Snippet" }, @@ -519,7 +519,7 @@ "label": "never", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "never", "insertTextFormat": "Snippet" }, @@ -527,7 +527,7 @@ "label": "json", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "json", "insertTextFormat": "Snippet" }, @@ -535,7 +535,7 @@ "label": "anydata", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "anydata", "insertTextFormat": "Snippet" }, @@ -543,7 +543,7 @@ "label": "any", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "any", "insertTextFormat": "Snippet" }, @@ -551,7 +551,7 @@ "label": "byte", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "byte", "insertTextFormat": "Snippet" }, @@ -559,7 +559,7 @@ "label": "cause = ...", "kind": "Snippet", "detail": "cause = error(\"\")", - "sortText": "AR", + "sortText": "A", "filterText": "cause", "insertText": "cause = ${1:error(\"\")}", "insertTextFormat": "Snippet" @@ -568,7 +568,7 @@ "label": "errID = ...", "kind": "Snippet", "detail": "errID = 0", - "sortText": "AR", + "sortText": "A", "filterText": "errID", "insertText": "errID = ${1:0}", "insertTextFormat": "Snippet" @@ -577,7 +577,7 @@ "label": "start", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "start", "insertText": "start ", "insertTextFormat": "Snippet" @@ -586,7 +586,7 @@ "label": "wait", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "wait", "insertText": "wait ", "insertTextFormat": "Snippet" @@ -595,7 +595,7 @@ "label": "flush", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "flush", "insertText": "flush ", "insertTextFormat": "Snippet" @@ -604,7 +604,7 @@ "label": "from clause", "kind": "Snippet", "detail": "Snippet", - "sortText": "BP", + "sortText": "T", "filterText": "from", "insertText": "from ${1:var} ${2:item} in ${3}", "insertTextFormat": "Snippet" @@ -613,7 +613,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -637,7 +637,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -661,7 +661,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -685,7 +685,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -709,7 +709,7 @@ "label": "function", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "function", "insertTextFormat": "Snippet" }, @@ -717,7 +717,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config14.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config14.json new file mode 100644 index 000000000000..1a71d6214f9b --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config14.json @@ -0,0 +1,741 @@ +{ + "position": { + "line": 8, + "character": 41 + }, + "source": "expression_context/source/error_constructor_expr_ctx_source14.bal", + "items": [ + { + "label": "ballerina/lang.runtime", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "runtime", + "insertText": "runtime", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.runtime;\n" + } + ] + }, + { + "label": "ballerina/lang.value", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "value", + "insertText": "value", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.value;\n" + } + ] + }, + { + "label": "ballerina/module1", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "module1", + "insertText": "module1", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/module1;\n" + } + ] + }, + { + "label": "ballerina/lang.array", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "array", + "insertText": "array", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.array;\n" + } + ] + }, + { + "label": "ballerina/jballerina.java", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "java", + "insertText": "java", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/jballerina.java;\n" + } + ] + }, + { + "label": "ballerina/lang.test", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "test", + "insertText": "test", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.test;\n" + } + ] + }, + { + "label": "boolean", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "map", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "map", + "insertTextFormat": "Snippet" + }, + { + "label": "object", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "object", + "insertTextFormat": "Snippet" + }, + { + "label": "stream", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "stream", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "table", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "table", + "insertTextFormat": "Snippet" + }, + { + "label": "transaction", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "transaction", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "new", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "new", + "insertText": "new ", + "insertTextFormat": "Snippet" + }, + { + "label": "isolated", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "isolated", + "insertText": "isolated ", + "insertTextFormat": "Snippet" + }, + { + "label": "transactional", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "transactional", + "insertText": "transactional", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "function", + "insertText": "function ", + "insertTextFormat": "Snippet" + }, + { + "label": "let", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "let", + "insertText": "let", + "insertTextFormat": "Snippet" + }, + { + "label": "typeof", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "typeof", + "insertText": "typeof ", + "insertTextFormat": "Snippet" + }, + { + "label": "trap", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "trap", + "insertText": "trap", + "insertTextFormat": "Snippet" + }, + { + "label": "client", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "client", + "insertText": "client ", + "insertTextFormat": "Snippet" + }, + { + "label": "true", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "true", + "insertText": "true", + "insertTextFormat": "Snippet" + }, + { + "label": "false", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "false", + "insertText": "false", + "insertTextFormat": "Snippet" + }, + { + "label": "null", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "null", + "insertText": "null", + "insertTextFormat": "Snippet" + }, + { + "label": "check", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "check", + "insertText": "check ", + "insertTextFormat": "Snippet" + }, + { + "label": "checkpanic", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "checkpanic", + "insertText": "checkpanic ", + "insertTextFormat": "Snippet" + }, + { + "label": "is", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "is", + "insertText": "is", + "insertTextFormat": "Snippet" + }, + { + "label": "error constructor", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "T", + "filterText": "error", + "insertText": "error(\"${1}\")", + "insertTextFormat": "Snippet" + }, + { + "label": "object constructor", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "T", + "filterText": "object", + "insertText": "object {${1}}", + "insertTextFormat": "Snippet" + }, + { + "label": "base16", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "T", + "filterText": "base16", + "insertText": "base16 `${1}`", + "insertTextFormat": "Snippet" + }, + { + "label": "base64", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "T", + "filterText": "base64", + "insertText": "base64 `${1}`", + "insertTextFormat": "Snippet" + }, + { + "label": "from", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "from", + "insertText": "from ", + "insertTextFormat": "Snippet" + }, + { + "label": "Thread", + "kind": "TypeParameter", + "detail": "Union", + "sortText": "R", + "insertText": "Thread", + "insertTextFormat": "Snippet" + }, + { + "label": "StrandData", + "kind": "Struct", + "detail": "Record", + "documentation": { + "left": "Describes Strand execution details for the runtime.\n" + }, + "sortText": "Q", + "insertText": "StrandData", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "start", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "start", + "insertText": "start ", + "insertTextFormat": "Snippet" + }, + { + "label": "wait", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "wait", + "insertText": "wait ", + "insertTextFormat": "Snippet" + }, + { + "label": "flush", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "flush", + "insertText": "flush ", + "insertTextFormat": "Snippet" + }, + { + "label": "from clause", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "T", + "filterText": "from", + "insertText": "from ${1:var} ${2:item} in ${3}", + "insertTextFormat": "Snippet" + }, + { + "label": "test/project2", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "project2", + "insertText": "project2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/project2;\n" + } + ] + }, + { + "label": "test/project1", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "project1", + "insertText": "project1", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/project1;\n" + } + ] + }, + { + "label": "test/local_project2", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "local_project2", + "insertText": "local_project2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/local_project2;\n" + } + ] + }, + { + "label": "test/local_project1", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "local_project1", + "insertText": "local_project1", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/local_project1;\n" + } + ] + }, + { + "label": "function", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "ballerina/lang.regexp", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "regexp", + "insertText": "regexp", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.regexp;\n" + } + ] + }, + { + "label": "ErrorData", + "kind": "Struct", + "detail": "Record", + "sortText": "Q", + "insertText": "ErrorData", + "insertTextFormat": "Snippet" + }, + { + "label": "testError", + "kind": "Variable", + "detail": "ERR", + "sortText": "AB", + "insertText": "testError", + "insertTextFormat": "Snippet" + }, + { + "label": "ERR", + "kind": "Event", + "detail": "Error", + "sortText": "AL", + "insertText": "ERR", + "insertTextFormat": "Snippet" + }, + { + "label": "name()", + "kind": "Function", + "detail": "()", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _._ \n \n \n" + } + }, + "sortText": "AC", + "filterText": "name", + "insertText": "name()", + "insertTextFormat": "Snippet" + }, + { + "label": "code = ...", + "kind": "Snippet", + "detail": "code = 0", + "sortText": "AR", + "filterText": "code", + "insertText": "code = ${1:0}", + "insertTextFormat": "Snippet" + }, + { + "label": "detail = ...", + "kind": "Snippet", + "detail": "detail = \"\"", + "sortText": "AR", + "filterText": "detail", + "insertText": "detail = ${1:\"\"}", + "insertTextFormat": "Snippet" + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config15.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config15.json new file mode 100644 index 000000000000..0f149c30b3b9 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config15.json @@ -0,0 +1,741 @@ +{ + "position": { + "line": 8, + "character": 50 + }, + "source": "expression_context/source/error_constructor_expr_ctx_source15.bal", + "items": [ + { + "label": "ballerina/lang.runtime", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "runtime", + "insertText": "runtime", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.runtime;\n" + } + ] + }, + { + "label": "ballerina/lang.value", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "value", + "insertText": "value", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.value;\n" + } + ] + }, + { + "label": "ballerina/module1", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "module1", + "insertText": "module1", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/module1;\n" + } + ] + }, + { + "label": "ballerina/lang.array", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "array", + "insertText": "array", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.array;\n" + } + ] + }, + { + "label": "ballerina/jballerina.java", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "java", + "insertText": "java", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/jballerina.java;\n" + } + ] + }, + { + "label": "ballerina/lang.test", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "test", + "insertText": "test", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.test;\n" + } + ] + }, + { + "label": "boolean", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "map", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "map", + "insertTextFormat": "Snippet" + }, + { + "label": "object", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "object", + "insertTextFormat": "Snippet" + }, + { + "label": "stream", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "stream", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "table", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "table", + "insertTextFormat": "Snippet" + }, + { + "label": "transaction", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "transaction", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "new", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "new", + "insertText": "new ", + "insertTextFormat": "Snippet" + }, + { + "label": "isolated", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "isolated", + "insertText": "isolated ", + "insertTextFormat": "Snippet" + }, + { + "label": "transactional", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "transactional", + "insertText": "transactional", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "function", + "insertText": "function ", + "insertTextFormat": "Snippet" + }, + { + "label": "let", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "let", + "insertText": "let", + "insertTextFormat": "Snippet" + }, + { + "label": "typeof", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "typeof", + "insertText": "typeof ", + "insertTextFormat": "Snippet" + }, + { + "label": "trap", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "trap", + "insertText": "trap", + "insertTextFormat": "Snippet" + }, + { + "label": "client", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "client", + "insertText": "client ", + "insertTextFormat": "Snippet" + }, + { + "label": "true", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "true", + "insertText": "true", + "insertTextFormat": "Snippet" + }, + { + "label": "false", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "false", + "insertText": "false", + "insertTextFormat": "Snippet" + }, + { + "label": "null", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "null", + "insertText": "null", + "insertTextFormat": "Snippet" + }, + { + "label": "check", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "check", + "insertText": "check ", + "insertTextFormat": "Snippet" + }, + { + "label": "checkpanic", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "checkpanic", + "insertText": "checkpanic ", + "insertTextFormat": "Snippet" + }, + { + "label": "is", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "is", + "insertText": "is", + "insertTextFormat": "Snippet" + }, + { + "label": "error constructor", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "T", + "filterText": "error", + "insertText": "error(\"${1}\")", + "insertTextFormat": "Snippet" + }, + { + "label": "object constructor", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "T", + "filterText": "object", + "insertText": "object {${1}}", + "insertTextFormat": "Snippet" + }, + { + "label": "base16", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "T", + "filterText": "base16", + "insertText": "base16 `${1}`", + "insertTextFormat": "Snippet" + }, + { + "label": "base64", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "T", + "filterText": "base64", + "insertText": "base64 `${1}`", + "insertTextFormat": "Snippet" + }, + { + "label": "from", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "from", + "insertText": "from ", + "insertTextFormat": "Snippet" + }, + { + "label": "Thread", + "kind": "TypeParameter", + "detail": "Union", + "sortText": "R", + "insertText": "Thread", + "insertTextFormat": "Snippet" + }, + { + "label": "StrandData", + "kind": "Struct", + "detail": "Record", + "documentation": { + "left": "Describes Strand execution details for the runtime.\n" + }, + "sortText": "Q", + "insertText": "StrandData", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "start", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "start", + "insertText": "start ", + "insertTextFormat": "Snippet" + }, + { + "label": "wait", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "wait", + "insertText": "wait ", + "insertTextFormat": "Snippet" + }, + { + "label": "flush", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "flush", + "insertText": "flush ", + "insertTextFormat": "Snippet" + }, + { + "label": "from clause", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "T", + "filterText": "from", + "insertText": "from ${1:var} ${2:item} in ${3}", + "insertTextFormat": "Snippet" + }, + { + "label": "test/project2", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "project2", + "insertText": "project2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/project2;\n" + } + ] + }, + { + "label": "test/project1", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "project1", + "insertText": "project1", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/project1;\n" + } + ] + }, + { + "label": "test/local_project2", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "local_project2", + "insertText": "local_project2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/local_project2;\n" + } + ] + }, + { + "label": "test/local_project1", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "local_project1", + "insertText": "local_project1", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/local_project1;\n" + } + ] + }, + { + "label": "function", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "ballerina/lang.regexp", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "regexp", + "insertText": "regexp", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.regexp;\n" + } + ] + }, + { + "label": "ErrorData", + "kind": "Struct", + "detail": "Record", + "sortText": "Q", + "insertText": "ErrorData", + "insertTextFormat": "Snippet" + }, + { + "label": "testError", + "kind": "Variable", + "detail": "ERR", + "sortText": "AB", + "insertText": "testError", + "insertTextFormat": "Snippet" + }, + { + "label": "ERR", + "kind": "Event", + "detail": "Error", + "sortText": "AL", + "insertText": "ERR", + "insertTextFormat": "Snippet" + }, + { + "label": "name()", + "kind": "Function", + "detail": "()", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _._ \n \n \n" + } + }, + "sortText": "AC", + "filterText": "name", + "insertText": "name()", + "insertTextFormat": "Snippet" + }, + { + "label": "code = ...", + "kind": "Snippet", + "detail": "code = 0", + "sortText": "A", + "filterText": "code", + "insertText": "code = ${1:0}", + "insertTextFormat": "Snippet" + }, + { + "label": "detail = ...", + "kind": "Snippet", + "detail": "detail = \"\"", + "sortText": "A", + "filterText": "detail", + "insertText": "detail = ${1:\"\"}", + "insertTextFormat": "Snippet" + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config16.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config16.json new file mode 100644 index 000000000000..f7c5d966a185 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config16.json @@ -0,0 +1,707 @@ +{ + "position": { + "line": 8, + "character": 57 + }, + "source": "expression_context/source/error_constructor_expr_ctx_source16.bal", + "items": [ + { + "label": "ballerina/lang.runtime", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "runtime", + "insertText": "runtime", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.runtime;\n" + } + ] + }, + { + "label": "ballerina/lang.value", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "value", + "insertText": "value", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.value;\n" + } + ] + }, + { + "label": "ballerina/module1", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "module1", + "insertText": "module1", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/module1;\n" + } + ] + }, + { + "label": "ballerina/lang.array", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "array", + "insertText": "array", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.array;\n" + } + ] + }, + { + "label": "ballerina/jballerina.java", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "java", + "insertText": "java", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/jballerina.java;\n" + } + ] + }, + { + "label": "ballerina/lang.test", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "test", + "insertText": "test", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.test;\n" + } + ] + }, + { + "label": "boolean", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "map", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "map", + "insertTextFormat": "Snippet" + }, + { + "label": "object", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "object", + "insertTextFormat": "Snippet" + }, + { + "label": "stream", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "stream", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "table", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "table", + "insertTextFormat": "Snippet" + }, + { + "label": "transaction", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "transaction", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "new", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "new", + "insertText": "new ", + "insertTextFormat": "Snippet" + }, + { + "label": "isolated", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "isolated", + "insertText": "isolated ", + "insertTextFormat": "Snippet" + }, + { + "label": "transactional", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "transactional", + "insertText": "transactional", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "function", + "insertText": "function ", + "insertTextFormat": "Snippet" + }, + { + "label": "let", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "let", + "insertText": "let", + "insertTextFormat": "Snippet" + }, + { + "label": "typeof", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "typeof", + "insertText": "typeof ", + "insertTextFormat": "Snippet" + }, + { + "label": "trap", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "trap", + "insertText": "trap", + "insertTextFormat": "Snippet" + }, + { + "label": "client", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "client", + "insertText": "client ", + "insertTextFormat": "Snippet" + }, + { + "label": "true", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "true", + "insertText": "true", + "insertTextFormat": "Snippet" + }, + { + "label": "false", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "false", + "insertText": "false", + "insertTextFormat": "Snippet" + }, + { + "label": "null", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "null", + "insertText": "null", + "insertTextFormat": "Snippet" + }, + { + "label": "check", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "check", + "insertText": "check ", + "insertTextFormat": "Snippet" + }, + { + "label": "checkpanic", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "checkpanic", + "insertText": "checkpanic ", + "insertTextFormat": "Snippet" + }, + { + "label": "is", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "is", + "insertText": "is", + "insertTextFormat": "Snippet" + }, + { + "label": "error constructor", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "T", + "filterText": "error", + "insertText": "error(\"${1}\")", + "insertTextFormat": "Snippet" + }, + { + "label": "object constructor", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "T", + "filterText": "object", + "insertText": "object {${1}}", + "insertTextFormat": "Snippet" + }, + { + "label": "base16", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "T", + "filterText": "base16", + "insertText": "base16 `${1}`", + "insertTextFormat": "Snippet" + }, + { + "label": "base64", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "T", + "filterText": "base64", + "insertText": "base64 `${1}`", + "insertTextFormat": "Snippet" + }, + { + "label": "from", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "from", + "insertText": "from ", + "insertTextFormat": "Snippet" + }, + { + "label": "Thread", + "kind": "TypeParameter", + "detail": "Union", + "sortText": "R", + "insertText": "Thread", + "insertTextFormat": "Snippet" + }, + { + "label": "StrandData", + "kind": "Struct", + "detail": "Record", + "documentation": { + "left": "Describes Strand execution details for the runtime.\n" + }, + "sortText": "Q", + "insertText": "StrandData", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "test/project2", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "project2", + "insertText": "project2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/project2;\n" + } + ] + }, + { + "label": "test/project1", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "project1", + "insertText": "project1", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/project1;\n" + } + ] + }, + { + "label": "test/local_project2", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "local_project2", + "insertText": "local_project2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/local_project2;\n" + } + ] + }, + { + "label": "test/local_project1", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "local_project1", + "insertText": "local_project1", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/local_project1;\n" + } + ] + }, + { + "label": "function", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "ballerina/lang.regexp", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "regexp", + "insertText": "regexp", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.regexp;\n" + } + ] + }, + { + "label": "newErr", + "kind": "Variable", + "detail": "error", + "sortText": "F", + "insertText": "newErr", + "insertTextFormat": "Snippet" + }, + { + "label": "ErrorData", + "kind": "Struct", + "detail": "Record", + "sortText": "Q", + "insertText": "ErrorData", + "insertTextFormat": "Snippet" + }, + { + "label": "testError", + "kind": "Variable", + "detail": "ERR", + "sortText": "F", + "insertText": "testError", + "insertTextFormat": "Snippet" + }, + { + "label": "z", + "kind": "Variable", + "detail": "int", + "sortText": "AB", + "insertText": "z", + "insertTextFormat": "Snippet" + }, + { + "label": "ERR", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "ERR", + "insertTextFormat": "Snippet" + }, + { + "label": "name(int z, error newErr)", + "kind": "Function", + "detail": "()", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _._ \n \n \n**Params** \n- `int` z \n- `error` newErr" + } + }, + "sortText": "G", + "filterText": "name", + "insertText": "name(${1})", + "insertTextFormat": "Snippet", + "command": { + "title": "editor.action.triggerParameterHints", + "command": "editor.action.triggerParameterHints" + } + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config9.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config9.json index 742097780002..d648ff9c3f09 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config9.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config9.json @@ -9,7 +9,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -33,7 +33,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -57,7 +57,7 @@ "label": "ballerina/module1", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet", @@ -81,7 +81,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -105,7 +105,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -129,7 +129,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -153,7 +153,7 @@ "label": "boolean", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "boolean", "insertTextFormat": "Snippet" }, @@ -161,7 +161,7 @@ "label": "decimal", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "decimal", "insertTextFormat": "Snippet" }, @@ -169,7 +169,7 @@ "label": "error", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "error", "insertTextFormat": "Snippet" }, @@ -177,7 +177,7 @@ "label": "float", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "float", "insertTextFormat": "Snippet" }, @@ -185,7 +185,7 @@ "label": "future", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "future", "insertTextFormat": "Snippet" }, @@ -193,7 +193,7 @@ "label": "int", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "int", "insertTextFormat": "Snippet" }, @@ -201,7 +201,7 @@ "label": "map", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "map", "insertTextFormat": "Snippet" }, @@ -209,7 +209,7 @@ "label": "object", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "object", "insertTextFormat": "Snippet" }, @@ -217,7 +217,7 @@ "label": "stream", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "stream", "insertTextFormat": "Snippet" }, @@ -225,7 +225,7 @@ "label": "string", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "string", "insertTextFormat": "Snippet" }, @@ -233,7 +233,7 @@ "label": "table", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "table", "insertTextFormat": "Snippet" }, @@ -241,7 +241,7 @@ "label": "transaction", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "transaction", "insertTextFormat": "Snippet" }, @@ -249,7 +249,7 @@ "label": "typedesc", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "typedesc", "insertTextFormat": "Snippet" }, @@ -257,7 +257,7 @@ "label": "xml", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "xml", "insertTextFormat": "Snippet" }, @@ -265,7 +265,7 @@ "label": "service", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "service", "insertText": "service", "insertTextFormat": "Snippet" @@ -274,7 +274,7 @@ "label": "new", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "new", "insertText": "new ", "insertTextFormat": "Snippet" @@ -283,7 +283,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -292,7 +292,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -301,7 +301,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -310,7 +310,7 @@ "label": "let", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "let", "insertText": "let", "insertTextFormat": "Snippet" @@ -319,7 +319,7 @@ "label": "typeof", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "typeof", "insertText": "typeof ", "insertTextFormat": "Snippet" @@ -328,7 +328,7 @@ "label": "trap", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "trap", "insertText": "trap", "insertTextFormat": "Snippet" @@ -337,7 +337,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -346,7 +346,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -355,7 +355,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -364,7 +364,7 @@ "label": "check", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "check", "insertText": "check ", "insertTextFormat": "Snippet" @@ -373,7 +373,7 @@ "label": "checkpanic", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "checkpanic", "insertText": "checkpanic ", "insertTextFormat": "Snippet" @@ -382,7 +382,7 @@ "label": "is", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "is", "insertText": "is", "insertTextFormat": "Snippet" @@ -391,7 +391,7 @@ "label": "error constructor", "kind": "Snippet", "detail": "Snippet", - "sortText": "BP", + "sortText": "T", "filterText": "error", "insertText": "error(\"${1}\")", "insertTextFormat": "Snippet" @@ -400,7 +400,7 @@ "label": "object constructor", "kind": "Snippet", "detail": "Snippet", - "sortText": "BP", + "sortText": "T", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -409,7 +409,7 @@ "label": "base16", "kind": "Snippet", "detail": "Snippet", - "sortText": "BP", + "sortText": "T", "filterText": "base16", "insertText": "base16 `${1}`", "insertTextFormat": "Snippet" @@ -418,7 +418,7 @@ "label": "base64", "kind": "Snippet", "detail": "Snippet", - "sortText": "BP", + "sortText": "T", "filterText": "base64", "insertText": "base64 `${1}`", "insertTextFormat": "Snippet" @@ -427,7 +427,7 @@ "label": "from", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "from", "insertText": "from ", "insertTextFormat": "Snippet" @@ -439,7 +439,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "BM", + "sortText": "Q", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -447,7 +447,7 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "BN", + "sortText": "R", "insertText": "Thread", "insertTextFormat": "Snippet" }, @@ -455,7 +455,7 @@ "label": "err1", "kind": "Variable", "detail": "Error1", - "sortText": "BB", + "sortText": "AB", "insertText": "err1", "insertTextFormat": "Snippet" }, @@ -469,7 +469,7 @@ "value": "**Package:** _._ \n \n \n" } }, - "sortText": "BC", + "sortText": "AC", "filterText": "func1", "insertText": "func1()", "insertTextFormat": "Snippet" @@ -478,7 +478,7 @@ "label": "ErrorDesc", "kind": "Struct", "detail": "Record", - "sortText": "BM", + "sortText": "Q", "insertText": "ErrorDesc", "insertTextFormat": "Snippet" }, @@ -486,7 +486,7 @@ "label": "Error1", "kind": "Event", "detail": "Error", - "sortText": "BL", + "sortText": "AL", "insertText": "Error1", "insertTextFormat": "Snippet" }, @@ -494,7 +494,7 @@ "label": "readonly", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "readonly", "insertTextFormat": "Snippet" }, @@ -502,7 +502,7 @@ "label": "handle", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "handle", "insertTextFormat": "Snippet" }, @@ -510,7 +510,7 @@ "label": "never", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "never", "insertTextFormat": "Snippet" }, @@ -518,7 +518,7 @@ "label": "json", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "json", "insertTextFormat": "Snippet" }, @@ -526,7 +526,7 @@ "label": "anydata", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "anydata", "insertTextFormat": "Snippet" }, @@ -534,7 +534,7 @@ "label": "any", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "any", "insertTextFormat": "Snippet" }, @@ -542,7 +542,7 @@ "label": "byte", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "byte", "insertTextFormat": "Snippet" }, @@ -550,7 +550,7 @@ "label": "stack = ...", "kind": "Snippet", "detail": "stack = \"\"", - "sortText": "AR", + "sortText": "A", "filterText": "stack", "insertText": "stack = ${1:\"\"}", "insertTextFormat": "Snippet" @@ -559,7 +559,7 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" @@ -568,7 +568,7 @@ "label": "start", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "start", "insertText": "start ", "insertTextFormat": "Snippet" @@ -577,7 +577,7 @@ "label": "wait", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "wait", "insertText": "wait ", "insertTextFormat": "Snippet" @@ -586,7 +586,7 @@ "label": "flush", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "flush", "insertText": "flush ", "insertTextFormat": "Snippet" @@ -595,7 +595,7 @@ "label": "from clause", "kind": "Snippet", "detail": "Snippet", - "sortText": "BP", + "sortText": "T", "filterText": "from", "insertText": "from ${1:var} ${2:item} in ${3}", "insertTextFormat": "Snippet" @@ -604,7 +604,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -628,7 +628,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -652,7 +652,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -676,7 +676,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -700,7 +700,7 @@ "label": "function", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "function", "insertTextFormat": "Snippet" }, @@ -708,7 +708,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/source/error_constructor_expr_ctx_source14.bal b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/source/error_constructor_expr_ctx_source14.bal new file mode 100644 index 000000000000..625048ca3ed9 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/source/error_constructor_expr_ctx_source14.bal @@ -0,0 +1,10 @@ +type ErrorData record {| + int code; + string detail; +|}; + +type ERR error; + +function name() { + ERR testError = error ERR("message", ); +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/source/error_constructor_expr_ctx_source15.bal b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/source/error_constructor_expr_ctx_source15.bal new file mode 100644 index 000000000000..a2e387440331 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/source/error_constructor_expr_ctx_source15.bal @@ -0,0 +1,10 @@ +type ErrorData record {| + int code; + string detail; +|}; + +type ERR error; + +function name() { + ERR testError = error ERR("message", "cause", ); +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/source/error_constructor_expr_ctx_source16.bal b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/source/error_constructor_expr_ctx_source16.bal new file mode 100644 index 000000000000..01b1654cf825 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/source/error_constructor_expr_ctx_source16.bal @@ -0,0 +1,10 @@ +type ErrorData record {| + int code; + string detail; +|}; + +type ERR error; + +function name(int z, error newErr) { + ERR testError = error ERR("message", "cause", code = ); +} From 15de73ba0df35473d70059840b9b194a9df08d6b Mon Sep 17 00:00:00 2001 From: Sasindu Alahakoon Date: Fri, 11 Nov 2022 18:09:48 +0530 Subject: [PATCH 077/450] Remove client delaration from compiler and parser --- .gitignore | 1 - .../io/ballerina/cli/task/CompileTask.java | 3 +- compiler/ballerina-lang/spotbugs-exclude.xml | 9 - .../compiler/api/impl/BaseVisitor.java | 5 - .../compiler/api/impl/NodeFinder.java | 891 +++++++++++++----- .../compiler/api/impl/ReferenceFinder.java | 19 - .../compiler/api/impl/SymbolFactory.java | 37 - .../compiler/api/impl/SymbolFinder.java | 25 - .../symbols/BallerinaAnnotationSymbol.java | 3 - .../symbols/BallerinaClientDeclSymbol.java | 129 --- .../api/symbols/AnnotationAttachPoint.java | 3 +- .../api/symbols/ClientDeclSymbol.java | 40 - .../compiler/api/symbols/SymbolKind.java | 1 - .../projects/CompilationOptions.java | 24 +- .../ballerina/projects/DocumentContext.java | 2 - .../io/ballerina/projects/ModuleConfig.java | 1 - .../io/ballerina/projects/ModuleContext.java | 7 - .../java/io/ballerina/projects/Package.java | 14 +- .../io/ballerina/projects/ResourceConfig.java | 8 +- .../ballerina/projects/ResourceContext.java | 2 +- .../projects/internal/BalaFiles.java | 36 - .../internal/PackageConfigCreator.java | 7 - .../internal/ProjectDiagnosticErrorCode.java | 9 +- .../projects/internal/ProjectFiles.java | 2 +- .../internal/bala/IDLClientsJson.java | 200 ---- .../internal/plugins/CompilerPlugins.java | 43 - .../projects/plugins/IDLClientGenerator.java | 42 - .../projects/plugins/IDLGeneratorPlugin.java | 37 - .../projects/plugins/IDLPluginContext.java | 36 - .../plugins/IDLSourceGeneratorContext.java | 46 - .../projects/util/ProjectConstants.java | 3 - .../ballerina/projects/util/ProjectPaths.java | 94 -- .../ballerina/projects/util/ProjectUtils.java | 63 +- .../src/main/java/module-info.java | 1 - .../org/ballerinalang/model/TreeBuilder.java | 19 +- .../model/elements/AttachPoint.java | 6 +- .../model/symbols/SymbolKind.java | 1 - .../model/tree/ClientDeclarationNode.java | 36 - .../ballerinalang/model/tree/NodeKind.java | 1 - .../ballerinalang/model/tree/PackageNode.java | 2 - .../util/diagnostic/DiagnosticErrorCode.java | 13 - .../ballerinalang/compiler/bir/BIRGen.java | 6 - .../compiler/desugar/ClosureDesugar.java | 16 +- .../compiler/desugar/ConstantPropagation.java | 12 - .../compiler/desugar/Desugar.java | 124 +-- .../compiler/desugar/ParameterDesugar.java | 15 +- .../compiler/parser/BLangNodeBuilder.java | 90 +- .../compiler/parser/NodeCloner.java | 10 - .../semantics/analyzer/CodeAnalyzer.java | 8 +- .../analyzer/CompilerPluginRunner.java | 4 - .../semantics/analyzer/DataflowAnalyzer.java | 20 +- .../semantics/analyzer/IsolationAnalyzer.java | 9 +- .../semantics/analyzer/SemanticAnalyzer.java | 440 +-------- .../semantics/analyzer/SymbolEnter.java | 144 ++- .../semantics/analyzer/SymbolResolver.java | 82 +- .../semantics/analyzer/TypeChecker.java | 287 +++--- .../compiler/semantics/model/SymbolTable.java | 4 - .../symbols/BClientDeclarationSymbol.java | 74 -- .../semantics/model/symbols/SymTag.java | 2 +- .../semantics/model/symbols/Symbols.java | 29 +- .../semantics/model/types/BNeverType.java | 6 - .../compiler/tree/BLangClientDeclaration.java | 85 -- .../compiler/tree/BLangNodeAnalyzer.java | 2 - .../compiler/tree/BLangNodeTransformer.java | 4 - .../compiler/tree/BLangNodeVisitor.java | 4 - .../compiler/tree/BLangPackage.java | 7 - .../tree/SimpleBLangNodeAnalyzer.java | 6 - .../ballerinalang/compiler/util/Names.java | 2 - .../wso2/ballerinalang/util/AttachPoints.java | 4 - .../src/main/resources/compiler.properties | 37 +- .../ballerina/projects/ProjectPathsTest.java | 45 +- .../diagnostics/DiagnosticErrorCode.java | 1 - .../internal/parser/BallerinaParser.java | 137 +-- .../parser/BallerinaParserErrorHandler.java | 87 +- .../internal/parser/ParserRuleContext.java | 5 - .../internal/parser/SyntaxErrors.java | 1 - .../tree/STModuleClientDeclarationNode.java | 134 --- .../internal/parser/tree/STNodeFactory.java | 34 - .../parser/tree/STNodeTransformer.java | 8 - .../internal/parser/tree/STNodeVisitor.java | 9 - .../internal/parser/tree/STTreeModifier.java | 36 - .../tree/ModuleClientDeclarationNode.java | 186 ---- .../compiler/syntax/tree/NodeFactory.java | 48 - .../compiler/syntax/tree/NodeTransformer.java | 8 - .../compiler/syntax/tree/NodeVisitor.java | 9 - .../compiler/syntax/tree/SyntaxKind.java | 1 - .../compiler/syntax/tree/TreeModifier.java | 48 - .../syntax_diagnostic_message.properties | 1 - .../compiler/parser/test/ParserTestUtils.java | 4 - .../declarations/ClientDeclarationTest.java | 102 -- .../test/syntax/misc/IdentifierTest.java | 12 - .../client-decl/client_decl_assert_01.json | 72 -- .../client-decl/client_decl_assert_02.json | 248 ----- .../client-decl/client_decl_assert_03.json | 78 -- .../client-decl/client_decl_assert_04.json | 74 -- .../client-decl/client_decl_assert_05.json | 97 -- .../client-decl/client_decl_assert_06.json | 74 -- .../client-decl/client_decl_assert_07.json | 97 -- .../client-decl/client_decl_assert_08.json | 101 -- .../client-decl/client_decl_assert_09.json | 88 -- .../client-decl/client_decl_assert_10.json | 79 -- .../client-decl/client_decl_assert_11.json | 80 -- .../client-decl/client_decl_assert_12.json | 207 ---- .../client-decl/client_decl_assert_13.json | 287 ------ .../client-decl/client_decl_assert_14.json | 239 ----- .../client-decl/client_decl_source_01.bal | 1 - .../client-decl/client_decl_source_02.bal | 7 - .../client-decl/client_decl_source_03.bal | 1 - .../client-decl/client_decl_source_04.bal | 1 - .../client-decl/client_decl_source_05.bal | 1 - .../client-decl/client_decl_source_06.bal | 1 - .../client-decl/client_decl_source_07.bal | 1 - .../client-decl/client_decl_source_08.bal | 1 - .../client-decl/client_decl_source_09.bal | 1 - .../client-decl/client_decl_source_10.bal | 1 - .../client-decl/client_decl_source_11.bal | 1 - .../client-decl/client_decl_source_12.bal | 5 - .../client-decl/client_decl_source_13.bal | 5 - .../client-decl/client_decl_source_14.bal | 6 - ...tifier_in_qualified_identifier_assert.json | 322 ------- ...ntifier_in_qualified_identifier_source.bal | 7 - ...f_client_keyword_as_identifier_assert.json | 484 ---------- ...of_client_keyword_as_identifier_source.bal | 7 - .../core/FormattingTreeModifier.java | 1 - .../ballerina-compiler-api-test/build.gradle | 2 - .../symbols/client_decl_proj/Ballerina.toml | 7 - .../symbols/client_decl_proj/main.bal | 37 - .../declarations/ClientDeclarationTest.java | 75 -- 128 files changed, 1008 insertions(+), 6158 deletions(-) delete mode 100644 compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaClientDeclSymbol.java delete mode 100644 compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/symbols/ClientDeclSymbol.java delete mode 100644 compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/bala/IDLClientsJson.java delete mode 100644 compiler/ballerina-lang/src/main/java/io/ballerina/projects/plugins/IDLClientGenerator.java delete mode 100644 compiler/ballerina-lang/src/main/java/io/ballerina/projects/plugins/IDLGeneratorPlugin.java delete mode 100644 compiler/ballerina-lang/src/main/java/io/ballerina/projects/plugins/IDLPluginContext.java delete mode 100644 compiler/ballerina-lang/src/main/java/io/ballerina/projects/plugins/IDLSourceGeneratorContext.java delete mode 100644 compiler/ballerina-lang/src/main/java/org/ballerinalang/model/tree/ClientDeclarationNode.java delete mode 100644 compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/BClientDeclarationSymbol.java delete mode 100644 compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangClientDeclaration.java delete mode 100644 compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STModuleClientDeclarationNode.java delete mode 100644 compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/ModuleClientDeclarationNode.java delete mode 100644 compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/declarations/ClientDeclarationTest.java delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_01.json delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_02.json delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_03.json delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_04.json delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_05.json delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_06.json delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_07.json delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_08.json delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_09.json delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_10.json delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_11.json delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_12.json delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_13.json delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_14.json delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_01.bal delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_02.bal delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_03.bal delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_04.bal delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_05.bal delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_06.bal delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_07.bal delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_08.bal delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_09.bal delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_10.bal delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_11.bal delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_12.bal delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_13.bal delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_14.bal delete mode 100644 compiler/ballerina-parser/src/test/resources/misc/identifiers/client_keyword_as_identifier_in_qualified_identifier_assert.json delete mode 100644 compiler/ballerina-parser/src/test/resources/misc/identifiers/client_keyword_as_identifier_in_qualified_identifier_source.bal delete mode 100644 compiler/ballerina-parser/src/test/resources/misc/identifiers/invalid_usage_of_client_keyword_as_identifier_assert.json delete mode 100644 compiler/ballerina-parser/src/test/resources/misc/identifiers/invalid_usage_of_client_keyword_as_identifier_source.bal delete mode 100644 tests/ballerina-compiler-api-test/src/test/resources/test-src/symbols/client_decl_proj/Ballerina.toml delete mode 100644 tests/ballerina-compiler-api-test/src/test/resources/test-src/symbols/client_decl_proj/main.bal delete mode 100644 tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/module/declarations/ClientDeclarationTest.java diff --git a/.gitignore b/.gitignore index 6c3e6e4fc56a..33774af78f03 100644 --- a/.gitignore +++ b/.gitignore @@ -33,7 +33,6 @@ velocity.log /composer/modules/web/dist-electron extractedDistribution misc/testerina/modules/report-tools/node_modules/ -generated # gradle .gradle diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/CompileTask.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/CompileTask.java index 51ad84d6cca2..f43ac3c4f3e6 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/CompileTask.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/CompileTask.java @@ -84,9 +84,8 @@ public void execute(Project project) { System.setProperty(CentralClientConstants.ENABLE_OUTPUT_STREAM, "true"); - List diagnostics = new ArrayList<>(); - try { + List diagnostics = new ArrayList<>(); long start = 0; if (project.buildOptions().dumpBuildTime()) { start = System.currentTimeMillis(); diff --git a/compiler/ballerina-lang/spotbugs-exclude.xml b/compiler/ballerina-lang/spotbugs-exclude.xml index 2a6a646975a8..834468961a60 100644 --- a/compiler/ballerina-lang/spotbugs-exclude.xml +++ b/compiler/ballerina-lang/spotbugs-exclude.xml @@ -280,10 +280,6 @@ - - - - @@ -315,11 +311,6 @@ - - - - - diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/BaseVisitor.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/BaseVisitor.java index 04b3c50583bc..b7bb3969cee6 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/BaseVisitor.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/BaseVisitor.java @@ -21,7 +21,6 @@ import org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachment; import org.wso2.ballerinalang.compiler.tree.BLangBlockFunctionBody; import org.wso2.ballerinalang.compiler.tree.BLangClassDefinition; -import org.wso2.ballerinalang.compiler.tree.BLangClientDeclaration; import org.wso2.ballerinalang.compiler.tree.BLangCompilationUnit; import org.wso2.ballerinalang.compiler.tree.BLangErrorVariable; import org.wso2.ballerinalang.compiler.tree.BLangExprFunctionBody; @@ -231,10 +230,6 @@ public void visit(BLangImportPackage importPkgNode) { public void visit(BLangXMLNS xmlnsNode) { } - @Override - public void visit(BLangClientDeclaration clientDecl) { - } - @Override public void visit(BLangFunction funcNode) { } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/NodeFinder.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/NodeFinder.java index e0963421f307..88b4d0d8ae08 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/NodeFinder.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/NodeFinder.java @@ -29,7 +29,6 @@ import org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachment; import org.wso2.ballerinalang.compiler.tree.BLangBlockFunctionBody; import org.wso2.ballerinalang.compiler.tree.BLangClassDefinition; -import org.wso2.ballerinalang.compiler.tree.BLangClientDeclaration; import org.wso2.ballerinalang.compiler.tree.BLangCompilationUnit; import org.wso2.ballerinalang.compiler.tree.BLangErrorVariable; import org.wso2.ballerinalang.compiler.tree.BLangExprFunctionBody; @@ -77,6 +76,7 @@ import org.wso2.ballerinalang.compiler.tree.expressions.BLangBinaryExpr; import org.wso2.ballerinalang.compiler.tree.expressions.BLangCheckPanickedExpr; import org.wso2.ballerinalang.compiler.tree.expressions.BLangCheckedExpr; +import org.wso2.ballerinalang.compiler.tree.expressions.BLangConstRef; import org.wso2.ballerinalang.compiler.tree.expressions.BLangConstant; import org.wso2.ballerinalang.compiler.tree.expressions.BLangElvisExpr; import org.wso2.ballerinalang.compiler.tree.expressions.BLangErrorConstructorExpr; @@ -155,7 +155,6 @@ import org.wso2.ballerinalang.compiler.tree.matchpatterns.BLangVarBindingPatternMatchPattern; import org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt; -import org.wso2.ballerinalang.compiler.tree.statements.BLangClientDeclarationStatement; import org.wso2.ballerinalang.compiler.tree.statements.BLangCompoundAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangDo; import org.wso2.ballerinalang.compiler.tree.statements.BLangErrorDestructure; @@ -195,6 +194,7 @@ import org.wso2.ballerinalang.compiler.tree.types.BLangTupleTypeNode; import org.wso2.ballerinalang.compiler.tree.types.BLangUnionTypeNode; import org.wso2.ballerinalang.compiler.tree.types.BLangUserDefinedType; +import org.wso2.ballerinalang.compiler.tree.types.BLangValueType; import java.util.ArrayList; import java.util.List; @@ -209,13 +209,13 @@ class NodeFinder extends BaseVisitor { private LineRange range; private BLangNode enclosingNode; private BLangNode enclosingContainer; - private boolean allowExprStmts; + private final boolean allowExprStmts; NodeFinder(boolean allowExprStmts) { this.allowExprStmts = allowExprStmts; } - BLangNode lookup(BLangPackage module, LineRange range) { + void lookup(BLangPackage module, LineRange range) { List topLevelNodes = new ArrayList<>(module.topLevelNodes); BLangTestablePackage tests = module.getTestablePkg(); @@ -223,7 +223,7 @@ BLangNode lookup(BLangPackage module, LineRange range) { topLevelNodes.addAll(tests.topLevelNodes); } - return lookupTopLevelNodes(topLevelNodes, range); + lookupTopLevelNodes(topLevelNodes, range); } BLangNode lookup(BLangCompilationUnit unit, LineRange range) { @@ -247,78 +247,57 @@ private BLangNode lookupTopLevelNodes(List nodes, LineRange range) this.enclosingNode = null; for (TopLevelNode node : nodes) { - if (!PositionUtil.isRangeWithinNode(this.range, node.getPosition()) || isLambdaFunction(node) - || isClassForService(node)) { - continue; + BLangNode bLangNode = (BLangNode) node; + if (PositionUtil.isRangeWithinNode(this.range, node.getPosition()) + && !isLambdaFunction(node) && !isClassForService(node)) { + bLangNode.accept(this); + return this.enclosingNode; } - - ((BLangNode) node).accept(this); - break; } - return this.enclosingNode; } - private void lookupNodes(List nodes) { + private boolean lookupNodes(List nodes) { for (BLangNode node : nodes) { - if (!PositionUtil.isRangeWithinNode(this.range, node.pos)) { - continue; - } - - node.accept(this); - - if (this.enclosingNode == null && !node.internal - && PositionUtil.withinRange(node.pos.lineRange(), this.range)) { - this.enclosingNode = node; - return; + if (lookupNode(node)) { + return true; } } + return false; } - private void lookupNode(BLangNode node) { + private boolean lookupNode(BLangNode node) { if (node == null) { - return; - } - - if (!PositionUtil.isRangeWithinNode(this.range, node.pos)) { - return; + return false; } - - node.accept(this); - - if (this.enclosingNode == null && !node.internal - && PositionUtil.withinRange(node.pos.lineRange(), this.range)) { - this.enclosingNode = node; + if (PositionUtil.isRangeWithinNode(this.range, node.pos)) { + node.accept(this); + return this.enclosingNode != null; } + return false; } @Override public void visit(BLangXMLNS xmlnsNode) { lookupNode(xmlnsNode.namespaceURI); } - - @Override - public void visit(BLangClientDeclarationStatement clientDeclStmt) { - lookupNode(clientDeclStmt.getClientDeclaration()); - } - - @Override - public void visit(BLangClientDeclaration clientDeclNode) { - lookupNode((BLangNode) clientDeclNode.getUri()); - } - @Override public void visit(BLangFunction funcNode) { - lookupNodes(funcNode.annAttachments); // Compare the target lookup pos with the function symbol pos to ensure that we are not looking for the // container of the function. if (!this.range.equals(funcNode.symbol.pos.lineRange())) { this.enclosingContainer = funcNode; } - lookupNodes(funcNode.requiredParams); - lookupNode(funcNode.restParam); - lookupNode(funcNode.returnTypeNode); + if (lookupNodes(funcNode.requiredParams)) { + return; + } + if (lookupNode(funcNode.restParam)) { + return; + } + if (lookupNode(funcNode.returnTypeNode)) { + return; + } lookupNode(funcNode.body); } @@ -345,9 +324,13 @@ public void visit(BLangExternalFunctionBody externFuncBody) { @Override public void visit(BLangService serviceNode) { - lookupNodes(serviceNode.annAttachments); + if (lookupNodes(serviceNode.annAttachments)) { + return; + } + if (lookupNodes(serviceNode.attachedExprs)) { + return; + } lookupNode(serviceNode.serviceClass); - lookupNodes(serviceNode.attachedExprs); } @Override @@ -357,34 +340,47 @@ public void visit(BLangTypeDefinition typeDefinition) { @Override public void visit(BLangConstant constant) { - lookupNode(constant.typeNode); - lookupNode(constant.expr); + if (lookupNode(constant.typeNode)) { + return; + } + if (lookupNode(constant.expr)) { + return; + } setEnclosingNode(constant, constant.name.pos); } @Override public void visit(BLangSimpleVariable varNode) { - lookupNodes(varNode.annAttachments); - lookupNode(varNode.typeNode); - lookupNode(varNode.expr); + if (lookupNodes(varNode.annAttachments)) { + return; + } + if (lookupNode(varNode.typeNode)) { + return; + } + if (lookupNode(varNode.expr)) { + return; + } setEnclosingNode(varNode, varNode.name.pos); } @Override public void visit(BLangAnnotation annotationNode) { - lookupNode(annotationNode.typeNode); + if (lookupNode(annotationNode.typeNode)) { + return; + } setEnclosingNode(annotationNode, annotationNode.name.pos); } @Override public void visit(BLangAnnotationAttachment annAttachmentNode) { - lookupNode(annAttachmentNode.expr); + if (lookupNode(annAttachmentNode.expr)) { + return; + } setEnclosingNode(annAttachmentNode, annAttachmentNode.annotationName.pos); } @Override public void visit(BLangTableKeySpecifier tableKeySpecifierNode) { - } @Override @@ -413,32 +409,44 @@ public void visit(BLangSimpleVariableDef varDefNode) { @Override public void visit(BLangAssignment assignNode) { - lookupNode(assignNode.varRef); + if (lookupNode(assignNode.varRef)) { + return; + } lookupNode(assignNode.expr); } @Override public void visit(BLangCompoundAssignment compoundAssignNode) { - lookupNode(compoundAssignNode.varRef); + if (lookupNode(compoundAssignNode.varRef)) { + return; + } lookupNode(compoundAssignNode.expr); } @Override public void visit(BLangRetry retryNode) { - lookupNode(retryNode.retryBody); - lookupNode(retryNode.retrySpec); + if (lookupNode(retryNode.retryBody)) { + return; + } + if (lookupNode(retryNode.retrySpec)) { + return; + } lookupNode(retryNode.onFailClause); } @Override public void visit(BLangRetryTransaction retryTransaction) { - lookupNode(retryTransaction.transaction); + if (lookupNode(retryTransaction.transaction)) { + return; + } lookupNode(retryTransaction.retrySpec); } @Override public void visit(BLangRetrySpec retrySpec) { - lookupNode(retrySpec.retryManagerType); + if (lookupNode(retrySpec.retryManagerType)) { + return; + } lookupNodes(retrySpec.argExprs); } @@ -468,48 +476,73 @@ public void visit(BLangExpressionStmt exprStmtNode) { @Override public void visit(BLangIf ifNode) { - lookupNode(ifNode.expr); - lookupNode(ifNode.body); + if (lookupNode(ifNode.expr)) { + return; + } + if (lookupNode(ifNode.body)) { + return; + } lookupNode(ifNode.elseStmt); } @Override public void visit(BLangQueryAction queryAction) { - lookupNodes(queryAction.queryClauseList); + if (lookupNodes(queryAction.queryClauseList)) { + return; + } lookupNode(queryAction.doClause); } @Override public void visit(BLangForeach foreach) { - lookupNode((BLangNode) foreach.variableDefinitionNode); - lookupNode(foreach.collection); - lookupNode(foreach.body); + if (lookupNode((BLangNode) foreach.variableDefinitionNode)) { + return; + } + if (lookupNode(foreach.collection)) { + return; + } + if (lookupNode(foreach.body)) { + return; + } lookupNode(foreach.onFailClause); } @Override public void visit(BLangFromClause fromClause) { - lookupNode(fromClause.collection); - lookupNode((BLangNode) fromClause.variableDefinitionNode); + if (lookupNode(fromClause.collection)) { + return; + } + if (lookupNode((BLangNode) fromClause.variableDefinitionNode)) { + return; + } + this.enclosingNode = fromClause; } @Override public void visit(BLangJoinClause joinClause) { - lookupNode(joinClause.collection); - lookupNode((BLangNode) joinClause.variableDefinitionNode); - lookupNode((BLangNode) joinClause.onClause); + if (lookupNode(joinClause.collection)) { + return; + } + if (lookupNode((BLangNode) joinClause.variableDefinitionNode)) { + return; + } + lookupNode(joinClause.onClause); } @Override public void visit(BLangLetClause letClause) { for (BLangLetVariable var : letClause.letVarDeclarations) { - lookupNode((BLangNode) var.definitionNode); + if (lookupNode((BLangNode) var.definitionNode)) { + return; + } } } @Override public void visit(BLangOnClause onClause) { - lookupNode(onClause.lhsExpr); + if (lookupNode(onClause.lhsExpr)) { + return; + } lookupNode(onClause.rhsExpr); } @@ -521,8 +554,11 @@ public void visit(BLangOrderKey orderKeyClause) { @Override public void visit(BLangOrderByClause orderByClause) { for (OrderKeyNode key : orderByClause.orderByKeyList) { - lookupNode((BLangNode) key); + if (lookupNode((BLangNode) key)) { + return; + } } + this.enclosingNode = orderByClause; } @Override @@ -552,38 +588,52 @@ public void visit(BLangLimitClause limitClause) { @Override public void visit(BLangWhile whileNode) { - lookupNode(whileNode.expr); - lookupNode(whileNode.body); + if (lookupNode(whileNode.expr)) { + return; + } + if (lookupNode(whileNode.body)) { + return; + } lookupNode(whileNode.onFailClause); } @Override public void visit(BLangLock lockNode) { - lookupNode(lockNode.body); + if (lookupNode(lockNode.body)) { + return; + } lookupNode(lockNode.onFailClause); } @Override public void visit(BLangTransaction transactionNode) { - lookupNode(transactionNode.transactionBody); + if (lookupNode(transactionNode.transactionBody)) { + return; + } lookupNode(transactionNode.onFailClause); } @Override public void visit(BLangTupleDestructure stmt) { - lookupNode(stmt.expr); + if (lookupNode(stmt.expr)) { + return; + } lookupNode(stmt.varRef); } @Override public void visit(BLangRecordDestructure stmt) { - lookupNode(stmt.expr); + if (lookupNode(stmt.expr)) { + return; + } lookupNode(stmt.varRef); } @Override public void visit(BLangErrorDestructure stmt) { - lookupNode(stmt.expr); + if (lookupNode(stmt.expr)) { + return; + } lookupNode(stmt.varRef); } @@ -594,7 +644,9 @@ public void visit(BLangForkJoin forkJoin) { @Override public void visit(BLangWorkerSend workerSendNode) { - lookupNode(workerSendNode.expr); + if (lookupNode(workerSendNode.expr)) { + return; + } setEnclosingNode(workerSendNode, workerSendNode.workerIdentifier.pos); } @@ -611,30 +663,42 @@ public void visit(BLangRollback rollbackNode) { @Override public void visit(BLangRecordLiteral recordLiteral) { for (RecordLiteralNode.RecordField field : recordLiteral.fields) { - lookupNode((BLangNode) field); + if (lookupNode((BLangNode) field)) { + return; + } } + this.enclosingNode = recordLiteral; } @Override public void visit(BLangTupleVarRef varRefExpr) { - lookupNodes(varRefExpr.expressions); - lookupNode((BLangNode) varRefExpr.restParam); + if (lookupNodes(varRefExpr.expressions)) { + return; + } + lookupNode(varRefExpr.restParam); } @Override public void visit(BLangRecordVarRef varRefExpr) { for (BLangRecordVarRef.BLangRecordVarRefKeyValue recordRefField : varRefExpr.recordRefFields) { - lookupNode(recordRefField.getBindingPattern()); + if (lookupNode(recordRefField.getBindingPattern())) { + return; + } } - lookupNode(varRefExpr.restParam); } @Override public void visit(BLangErrorVarRef varRefExpr) { - lookupNode(varRefExpr.message); - lookupNodes(varRefExpr.detail); - lookupNode(varRefExpr.cause); + if (lookupNode(varRefExpr.message)) { + return; + } + if (lookupNodes(varRefExpr.detail)) { + return; + } + if (lookupNode(varRefExpr.cause)) { + return; + } lookupNode(varRefExpr.restVar); } @@ -658,15 +722,24 @@ public void visit(BLangFieldBasedAccess fieldAccessExpr) { @Override public void visit(BLangIndexBasedAccess indexAccessExpr) { - lookupNode(indexAccessExpr.expr); - lookupNode(indexAccessExpr.indexExpr); + if (lookupNode(indexAccessExpr.expr)) { + return; + } + if (lookupNode(indexAccessExpr.indexExpr)) { + return; + } + this.enclosingNode = indexAccessExpr; } @Override public void visit(BLangInvocation invocationExpr) { // Looking up args expressions since requiredArgs and restArgs get set only when compilation is successful - lookupNodes(invocationExpr.argExprs); - lookupNode(invocationExpr.expr); + if (lookupNodes(invocationExpr.argExprs)) { + return; + } + if (lookupNode(invocationExpr.expr)) { + return; + } if (setEnclosingNode(invocationExpr, invocationExpr.name.pos)) { return; @@ -677,17 +750,26 @@ public void visit(BLangInvocation invocationExpr) { @Override public void visit(BLangTypeInit typeInit) { - lookupNode(typeInit.userDefinedType); - lookupNodes(typeInit.argsExpr); + if (lookupNode(typeInit.userDefinedType)) { + return; + } + if (lookupNodes(typeInit.argsExpr)) { + return; + } setEnclosingNode(typeInit, typeInit.pos); } @Override public void visit(BLangInvocation.BLangActionInvocation actionInvocationExpr) { - lookupNodes(actionInvocationExpr.argExprs); - lookupNodes(actionInvocationExpr.restArgs); - lookupNode(actionInvocationExpr.expr); - + if (lookupNodes(actionInvocationExpr.argExprs)) { + return; + } + if (lookupNodes(actionInvocationExpr.restArgs)) { + return; + } + if (lookupNode(actionInvocationExpr.expr)) { + return; + } if (setEnclosingNode(actionInvocationExpr, actionInvocationExpr.name.pos)) { return; } @@ -697,51 +779,80 @@ public void visit(BLangInvocation.BLangActionInvocation actionInvocationExpr) { @Override public void visit(BLangTernaryExpr ternaryExpr) { - lookupNode(ternaryExpr.expr); - lookupNode(ternaryExpr.thenExpr); - lookupNode(ternaryExpr.elseExpr); + if (lookupNode(ternaryExpr.expr)) { + return; + } + if (lookupNode(ternaryExpr.thenExpr)) { + return; + } + if (lookupNode(ternaryExpr.elseExpr)) { + return; + } + this.enclosingNode = ternaryExpr; } @Override public void visit(BLangWaitExpr awaitExpr) { lookupNodes(awaitExpr.exprList); - setEnclosingNode(awaitExpr, awaitExpr.pos); } @Override public void visit(BLangTrapExpr trapExpr) { - lookupNode(trapExpr.expr); + if (lookupNode(trapExpr.expr)) { + return; + } + this.enclosingNode = trapExpr; } @Override public void visit(BLangBinaryExpr binaryExpr) { - lookupNode(binaryExpr.lhsExpr); - lookupNode(binaryExpr.rhsExpr); + if (lookupNode(binaryExpr.lhsExpr)) { + return; + } + if (lookupNode(binaryExpr.rhsExpr)) { + return; + } + if (PositionUtil.withinRange(binaryExpr.pos.lineRange(), this.range)) { + this.enclosingNode = binaryExpr; + } } @Override public void visit(BLangElvisExpr elvisExpr) { - lookupNode(elvisExpr.lhsExpr); + if (lookupNode(elvisExpr.lhsExpr)) { + return; + } lookupNode(elvisExpr.rhsExpr); } @Override public void visit(BLangGroupExpr groupExpr) { - lookupNode(groupExpr.expression); + if (lookupNode(groupExpr.expression)) { + return; + } + this.enclosingNode = groupExpr; } @Override public void visit(BLangLetExpression letExpr) { for (BLangLetVariable var : letExpr.letVarDeclarations) { - lookupNode((BLangNode) var.definitionNode); + if (lookupNode((BLangNode) var.definitionNode)) { + return; + } } - lookupNode(letExpr.expr); + if (lookupNode(letExpr.expr)) { + return; + } + this.enclosingNode = letExpr; } @Override public void visit(BLangListConstructorExpr listConstructorExpr) { - lookupNodes(listConstructorExpr.exprs); + if (lookupNodes(listConstructorExpr.exprs)) { + return; + } + this.enclosingNode = listConstructorExpr; } @Override @@ -751,8 +862,15 @@ public void visit(BLangListConstructorExpr.BLangListConstructorSpreadOpExpr spre @Override public void visit(BLangTableConstructorExpr tableConstructorExpr) { - lookupNode(tableConstructorExpr.tableKeySpecifier); - lookupNodes(tableConstructorExpr.recordLiteralList); + if (lookupNode(tableConstructorExpr.tableKeySpecifier)) { + return; + } + if (lookupNodes(tableConstructorExpr.recordLiteralList)) { + return; + } + if (PositionUtil.withinRange(tableConstructorExpr.pos.lineRange(), this.range)) { + this.enclosingNode = tableConstructorExpr; + } } @Override @@ -767,7 +885,10 @@ public void visit(BLangListConstructorExpr.BLangArrayLiteral arrayLiteral) { @Override public void visit(BLangUnaryExpr unaryExpr) { - lookupNode(unaryExpr.expr); + if (lookupNode(unaryExpr.expr)) { + return; + } + this.enclosingNode = unaryExpr; } @Override @@ -777,9 +898,16 @@ public void visit(BLangTypedescExpr typedescExpr) { @Override public void visit(BLangTypeConversionExpr conversionExpr) { - lookupNodes(conversionExpr.annAttachments); - lookupNode(conversionExpr.typeNode); - lookupNode(conversionExpr.expr); + if (lookupNodes(conversionExpr.annAttachments)) { + return; + } + if (lookupNode(conversionExpr.typeNode)) { + return; + } + if (lookupNode(conversionExpr.expr)) { + return; + } + this.enclosingNode = conversionExpr; } @Override @@ -799,57 +927,92 @@ public void visit(BLangXMLAttribute xmlAttribute) { @Override public void visit(BLangXMLElementLiteral xmlElementLiteral) { - lookupNode(xmlElementLiteral.startTagName); - lookupNodes(xmlElementLiteral.attributes); - lookupNodes(xmlElementLiteral.children); - lookupNode(xmlElementLiteral.endTagName); + if (lookupNode(xmlElementLiteral.startTagName)) { + return; + } + if (lookupNodes(xmlElementLiteral.attributes)) { + return; + } + if (lookupNodes(xmlElementLiteral.children)) { + return; + } + if (lookupNode(xmlElementLiteral.endTagName)) { + return; + } + this.enclosingNode = xmlElementLiteral; } @Override public void visit(BLangXMLTextLiteral xmlTextLiteral) { - lookupNode(xmlTextLiteral.concatExpr); + if (lookupNode(xmlTextLiteral.concatExpr)) { + return; + } lookupNodes(xmlTextLiteral.textFragments); } @Override public void visit(BLangXMLCommentLiteral xmlCommentLiteral) { - lookupNode(xmlCommentLiteral.concatExpr); + if (lookupNode(xmlCommentLiteral.concatExpr)) { + return; + } lookupNodes(xmlCommentLiteral.textFragments); } @Override public void visit(BLangXMLProcInsLiteral xmlProcInsLiteral) { - lookupNode(xmlProcInsLiteral.dataConcatExpr); - lookupNodes(xmlProcInsLiteral.dataFragments); + if (lookupNode(xmlProcInsLiteral.dataConcatExpr)) { + return; + } + if (lookupNodes(xmlProcInsLiteral.dataFragments)) { + return; + } lookupNode(xmlProcInsLiteral.target); } @Override public void visit(BLangXMLQuotedString xmlQuotedString) { - lookupNode(xmlQuotedString.concatExpr); + if (lookupNode(xmlQuotedString.concatExpr)) { + return; + } lookupNodes(xmlQuotedString.textFragments); } @Override public void visit(BLangStringTemplateLiteral stringTemplateLiteral) { lookupNodes(stringTemplateLiteral.exprs); + setEnclosingNode(stringTemplateLiteral, stringTemplateLiteral.pos); } @Override public void visit(BLangRawTemplateLiteral rawTemplateLiteral) { - lookupNodes(rawTemplateLiteral.strings); - lookupNodes(rawTemplateLiteral.insertions); + if (lookupNodes(rawTemplateLiteral.strings)) { + return; + } + if (lookupNodes(rawTemplateLiteral.insertions)) { + return; + } + this.enclosingNode = rawTemplateLiteral; } @Override public void visit(BLangLambdaFunction bLangLambdaFunction) { - lookupNode(bLangLambdaFunction.function); + if (lookupNode(bLangLambdaFunction.function)) { + return; + } + if (PositionUtil.withinRange(bLangLambdaFunction.pos.lineRange(), this.range)) { + this.enclosingNode = bLangLambdaFunction; + } } @Override public void visit(BLangArrowFunction bLangArrowFunction) { - lookupNodes(bLangArrowFunction.params); - lookupNode(bLangArrowFunction.body); + if (lookupNodes(bLangArrowFunction.params)) { + return; + } + if (lookupNode(bLangArrowFunction.body)) { + return; + } + this.enclosingNode = bLangArrowFunction; } @Override @@ -859,19 +1022,26 @@ public void visit(BLangRestArgsExpression bLangVarArgsExpression) { @Override public void visit(BLangNamedArgsExpression bLangNamedArgsExpression) { - lookupNode(bLangNamedArgsExpression.expr); + if (lookupNode(bLangNamedArgsExpression.expr)) { + return; + } setEnclosingNode(bLangNamedArgsExpression.name, bLangNamedArgsExpression.name.pos); } @Override public void visit(BLangIsAssignableExpr assignableExpr) { - lookupNode(assignableExpr.lhsExpr); + if (lookupNode(assignableExpr.lhsExpr)) { + return; + } lookupNode(assignableExpr.typeNode); } @Override public void visit(BLangCheckedExpr checkedExpr) { - lookupNode(checkedExpr.expr); + if (lookupNode(checkedExpr.expr)) { + return; + } + this.enclosingNode = checkedExpr; } @Override @@ -881,7 +1051,10 @@ public void visit(BLangFail failExpr) { @Override public void visit(BLangCheckPanickedExpr checkPanickedExpr) { - lookupNode(checkPanickedExpr.expr); + if (lookupNode(checkPanickedExpr.expr)) { + return; + } + this.enclosingNode = checkPanickedExpr; } @Override @@ -891,24 +1064,37 @@ public void visit(BLangServiceConstructorExpr serviceConstructorExpr) { @Override public void visit(BLangTypeTestExpr typeTestExpr) { - lookupNode(typeTestExpr.expr); - lookupNode(typeTestExpr.typeNode); + if (lookupNode(typeTestExpr.expr)) { + return; + } + if (lookupNode(typeTestExpr.typeNode)) { + return; + } + this.enclosingNode = typeTestExpr; } @Override public void visit(BLangIsLikeExpr typeTestExpr) { - lookupNode(typeTestExpr.expr); + if (lookupNode(typeTestExpr.expr)) { + return; + } lookupNode(typeTestExpr.typeNode); } @Override public void visit(BLangAnnotAccessExpr annotAccessExpr) { - lookupNode(annotAccessExpr.expr); + if (lookupNode(annotAccessExpr.expr)) { + return; + } + this.enclosingNode = annotAccessExpr; } @Override public void visit(BLangQueryExpr queryExpr) { - lookupNodes(queryExpr.queryClauseList); + if (lookupNodes(queryExpr.queryClauseList)) { + return; + } + this.enclosingNode = queryExpr; } @Override @@ -923,14 +1109,20 @@ public void visit(BLangConstrainedType constrainedType) { @Override public void visit(BLangStreamType streamType) { - lookupNode(streamType.constraint); + if (lookupNode(streamType.constraint)) { + return; + } lookupNode(streamType.error); } @Override public void visit(BLangTableTypeNode tableType) { - lookupNode(tableType.constraint); - lookupNode(tableType.tableKeySpecifier); + if (lookupNode(tableType.constraint)) { + return; + } + if (lookupNode(tableType.tableKeySpecifier)) { + return; + } lookupNode(tableType.tableKeyTypeConstraint); } @@ -941,8 +1133,12 @@ public void visit(BLangUserDefinedType userDefinedType) { @Override public void visit(BLangFunctionTypeNode functionTypeNode) { - lookupNodes(functionTypeNode.params); - lookupNode(functionTypeNode.restParam); + if (lookupNodes(functionTypeNode.params)) { + return; + } + if (lookupNode(functionTypeNode.restParam)) { + return; + } lookupNode(functionTypeNode.returnTypeNode); } @@ -958,35 +1154,75 @@ public void visit(BLangIntersectionTypeNode intersectionTypeNode) { @Override public void visit(BLangClassDefinition classDefinition) { - lookupNodes(classDefinition.annAttachments); - lookupNodes(classDefinition.fields); - lookupNodes(classDefinition.referencedFields); - lookupNode(classDefinition.initFunction); - lookupNodes(classDefinition.functions); - lookupNodes(classDefinition.typeRefs); + if (lookupNodes(classDefinition.annAttachments)) { + return; + } + if (lookupNodes(classDefinition.fields)) { + return; + } + if (lookupNodes(classDefinition.referencedFields)) { + return; + } + if (lookupNode(classDefinition.initFunction)) { + return; + } + if (lookupNodes(classDefinition.functions)) { + return; + } + if (lookupAnnAttachmentsAttachedToFunctions(classDefinition.functions)) { + return; + } + if (lookupNodes(classDefinition.typeRefs)) { + return; + } setEnclosingNode(classDefinition, classDefinition.name.pos); } + private boolean lookupAnnAttachmentsAttachedToFunctions(List functions) { + for (BLangFunction func : functions) { + if (lookupNodes(func.annAttachments)) { + return true; + } + } + return false; + } + @Override public void visit(BLangInvocation.BLangResourceAccessInvocation resourceAccessInvocation) { - lookupNodes(resourceAccessInvocation.annAttachments); - lookupNode(resourceAccessInvocation.expr); - lookupNode(resourceAccessInvocation.resourceAccessPathSegments); - lookupNodes(resourceAccessInvocation.requiredArgs); - lookupNodes(resourceAccessInvocation.restArgs); + if (lookupNodes(resourceAccessInvocation.annAttachments)) { + return; + } + if (lookupNode(resourceAccessInvocation.expr)) { + return; + } + if (lookupNode(resourceAccessInvocation.resourceAccessPathSegments)) { + return; + } + if (lookupNodes(resourceAccessInvocation.requiredArgs)) { + return; + } + if (lookupNodes(resourceAccessInvocation.restArgs)) { + return; + } setEnclosingNode(resourceAccessInvocation, resourceAccessInvocation.pos); } @Override public void visit(BLangObjectTypeNode objectTypeNode) { - lookupNodes(objectTypeNode.fields); - lookupNodes(objectTypeNode.functions); + if (lookupNodes(objectTypeNode.fields)) { + return; + } + if (lookupNodes(objectTypeNode.functions)) { + return; + } lookupNodes(objectTypeNode.typeRefs); } @Override public void visit(BLangRecordTypeNode recordTypeNode) { - lookupNodes(recordTypeNode.fields); + if (lookupNodes(recordTypeNode.fields)) { + return; + } lookupNodes(recordTypeNode.typeRefs); } @@ -997,7 +1233,9 @@ public void visit(BLangFiniteTypeNode finiteTypeNode) { @Override public void visit(BLangTupleTypeNode tupleTypeNode) { - lookupNodes(tupleTypeNode.memberTypeNodes); + if (lookupNodes(tupleTypeNode.memberTypeNodes)) { + return; + } lookupNode(tupleTypeNode.restParamType); } @@ -1008,14 +1246,23 @@ public void visit(BLangErrorType errorType) { @Override public void visit(BLangErrorConstructorExpr errorConstructorExpr) { - lookupNode(errorConstructorExpr.errorTypeRef); - lookupNodes(errorConstructorExpr.positionalArgs); - lookupNodes(errorConstructorExpr.namedArgs); + if (lookupNode(errorConstructorExpr.errorTypeRef)) { + return; + } + if (lookupNodes(errorConstructorExpr.positionalArgs)) { + return; + } + if (lookupNodes(errorConstructorExpr.namedArgs)) { + return; + } + this.enclosingNode = errorConstructorExpr; } @Override public void visit(BLangIndexBasedAccess.BLangStructFieldAccessExpr fieldAccessExpr) { - lookupNode(fieldAccessExpr.expr); + if (lookupNode(fieldAccessExpr.expr)) { + return; + } lookupNode(fieldAccessExpr.indexExpr); } @@ -1024,52 +1271,67 @@ public void visit(BLangFieldBasedAccess.BLangStructFunctionVarRef functionVarRef if (setEnclosingNode(functionVarRef, functionVarRef.field.pos)) { return; } - lookupNode(functionVarRef.expr); } @Override public void visit(BLangIndexBasedAccess.BLangMapAccessExpr mapKeyAccessExpr) { - lookupNode(mapKeyAccessExpr.expr); + if (lookupNode(mapKeyAccessExpr.expr)) { + return; + } lookupNode(mapKeyAccessExpr.indexExpr); } @Override public void visit(BLangIndexBasedAccess.BLangArrayAccessExpr arrayIndexAccessExpr) { - lookupNode(arrayIndexAccessExpr.expr); + if (lookupNode(arrayIndexAccessExpr.expr)) { + return; + } lookupNode(arrayIndexAccessExpr.indexExpr); } @Override public void visit(BLangIndexBasedAccess.BLangTableAccessExpr tableKeyAccessExpr) { - lookupNode(tableKeyAccessExpr.expr); + if (lookupNode(tableKeyAccessExpr.expr)) { + return; + } lookupNode(tableKeyAccessExpr.indexExpr); } @Override public void visit(BLangIndexBasedAccess.BLangXMLAccessExpr xmlAccessExpr) { - lookupNode(xmlAccessExpr.expr); + if (lookupNode(xmlAccessExpr.expr)) { + return; + } lookupNode(xmlAccessExpr.indexExpr); } @Override public void visit(BLangRecordLiteral.BLangMapLiteral mapLiteral) { for (RecordLiteralNode.RecordField field : mapLiteral.fields) { - lookupNode((BLangNode) field); + if (lookupNode((BLangNode) field)) { + return; + } } } @Override public void visit(BLangRecordLiteral.BLangStructLiteral structLiteral) { for (RecordLiteralNode.RecordField field : structLiteral.fields) { - lookupNode((BLangNode) field); + if (lookupNode((BLangNode) field)) { + return; + } } } @Override public void visit(BLangInvocation.BFunctionPointerInvocation bFunctionPointerInvocation) { - lookupNodes(bFunctionPointerInvocation.requiredArgs); - lookupNodes(bFunctionPointerInvocation.restArgs); + if (lookupNodes(bFunctionPointerInvocation.requiredArgs)) { + return; + } + if (lookupNodes(bFunctionPointerInvocation.restArgs)) { + return; + } setEnclosingNode(bFunctionPointerInvocation, bFunctionPointerInvocation.name.pos); } @@ -1079,8 +1341,12 @@ public void visit(BLangInvocation.BLangAttachedFunctionInvocation iExpr) { return; } - lookupNode(iExpr.expr); - lookupNodes(iExpr.requiredArgs); + if (lookupNode(iExpr.expr)) { + return; + } + if (lookupNodes(iExpr.requiredArgs)) { + return; + } lookupNodes(iExpr.restArgs); } @@ -1091,13 +1357,17 @@ public void visit(BLangListConstructorExpr.BLangJSONArrayLiteral jsonArrayLitera @Override public void visit(BLangIndexBasedAccess.BLangJSONAccessExpr jsonAccessExpr) { - lookupNode(jsonAccessExpr.expr); + if (lookupNode(jsonAccessExpr.expr)) { + return; + } lookupNode(jsonAccessExpr.indexExpr); } @Override public void visit(BLangIndexBasedAccess.BLangStringAccessExpr stringAccessExpr) { - lookupNode(stringAccessExpr.expr); + if (lookupNode(stringAccessExpr.expr)) { + return; + } lookupNode(stringAccessExpr.indexExpr); } @@ -1106,7 +1376,6 @@ public void visit(BLangXMLNS.BLangLocalXMLNS xmlnsNode) { if (setEnclosingNode(xmlnsNode, xmlnsNode.prefix.pos)) { return; } - lookupNode(xmlnsNode.namespaceURI); } @@ -1126,16 +1395,26 @@ public void visit(BLangXMLSequenceLiteral bLangXMLSequenceLiteral) { @Override public void visit(BLangStatementExpression bLangStatementExpression) { - lookupNode(bLangStatementExpression.stmt); + if (lookupNode(bLangStatementExpression.stmt)) { + return; + } lookupNode(bLangStatementExpression.expr); } @Override public void visit(BLangTupleVariable bLangTupleVariable) { - lookupNodes(bLangTupleVariable.annAttachments); - lookupNode(bLangTupleVariable.typeNode); - lookupNodes(bLangTupleVariable.memberVariables); - lookupNode(bLangTupleVariable.restVariable); + if (lookupNodes(bLangTupleVariable.annAttachments)) { + return; + } + if (lookupNode(bLangTupleVariable.typeNode)) { + return; + } + if (lookupNodes(bLangTupleVariable.memberVariables)) { + return; + } + if (lookupNode(bLangTupleVariable.restVariable)) { + return; + } lookupNode(bLangTupleVariable.expr); } @@ -1147,10 +1426,16 @@ public void visit(BLangTupleVariableDef bLangTupleVariableDef) { @Override public void visit(BLangRecordVariable bLangRecordVariable) { for (BLangRecordVariable.BLangRecordVariableKeyValue var : bLangRecordVariable.variableList) { - lookupNode(var.valueBindingPattern); + if (lookupNode(var.valueBindingPattern)) { + return; + } + } + if (lookupNode(bLangRecordVariable.restParam)) { + return; + } + if (lookupNode(bLangRecordVariable.expr)) { + return; } - lookupNode(bLangRecordVariable.restParam); - lookupNode(bLangRecordVariable.expr); lookupNodes(bLangRecordVariable.annAttachments); } @@ -1161,18 +1446,34 @@ public void visit(BLangRecordVariableDef bLangRecordVariableDef) { @Override public void visit(BLangErrorVariable bLangErrorVariable) { - lookupNodes(bLangErrorVariable.annAttachments); - lookupNode(bLangErrorVariable.typeNode); - lookupNode(bLangErrorVariable.message); + if (lookupNodes(bLangErrorVariable.annAttachments)) { + return; + } + if (lookupNode(bLangErrorVariable.typeNode)) { + return; + } + if (lookupNode(bLangErrorVariable.message)) { + return; + } for (BLangErrorVariable.BLangErrorDetailEntry detail : bLangErrorVariable.detail) { - lookupNode(detail.valueBindingPattern); + if (lookupNode(detail.valueBindingPattern)) { + return; + } } - lookupNode(bLangErrorVariable.detailExpr); - lookupNode(bLangErrorVariable.cause); - lookupNode(bLangErrorVariable.reasonMatchConst); - lookupNode(bLangErrorVariable.restDetail); + if (lookupNode(bLangErrorVariable.detailExpr)) { + return; + } + if (lookupNode(bLangErrorVariable.cause)) { + return; + } + if (lookupNode(bLangErrorVariable.reasonMatchConst)) { + return; + } + if (lookupNode(bLangErrorVariable.restDetail)) { + return; + } lookupNode(bLangErrorVariable.expr); } @@ -1188,7 +1489,9 @@ public void visit(BLangWorkerFlushExpr workerFlushExpr) { @Override public void visit(BLangWorkerSyncSendExpr syncSendExpr) { - lookupNode(syncSendExpr.expr); + if (lookupNode(syncSendExpr.expr)) { + return; + } setEnclosingNode(syncSendExpr, syncSendExpr.workerIdentifier.pos); } @@ -1204,7 +1507,9 @@ public void visit(BLangWaitForAllExpr.BLangWaitLiteral waitLiteral) { @Override public void visit(BLangRecordLiteral.BLangRecordKeyValueField recordKeyValue) { - lookupNode(recordKeyValue.key); + if (lookupNode(recordKeyValue.key)) { + return; + } lookupNode(recordKeyValue.valueExpr); } @@ -1220,7 +1525,9 @@ public void visit(BLangRecordLiteral.BLangRecordSpreadOperatorField spreadOperat @Override public void visit(BLangWaitForAllExpr.BLangWaitKeyValue waitKeyValue) { - lookupNode(waitKeyValue.keyExpr); + if (lookupNode(waitKeyValue.keyExpr)) { + return; + } lookupNode(waitKeyValue.valueExpr); } @@ -1231,34 +1538,56 @@ public void visit(BLangXMLElementFilter xmlElementFilter) { @Override public void visit(BLangXMLElementAccess xmlElementAccess) { - lookupNode(xmlElementAccess.expr); - lookupNodes(xmlElementAccess.filters); + if (lookupNode(xmlElementAccess.expr)) { + return; + } + if (lookupNodes(xmlElementAccess.filters)) { + return; + } + this.enclosingNode = xmlElementAccess; } @Override public void visit(BLangXMLNavigationAccess xmlNavigation) { - lookupNode(xmlNavigation.expr); - lookupNode(xmlNavigation.childIndex); - lookupNodes(xmlNavigation.filters); + if (lookupNode(xmlNavigation.expr)) { + return; + } + if (lookupNode(xmlNavigation.childIndex)) { + return; + } + if (lookupNodes(xmlNavigation.filters)) { + return; + } + this.enclosingNode = xmlNavigation; } @Override public void visit(BLangMatchStatement matchStatementNode) { - lookupNode(matchStatementNode.expr); - lookupNodes(matchStatementNode.matchClauses); + if (lookupNode(matchStatementNode.expr)) { + return; + } + if (lookupNodes(matchStatementNode.matchClauses)) { + return; + } lookupNode(matchStatementNode.onFailClause); } @Override public void visit(BLangMatchClause matchClause) { - lookupNodes(matchClause.matchPatterns); - lookupNode(matchClause.matchGuard); + if (lookupNodes(matchClause.matchPatterns)) { + return; + } + if (lookupNode(matchClause.matchGuard)) { + return; + } lookupNode(matchClause.blockStmt); } @Override public void visit(BLangMappingMatchPattern mappingMatchPattern) { - lookupNodes(mappingMatchPattern.fieldMatchPatterns); + if (lookupNodes(mappingMatchPattern.fieldMatchPatterns)) { + return; + } lookupNode(mappingMatchPattern.restMatchPattern); } @@ -1269,15 +1598,23 @@ public void visit(BLangFieldMatchPattern fieldMatchPattern) { @Override public void visit(BLangListMatchPattern listMatchPattern) { - lookupNodes(listMatchPattern.matchPatterns); + if (lookupNodes(listMatchPattern.matchPatterns)) { + return; + } lookupNode(listMatchPattern.restMatchPattern); } @Override public void visit(BLangErrorMatchPattern errorMatchPattern) { - lookupNode(errorMatchPattern.errorTypeReference); - lookupNode(errorMatchPattern.errorMessageMatchPattern); - lookupNode(errorMatchPattern.errorCauseMatchPattern); + if (lookupNode(errorMatchPattern.errorTypeReference)) { + return; + } + if (lookupNode(errorMatchPattern.errorMessageMatchPattern)) { + return; + } + if (lookupNode(errorMatchPattern.errorCauseMatchPattern)) { + return; + } lookupNode(errorMatchPattern.errorFieldMatchPatterns); } @@ -1288,19 +1625,25 @@ public void visit(BLangErrorMessageMatchPattern errorMessageMatchPattern) { @Override public void visit(BLangErrorCauseMatchPattern errorCauseMatchPattern) { - lookupNode(errorCauseMatchPattern.simpleMatchPattern); + if (lookupNode(errorCauseMatchPattern.simpleMatchPattern)) { + return; + } lookupNode(errorCauseMatchPattern.errorMatchPattern); } @Override public void visit(BLangErrorFieldMatchPatterns errorFieldMatchPatterns) { - lookupNodes(errorFieldMatchPatterns.namedArgMatchPatterns); + if (lookupNodes(errorFieldMatchPatterns.namedArgMatchPatterns)) { + return; + } lookupNode(errorFieldMatchPatterns.restMatchPattern); } @Override public void visit(BLangSimpleMatchPattern simpleMatchPattern) { - lookupNode(simpleMatchPattern.constPattern); + if (lookupNode(simpleMatchPattern.constPattern)) { + return; + } lookupNode(simpleMatchPattern.varVariableName); } @@ -1331,7 +1674,9 @@ public void visit(BLangRestMatchPattern restMatchPattern) { @Override public void visit(BLangMappingBindingPattern mappingBindingPattern) { - lookupNodes(mappingBindingPattern.fieldBindingPatterns); + if (lookupNodes(mappingBindingPattern.fieldBindingPatterns)) { + return; + } lookupNode(mappingBindingPattern.restBindingPattern); } @@ -1347,9 +1692,15 @@ public void visit(BLangRestBindingPattern restBindingPattern) { @Override public void visit(BLangErrorBindingPattern errorBindingPattern) { - lookupNode(errorBindingPattern.errorMessageBindingPattern); - lookupNode(errorBindingPattern.errorTypeReference); - lookupNode(errorBindingPattern.errorCauseBindingPattern); + if (lookupNode(errorBindingPattern.errorMessageBindingPattern)) { + return; + } + if (lookupNode(errorBindingPattern.errorTypeReference)) { + return; + } + if (lookupNode(errorBindingPattern.errorCauseBindingPattern)) { + return; + } lookupNode(errorBindingPattern.errorFieldBindingPatterns); } @@ -1360,13 +1711,17 @@ public void visit(BLangErrorMessageBindingPattern errorMessageBindingPattern) { @Override public void visit(BLangErrorCauseBindingPattern errorCauseBindingPattern) { - lookupNode(errorCauseBindingPattern.simpleBindingPattern); + if (lookupNode(errorCauseBindingPattern.simpleBindingPattern)) { + return; + } lookupNode(errorCauseBindingPattern.errorBindingPattern); } @Override public void visit(BLangErrorFieldBindingPatterns errorFieldBindingPatterns) { - lookupNodes(errorFieldBindingPatterns.namedArgBindingPatterns); + if (lookupNodes(errorFieldBindingPatterns.namedArgBindingPatterns)) { + return; + } lookupNode(errorFieldBindingPatterns.restBindingPattern); } @@ -1387,16 +1742,40 @@ public void visit(BLangCaptureBindingPattern captureBindingPattern) { @Override public void visit(BLangListBindingPattern listBindingPattern) { - lookupNodes(listBindingPattern.bindingPatterns); + if (lookupNodes(listBindingPattern.bindingPatterns)) { + return; + } lookupNode(listBindingPattern.restBindingPattern); } @Override public void visit(BLangDo doNode) { - lookupNode(doNode.body); + if (lookupNode(doNode.body)) { + return; + } lookupNode(doNode.onFailClause); } + @Override + public void visit(BLangLiteral literalExpr) { + this.enclosingNode = literalExpr; + } + + @Override + public void visit(BLangValueType valueType) { + this.enclosingNode = valueType; + } + + @Override + public void visit(BLangConstRef constRef) { + this.enclosingNode = constRef; + } + + @Override + public void visit(BLangFieldBasedAccess.BLangNSPrefixedFieldBasedAccess nsPrefixedFieldBasedAccess) { + this.enclosingNode = nsPrefixedFieldBasedAccess; + } + @Override public void visit(BLangOnFailClause onFailClause) { lookupNode((BLangNode) onFailClause.variableDefinitionNode); @@ -1406,11 +1785,6 @@ public void visit(BLangOnFailClause onFailClause) { this.enclosingContainer = onFailClause; } - @Override - public void visit(BLangLiteral literal) { - setEnclosingNode(literal, literal.pos); - } - @Override public void visit(BLangRegExpTemplateLiteral regExpTemplateLiteral) { lookupNode(regExpTemplateLiteral.reDisjunction); @@ -1423,7 +1797,9 @@ public void visit(BLangReSequence reSequence) { @Override public void visit(BLangReAtomQuantifier reAtomQuantifier) { - lookupNode(reAtomQuantifier.atom); + if (lookupNode(reAtomQuantifier.atom)) { + return; + } lookupNode(reAtomQuantifier.quantifier); } @@ -1434,15 +1810,23 @@ public void visit(BLangReAtomCharOrEscape reAtomCharOrEscape) { @Override public void visit(BLangReQuantifier reQuantifier) { - lookupNode(reQuantifier.quantifier); + if (lookupNode(reQuantifier.quantifier)) { + return; + } lookupNode(reQuantifier.nonGreedyChar); } @Override public void visit(BLangReCharacterClass reCharacterClass) { - lookupNode(reCharacterClass.characterClassStart); - lookupNode(reCharacterClass.negation); - lookupNode(reCharacterClass.charSet); + if (lookupNode(reCharacterClass.characterClassStart)) { + return; + } + if (lookupNode(reCharacterClass.negation)) { + return; + } + if (lookupNode(reCharacterClass.charSet)) { + return; + } lookupNode(reCharacterClass.characterClassEnd); } @@ -1453,8 +1837,12 @@ public void visit(BLangReCharSet reCharSet) { @Override public void visit(BLangReCharSetRange reCharSetRange) { - lookupNode(reCharSetRange.lhsCharSetAtom); - lookupNode(reCharSetRange.dash); + if (lookupNode(reCharSetRange.lhsCharSetAtom)) { + return; + } + if (lookupNode(reCharSetRange.dash)) { + return; + } lookupNode(reCharSetRange.rhsCharSetAtom); } @@ -1466,8 +1854,12 @@ public void visit(BLangReAssertion reAssertion) { @Override public void visit(BLangReCapturingGroups reCapturingGroups) { lookupNode(reCapturingGroups.openParen); - lookupNode(reCapturingGroups.flagExpr); - lookupNode(reCapturingGroups.disjunction); + if (lookupNode(reCapturingGroups.flagExpr)) { + return; + } + if (lookupNode(reCapturingGroups.disjunction)) { + return; + } lookupNode(reCapturingGroups.closeParen); } @@ -1483,8 +1875,12 @@ public void visit(BLangReFlagsOnOff reFlagsOnOff) { @Override public void visit(BLangReFlagExpression reFlagExpression) { - lookupNode(reFlagExpression.questionMark); - lookupNode(reFlagExpression.flagsOnOff); + if (lookupNode(reFlagExpression.questionMark)) { + return; + } + if (lookupNode(reFlagExpression.flagsOnOff)) { + return; + } lookupNode(reFlagExpression.colon); } @@ -1495,7 +1891,10 @@ private boolean setEnclosingNode(BLangNode node, Location pos) { this.enclosingNode = node; return true; } - + if (this.enclosingNode == null && PositionUtil.withinRange(node.pos.lineRange(), this.range)) { + this.enclosingNode = node; + return true; + } return false; } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/ReferenceFinder.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/ReferenceFinder.java index 2e9af20fc9d3..536fdcc3f241 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/ReferenceFinder.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/ReferenceFinder.java @@ -29,7 +29,6 @@ import org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachment; import org.wso2.ballerinalang.compiler.tree.BLangBlockFunctionBody; import org.wso2.ballerinalang.compiler.tree.BLangClassDefinition; -import org.wso2.ballerinalang.compiler.tree.BLangClientDeclaration; import org.wso2.ballerinalang.compiler.tree.BLangCompilationUnit; import org.wso2.ballerinalang.compiler.tree.BLangErrorVariable; import org.wso2.ballerinalang.compiler.tree.BLangExprFunctionBody; @@ -158,7 +157,6 @@ import org.wso2.ballerinalang.compiler.tree.matchpatterns.BLangVarBindingPatternMatchPattern; import org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt; -import org.wso2.ballerinalang.compiler.tree.statements.BLangClientDeclarationStatement; import org.wso2.ballerinalang.compiler.tree.statements.BLangCompoundAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangDo; import org.wso2.ballerinalang.compiler.tree.statements.BLangErrorDestructure; @@ -285,18 +283,6 @@ public void visit(BLangXMLNS xmlnsNode) { find(xmlnsNode.namespaceURI); addIfSameSymbol(xmlnsNode.symbol, xmlnsNode.prefix.pos); } - - @Override - public void visit(BLangClientDeclarationStatement clientDeclStmt) { - find(clientDeclStmt.getClientDeclaration()); - } - - @Override - public void visit(BLangClientDeclaration clientDeclNode) { - find((BLangNode) clientDeclNode.getUri()); - addIfSameSymbol(clientDeclNode.symbol, clientDeclNode.prefix.pos); - } - @Override public void visit(BLangFunction funcNode) { find(funcNode.annAttachments); @@ -1225,11 +1211,6 @@ public void visit(BLangErrorVariableDef bLangErrorVariableDef) { @Override public void visit(BLangWorkerFlushExpr workerFlushExpr) { - // Ignore incomplete worker-flush expressions - // Ex: var a = flush; - if (workerFlushExpr.workerIdentifier == null) { - return; - } addIfSameSymbol(workerFlushExpr.workerSymbol, workerFlushExpr.workerIdentifier.pos); } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFactory.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFactory.java index 5258b8e3e07e..9ac47cc55a03 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFactory.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFactory.java @@ -23,7 +23,6 @@ import io.ballerina.compiler.api.impl.symbols.BallerinaAnnotationSymbol; import io.ballerina.compiler.api.impl.symbols.BallerinaClassFieldSymbol; import io.ballerina.compiler.api.impl.symbols.BallerinaClassSymbol; -import io.ballerina.compiler.api.impl.symbols.BallerinaClientDeclSymbol; import io.ballerina.compiler.api.impl.symbols.BallerinaConstantSymbol; import io.ballerina.compiler.api.impl.symbols.BallerinaEnumSymbol; import io.ballerina.compiler.api.impl.symbols.BallerinaFunctionSymbol; @@ -67,7 +66,6 @@ import org.wso2.ballerinalang.compiler.semantics.model.symbols.BAnnotationSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BAttachedFunction; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BClassSymbol; -import org.wso2.ballerinalang.compiler.semantics.model.symbols.BClientDeclarationSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BConstantSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BEnumSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol; @@ -234,10 +232,6 @@ public Symbol getBCompiledSymbol(BSymbol symbol, String name) { return createXMLNamespaceSymbol((BXMLNSSymbol) symbol); } - if (symbol.kind == SymbolKind.CLIENT_DECL) { - return createClientDeclSymbol((BClientDeclarationSymbol) symbol); - } - throw new IllegalArgumentException("Unsupported symbol type: " + symbol.getClass().getName()); } @@ -674,37 +668,6 @@ public BallerinaXMLNSSymbol createXMLNamespaceSymbol(BXMLNSSymbol symbol) { return symbolBuilder.build(); } - /** - * Creates a client declaration Symbol. - * - * @param symbol declaration symbol to convert - * @return {@link BallerinaClientDeclSymbol} - */ - private BallerinaClientDeclSymbol createClientDeclSymbol(BClientDeclarationSymbol symbol) { - BallerinaClientDeclSymbol.ClientDeclSymbolBuilder symbolBuilder = - new BallerinaClientDeclSymbol.ClientDeclSymbolBuilder(symbol.getName().getValue(), symbol, context); - - for (AnnotationAttachmentSymbol annot : symbol.getAnnotations()) { - BallerinaAnnotationAttachmentSymbol annotAttachment = - createAnnotAttachment((BAnnotationAttachmentSymbol) annot); - symbolBuilder.withAnnotationAttachment(annotAttachment); - symbolBuilder.withAnnotation(annotAttachment.typeDescriptor()); - } - - return symbolBuilder.build(); - } - - /** - * Get associated module of the given client declaration symbol. - * - * @param clientDeclSymbol Client declaration Symbol - * @return {@link BallerinaModule} symbol generated - */ - public BallerinaModule getAssociatedModule(BClientDeclarationSymbol clientDeclSymbol) { - BPackageSymbol packageSymbol = (BPackageSymbol) symResolver.resolveClientDeclPrefix(clientDeclSymbol); - return createModuleSymbol(packageSymbol, packageSymbol.getName().value); - } - /** * Create a module symbol. * diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFinder.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFinder.java index 15f37ce527a3..c7c1f71a34b9 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFinder.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFinder.java @@ -34,7 +34,6 @@ import org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachment; import org.wso2.ballerinalang.compiler.tree.BLangBlockFunctionBody; import org.wso2.ballerinalang.compiler.tree.BLangClassDefinition; -import org.wso2.ballerinalang.compiler.tree.BLangClientDeclaration; import org.wso2.ballerinalang.compiler.tree.BLangCompilationUnit; import org.wso2.ballerinalang.compiler.tree.BLangErrorVariable; import org.wso2.ballerinalang.compiler.tree.BLangExprFunctionBody; @@ -173,7 +172,6 @@ import org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt; import org.wso2.ballerinalang.compiler.tree.statements.BLangBreak; -import org.wso2.ballerinalang.compiler.tree.statements.BLangClientDeclarationStatement; import org.wso2.ballerinalang.compiler.tree.statements.BLangCompoundAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangContinue; import org.wso2.ballerinalang.compiler.tree.statements.BLangDo; @@ -291,20 +289,6 @@ public void visit(BLangXMLNS xmlnsNode) { lookupNode(xmlnsNode.namespaceURI); } - @Override - public void visit(BLangClientDeclarationStatement clientDeclarationStatement) { - lookupNode(clientDeclarationStatement.getClientDeclaration()); - } - - @Override - public void visit(BLangClientDeclaration clientDeclNode) { - if (setEnclosingNode(clientDeclNode.symbol, clientDeclNode.prefix.pos)) { - return; - } - - lookupNode((BLangNode) clientDeclNode.getUri()); - } - @Override public void visit(BLangFunction funcNode) { if (setEnclosingNode(funcNode.symbol, funcNode.name.pos)) { @@ -1264,10 +1248,6 @@ public void visit(BLangClassDefinition classDefinition) { lookupNodes(classDefinition.fields); lookupNodes(classDefinition.referencedFields); lookupNode(classDefinition.initFunction); - for (BLangFunction method : classDefinition.functions) { - lookupNodes(method.annAttachments); - } - lookupNodes(classDefinition.functions); lookupNodes(classDefinition.typeRefs); } @@ -1553,11 +1533,6 @@ public void visit(BLangErrorVariableDef bLangErrorVariableDef) { @Override public void visit(BLangWorkerFlushExpr workerFlushExpr) { - // Ignore incomplete worker-flush expressions - // Ex: var a = flush; - if (workerFlushExpr.workerIdentifier == null) { - return; - } setEnclosingNode(workerFlushExpr.workerSymbol, workerFlushExpr.workerIdentifier.pos); } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaAnnotationSymbol.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaAnnotationSymbol.java index fdfa195f6777..59a5af8e5540 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaAnnotationSymbol.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaAnnotationSymbol.java @@ -241,9 +241,6 @@ public static List getAttachPoints(int maskedPoints) { if (Symbols.isAttachPointPresent(maskedPoints, AttachPoints.RECORD_FIELD)) { annotationAttachPoints.add(AnnotationAttachPoint.RECORD_FIELD); } - if (Symbols.isAttachPointPresent(maskedPoints, AttachPoints.CLIENT)) { - annotationAttachPoints.add(AnnotationAttachPoint.CLIENT); - } return annotationAttachPoints; } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaClientDeclSymbol.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaClientDeclSymbol.java deleted file mode 100644 index 9e4f2f067562..000000000000 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaClientDeclSymbol.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package io.ballerina.compiler.api.impl.symbols; - -import io.ballerina.compiler.api.SymbolTransformer; -import io.ballerina.compiler.api.SymbolVisitor; -import io.ballerina.compiler.api.impl.SymbolFactory; -import io.ballerina.compiler.api.symbols.AnnotationAttachmentSymbol; -import io.ballerina.compiler.api.symbols.AnnotationSymbol; -import io.ballerina.compiler.api.symbols.ClientDeclSymbol; -import io.ballerina.compiler.api.symbols.ModuleSymbol; -import io.ballerina.compiler.api.symbols.SymbolKind; -import org.wso2.ballerinalang.compiler.semantics.model.symbols.BClientDeclarationSymbol; -import org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol; -import org.wso2.ballerinalang.compiler.util.CompilerContext; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * Represents an client declaration Symbol. - * - * @since 2201.3.0 - */ -public class BallerinaClientDeclSymbol extends BallerinaSymbol implements ClientDeclSymbol { - - private final String serviceUri; - private ModuleSymbol moduleSymbol; - private final List annots; - private final List annotAttachments; - - private BallerinaClientDeclSymbol(String name, BSymbol symbol, String serviceUri, List annots, - List annotAttachments, CompilerContext context) { - super(name, SymbolKind.CLIENT_DECLARATION, symbol, context); - this.annotAttachments = Collections.unmodifiableList(annotAttachments); - this.serviceUri = serviceUri; - this.annots = annots; - } - - @Override - public String serviceUri() { - return this.serviceUri; - } - - @Override - public ModuleSymbol moduleSymbol() { - if (this.moduleSymbol != null) { - return moduleSymbol; - } - - SymbolFactory symbolFactory = SymbolFactory.getInstance(context); - this.moduleSymbol = symbolFactory.getAssociatedModule((BClientDeclarationSymbol) this.getInternalSymbol()); - return this.moduleSymbol; - } - - @Override - public List annotations() { - return this.annots; - } - - @Override - public List annotAttachments() { - return this.annotAttachments; - } - - @Override - public void accept(SymbolVisitor visitor) { - visitor.visit(this); - } - - @Override - public T apply(SymbolTransformer transformer) { - return transformer.transform(this); - } - - /** - * Represents Ballerina client-declaration Symbol Builder. - */ - public static class ClientDeclSymbolBuilder extends SymbolBuilder { - - protected String uri; - private List annots = new ArrayList<>(); - private List annotAttachments = new ArrayList<>(); - - /** - * Symbol Builder's Constructor. - * - * @param name Symbol Name - * @param symbol client-declaration symbol - * @param context context of the compilation - */ - public ClientDeclSymbolBuilder(String name, BClientDeclarationSymbol symbol, CompilerContext context) { - super(name, SymbolKind.CLIENT_DECLARATION, symbol, context); - this.uri = symbol.uri; - } - - public ClientDeclSymbolBuilder withAnnotation(AnnotationSymbol annot) { - this.annots.add(annot); - return this; - } - - public ClientDeclSymbolBuilder withAnnotationAttachment(AnnotationAttachmentSymbol annotationAttachment) { - this.annotAttachments.add(annotationAttachment); - return this; - } - - @Override - public BallerinaClientDeclSymbol build() { - return new BallerinaClientDeclSymbol(this.name, this.bSymbol, this.uri, this.annots, this.annotAttachments, - this.context); - } - } -} diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/symbols/AnnotationAttachPoint.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/symbols/AnnotationAttachPoint.java index 96bb8aea6f3b..446ffc342902 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/symbols/AnnotationAttachPoint.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/symbols/AnnotationAttachPoint.java @@ -40,6 +40,5 @@ public enum AnnotationAttachPoint { EXTERNAL, VAR, CONST, - WORKER, - CLIENT + WORKER; } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/symbols/ClientDeclSymbol.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/symbols/ClientDeclSymbol.java deleted file mode 100644 index 8fccdf0d7b2c..000000000000 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/symbols/ClientDeclSymbol.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package io.ballerina.compiler.api.symbols; - -/** - * Represents an client declaration Symbol. - * - * @since 2201.3.0 - */ -public interface ClientDeclSymbol extends Symbol, Annotatable { - - /** - * Get the service URI. - * - * @return {@link String} service URI - */ - String serviceUri(); - - /** - * Get associated module symbol. - * - * @return {@link ModuleSymbol} module symbol - */ - ModuleSymbol moduleSymbol(); -} diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/symbols/SymbolKind.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/symbols/SymbolKind.java index a591f53355a4..bc4db4861dc5 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/symbols/SymbolKind.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/symbols/SymbolKind.java @@ -33,7 +33,6 @@ public enum SymbolKind { TYPE, VARIABLE, SERVICE_DECLARATION, - CLIENT_DECLARATION, CLASS, WORKER, ANNOTATION, diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/CompilationOptions.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/CompilationOptions.java index e7272dd685b2..1263b6ff0040 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/CompilationOptions.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/CompilationOptions.java @@ -34,7 +34,6 @@ public class CompilationOptions { Boolean dumpRawGraphs; Boolean withCodeGenerators; Boolean withCodeModifiers; - Boolean withIDLGenerators; Boolean configSchemaGen; Boolean exportOpenAPI; Boolean enableCache; @@ -42,8 +41,8 @@ public class CompilationOptions { CompilationOptions(Boolean offlineBuild, Boolean observabilityIncluded, Boolean dumpBir, Boolean dumpBirFile, String cloud, Boolean listConflictedClasses, Boolean sticky, Boolean dumpGraph, Boolean dumpRawGraphs, Boolean withCodeGenerators, - Boolean withCodeModifiers, Boolean withIDLGenerators, Boolean configSchemaGen, - Boolean exportOpenAPI, Boolean enableCache) { + Boolean withCodeModifiers, Boolean configSchemaGen, Boolean exportOpenAPI, + Boolean enableCache) { this.offlineBuild = offlineBuild; this.observabilityIncluded = observabilityIncluded; this.dumpBir = dumpBir; @@ -55,7 +54,6 @@ public class CompilationOptions { this.dumpRawGraphs = dumpRawGraphs; this.withCodeGenerators = withCodeGenerators; this.withCodeModifiers = withCodeModifiers; - this.withIDLGenerators = withIDLGenerators; this.configSchemaGen = configSchemaGen; this.exportOpenAPI = exportOpenAPI; this.enableCache = enableCache; @@ -105,10 +103,6 @@ public boolean withCodeModifiers() { return toBooleanDefaultIfNull(this.withCodeModifiers); } - public boolean withIDLGenerators() { - return toBooleanDefaultIfNull(this.withIDLGenerators); - } - public Boolean configSchemaGen() { return toBooleanDefaultIfNull(this.configSchemaGen); } @@ -184,11 +178,6 @@ CompilationOptions acceptTheirs(CompilationOptions theirOptions) { } else { compilationOptionsBuilder.withCodeModifiers(this.withCodeModifiers); } - if (theirOptions.withIDLGenerators != null) { - compilationOptionsBuilder.withIDLGenerators(theirOptions.withIDLGenerators); - } else { - compilationOptionsBuilder.withIDLGenerators(this.withIDLGenerators); - } if (theirOptions.configSchemaGen != null) { compilationOptionsBuilder.setConfigSchemaGen(theirOptions.configSchemaGen); } else { @@ -249,7 +238,6 @@ public static class CompilationOptionsBuilder { private Boolean dumpRawGraph; private Boolean withCodeGenerators; private Boolean withCodeModifiers; - private Boolean withIDLGenerators; private Boolean configSchemaGen; private Boolean exportOpenAPI; private Boolean enableCache; @@ -314,11 +302,6 @@ CompilationOptionsBuilder withCodeModifiers(Boolean value) { return this; } - CompilationOptionsBuilder withIDLGenerators(Boolean value) { - withIDLGenerators = value; - return this; - } - CompilationOptionsBuilder setExportOpenAPI(Boolean value) { exportOpenAPI = value; return this; @@ -332,8 +315,7 @@ public CompilationOptionsBuilder setEnableCache(Boolean value) { public CompilationOptions build() { return new CompilationOptions(offline, observabilityIncluded, dumpBir, dumpBirFile, cloud, listConflictedClasses, sticky, dumpGraph, dumpRawGraph, - withCodeGenerators, withCodeModifiers, withIDLGenerators, configSchemaGen, exportOpenAPI, - enableCache); + withCodeGenerators, withCodeModifiers, configSchemaGen, exportOpenAPI, enableCache); } } } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/DocumentContext.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/DocumentContext.java index a304ee0f9f11..8772490f4351 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/DocumentContext.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/DocumentContext.java @@ -48,7 +48,6 @@ * @since 2.0.0 */ class DocumentContext { - // TODO This constant should not be here private static final String IDENTIFIER_LITERAL_PREFIX = "'"; @@ -183,5 +182,4 @@ private void reportSyntaxDiagnostics(PackageID pkgID, SyntaxTree tree, BLangDiag DocumentContext duplicate() { return new DocumentContext(this.documentId, this.name, syntaxTree().toSourceCode()); } - } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleConfig.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleConfig.java index b5935a4a50f4..a4b12d111bbe 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleConfig.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleConfig.java @@ -112,5 +112,4 @@ public List resources() { public List testResources() { return testResources; } - } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleContext.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleContext.java index ef4f12d08771..811a9bd7da2a 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleContext.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleContext.java @@ -44,7 +44,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -91,7 +90,6 @@ class ModuleContext { private ModuleCompilationState moduleCompState; private Set allModuleLoadRequests = null; private Set allTestModuleLoadRequests = null; - private List idlPluginDiagnostics; ModuleContext(Project project, ModuleId moduleId, @@ -121,7 +119,6 @@ class ModuleContext { ProjectEnvironment projectEnvironment = project.projectEnvironmentContext(); this.bootstrap = new Bootstrap(projectEnvironment.getService(PackageResolver.class)); this.compilationCache = projectEnvironment.getService(CompilationCache.class); - this.idlPluginDiagnostics = new ArrayList<>(); } static ModuleContext from(Project project, ModuleConfig moduleConfig) { @@ -272,10 +269,6 @@ List diagnostics() { return Collections.emptyList(); } - List idlPluginDiagnostics() { - return idlPluginDiagnostics; - } - private void parseTestSources(BLangPackage pkgNode, PackageID pkgId, CompilerContext compilerContext) { BLangTestablePackage testablePkg = TreeBuilder.createTestablePackageNode(); // TODO Not sure why we need to do this. It is there in the current implementation diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Package.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Package.java index 5cb4a4592486..ea351526d3e6 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Package.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Package.java @@ -394,13 +394,13 @@ public static class Modifier { private DependencyManifest dependencyManifest; private Map moduleContextMap; private Project project; + private final DependencyGraph dependencyGraph; private CompilationOptions compilationOptions; private TomlDocumentContext ballerinaTomlContext; private TomlDocumentContext dependenciesTomlContext; private TomlDocumentContext cloudTomlContext; private TomlDocumentContext compilerPluginTomlContext; private MdDocumentContext packageMdContext; - private PackageContext oldPackageContext; public Modifier(Package oldPackage) { this.packageId = oldPackage.packageId(); @@ -408,13 +408,13 @@ public Modifier(Package oldPackage) { this.dependencyManifest = oldPackage.dependencyManifest(); this.moduleContextMap = copyModules(oldPackage); this.project = oldPackage.project; + this.dependencyGraph = oldPackage.getResolution().dependencyGraph(); this.compilationOptions = oldPackage.compilationOptions(); this.ballerinaTomlContext = oldPackage.packageContext.ballerinaTomlContext().orElse(null); this.dependenciesTomlContext = oldPackage.packageContext.dependenciesTomlContext().orElse(null); this.cloudTomlContext = oldPackage.packageContext.cloudTomlContext().orElse(null); this.compilerPluginTomlContext = oldPackage.packageContext.compilerPluginTomlContext().orElse(null); this.packageMdContext = oldPackage.packageContext.packageMdContext().orElse(null); - this.oldPackageContext = oldPackage.packageContext; } Modifier updateModules(Set newModuleContexts) { @@ -527,6 +527,8 @@ public Modifier removePackageMd() { return this; } + + Modifier updateBallerinaToml(BallerinaToml ballerinaToml) { this.ballerinaTomlContext = ballerinaToml.ballerinaTomlContext(); updatePackageManifest(); @@ -580,11 +582,9 @@ private Package createNewPackage() { this.compilationOptions, this.moduleContextMap, DependencyGraph.emptyGraph()); this.project.setCurrentPackage(new Package(newPackageContext, this.project)); - if (oldPackageContext.cachedCompilation() != null) { - DependencyGraph newDepGraph = this.project.currentPackage().getResolution() - .dependencyGraph(); - cleanPackageCache(oldPackageContext.getResolution().dependencyGraph(), newDepGraph); - } + DependencyGraph newDepGraph = this.project.currentPackage().getResolution() + .dependencyGraph(); + cleanPackageCache(this.dependencyGraph, newDepGraph); return this.project.currentPackage(); } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ResourceConfig.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ResourceConfig.java index 86e717a95018..a78e095b8614 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ResourceConfig.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ResourceConfig.java @@ -19,7 +19,6 @@ package io.ballerina.projects; import java.nio.file.Path; -import java.util.Optional; /** * {@code ResourceConfig} contains necessary configuration elements required @@ -64,11 +63,8 @@ public String name() { return name; } - public Optional content() { - if (content == null) { - return Optional.empty(); - } - return Optional.of(content); + byte[] content() { + return content; } Path path() { diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ResourceContext.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ResourceContext.java index 900b9fcd80ec..067b4fed5c96 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ResourceContext.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ResourceContext.java @@ -46,7 +46,7 @@ static ResourceContext from(ResourceConfig documentConfig) { return new ResourceContext( documentConfig.documentId(), documentConfig.name(), - documentConfig.content().orElse(null), + documentConfig.content(), documentConfig.path()); } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/BalaFiles.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/BalaFiles.java index c3adba1b7a6f..fd4c25c5c514 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/BalaFiles.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/BalaFiles.java @@ -20,7 +20,6 @@ import com.google.gson.Gson; import com.google.gson.JsonSyntaxException; -import com.google.gson.reflect.TypeToken; import io.ballerina.projects.DependencyGraph; import io.ballerina.projects.DependencyManifest; import io.ballerina.projects.ModuleDescriptor; @@ -33,18 +32,14 @@ import io.ballerina.projects.ProjectException; import io.ballerina.projects.internal.bala.CompilerPluginJson; import io.ballerina.projects.internal.bala.DependencyGraphJson; -import io.ballerina.projects.internal.bala.IDLClientsJson; import io.ballerina.projects.internal.bala.ModuleDependency; import io.ballerina.projects.internal.model.CompilerPluginDescriptor; import io.ballerina.projects.internal.model.PackageJson; import io.ballerina.projects.util.ProjectConstants; import io.ballerina.projects.util.ProjectUtils; -import io.ballerina.tools.text.LineRange; -import org.ballerinalang.model.elements.PackageID; import java.io.BufferedReader; import java.io.IOException; -import java.lang.reflect.Type; import java.net.URI; import java.nio.charset.Charset; import java.nio.file.FileSystem; @@ -70,7 +65,6 @@ import static io.ballerina.projects.util.ProjectConstants.COMPILER_PLUGIN_DIR; import static io.ballerina.projects.util.ProjectConstants.COMPILER_PLUGIN_JSON; import static io.ballerina.projects.util.ProjectConstants.DEPENDENCY_GRAPH_JSON; -import static io.ballerina.projects.util.ProjectConstants.IDL_CLIENTS_JSON; import static io.ballerina.projects.util.ProjectConstants.MODULES_ROOT; import static io.ballerina.projects.util.ProjectConstants.MODULE_NAME_SEPARATOR; import static io.ballerina.projects.util.ProjectConstants.PACKAGE_JSON; @@ -247,36 +241,6 @@ static DependencyGraphResult createPackageDependencyGraphFromJson(Path dependenc return new DependencyGraphResult(packageDependencyGraph, moduleDescriptorListMap); } - static Map>>> createIDLClientsMapFromJson ( - Path balaPath) { - if (Files.isDirectory(balaPath)) { - Path idlClientsJsonPath = balaPath.resolve(IDL_CLIENTS_JSON); - return getIdlClientsMap(idlClientsJsonPath); - } - - URI zipURI = URI.create("jar:" + balaPath.toAbsolutePath().toUri().toString()); - try (FileSystem zipFileSystem = FileSystems.newFileSystem(zipURI, new HashMap<>())) { - Path idlClientsJsonPath = zipFileSystem.getPath(IDL_CLIENTS_JSON); - return getIdlClientsMap(idlClientsJsonPath); - } catch (IOException e) { - throw new ProjectException("Failed to read idl client file from .bala:" + balaPath); - } - } - - private static Map>>> getIdlClientsMap( - Path idlClientsJsonPath) { - if (Files.notExists(idlClientsJsonPath)) { - return Collections.emptyMap(); - } - Type clientMapType = new TypeToken() { }.getType(); - try { - IDLClientsJson idlClientsJson = new Gson().fromJson(Files.readString(idlClientsJsonPath), clientMapType); - return IDLClientsJson.transformToMap(idlClientsJson); - } catch (IOException e) { - throw new ProjectException("failed to read idl clients file: " + idlClientsJsonPath); - } - } - private static PackageManifest createPackageManifestFromBalaFile(Path balrPath) { URI zipURI = URI.create("jar:" + balrPath.toAbsolutePath().toUri().toString()); try (FileSystem zipFileSystem = FileSystems.newFileSystem(zipURI, new HashMap<>())) { diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageConfigCreator.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageConfigCreator.java index e52a7ca907bb..df725eb0defd 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageConfigCreator.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageConfigCreator.java @@ -36,8 +36,6 @@ import io.ballerina.projects.ResourceConfig; import io.ballerina.projects.TomlDocument; import io.ballerina.projects.util.ProjectConstants; -import io.ballerina.tools.text.LineRange; -import org.ballerinalang.model.elements.PackageID; import java.nio.file.Path; import java.util.Collections; @@ -45,7 +43,6 @@ import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.Optional; import java.util.stream.Collectors; /** @@ -155,10 +152,6 @@ public static PackageConfig createPackageConfig(PackageData packageData, packageDependencyGraph); } - public static Map>>> getIDLClientMap (Path balaPath) { - return BalaFiles.createIDLClientsMapFromJson(balaPath); - } - private static ModuleConfig createDefaultModuleConfig(PackageDescriptor pkgDesc, ModuleData moduleData, PackageId packageId, diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ProjectDiagnosticErrorCode.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ProjectDiagnosticErrorCode.java index 9078950f72ce..c058a3e9e864 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ProjectDiagnosticErrorCode.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ProjectDiagnosticErrorCode.java @@ -35,14 +35,7 @@ public enum ProjectDiagnosticErrorCode implements DiagnosticCode { PACKAGE_NOT_FOUND("BCE5005", "package.not.found"), MISSING_PKG_INFO_IN_BALLERINA_TOML("BCE5006", "missing.package.info"), MODULE_NOT_FOUND("BCE5100", "module.not.found"), - UNSUPPORTED_COMPILER_PLUGIN_TYPE("BCE5200", "unsupported.compiler.plugin.type"), - - // IDL Plugin errors - INVALID_IDL_URI("BCE5300", "invalid.idl.uri"), - UNEXPECTED_IDL_EXCEPTION("BCE5301", "unexpected.idl.exception"), - MATCHING_PLUGIN_NOT_FOUND("BCE5303", "matching.plugin.not.found"), - CLIENT_DECL_IN_UNSUPPORTED_PROJECT_KIND("BCE5304", - "client.declaration.in.unsupported.project.kind") + UNSUPPORTED_COMPILER_PLUGIN_TYPE("BCE5200", "unsupported.compiler.plugin.type") ; private final String diagnosticId; diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ProjectFiles.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ProjectFiles.java index 127edd968178..cd7861b86e74 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ProjectFiles.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ProjectFiles.java @@ -107,7 +107,7 @@ private static List loadOtherModules(Path packageDirPath) { } } - public static ModuleData loadModule(Path moduleDirPath) { + private static ModuleData loadModule(Path moduleDirPath) { List srcDocs = loadDocuments(moduleDirPath); List testSrcDocs; Path testDirPath = moduleDirPath.resolve("tests"); diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/bala/IDLClientsJson.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/bala/IDLClientsJson.java deleted file mode 100644 index 76091fa8b581..000000000000 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/bala/IDLClientsJson.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.projects.internal.bala; - -import com.google.gson.annotations.SerializedName; -import io.ballerina.tools.text.LineRange; -import org.ballerinalang.model.elements.PackageID; -import org.wso2.ballerinalang.compiler.util.Name; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -/** - * Represents the JSON model of IDL client entries. - * - * @since 2201.3.0 - */ -public class IDLClientsJson { - - private static final String IDL_CLIENTS = "idlClients"; - @SerializedName(IDL_CLIENTS) private List idlClients; - - private IDLClientsJson(List idlClients) { - this.idlClients = idlClients; - } - - static class IDLClientEntry { - PackageID sourcePkgId; - List sourceFileInfo; - - IDLClientEntry(PackageID sourcePkgId, List sourceFileInfo) { - this.sourcePkgId = sourcePkgId; - this.sourceFileInfo = sourceFileInfo; - } - } - - static class PackageID { - String org; - String packageName; - String moduleNamePart; - String version; - - public PackageID(String org, String packageName, String moduleNamePart, String version) { - this.org = org; - this.packageName = packageName; - this.moduleNamePart = moduleNamePart; - this.version = version; - } - } - - static class SourceFileInfo { - String srcFile; - List lineRangeInfo; - - public SourceFileInfo(String srcFile, List lineRangeInfo) { - this.srcFile = srcFile; - this.lineRangeInfo = lineRangeInfo; - } - } - - static class LineRangeInfo { - LineRange lineRange; - PackageID clientId; - - public LineRangeInfo (LineRange lineRange, PackageID clientId) { - this.lineRange = lineRange; - this.clientId = clientId; - } - } - - static class LineRange { - LinePosition startLine; - LinePosition endLine; - - public LineRange(int startLine, int startOffset, int endLine, int endOffset) { - this.startLine = new LinePosition(startLine, startOffset); - this.endLine = new LinePosition(endLine, endOffset); - } - } - - static class LinePosition { - int line; - int offset; - - public LinePosition(int line, int offset) { - this.line = line; - this.offset = offset; - } - } - - public static IDLClientsJson from(Map>>> idlClientMap) { - List idlClientsJsonList = new ArrayList<>(); - for (Map.Entry>>> sourceEntry : idlClientMap.entrySet()) { - // Add source module - PackageID sourcePkgJson = getPackageIDJson(sourceEntry.getKey()); - List sourceFileInfos = new ArrayList<>(); - IDLClientEntry idlClientEntry = new IDLClientEntry(sourcePkgJson, sourceFileInfos); - idlClientsJsonList.add(idlClientEntry); - - // Add source files for added modules - for (Map.Entry>> sourceFileEntry : - sourceEntry.getValue().entrySet()) { - List lineRangeInfos = new ArrayList<>(); - sourceFileInfos.add(new SourceFileInfo(sourceFileEntry.getKey(), lineRangeInfos)); - - // Add line range and client module info - for (Map.Entry> lineRangeEntry : - sourceFileEntry.getValue().entrySet()) { - PackageID clientPkg = getPackageIDJson(lineRangeEntry.getValue().orElseThrow()); - LineRange lineRangeJson = new LineRange(lineRangeEntry.getKey().startLine().line(), - lineRangeEntry.getKey().startLine().offset(), - lineRangeEntry.getKey().endLine().line(), - lineRangeEntry.getKey().endLine().offset()); - lineRangeInfos.add(new LineRangeInfo(lineRangeJson, clientPkg)); - } - } - } - return new IDLClientsJson(idlClientsJsonList); - } - - public static Map>>> transformToMap ( - IDLClientsJson idlClientsJson) { - Map>>> - idlClientMap = new HashMap<>(); - - for (IDLClientEntry idlClientEntry : idlClientsJson.idlClients) { - // Add source module to map - PackageID sourcePkgId = idlClientEntry.sourcePkgId; - org.ballerinalang.model.elements.PackageID pkgId = getPackageID(sourcePkgId); - List sourceFileInfos = idlClientEntry.sourceFileInfo; - Map>> srcFileMap = - new HashMap<>(); - idlClientMap.put(pkgId, srcFileMap); - - // Add source file info - for (SourceFileInfo sourceFileInfo : sourceFileInfos) { - Map> - lineRangeMap = new HashMap<>(); - srcFileMap.put(sourceFileInfo.srcFile, lineRangeMap); - List lineRangeInfos = sourceFileInfo.lineRangeInfo; - - // Add line range info - for (LineRangeInfo lineRangeInfo : lineRangeInfos) { - org.ballerinalang.model.elements.PackageID clientPkgId = getPackageID(lineRangeInfo.clientId); - lineRangeMap.put( - createLineRange(lineRangeInfo.lineRange, sourceFileInfo.srcFile), Optional.of(clientPkgId)); - } - } - } - return idlClientMap; - } - - private static PackageID getPackageIDJson(org.ballerinalang.model.elements.PackageID sourcePkg) { - return new PackageID(sourcePkg.orgName.value, sourcePkg.pkgName.value, sourcePkg.name.value, - sourcePkg.version.value); - } - - private static org.ballerinalang.model.elements.PackageID getPackageID(PackageID sourcePkgId) { - return new org.ballerinalang.model.elements.PackageID(new Name(sourcePkgId.org), - new Name(sourcePkgId.packageName), new Name(sourcePkgId.moduleNamePart), - new Name(sourcePkgId.version), null); - } - - private static io.ballerina.tools.text.LineRange createLineRange(LineRange lineRange, String srcFileName) { - io.ballerina.tools.text.LinePosition start = io.ballerina.tools.text.LinePosition.from( - lineRange.startLine.line, lineRange.startLine.offset); - io.ballerina.tools.text.LinePosition end = io.ballerina.tools.text.LinePosition.from( - lineRange.endLine.line, lineRange.endLine.offset); - return io.ballerina.tools.text.LineRange.from(srcFileName, start, end); - } -} diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/plugins/CompilerPlugins.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/plugins/CompilerPlugins.java index 3b59615ab32f..7a5a5c04146e 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/plugins/CompilerPlugins.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/plugins/CompilerPlugins.java @@ -19,25 +19,15 @@ import io.ballerina.compiler.internal.parser.tree.STAnnotationNode; import io.ballerina.compiler.syntax.tree.AnnotationNode; -import io.ballerina.compiler.syntax.tree.BasicLiteralNode; -import io.ballerina.compiler.syntax.tree.ClientDeclarationNode; -import io.ballerina.compiler.syntax.tree.ModuleClientDeclarationNode; -import io.ballerina.compiler.syntax.tree.Node; import io.ballerina.compiler.syntax.tree.NodeList; -import io.ballerina.compiler.syntax.tree.SyntaxKind; -import io.ballerina.projects.Project; import io.ballerina.projects.ProjectException; import io.ballerina.projects.plugins.CompilerPlugin; -import io.ballerina.projects.plugins.IDLGeneratorPlugin; -import io.ballerina.projects.util.ProjectConstants; -import java.io.IOException; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; -import java.nio.file.Files; import java.nio.file.Path; import java.security.AccessController; import java.security.PrivilegedAction; @@ -45,7 +35,6 @@ import java.util.Comparator; import java.util.List; import java.util.ServiceLoader; -import java.util.stream.Stream; /** * This class contains a set of utility method related to compiler plugin implementation. @@ -70,16 +59,6 @@ public static List getBuiltInPlugins() { return builtInPlugins; } - public static List getBuiltInIDLPlugins() { - List builtInIDLPlugins = new ArrayList<>(); - ServiceLoader idlPluginServiceLoader = ServiceLoader - .load(IDLGeneratorPlugin.class, CompilerPlugins.class.getClassLoader()); - for (IDLGeneratorPlugin idlGeneratorPlugin : idlPluginServiceLoader) { - builtInIDLPlugins.add(idlGeneratorPlugin); - } - return builtInIDLPlugins; - } - public static CompilerPlugin loadCompilerPlugin(String pluginClassName, List jarDependencyPaths) { ClassLoader classLoader = createClassLoader(jarDependencyPaths); Class pluginClass = loadPluginClass(pluginClassName, classLoader); @@ -137,15 +116,6 @@ private static URL[] getJarURLS(List jarDependencyPaths) { return jarURLS; } - public static boolean moduleExists(String moduleName, Project project) { - Path moduleRoot = project.sourceRoot().resolve(ProjectConstants.GENERATED_MODULES_ROOT).resolve(moduleName); - try (Stream list = Files.list(moduleRoot)) { - return Files.exists(moduleRoot) && list.findFirst().isPresent(); - } catch (IOException e) { - return false; - } - } - public static List annotationsAsStr(NodeList supportedAnnotations) { List annotations = new ArrayList<>(); StringBuilder id = new StringBuilder(); @@ -162,17 +132,4 @@ public static List annotationsAsStr(NodeList supportedAn annotations.sort(Comparator.naturalOrder()); return annotations; } - - public static String getUri(Node clientNode) { - BasicLiteralNode clientUri; - - if (clientNode.kind() == SyntaxKind.MODULE_CLIENT_DECLARATION) { - clientUri = ((ModuleClientDeclarationNode) clientNode).clientUri(); - } else { - clientUri = ((ClientDeclarationNode) clientNode).clientUri(); - } - - String text = clientUri.literalToken().text(); - return text.substring(1, text.length() - 1); - } } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/plugins/IDLClientGenerator.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/plugins/IDLClientGenerator.java deleted file mode 100644 index 9b414132865d..000000000000 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/plugins/IDLClientGenerator.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.projects.plugins; - -/** - * Represent an IDL client analysis task. - * - * @since 2.3.0 - */ -public abstract class IDLClientGenerator { - - /** - * Checks whether the plugin can support code generation for the passed client node. - * - * @param generatorContext IDL client source generator context - * @return whether the client can be generated - */ - public abstract boolean canHandle(IDLSourceGeneratorContext generatorContext); - - /** - * Performs a IDL generation with the passed context. - * - * @param generatorContext IDL client source generator context - */ - public abstract void perform(IDLSourceGeneratorContext generatorContext); -} diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/plugins/IDLGeneratorPlugin.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/plugins/IDLGeneratorPlugin.java deleted file mode 100644 index d53cec403176..000000000000 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/plugins/IDLGeneratorPlugin.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.projects.plugins; - -/** - * Represents a collection of IDL generator tasks that can analyze syntax node and symbols - * and generate new client. - *

- * These tasks may report diagnostics as well. - * - * @since 2.3.0 - */ -public abstract class IDLGeneratorPlugin { - - /** - * Initializes the IDL client code generator with the plugin context. - * - * @param pluginContext the context to which the client can be added. - */ - public abstract void init(IDLPluginContext pluginContext); -} diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/plugins/IDLPluginContext.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/plugins/IDLPluginContext.java deleted file mode 100644 index 7e5335fce4bc..000000000000 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/plugins/IDLPluginContext.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.projects.plugins; - -/** - * Represent the context required to initialize a {@code IDLClientGenerator}. - *

- * This class can be used to add various generator tasks during the {@code CodeGenerator} initialization. - * - * @since 2.3.0 - */ -public interface IDLPluginContext { - /** - * Add a {@code IDLClientGenerator} instance to the current compilation. - * - * @param codeGenerator the {@code IDLClientGenerator} instance - */ - void addCodeGenerator(IDLClientGenerator codeGenerator); - -} diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/plugins/IDLSourceGeneratorContext.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/plugins/IDLSourceGeneratorContext.java deleted file mode 100644 index 84375c2f118f..000000000000 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/plugins/IDLSourceGeneratorContext.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.projects.plugins; - -import io.ballerina.compiler.syntax.tree.AnnotationNode; -import io.ballerina.compiler.syntax.tree.Node; -import io.ballerina.compiler.syntax.tree.NodeList; -import io.ballerina.projects.ModuleConfig; -import io.ballerina.projects.Package; -import io.ballerina.tools.diagnostics.Diagnostic; - -import java.nio.file.Path; - -/** - * The context for the IDl client source code generator task. - * - * @since 2.3.0 - */ -public interface IDLSourceGeneratorContext { - - Node clientNode(); - - Package currentPackage(); - - Path resourcePath(); - - void reportDiagnostic(Diagnostic diagnostic); - - void addClient(ModuleConfig clientModule, NodeList supportedAnnotations); -} diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectConstants.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectConstants.java index b1d5857e220a..8c17fb092720 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectConstants.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectConstants.java @@ -42,7 +42,6 @@ public class ProjectConstants { public static final String BALA_JSON = "bala.json"; public static final String COMPILER_PLUGIN_JSON = "compiler-plugin.json"; public static final String DEPENDENCY_GRAPH_JSON = "dependency-graph.json"; - public static final String IDL_CLIENTS_JSON = "idl-clients.json"; public static final String BUILD_FILE = "build"; public static final String SOURCE_DIR_NAME = "src"; @@ -64,7 +63,6 @@ public class ProjectConstants { // Bala specific constants public static final String MODULES_ROOT = "modules"; - public static final String GENERATED_MODULES_ROOT = "generated"; public static final String LIB_DIR = "lib"; public static final String COMPILER_PLUGIN_DIR = "compiler-plugin"; @@ -80,7 +78,6 @@ public class ProjectConstants { public static final String BLANG_COMPILED_PKG_BIR_EXT = ".bir"; public static final String BLANG_COMPILED_JAR_EXT = ".jar"; public static final String RESOURCE_DIR_NAME = "resources"; - public static final String IDL_CACHE_FILE = "idl-plugin-cache.json"; public static final String TARGET_BALA_DIR_NAME = "bala"; public static final String BALLERINA_HOME = "ballerina.home"; diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectPaths.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectPaths.java index 34d449a1a46c..1a09958faa1f 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectPaths.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectPaths.java @@ -55,21 +55,12 @@ public static Path packageRoot(Path filepath) throws ProjectException { if (isModulesRoot(filepath)) { return findProjectRoot(filepath).orElseThrow(); } - if (isGeneratedModulesRoot(filepath)) { - return findProjectRoot(filepath).orElseThrow(); - } if (isAModuleRoot(filepath)) { return findProjectRoot(filepath).orElseThrow(); } - if (isAGeneratedModuleRoot(filepath)) { - return findProjectRoot(filepath).orElseThrow(); - } if (isAModuleTestsRoot(filepath)) { return findProjectRoot(filepath).orElseThrow(); } - if (isAGeneratedModuleTestsRoot(filepath)) { - return findProjectRoot(filepath).orElseThrow(); - } throw new ProjectException("provided directory does not belong to a Ballerina package: " + filepath); } @@ -115,19 +106,6 @@ public static Path packageRoot(Path filepath) throws ProjectException { Path modulesRoot = Optional.of(Optional.of(testsRoot.getParent()).get().getParent()).get(); return modulesRoot.getParent(); } - - // check if the file is a source file in a non-default module - if (isGeneratedModuleSrcFile(filepath)) { - Path modulesRoot = Optional.of(Optional.of(absFilePath.getParent()).get().getParent()).get(); - return modulesRoot.getParent(); - } - // check if the file is a test file in a non-default module - if (isGeneratedModuleTestFile(filepath)) { - Path testsRoot = Optional.of(absFilePath.getParent()).get(); - Path modulesRoot = Optional.of(Optional.of(testsRoot.getParent()).get().getParent()).get(); - return modulesRoot.getParent(); - } - } else { // check if the file is a source file in a bala project if (isBalaProjectSrcFile(filepath)) { @@ -149,16 +127,6 @@ private static boolean isModulesRoot(Path filepath) { return false; } - private static boolean isGeneratedModulesRoot(Path filepath) { - Path absFilePath = filepath.toAbsolutePath().normalize(); - Optional projectRoot = findProjectRoot(absFilePath); - if (projectRoot.isPresent()) { - Path modulesRoot = projectRoot.get().resolve(ProjectConstants.GENERATED_MODULES_ROOT); - return modulesRoot.toAbsolutePath().normalize().toString().equals(absFilePath.toString()); - } - return false; - } - private static boolean isAModuleTestsRoot(Path filepath) { Path absFilePath = filepath.toAbsolutePath().normalize(); Optional projectRoot = findProjectRoot(filepath); @@ -184,26 +152,6 @@ private static boolean isAModuleTestsRoot(Path filepath) { return false; } - private static boolean isAGeneratedModuleTestsRoot(Path filepath) { - Path absFilePath = filepath.toAbsolutePath().normalize(); - Optional projectRoot = findProjectRoot(filepath); - if (projectRoot.isPresent()) { - Path fileName = absFilePath.getFileName(); - if (fileName != null) { - if (fileName.toString().equals(ProjectConstants.TEST_DIR_NAME)) { - Path parent = filepath.getParent(); - if (parent != null) { - // Check if it is the root of a generated module - Path moduleRoot = projectRoot.get().resolve(ProjectConstants.GENERATED_MODULES_ROOT).resolve( - Optional.of(parent.getFileName()).get()); - return moduleRoot.toAbsolutePath().normalize().toString().equals(parent.toString()); - } - } - } - } - return false; - } - private static boolean isAModuleRoot(Path filepath) { Path absFilePath = filepath.toAbsolutePath().normalize(); Optional projectRoot = findProjectRoot(absFilePath); @@ -217,19 +165,6 @@ private static boolean isAModuleRoot(Path filepath) { return false; } - private static boolean isAGeneratedModuleRoot(Path filepath) { - Path absFilePath = filepath.toAbsolutePath().normalize(); - Optional projectRoot = findProjectRoot(absFilePath); - if (projectRoot.isPresent()) { - Path fileName = absFilePath.getFileName(); - if (fileName != null) { - Path moduleRoot = projectRoot.get().resolve(ProjectConstants.GENERATED_MODULES_ROOT).resolve(fileName); - return moduleRoot.toAbsolutePath().normalize().toString().equals(absFilePath.toString()); - } - } - return false; - } - /** * Returns whether the provided path is a valid Ballerina source file. * @@ -295,15 +230,6 @@ public static boolean isStandaloneBalFile(Path filepath) { return false; } - // check if the filepath is a source filepath in a generated module - if (isGeneratedModuleSrcFile(filepath)) { - return false; - } - // check if the filepath is a test filepath in a generated module - if (isGeneratedModuleTestFile(filepath)) { - return false; - } - if (isBalaProjectSrcFile(filepath)) { return false; } @@ -335,14 +261,6 @@ static boolean isNonDefaultModuleSrcFile(Path filePath) { && hasBallerinaToml(projectRoot); } - private static boolean isGeneratedModuleSrcFile(Path filePath) { - Path absFilePath = filePath.toAbsolutePath().normalize(); - Path modulesRoot = Optional.of(Optional.of(absFilePath.getParent()).get().getParent()).get(); - Path projectRoot = modulesRoot.getParent(); - return ProjectConstants.GENERATED_MODULES_ROOT.equals(modulesRoot.toFile().getName()) - && hasBallerinaToml(projectRoot); - } - static boolean isBalaProjectSrcFile(Path filePath) { Path absFilePath = filePath.toAbsolutePath().normalize(); Path modulesRoot = Optional.of(Optional.of(absFilePath.getParent()).get().getParent()).get(); @@ -363,18 +281,6 @@ static boolean isNonDefaultModuleTestFile(Path filePath) { && hasBallerinaToml(projectRoot); } - private static boolean isGeneratedModuleTestFile(Path filePath) { - Path absFilePath = filePath.toAbsolutePath().normalize(); - Path testsRoot = Optional.of(absFilePath.getParent()).get(); - if (!ProjectConstants.TEST_DIR_NAME.equals(testsRoot.toFile().getName())) { - return false; - } - Path modulesRoot = Optional.of(Optional.of(testsRoot.getParent()).get().getParent()).get(); - Path projectRoot = modulesRoot.getParent(); - return ProjectConstants.GENERATED_MODULES_ROOT.equals(modulesRoot.toFile().getName()) - && hasBallerinaToml(projectRoot); - } - private static boolean hasBallerinaToml(Path filePath) { Path absFilePath = filePath.toAbsolutePath().normalize(); return absFilePath.resolve(BALLERINA_TOML).toFile().exists(); diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectUtils.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectUtils.java index 5b1668f77894..75f6a0c1ce15 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectUtils.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectUtils.java @@ -20,13 +20,10 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonSyntaxException; -import io.ballerina.projects.DocumentConfig; import io.ballerina.projects.DocumentId; import io.ballerina.projects.JarLibrary; import io.ballerina.projects.JvmTarget; import io.ballerina.projects.Module; -import io.ballerina.projects.ModuleConfig; -import io.ballerina.projects.ModuleDescriptor; import io.ballerina.projects.ModuleId; import io.ballerina.projects.ModuleName; import io.ballerina.projects.Package; @@ -40,12 +37,8 @@ import io.ballerina.projects.Project; import io.ballerina.projects.ProjectException; import io.ballerina.projects.ResolvedPackageDependency; -import io.ballerina.projects.ResourceConfig; import io.ballerina.projects.SemanticVersion; import io.ballerina.projects.Settings; -import io.ballerina.projects.internal.DocumentData; -import io.ballerina.projects.internal.ModuleData; -import io.ballerina.projects.internal.ProjectFiles; import io.ballerina.projects.internal.model.BuildJson; import io.ballerina.projects.internal.model.Dependency; import org.apache.commons.compress.archivers.jar.JarArchiveEntry; @@ -979,16 +972,13 @@ public static boolean isProjectUpdated(Project project) { try { BuildJson buildJson = readBuildJson(buildFile); long lastProjectUpdatedTime = FileUtils.lastModifiedTimeOfBalProject(project.sourceRoot()); - PackageName packageName = project.currentPackage().packageName(); - if (buildJson == null - || buildJson.getLastModifiedTime() == null - || buildJson.getLastModifiedTime().entrySet().isEmpty() - || buildJson.getLastModifiedTime().get(packageName.value()) == null) { - return true; // return true if `build` file does not exist + if (buildJson != null + && buildJson.getLastModifiedTime() != null + && !buildJson.getLastModifiedTime().entrySet().isEmpty()) { + long defaultModuleLastModifiedTime = buildJson.getLastModifiedTime() + .get(project.currentPackage().packageName().value()); + return lastProjectUpdatedTime > defaultModuleLastModifiedTime; } - long defaultModuleLastModifiedTime = buildJson.getLastModifiedTime() - .get(packageName.value()); - return lastProjectUpdatedTime > defaultModuleLastModifiedTime; } catch (IOException e) { // if reading `build` file fails // delete `build` file and return true @@ -1178,45 +1168,4 @@ public static Path getPackagePath(Path balaDirPath, String org, String name, Str } return balaPath; } - - public static void writeModule(ModuleConfig moduleConfig, Path modulesRoot) throws IOException { - Path moduleDirPath = modulesRoot.resolve(moduleConfig.moduleDescriptor().name().moduleNamePart()); - Files.createDirectories(moduleDirPath); - for (DocumentConfig sourceDoc : moduleConfig.sourceDocs()) { - Files.writeString(moduleDirPath.resolve(sourceDoc.name()), sourceDoc.content()); - } - - Path moduleTestDirPath = moduleDirPath.resolve(ProjectConstants.TEST_DIR_NAME); - Files.createDirectories(moduleTestDirPath); - for (DocumentConfig testSourceDoc : moduleConfig.testSourceDocs()) { - Files.writeString(moduleTestDirPath.resolve(testSourceDoc.name()), testSourceDoc.content()); - } - - Path moduleResourcesDirPath = moduleDirPath.resolve(ProjectConstants.RESOURCE_DIR_NAME); - Files.createDirectories(moduleTestDirPath); - for (ResourceConfig resource : moduleConfig.resources()) { - Files.write(moduleResourcesDirPath.resolve(resource.name()), resource.content().orElse(null)); - } - } - - public static ModuleConfig createModuleConfig (String moduleName, Project project) { - ModuleData moduleData = ProjectFiles.loadModule( - project.sourceRoot().resolve(ProjectConstants.GENERATED_MODULES_ROOT).resolve(moduleName)); - ModuleId moduleId = ModuleId.create(moduleName, project.currentPackage().packageId()); - List documentConfigs = new ArrayList<>(); - List testDocumentConfigs = new ArrayList<>(); - for (DocumentData sourceDoc : moduleData.sourceDocs()) { - DocumentId documentId = DocumentId.create(sourceDoc.name(), moduleId); - documentConfigs.add(DocumentConfig.from(documentId, sourceDoc.content(), sourceDoc.name())); - } - for (DocumentData sourceDoc : moduleData.testSourceDocs()) { - DocumentId documentId = DocumentId.create(sourceDoc.name(), moduleId); - testDocumentConfigs.add(DocumentConfig.from(documentId, sourceDoc.content(), sourceDoc.name())); - } - ModuleDescriptor moduleDescriptor = ModuleDescriptor.from( - ModuleName.from(project.currentPackage().packageName(), moduleName), - project.currentPackage().descriptor()); - return ModuleConfig.from( - moduleId, moduleDescriptor, documentConfigs, testDocumentConfigs, null, new ArrayList<>()); - } } diff --git a/compiler/ballerina-lang/src/main/java/module-info.java b/compiler/ballerina-lang/src/main/java/module-info.java index e417f5d3181e..b9a7ebc5bb6a 100644 --- a/compiler/ballerina-lang/src/main/java/module-info.java +++ b/compiler/ballerina-lang/src/main/java/module-info.java @@ -1,6 +1,5 @@ module io.ballerina.lang { uses io.ballerina.projects.plugins.CompilerPlugin; - uses io.ballerina.projects.plugins.IDLGeneratorPlugin; requires java.compiler; requires toml4j; requires com.google.gson; diff --git a/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/TreeBuilder.java b/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/TreeBuilder.java index 52df84adca62..3d5af1d78fa9 100644 --- a/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/TreeBuilder.java +++ b/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/TreeBuilder.java @@ -33,7 +33,6 @@ import org.ballerinalang.model.tree.AnnotationNode; import org.ballerinalang.model.tree.BlockFunctionBodyNode; import org.ballerinalang.model.tree.ClassDefinition; -import org.ballerinalang.model.tree.ClientDeclarationNode; import org.ballerinalang.model.tree.CompilationUnitNode; import org.ballerinalang.model.tree.ErrorVariableNode; import org.ballerinalang.model.tree.FunctionBodyNode; @@ -42,6 +41,7 @@ import org.ballerinalang.model.tree.ImportPackageNode; import org.ballerinalang.model.tree.MarkdownDocumentationNode; import org.ballerinalang.model.tree.MarkdownDocumentationReferenceAttributeNode; +import org.ballerinalang.model.tree.NodeKind; import org.ballerinalang.model.tree.PackageNode; import org.ballerinalang.model.tree.RecordVariableNode; import org.ballerinalang.model.tree.RetrySpecNode; @@ -145,7 +145,6 @@ import org.ballerinalang.model.tree.statements.AssignmentNode; import org.ballerinalang.model.tree.statements.BlockStatementNode; import org.ballerinalang.model.tree.statements.BreakNode; -import org.ballerinalang.model.tree.statements.ClientDeclarationStatementNode; import org.ballerinalang.model.tree.statements.CompoundAssignmentNode; import org.ballerinalang.model.tree.statements.ConstantNode; import org.ballerinalang.model.tree.statements.ContinueNode; @@ -190,7 +189,6 @@ import org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachment; import org.wso2.ballerinalang.compiler.tree.BLangBlockFunctionBody; import org.wso2.ballerinalang.compiler.tree.BLangClassDefinition; -import org.wso2.ballerinalang.compiler.tree.BLangClientDeclaration; import org.wso2.ballerinalang.compiler.tree.BLangCompilationUnit; import org.wso2.ballerinalang.compiler.tree.BLangErrorVariable; import org.wso2.ballerinalang.compiler.tree.BLangExprFunctionBody; @@ -203,6 +201,7 @@ import org.wso2.ballerinalang.compiler.tree.BLangPackage; import org.wso2.ballerinalang.compiler.tree.BLangRecordVariable; import org.wso2.ballerinalang.compiler.tree.BLangResourceFunction; +import org.wso2.ballerinalang.compiler.tree.BLangResourcePathSegment; import org.wso2.ballerinalang.compiler.tree.BLangRetrySpec; import org.wso2.ballerinalang.compiler.tree.BLangService; import org.wso2.ballerinalang.compiler.tree.BLangSimpleVariable; @@ -329,7 +328,6 @@ import org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt; import org.wso2.ballerinalang.compiler.tree.statements.BLangBreak; -import org.wso2.ballerinalang.compiler.tree.statements.BLangClientDeclarationStatement; import org.wso2.ballerinalang.compiler.tree.statements.BLangCompoundAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangContinue; import org.wso2.ballerinalang.compiler.tree.statements.BLangDo; @@ -407,15 +405,6 @@ public static XMLNSDeclarationNode createXMLNSNode() { public static XMLNSDeclStatementNode createXMLNSDeclrStatementNode() { return new BLangXMLNSStatement(); } - - public static ClientDeclarationNode createClientDeclarationNode() { - return new BLangClientDeclaration(); - } - - public static ClientDeclarationStatementNode createClientDeclarationStatementNode() { - return new BLangClientDeclarationStatement(); - } - public static SimpleVariableNode createSimpleVariableNode() { return new BLangSimpleVariable(); } @@ -1149,6 +1138,10 @@ public static FunctionNode createResourceFunctionNode() { return new BLangResourceFunction(); } + public static BLangResourcePathSegment createResourcePathSegmentNode(NodeKind kind) { + return new BLangResourcePathSegment(kind); + } + public static IgnoreNode createIgnoreExprNode() { return new BLangIgnoreExpr(); } diff --git a/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/elements/AttachPoint.java b/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/elements/AttachPoint.java index cdd0e1995bcb..d4eed83cc3d2 100644 --- a/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/elements/AttachPoint.java +++ b/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/elements/AttachPoint.java @@ -104,11 +104,7 @@ public enum Point { /** * Indicate class Attach point. */ - CLASS("class"), - /** - * Indicate client declaration attach point. - */ - CLIENT("client"); + CLASS("class"); private String value; diff --git a/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/symbols/SymbolKind.java b/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/symbols/SymbolKind.java index 178a3ffea320..9a814bd3f614 100644 --- a/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/symbols/SymbolKind.java +++ b/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/symbols/SymbolKind.java @@ -53,7 +53,6 @@ public enum SymbolKind { TYPEOF_OPERATOR, XMLNS, - CLIENT_DECL, SCOPE, OTHER, diff --git a/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/tree/ClientDeclarationNode.java b/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/tree/ClientDeclarationNode.java deleted file mode 100644 index eea7163a5a29..000000000000 --- a/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/tree/ClientDeclarationNode.java +++ /dev/null @@ -1,36 +0,0 @@ -/* -* Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ -package org.ballerinalang.model.tree; - -import org.ballerinalang.model.tree.expressions.LiteralNode; - -/** - * Represent a client declaration. - * - * @since 2201.3.0 - */ -public interface ClientDeclarationNode extends TopLevelNode { - - LiteralNode getUri(); - - void setUri(LiteralNode uri); - - IdentifierNode getPrefix(); - - void setPrefix(IdentifierNode prefix); -} diff --git a/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/tree/NodeKind.java b/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/tree/NodeKind.java index 16785b8ff2d7..11d891f94d49 100644 --- a/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/tree/NodeKind.java +++ b/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/tree/NodeKind.java @@ -57,7 +57,6 @@ public enum NodeKind { TABLE_KEY_TYPE_CONSTRAINT, RETRY_SPEC, CLASS_DEFN, - CLIENT_DECL, /* Expressions */ DOCUMENTATION_ATTRIBUTE, diff --git a/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/tree/PackageNode.java b/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/tree/PackageNode.java index 541a4101c070..08af129b1167 100644 --- a/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/tree/PackageNode.java +++ b/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/tree/PackageNode.java @@ -39,8 +39,6 @@ public interface PackageNode extends Node { void addNamespaceDeclaration(XMLNSDeclarationNode xmlnsDecl); - List getClientDeclarations(); - List getConstants(); List getGlobalVariables(); diff --git a/compiler/ballerina-lang/src/main/java/org/ballerinalang/util/diagnostic/DiagnosticErrorCode.java b/compiler/ballerina-lang/src/main/java/org/ballerinalang/util/diagnostic/DiagnosticErrorCode.java index 62929279f0e4..497687dd93bd 100644 --- a/compiler/ballerina-lang/src/main/java/org/ballerinalang/util/diagnostic/DiagnosticErrorCode.java +++ b/compiler/ballerina-lang/src/main/java/org/ballerinalang/util/diagnostic/DiagnosticErrorCode.java @@ -779,22 +779,9 @@ public enum DiagnosticErrorCode implements DiagnosticCode { UNSUPPORTED_RESOURCE_ACCESS_REST_SEGMENT_TYPE("BCE4032", "unsupported.resource.access.rest.segment.type"), INVALID_RESOURCE_METHOD_RETURN_TYPE("BCE4033", "invalid.resource.method.return.type"), OUT_OF_RANGE("BCE4034", "numeric.literal.out.of.range"), - INVALID_START_CHAR_CODE_IN_RANGE("BCE4035", "invalid.start.char.code.in.range"), INVALID_QUANTIFIER_MINIMUM("BCE4036", "invalid.quantifier.minimum"), DUPLICATE_FLAGS("BCE4037", "duplicate.flags"), - - INVALID_USAGE_OF_THE_CLIENT_KEYWORD_AS_UNQUOTED_IDENTIFIER( - "BCE4038", "invalid.usage.of.the.client.keyword.as.an.unquoted.identifier"), - INVALID_NON_ANYDATA_CLIENT_DECL_ANNOTATION("BCE4039", "invalid.non.anydata.client.decl.annotation"), - NO_MODULE_GENERATED_FOR_CLIENT_DECL("BCE4040", "no.module.generated.for.client.decl"), - UNUSED_CLIENT_DECL_PREFIX("BCE4041", "unused.client.decl.prefix"), - UNSUPPORTED_EXPOSURE_OF_CONSTRUCT_FROM_MODULE_GENERATED_FOR_CLIENT_DECL( - "BCE4042", "unsupported.exposure.of.construct.from.module.generated.for.client.decl"), - MODULE_GENERATED_FOR_CLIENT_DECL_MUST_HAVE_A_CLIENT_OBJECT_TYPE( - "BCE4043", "module.generated.for.client.decl.must.have.a.client.object.type"), - MODULE_GENERATED_FOR_CLIENT_DECL_CANNOT_HAVE_MUTABLE_STATE( - "BCE4044", "module.generated.for.client.decl.cannot.have.mutable.state"), CANNOT_IMPORT_MODULE_GENERATED_FOR_CLIENT_DECL( "BCE4045", "cannot.import.module.generated.for.a.client.decl"), CANNOT_INFER_TYPEDESC_ARGUMENT_WITHOUT_CET("BCE4046", diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java index a0552c05481a..1721dc902286 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java @@ -90,7 +90,6 @@ import org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachment; import org.wso2.ballerinalang.compiler.tree.BLangBlockFunctionBody; import org.wso2.ballerinalang.compiler.tree.BLangClassDefinition; -import org.wso2.ballerinalang.compiler.tree.BLangClientDeclaration; import org.wso2.ballerinalang.compiler.tree.BLangConstantValue; import org.wso2.ballerinalang.compiler.tree.BLangExternalFunctionBody; import org.wso2.ballerinalang.compiler.tree.BLangFunction; @@ -2136,11 +2135,6 @@ public void visit(BLangXMLNSStatement xmlnsStmtNode) { public void visit(BLangXMLNS xmlnsNode) { // do nothing } - - @Override - public void visit(BLangClientDeclaration clientDeclaration) { - } - @Override public void visit(BLangClientDeclarationStatement clientDeclarationStatement) { } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ClosureDesugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ClosureDesugar.java index fde63935ea90..1982e7795f4e 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ClosureDesugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ClosureDesugar.java @@ -45,7 +45,6 @@ import org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachment; import org.wso2.ballerinalang.compiler.tree.BLangBlockFunctionBody; import org.wso2.ballerinalang.compiler.tree.BLangClassDefinition; -import org.wso2.ballerinalang.compiler.tree.BLangClientDeclaration; import org.wso2.ballerinalang.compiler.tree.BLangErrorVariable; import org.wso2.ballerinalang.compiler.tree.BLangExternalFunctionBody; import org.wso2.ballerinalang.compiler.tree.BLangFunction; @@ -130,7 +129,6 @@ import org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt; import org.wso2.ballerinalang.compiler.tree.statements.BLangBreak; -import org.wso2.ballerinalang.compiler.tree.statements.BLangClientDeclarationStatement; import org.wso2.ballerinalang.compiler.tree.statements.BLangContinue; import org.wso2.ballerinalang.compiler.tree.statements.BLangDo; import org.wso2.ballerinalang.compiler.tree.statements.BLangErrorDestructure; @@ -1133,17 +1131,6 @@ public void visit(BLangPanic panicNode) { panicNode.expr = rewriteExpr(panicNode.expr); result = panicNode; } - - @Override - public void visit(BLangClientDeclaration clientDeclaration) { - this.result = clientDeclaration; - } - - @Override - public void visit(BLangClientDeclarationStatement clientDeclarationStatement) { - this.result = clientDeclarationStatement; - } - public void visit(BLangDo doNode) { doNode.body = rewrite(doNode.body, env); result = doNode; @@ -1624,7 +1611,8 @@ public void visit(BLangDynamicArgExpr dynamicParamExpr) { @Override public void visit(BLangRegExpTemplateLiteral regExpTemplateLiteral) { List interpolationsList = - symResolver.getListOfInterpolations(regExpTemplateLiteral.reDisjunction.sequenceList); + symResolver.getListOfInterpolations(regExpTemplateLiteral.reDisjunction.sequenceList, + new ArrayList<>()); interpolationsList.forEach(this::rewriteExpr); result = regExpTemplateLiteral; } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ConstantPropagation.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ConstantPropagation.java index b9e7c9179d1e..dc196eb2620a 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ConstantPropagation.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ConstantPropagation.java @@ -32,7 +32,6 @@ import org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachment; import org.wso2.ballerinalang.compiler.tree.BLangBlockFunctionBody; import org.wso2.ballerinalang.compiler.tree.BLangClassDefinition; -import org.wso2.ballerinalang.compiler.tree.BLangClientDeclaration; import org.wso2.ballerinalang.compiler.tree.BLangErrorVariable; import org.wso2.ballerinalang.compiler.tree.BLangExprFunctionBody; import org.wso2.ballerinalang.compiler.tree.BLangExternalFunctionBody; @@ -142,7 +141,6 @@ import org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt; import org.wso2.ballerinalang.compiler.tree.statements.BLangBreak; -import org.wso2.ballerinalang.compiler.tree.statements.BLangClientDeclarationStatement; import org.wso2.ballerinalang.compiler.tree.statements.BLangCompoundAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangContinue; import org.wso2.ballerinalang.compiler.tree.statements.BLangDo; @@ -1108,16 +1106,6 @@ public void visit(BLangSimpleVarRef varRefExpr) { result = varRefExpr; } - @Override - public void visit(BLangClientDeclaration clientDeclaration) { - result = clientDeclaration; - } - - @Override - public void visit(BLangClientDeclarationStatement clientDeclarationStatement) { - result = clientDeclarationStatement; - } - @Override public void visit(BLangRegExpTemplateLiteral regExpTemplateLiteral) { rewrite(regExpTemplateLiteral.reDisjunction); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java index a9ab8c3b05e1..28efbb5ded08 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java @@ -19,7 +19,6 @@ import io.ballerina.runtime.api.constants.RuntimeConstants; import io.ballerina.tools.diagnostics.Location; -import io.ballerina.tools.text.LineRange; import org.apache.commons.lang3.StringEscapeUtils; import org.ballerinalang.compiler.CompilerPhase; import org.ballerinalang.model.TreeBuilder; @@ -60,6 +59,7 @@ import org.wso2.ballerinalang.compiler.semantics.model.symbols.BPackageSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BRecordTypeSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BResourceFunction; +import org.wso2.ballerinalang.compiler.semantics.model.symbols.BResourcePathSegmentSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BTypeSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol; @@ -85,7 +85,6 @@ import org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachment; import org.wso2.ballerinalang.compiler.tree.BLangBlockFunctionBody; import org.wso2.ballerinalang.compiler.tree.BLangClassDefinition; -import org.wso2.ballerinalang.compiler.tree.BLangClientDeclaration; import org.wso2.ballerinalang.compiler.tree.BLangErrorVariable; import org.wso2.ballerinalang.compiler.tree.BLangExprFunctionBody; import org.wso2.ballerinalang.compiler.tree.BLangExternalFunctionBody; @@ -245,7 +244,6 @@ import org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt; import org.wso2.ballerinalang.compiler.tree.statements.BLangBreak; -import org.wso2.ballerinalang.compiler.tree.statements.BLangClientDeclarationStatement; import org.wso2.ballerinalang.compiler.tree.statements.BLangCompoundAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangContinue; import org.wso2.ballerinalang.compiler.tree.statements.BLangDo; @@ -806,7 +804,6 @@ public void visit(BLangPackage pkgNode) { pkgNode.xmlnsList = rewrite(pkgNode.xmlnsList, env); pkgNode.constants = rewrite(pkgNode.constants, env); pkgNode.globalVars = rewrite(pkgNode.globalVars, env); - pkgNode.clientDeclarations = rewrite(pkgNode.clientDeclarations, env); pkgNode.classDefinitions = rewrite(pkgNode.classDefinitions, env); serviceDesugar.rewriteListeners(pkgNode.globalVars, env, pkgNode.startFunction, pkgNode.stopFunction); @@ -3191,7 +3188,8 @@ protected BLangWhile createRetryWhileLoop(Location pos, BLangDo retryDo = wrapStatementWithinDo(pos, retryBody, internalOnFail); - BLangTypeTestExpr isErrorCheck = createTypeCheckExpr(pos, retryResultRef, getErrorTypeNode()); + BLangTypeTestExpr isErrorCheck = createTypeCheckExpr(pos, retryResultRef, + getErrorTypeNode()); BLangBinaryExpr shouldRetryCheck = ASTBuilderUtil.createBinaryExpr(pos, isErrorCheck, shouldRetryRef, symTable.booleanType, OperatorKind.AND, null); BLangGroupExpr rhsCheck = new BLangGroupExpr(); @@ -3379,10 +3377,9 @@ protected BLangNode createExpressionStatement(Location location, } } - void failFastForErrorResult(Location pos, BlockNode blockStmt, BLangTypeTestExpr typeTestExpr, - BLangExpression resultRef) { + protected void createErrorReturn(Location pos, BlockNode blockStmt, BLangSimpleVarRef resultRef) { BLangIf returnError = ASTBuilderUtil.createIfStmt(pos, blockStmt); - returnError.expr = typeTestExpr; + returnError.expr = createTypeCheckExpr(pos, resultRef, getErrorTypeNode()); returnError.body = ASTBuilderUtil.createBlockStmt(pos); BLangFail failExpressionNode = (BLangFail) TreeBuilder.createFailNode(); failExpressionNode.expr = addConversionExprIfRequired(resultRef, symTable.errorType); @@ -6527,7 +6524,7 @@ public void visit(BLangInvocation.BLangResourceAccessInvocation resourceAccessIn reorderArguments(pathParamInvocation); BResourceFunction targetResourceFunc = resourceAccessInvocation.targetResourceFunc; - List resourcePath = targetResourceFunc.resourcePath; + List pathSegmentSymbols = targetResourceFunc.pathSegmentSymbols; int pathParamInvocationRequiredArgCount = pathParamInvocation.requiredArgs.size(); @@ -6546,7 +6543,7 @@ public void visit(BLangInvocation.BLangResourceAccessInvocation resourceAccessIn for (int i = 0; i < pathParamInvocationRequiredArgCount; i++) { BLangExpression requiredArg = pathParamInvocation.requiredArgs.get(i); // Resource path size is always >= pathParamInvocationRequiredArgCount - Name resourcePathName = resourcePath.get(i); + Name resourcePathName = pathSegmentSymbols.get(i).name; if (firstRequiredArgFromRestArg == null && requiredArg.getKind() == NodeKind.STATEMENT_EXPRESSION) { firstRequiredArgFromRestArg = (BLangStatementExpression) requiredArg; if (resourcePathName.value.equals("^")) { @@ -6570,7 +6567,7 @@ public void visit(BLangInvocation.BLangResourceAccessInvocation resourceAccessIn } } - Name lastResourcePathName = resourcePath.get(resourcePath.size() - 1); + Name lastResourcePathName = pathSegmentSymbols.get(pathSegmentSymbols.size() - 1).name; if (lastResourcePathName.value.equals("^^")) { // After reordering pathParamInvocation.restArgs size will always be 0 or 1 for (BLangExpression restArg : pathParamInvocation.restArgs) { @@ -6634,26 +6631,27 @@ private BLangInvocation createInvocationForPathParams( resourceAccessInvocation.symbol.pos, VIRTUAL); BResourceFunction targetResourceFunc = resourceAccessInvocation.targetResourceFunc; - List resourcePath = targetResourceFunc.resourcePath; + List pathSegmentSymbols = targetResourceFunc.pathSegmentSymbols; List resourceAccessPathSegments = resourceAccessInvocation.resourceAccessPathSegments.exprs; - List invocationParams = new ArrayList<>(resourcePath.size()); - BTupleType resourcePathType = targetResourceFunc.resourcePathType; - for (BType type : resourcePathType.tupleTypes) { - BVarSymbol param = new BVarSymbol(0, Names.EMPTY, this.env.scope.owner.pkgID, type, - this.env.scope.owner, type.tsymbol.pos, VIRTUAL); - invocationParams.add(param); - } - - invokableSymbol.params = invocationParams; + List invocationParams = new ArrayList<>(pathSegmentSymbols.size()); - BType resourcePathRestType = resourcePathType.restType; - if (resourcePathRestType != null) { + int pathSegmentCount = pathSegmentSymbols.size(); + BResourcePathSegmentSymbol lastPathSegmentSym = pathSegmentSymbols.get(pathSegmentSymbols.size() - 1); + if (lastPathSegmentSym.kind == SymbolKind.RESOURCE_PATH_REST_PARAM_SEGMENT) { invokableSymbol.restParam = new BVarSymbol(0, Names.EMPTY, this.env.scope.owner.pkgID, - new BArrayType(resourcePathRestType), this.env.scope.owner, - resourcePathRestType.tsymbol.pos, VIRTUAL); + new BArrayType(lastPathSegmentSym.type), this.env.scope.owner, lastPathSegmentSym.pos, VIRTUAL); + pathSegmentCount--; + } + + if (pathSegmentCount > 0 && lastPathSegmentSym.kind != SymbolKind.RESOURCE_ROOT_PATH_SEGMENT) { + invocationParams.addAll(pathSegmentSymbols.subList(0, pathSegmentCount).stream() + .map(s -> new BVarSymbol(0, Names.EMPTY, this.env.scope.owner.pkgID, s.type, + this.env.scope.owner, s.pos, VIRTUAL)).collect(Collectors.toList())); } + invokableSymbol.params = invocationParams; + bLangInvocation.symbol = invokableSymbol; for (int i = 0; i < resourceAccessPathSegments.size(); i++) { @@ -7249,8 +7247,11 @@ private BLangStatementExpression createStmtExprForNullableBinaryExpr(BLangBinary BLangSimpleVarRef rhsVarRef = ASTBuilderUtil.createVariableRef(binaryExpr.pos, rhsVarDef.var.symbol); blockStmt.addStatement(rhsVarDef); - BLangTypeTestExpr typeTestExprOne = getNilTypeTestExpr(binaryExpr.pos, lhsVarRef); - BLangTypeTestExpr typeTestExprTwo = getNilTypeTestExpr(binaryExpr.pos, rhsVarRef); + BLangTypeTestExpr typeTestExprOne = createTypeCheckExpr(binaryExpr.pos, lhsVarRef, getNillTypeNode()); + typeTestExprOne.setBType(symTable.booleanType); + + BLangTypeTestExpr typeTestExprTwo = createTypeCheckExpr(binaryExpr.pos, rhsVarRef, getNillTypeNode()); + typeTestExprTwo.setBType(symTable.booleanType); BLangBinaryExpr ifBlockCondition = ASTBuilderUtil.createBinaryExpr(binaryExpr.pos, typeTestExprOne, typeTestExprTwo, symTable.booleanType, OperatorKind.OR, binaryExpr.opSymbol); @@ -7281,10 +7282,6 @@ private BLangStatementExpression createStmtExprForNullableBinaryExpr(BLangBinary return stmtExpr; } - BLangTypeTestExpr getNilTypeTestExpr(Location pos, BLangExpression expr) { - return createTypeCheckExpr(pos, expr, getNillTypeNode()); - } - private BType getBinaryExprOperandNonNilType(BType operandType) { return operandType.isNullable() ? types.getSafeType(operandType, true, false) : operandType; } @@ -7543,8 +7540,8 @@ public void visit(BLangElvisExpr elvisExpr) { BLangBlockStmt elseBody = ASTBuilderUtil.createBlockStmt(pos); elseBody.addStatement(notNilAssignment); - BLangIf ifStmt = ASTBuilderUtil.createIfElseStmt(pos, getNilTypeTestExpr(pos, lhsResultVarRef), - ifBody, elseBody); + BLangIf ifStmt = ASTBuilderUtil.createIfElseStmt(pos, + createTypeCheckExpr(pos, lhsResultVarRef, getNillTypeNode()), ifBody, elseBody); BLangBlockStmt blockStmt = ASTBuilderUtil.createBlockStmt(pos, new ArrayList<>() {{ add(resultVarDef); add(lhsResultVarDef); @@ -7650,7 +7647,9 @@ private BLangStatementExpression createStmtExprForNilableUnaryExpr(BLangUnaryExp blockStmt.addStatement(tempVarDef); - BLangTypeTestExpr typeTestExpr = getNilTypeTestExpr(unaryExpr.pos, unaryExpr.expr); + BLangTypeTestExpr typeTestExpr = createTypeCheckExpr(unaryExpr.pos, unaryExpr.expr, + getNillTypeNode()); + typeTestExpr.setBType(symTable.booleanType); BLangBlockStmt ifBody = ASTBuilderUtil.createBlockStmt(unaryExpr.pos); BLangAssignment bLangAssignmentIf = ASTBuilderUtil.createAssignmentStmt(unaryExpr.pos, ifBody); @@ -8496,18 +8495,6 @@ public void visit(BLangConstRef constantRef) { result = ASTBuilderUtil.createLiteral(constantRef.pos, constantRef.getBType(), constantRef.value); } - @Override - public void visit(BLangClientDeclaration clientDeclaration) { - addImportForModuleGeneratedForClientDecl(clientDeclaration); - this.result = clientDeclaration; - } - - @Override - public void visit(BLangClientDeclarationStatement clientDeclarationStatement) { - addImportForModuleGeneratedForClientDecl(clientDeclarationStatement.clientDeclaration); - this.result = clientDeclarationStatement; - } - @Override public void visit(BLangRegExpTemplateLiteral regExpTemplateLiteral) { regExpTemplateLiteral.reDisjunction = rewriteExpr(regExpTemplateLiteral.reDisjunction); @@ -10082,7 +10069,7 @@ private BLangBinaryExpr getModifiedIntRangeEndExpr(BLangExpression expr) { symTable.intType)); } - BLangLiteral getBooleanLiteral(boolean value) { + private BLangLiteral getBooleanLiteral(boolean value) { BLangLiteral literal = (BLangLiteral) TreeBuilder.createLiteralExpression(); literal.value = value; literal.setBType(symTable.booleanType); @@ -10297,47 +10284,4 @@ protected void addTransactionInternalModuleImport() { env.enclPkg.symbol.imports.add(importDcl.symbol); } } - - private void addImportForModuleGeneratedForClientDecl(BLangClientDeclaration clientDeclaration) { - // Currently happens when client declarations are in single bal files. May not be required once it is - // restricted. - if (!symTable.clientDeclarations.containsKey(clientDeclaration.symbol.pkgID) || - !symTable.clientDeclarations.get(clientDeclaration.symbol.pkgID) - .containsKey(clientDeclaration.prefix.pos.lineRange().filePath())) { - return; - } - Map> lineRangeMap = - symTable.clientDeclarations.get(clientDeclaration.symbol.pkgID) - .get(clientDeclaration.prefix.pos.lineRange().filePath()); - if (!lineRangeMap.containsKey(clientDeclaration.prefix.pos.lineRange())) { - return; - } - - Optional optionalPackageID = lineRangeMap.get(clientDeclaration.prefix.pos.lineRange()); - - // No compatible plugin was found to generate a module for the client declaration. - if (optionalPackageID.isEmpty()) { - return; - } - - PackageID packageID = optionalPackageID.get(); - - // Also happens with single bal files when there are IDL client plugins. - // TODO: 2022-08-30 Remove once fixed from the project API side. - if (Names.ANON_ORG.equals(packageID.orgName) && Names.DOT.equals(packageID.name)) { - return; - } - - BLangImportPackage importDcl = (BLangImportPackage) TreeBuilder.createImportPackageNode(); - BLangPackage enclPkg = env.enclPkg; - Location pos = enclPkg.pos; - importDcl.pos = pos; - importDcl.pkgNameComps = List.of(ASTBuilderUtil.createIdentifier(pos, packageID.name.value)); - importDcl.orgName = ASTBuilderUtil.createIdentifier(pos, packageID.orgName.value); - importDcl.version = ASTBuilderUtil.createIdentifier(pos, packageID.version.value); - BPackageSymbol moduleSymbol = symResolver.getModuleForPackageId(packageID); - importDcl.symbol = moduleSymbol; - enclPkg.imports.add(importDcl); - enclPkg.symbol.imports.add(moduleSymbol); - } } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ParameterDesugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ParameterDesugar.java index e96e1f9b756d..3d2972c02064 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ParameterDesugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ParameterDesugar.java @@ -40,7 +40,6 @@ import org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachment; import org.wso2.ballerinalang.compiler.tree.BLangBlockFunctionBody; import org.wso2.ballerinalang.compiler.tree.BLangClassDefinition; -import org.wso2.ballerinalang.compiler.tree.BLangClientDeclaration; import org.wso2.ballerinalang.compiler.tree.BLangErrorVariable; import org.wso2.ballerinalang.compiler.tree.BLangExprFunctionBody; import org.wso2.ballerinalang.compiler.tree.BLangExternalFunctionBody; @@ -129,7 +128,6 @@ import org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt; import org.wso2.ballerinalang.compiler.tree.statements.BLangBreak; -import org.wso2.ballerinalang.compiler.tree.statements.BLangClientDeclarationStatement; import org.wso2.ballerinalang.compiler.tree.statements.BLangCompoundAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangContinue; import org.wso2.ballerinalang.compiler.tree.statements.BLangDo; @@ -1465,7 +1463,8 @@ public void visit(BLangXMLSequenceLiteral xmlSequenceLiteral) { @Override public void visit(BLangRegExpTemplateLiteral regExpTemplateLiteral) { List interpolationsList = - symResolver.getListOfInterpolations(regExpTemplateLiteral.reDisjunction.sequenceList); + symResolver.getListOfInterpolations(regExpTemplateLiteral.reDisjunction.sequenceList, + new ArrayList<>()); interpolationsList.forEach(this::rewriteExpr); result = regExpTemplateLiteral; } @@ -1494,16 +1493,6 @@ public void visit(BLangMarkdownDocumentation bLangMarkdownDocumentation) { /* Ignore */ } - @Override - public void visit(BLangClientDeclaration clientDeclaration) { - this.result = clientDeclaration; - } - - @Override - public void visit(BLangClientDeclarationStatement clientDeclarationStatement) { - this.result = clientDeclarationStatement; - } - // Rewrite methods @SuppressWarnings("unchecked") diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java index b963dad250b5..85e293f18a84 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java @@ -38,7 +38,6 @@ import io.ballerina.compiler.syntax.tree.CheckExpressionNode; import io.ballerina.compiler.syntax.tree.ChildNodeList; import io.ballerina.compiler.syntax.tree.ClassDefinitionNode; -import io.ballerina.compiler.syntax.tree.ClientDeclarationNode; import io.ballerina.compiler.syntax.tree.ClientResourceAccessActionNode; import io.ballerina.compiler.syntax.tree.CommitActionNode; import io.ballerina.compiler.syntax.tree.CompoundAssignmentStatementNode; @@ -117,7 +116,6 @@ import io.ballerina.compiler.syntax.tree.MetadataNode; import io.ballerina.compiler.syntax.tree.MethodCallExpressionNode; import io.ballerina.compiler.syntax.tree.MethodDeclarationNode; -import io.ballerina.compiler.syntax.tree.ModuleClientDeclarationNode; import io.ballerina.compiler.syntax.tree.ModuleMemberDeclarationNode; import io.ballerina.compiler.syntax.tree.ModulePartNode; import io.ballerina.compiler.syntax.tree.ModuleVariableDeclarationNode; @@ -285,7 +283,6 @@ import org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachment; import org.wso2.ballerinalang.compiler.tree.BLangBlockFunctionBody; import org.wso2.ballerinalang.compiler.tree.BLangClassDefinition; -import org.wso2.ballerinalang.compiler.tree.BLangClientDeclaration; import org.wso2.ballerinalang.compiler.tree.BLangCompilationUnit; import org.wso2.ballerinalang.compiler.tree.BLangErrorVariable; import org.wso2.ballerinalang.compiler.tree.BLangExprFunctionBody; @@ -300,6 +297,7 @@ import org.wso2.ballerinalang.compiler.tree.BLangRecordVariable; import org.wso2.ballerinalang.compiler.tree.BLangRecordVariable.BLangRecordVariableKeyValue; import org.wso2.ballerinalang.compiler.tree.BLangResourceFunction; +import org.wso2.ballerinalang.compiler.tree.BLangResourcePathSegment; import org.wso2.ballerinalang.compiler.tree.BLangRetrySpec; import org.wso2.ballerinalang.compiler.tree.BLangService; import org.wso2.ballerinalang.compiler.tree.BLangSimpleVariable; @@ -437,7 +435,6 @@ import org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt; import org.wso2.ballerinalang.compiler.tree.statements.BLangBreak; -import org.wso2.ballerinalang.compiler.tree.statements.BLangClientDeclarationStatement; import org.wso2.ballerinalang.compiler.tree.statements.BLangCompoundAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangContinue; import org.wso2.ballerinalang.compiler.tree.statements.BLangDo; @@ -782,50 +779,61 @@ private BLangFunction createResourceFunctionNode(IdentifierToken accessorName, populateFunctionNode(name, qualifierList, methodSignature, functionBody, bLFunction); bLFunction.methodName = createIdentifier(accessorName); - bLFunction.resourcePath = new ArrayList<>(); List params = new ArrayList<>(); - BLangTupleTypeNode tupleTypeNode = (BLangTupleTypeNode) TreeBuilder.createTupleTypeNode(); + List resourcePathSegments = new ArrayList<>(); for (Node pathSegment : relativeResourcePath) { + BLangResourcePathSegment bLangPathSegment; switch (pathSegment.kind()) { case SLASH_TOKEN: continue; case RESOURCE_PATH_SEGMENT_PARAM: BLangSimpleVariable param = (BLangSimpleVariable) pathSegment.apply(this); + bLangPathSegment = TreeBuilder.createResourcePathSegmentNode(NodeKind.RESOURCE_PATH_PARAM_SEGMENT); if (!param.name.value.equals(Names.EMPTY.value)) { params.add(param); bLFunction.addPathParam(param); - bLFunction.resourcePath.add(createIdentifier(getPosition(pathSegment), "^")); + bLangPathSegment.name = createIdentifier(getPosition(pathSegment), "^"); } else { - bLFunction.resourcePath.add(createIdentifier(getPosition(pathSegment), "$^")); + bLangPathSegment.name = createIdentifier(getPosition(pathSegment), "$^"); } - tupleTypeNode.memberTypeNodes.add(param.typeNode); + bLangPathSegment.typeNode = param.typeNode; + bLangPathSegment.pos = param.pos; break; case RESOURCE_PATH_REST_PARAM: BLangSimpleVariable restParam = (BLangSimpleVariable) pathSegment.apply(this); + bLangPathSegment = + TreeBuilder.createResourcePathSegmentNode(NodeKind.RESOURCE_PATH_REST_PARAM_SEGMENT); if (!restParam.name.value.equals(Names.EMPTY.value)) { params.add(restParam); bLFunction.setRestPathParam(restParam); - bLFunction.resourcePath.add(createIdentifier(getPosition(pathSegment), "^^")); + bLangPathSegment.name = createIdentifier(getPosition(pathSegment), "^^"); } else { - bLFunction.resourcePath.add(createIdentifier(getPosition(pathSegment), "$^^")); + bLangPathSegment.name = createIdentifier(getPosition(pathSegment), "$^^"); } - tupleTypeNode.restParamType = ((BLangArrayType) restParam.typeNode).elemtype; + bLangPathSegment.typeNode = ((BLangArrayType) restParam.typeNode).elemtype; + bLangPathSegment.pos = restParam.pos; break; case DOT_TOKEN: - bLFunction.resourcePath.add(createIdentifier((Token) pathSegment)); + bLangPathSegment = TreeBuilder.createResourcePathSegmentNode(NodeKind.RESOURCE_ROOT_PATH_SEGMENT); + bLangPathSegment.name = createIdentifier((Token) pathSegment); + bLangPathSegment.pos = bLangPathSegment.name.pos; break; default: - bLFunction.resourcePath.add(createIdentifier((Token) pathSegment)); + bLangPathSegment = + TreeBuilder.createResourcePathSegmentNode(NodeKind.RESOURCE_PATH_IDENTIFIER_SEGMENT); + bLangPathSegment.name = createIdentifier((Token) pathSegment); BLangFiniteTypeNode bLangFiniteTypeNode = (BLangFiniteTypeNode) TreeBuilder.createFiniteTypeNode(); BLangLiteral simpleLiteral = createSimpleLiteral(pathSegment, true); bLangFiniteTypeNode.valueSpace.add(simpleLiteral); - tupleTypeNode.memberTypeNodes.add(bLangFiniteTypeNode); + bLangPathSegment.typeNode = bLangFiniteTypeNode; + bLangPathSegment.pos = bLangPathSegment.name.pos; } + resourcePathSegments.add(bLangPathSegment); } bLFunction.getParameters().addAll(0, params); - bLFunction.resourcePathType = tupleTypeNode; + bLFunction.resourcePathSegments = resourcePathSegments; return bLFunction; } @@ -3625,27 +3633,6 @@ public BLangNode transform(ModuleXMLNamespaceDeclarationNode xmlnsDeclNode) { return xmlns; } - @Override - public BLangNode transform(ClientDeclarationNode clientDeclarationNode) { - BLangClientDeclarationStatement clientDeclarationStatement = - (BLangClientDeclarationStatement) TreeBuilder.createClientDeclarationStatementNode(); - Location position = getPosition(clientDeclarationNode); - clientDeclarationStatement.clientDeclaration = createClientDeclaration(clientDeclarationNode.clientUri(), - clientDeclarationNode.clientPrefix(), - position, - clientDeclarationNode.annotations()); - clientDeclarationStatement.pos = position; - return clientDeclarationStatement; - } - - @Override - public BLangNode transform(ModuleClientDeclarationNode moduleClientDeclarationNode) { - return createClientDeclaration(moduleClientDeclarationNode.clientUri(), - moduleClientDeclarationNode.clientPrefix(), - getPosition(moduleClientDeclarationNode), - moduleClientDeclarationNode.annotations()); - } - @Override public BLangNode transform(XMLQualifiedNameNode xmlQualifiedNameNode) { BLangXMLQName xmlName = (BLangXMLQName) TreeBuilder.createXMLQNameNode(); @@ -5415,15 +5402,8 @@ private BLangNode createActionOrExpression(Node actionOrExpression) { BLangIdentifier[] nameReference = createBLangNameReference(actionOrExpression); BLangSimpleVarRef bLVarRef = (BLangSimpleVarRef) TreeBuilder.createSimpleVariableReferenceNode(); bLVarRef.pos = getPosition(actionOrExpression); - - BLangIdentifier alias = nameReference[0]; - bLVarRef.pkgAlias = this.createIdentifier(alias.getPosition(), alias.getValue()); - bLVarRef.pkgAlias.setLiteral(alias.isLiteral); - - BLangIdentifier name = nameReference[1]; - bLVarRef.variableName = this.createIdentifier(name.getPosition(), name.getValue()); - bLVarRef.variableName.setLiteral(name.isLiteral); - + bLVarRef.pkgAlias = this.createIdentifier(nameReference[0].getPosition(), nameReference[0].getValue()); + bLVarRef.variableName = this.createIdentifier(nameReference[1].getPosition(), nameReference[1].getValue()); return bLVarRef; } else if (actionOrExpression.kind() == SyntaxKind.BRACED_EXPRESSION) { BLangGroupExpr group = (BLangGroupExpr) TreeBuilder.createGroupExpressionNode(); @@ -6010,12 +5990,7 @@ private BLangLiteral createSimpleLiteral(Node literal, boolean isFiniteType) { String textValue; if (literal instanceof BasicLiteralNode) { - Token token = ((BasicLiteralNode) literal).literalToken(); - if (type == SyntaxKind.STRING_LITERAL && token.isMissing()) { - textValue = "\"\""; - } else { - textValue = token.text(); - } + textValue = ((BasicLiteralNode) literal).literalToken().text(); } else if (literal instanceof Token) { textValue = ((Token) literal).text(); } else { @@ -6980,15 +6955,4 @@ private void setClassQualifiers(NodeList qualifiers, BLangClassDefinition } } } - - private BLangClientDeclaration createClientDeclaration(BasicLiteralNode basicLiteralNode, - IdentifierToken identifierToken, Location position, - NodeList annotations) { - BLangClientDeclaration clientDeclaration = (BLangClientDeclaration) TreeBuilder.createClientDeclarationNode(); - clientDeclaration.uri = createSimpleLiteral(basicLiteralNode); - clientDeclaration.prefix = createIdentifier(identifierToken); - clientDeclaration.pos = position; - clientDeclaration.annAttachments = applyAll(annotations); - return clientDeclaration; - } } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/NodeCloner.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/NodeCloner.java index 96bc531bcbc0..da4b6cdf4d6b 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/NodeCloner.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/NodeCloner.java @@ -27,7 +27,6 @@ import org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachment; import org.wso2.ballerinalang.compiler.tree.BLangBlockFunctionBody; import org.wso2.ballerinalang.compiler.tree.BLangClassDefinition; -import org.wso2.ballerinalang.compiler.tree.BLangClientDeclaration; import org.wso2.ballerinalang.compiler.tree.BLangCompilationUnit; import org.wso2.ballerinalang.compiler.tree.BLangErrorVariable; import org.wso2.ballerinalang.compiler.tree.BLangErrorVariable.BLangErrorDetailEntry; @@ -448,15 +447,6 @@ public void visit(BLangXMLNS source) { clone.prefix = source.prefix; } - @Override - public void visit(BLangClientDeclaration source) { - BLangClientDeclaration clone = new BLangClientDeclaration(); - source.cloneRef = clone; - clone.uri = clone(source.uri); - clone.prefix = source.prefix; - clone.annAttachments = cloneList(source.annAttachments); - } - @Override public void visit(BLangFunction source) { BLangFunction clone = new BLangFunction(); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java index 848b9fa19230..097610841e40 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java @@ -67,7 +67,6 @@ import org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachment; import org.wso2.ballerinalang.compiler.tree.BLangBlockFunctionBody; import org.wso2.ballerinalang.compiler.tree.BLangClassDefinition; -import org.wso2.ballerinalang.compiler.tree.BLangClientDeclaration; import org.wso2.ballerinalang.compiler.tree.BLangCompilationUnit; import org.wso2.ballerinalang.compiler.tree.BLangErrorVariable; import org.wso2.ballerinalang.compiler.tree.BLangExprFunctionBody; @@ -1589,10 +1588,6 @@ public void visit(BLangXMLNS xmlnsNode, AnalyzerData data) { /* ignore */ } - @Override - public void visit(BLangClientDeclaration node, AnalyzerData data) { - } - @Override public void visit(BLangService serviceNode, AnalyzerData data) { } @@ -3412,7 +3407,8 @@ public void visit(BLangAnnotAccessExpr annotAccessExpr, AnalyzerData data) { @Override public void visit(BLangRegExpTemplateLiteral regExpTemplateLiteral, AnalyzerData data) { List interpolationsList = - symResolver.getListOfInterpolations(regExpTemplateLiteral.reDisjunction.sequenceList); + symResolver.getListOfInterpolations(regExpTemplateLiteral.reDisjunction.sequenceList, + new ArrayList<>()); interpolationsList.forEach(interpolation -> analyzeExpr(interpolation, data)); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CompilerPluginRunner.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CompilerPluginRunner.java index f9702fef44df..2b02fcb66b7d 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CompilerPluginRunner.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CompilerPluginRunner.java @@ -39,7 +39,6 @@ import org.wso2.ballerinalang.compiler.tree.BLangAnnotation; import org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachment; import org.wso2.ballerinalang.compiler.tree.BLangClassDefinition; -import org.wso2.ballerinalang.compiler.tree.BLangClientDeclaration; import org.wso2.ballerinalang.compiler.tree.BLangErrorVariable; import org.wso2.ballerinalang.compiler.tree.BLangFunction; import org.wso2.ballerinalang.compiler.tree.BLangImportPackage; @@ -259,9 +258,6 @@ public void visit(BLangErrorVariable bLangErrorVariable) { public void visit(BLangXMLNS xmlnsNode) { } - public void visit(BLangClientDeclaration clientDeclarationNode) { - } - public void visit(BLangConstant constant) { /* ignore */ } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java index c8d51313f4c3..1d6097399b95 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java @@ -34,7 +34,6 @@ import org.wso2.ballerinalang.compiler.semantics.analyzer.cyclefind.GlobalVariableRefAnalyzer; import org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv; import org.wso2.ballerinalang.compiler.semantics.model.SymbolTable; -import org.wso2.ballerinalang.compiler.semantics.model.symbols.BClientDeclarationSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BConstantSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BObjectTypeSymbol; @@ -55,7 +54,6 @@ import org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachment; import org.wso2.ballerinalang.compiler.tree.BLangBlockFunctionBody; import org.wso2.ballerinalang.compiler.tree.BLangClassDefinition; -import org.wso2.ballerinalang.compiler.tree.BLangClientDeclaration; import org.wso2.ballerinalang.compiler.tree.BLangCompilationUnit; import org.wso2.ballerinalang.compiler.tree.BLangErrorVariable; import org.wso2.ballerinalang.compiler.tree.BLangExprFunctionBody; @@ -162,7 +160,6 @@ import org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt; import org.wso2.ballerinalang.compiler.tree.statements.BLangBreak; -import org.wso2.ballerinalang.compiler.tree.statements.BLangClientDeclarationStatement; import org.wso2.ballerinalang.compiler.tree.statements.BLangCompoundAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangContinue; import org.wso2.ballerinalang.compiler.tree.statements.BLangDo; @@ -733,20 +730,6 @@ public void visit(BLangXMLNSStatement xmlnsStmt) { analyzeNode(xmlnsStmt.xmlnsDecl, env); } - @Override - public void visit(BLangClientDeclaration clientDeclaration) { - BClientDeclarationSymbol symbol = (BClientDeclarationSymbol) clientDeclaration.symbol; - if (!symbol.used) { - BLangIdentifier prefix = clientDeclaration.prefix; - dlog.error(prefix.pos, DiagnosticErrorCode.UNUSED_CLIENT_DECL_PREFIX, prefix.value); - } - } - - @Override - public void visit(BLangClientDeclarationStatement clientDeclarationStatement) { - analyzeNode(clientDeclarationStatement.clientDeclaration, env); - } - @Override public void visit(BLangIf ifNode) { analyzeNode(ifNode.expr, env); @@ -2212,7 +2195,8 @@ private void addUninitializedVar(BLangVariable variable) { @Override public void visit(BLangRegExpTemplateLiteral regExpTemplateLiteral) { List interpolationsList = - symResolver.getListOfInterpolations(regExpTemplateLiteral.reDisjunction.sequenceList); + symResolver.getListOfInterpolations(regExpTemplateLiteral.reDisjunction.sequenceList, + new ArrayList<>()); interpolationsList.forEach(interpolation -> analyzeNode(interpolation, env)); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/IsolationAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/IsolationAnalyzer.java index 0dccc18517bd..fdfa9bf93071 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/IsolationAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/IsolationAnalyzer.java @@ -80,7 +80,6 @@ import org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachment; import org.wso2.ballerinalang.compiler.tree.BLangBlockFunctionBody; import org.wso2.ballerinalang.compiler.tree.BLangClassDefinition; -import org.wso2.ballerinalang.compiler.tree.BLangClientDeclaration; import org.wso2.ballerinalang.compiler.tree.BLangCompilationUnit; import org.wso2.ballerinalang.compiler.tree.BLangErrorVariable; import org.wso2.ballerinalang.compiler.tree.BLangExprFunctionBody; @@ -2011,11 +2010,6 @@ public void visit(BLangXMLNavigationAccess xmlNavigation) { analyzeNode(childIndex, env); } } - - @Override - public void visit(BLangClientDeclaration clientDeclaration) { - } - @Override public void visit(BLangClientDeclarationStatement clientDeclarationStatement) { analyzeNode(clientDeclarationStatement.clientDeclaration, env); @@ -2024,7 +2018,8 @@ public void visit(BLangClientDeclarationStatement clientDeclarationStatement) { @Override public void visit(BLangRegExpTemplateLiteral regExpTemplateLiteral) { List interpolationsList = - symResolver.getListOfInterpolations(regExpTemplateLiteral.reDisjunction.sequenceList); + symResolver.getListOfInterpolations(regExpTemplateLiteral.reDisjunction.sequenceList, + new ArrayList<>()); interpolationsList.forEach(interpolation -> analyzeNode(interpolation, env)); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java index 1b347cd8d2f6..1ec6389d8156 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java @@ -20,7 +20,6 @@ import io.ballerina.compiler.api.symbols.DiagnosticState; import io.ballerina.projects.ModuleDescriptor; import io.ballerina.tools.diagnostics.Location; -import io.ballerina.tools.text.LineRange; import org.ballerinalang.compiler.CompilerPhase; import org.ballerinalang.model.TreeBuilder; import org.ballerinalang.model.elements.AttachPoint; @@ -39,12 +38,10 @@ import org.wso2.ballerinalang.compiler.parser.BLangAnonymousModelHelper; import org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv; import org.wso2.ballerinalang.compiler.semantics.model.SymbolTable; -import org.wso2.ballerinalang.compiler.semantics.model.TypeVisitor; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BAnnotationAttachmentSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BAnnotationSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BAttachedFunction; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BClassSymbol; -import org.wso2.ballerinalang.compiler.semantics.model.symbols.BClientDeclarationSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BEnumSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableTypeSymbol; @@ -58,43 +55,24 @@ import org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.SymTag; import org.wso2.ballerinalang.compiler.semantics.model.symbols.Symbols; -import org.wso2.ballerinalang.compiler.semantics.model.types.BAnnotationType; -import org.wso2.ballerinalang.compiler.semantics.model.types.BAnyType; -import org.wso2.ballerinalang.compiler.semantics.model.types.BAnydataType; import org.wso2.ballerinalang.compiler.semantics.model.types.BArrayType; -import org.wso2.ballerinalang.compiler.semantics.model.types.BBuiltInRefType; import org.wso2.ballerinalang.compiler.semantics.model.types.BErrorType; import org.wso2.ballerinalang.compiler.semantics.model.types.BField; -import org.wso2.ballerinalang.compiler.semantics.model.types.BFiniteType; -import org.wso2.ballerinalang.compiler.semantics.model.types.BFutureType; -import org.wso2.ballerinalang.compiler.semantics.model.types.BHandleType; import org.wso2.ballerinalang.compiler.semantics.model.types.BIntersectionType; -import org.wso2.ballerinalang.compiler.semantics.model.types.BInvokableType; -import org.wso2.ballerinalang.compiler.semantics.model.types.BJSONType; import org.wso2.ballerinalang.compiler.semantics.model.types.BMapType; -import org.wso2.ballerinalang.compiler.semantics.model.types.BNeverType; -import org.wso2.ballerinalang.compiler.semantics.model.types.BNilType; -import org.wso2.ballerinalang.compiler.semantics.model.types.BNoType; import org.wso2.ballerinalang.compiler.semantics.model.types.BObjectType; -import org.wso2.ballerinalang.compiler.semantics.model.types.BPackageType; -import org.wso2.ballerinalang.compiler.semantics.model.types.BParameterizedType; import org.wso2.ballerinalang.compiler.semantics.model.types.BRecordType; -import org.wso2.ballerinalang.compiler.semantics.model.types.BStreamType; import org.wso2.ballerinalang.compiler.semantics.model.types.BStructureType; import org.wso2.ballerinalang.compiler.semantics.model.types.BTableType; import org.wso2.ballerinalang.compiler.semantics.model.types.BTupleType; import org.wso2.ballerinalang.compiler.semantics.model.types.BType; import org.wso2.ballerinalang.compiler.semantics.model.types.BTypeIdSet; import org.wso2.ballerinalang.compiler.semantics.model.types.BTypeReferenceType; -import org.wso2.ballerinalang.compiler.semantics.model.types.BTypedescType; import org.wso2.ballerinalang.compiler.semantics.model.types.BUnionType; -import org.wso2.ballerinalang.compiler.semantics.model.types.BXMLType; import org.wso2.ballerinalang.compiler.tree.BLangAnnotation; import org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachment; import org.wso2.ballerinalang.compiler.tree.BLangBlockFunctionBody; import org.wso2.ballerinalang.compiler.tree.BLangClassDefinition; -import org.wso2.ballerinalang.compiler.tree.BLangClientDeclaration; -import org.wso2.ballerinalang.compiler.tree.BLangCompilationUnit; import org.wso2.ballerinalang.compiler.tree.BLangErrorVariable; import org.wso2.ballerinalang.compiler.tree.BLangExprFunctionBody; import org.wso2.ballerinalang.compiler.tree.BLangExternalFunctionBody; @@ -104,6 +82,7 @@ import org.wso2.ballerinalang.compiler.tree.BLangPackage; import org.wso2.ballerinalang.compiler.tree.BLangRecordVariable; import org.wso2.ballerinalang.compiler.tree.BLangResourceFunction; +import org.wso2.ballerinalang.compiler.tree.BLangResourcePathSegment; import org.wso2.ballerinalang.compiler.tree.BLangRetrySpec; import org.wso2.ballerinalang.compiler.tree.BLangService; import org.wso2.ballerinalang.compiler.tree.BLangSimpleVariable; @@ -171,7 +150,6 @@ import org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt; import org.wso2.ballerinalang.compiler.tree.statements.BLangBreak; -import org.wso2.ballerinalang.compiler.tree.statements.BLangClientDeclarationStatement; import org.wso2.ballerinalang.compiler.tree.statements.BLangCompoundAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangContinue; import org.wso2.ballerinalang.compiler.tree.statements.BLangDo; @@ -377,7 +355,6 @@ public void visit(BLangPackage pkgNode, AnalyzerData data) { data.env = lambdaFunction.capturedClosureEnv; analyzeNode(lambdaFunction.function, data); } - validateClientDeclarations(pkgNode, data); pkgNode.getTestablePkgs().forEach(testablePackage -> visit((BLangPackage) testablePackage, data)); pkgNode.completedPhases.add(CompilerPhase.TYPE_CHECK); @@ -435,40 +412,6 @@ public void visit(BLangXMLNSStatement xmlnsStmtNode, AnalyzerData data) { analyzeNode(xmlnsStmtNode.xmlnsDecl, data); } - @Override - public void visit(BLangClientDeclaration clientDeclaration, AnalyzerData data) { - SymbolEnv currentEnv = data.env; - - // Module-level client declarations are defined during symbol enter for the module (package) node. - // So we only define for client declaration statements here. - if (clientDeclaration.symbol == null) { - symbolEnter.defineNode(clientDeclaration, currentEnv); - } - - BClientDeclarationSymbol symbol = (BClientDeclarationSymbol) clientDeclaration.symbol; - - List annAttachments = clientDeclaration.annAttachments; - - for (BLangAnnotationAttachment annotationAttachment : annAttachments) { - annotationAttachment.attachPoints.add(AttachPoint.Point.CLIENT); - annotationAttachment.accept(this, data); - - BAnnotationAttachmentSymbol annotationAttachmentSymbol = annotationAttachment.annotationAttachmentSymbol; - if (annotationAttachmentSymbol != null) { - symbol.addAnnotation(annotationAttachmentSymbol); - } - } - validateAnnotationAttachmentCount(annAttachments); - - typeChecker.checkExpr(clientDeclaration.uri, currentEnv, symTable.stringType, data.prevEnvs, - data.commonAnalyzerData); - } - - @Override - public void visit(BLangClientDeclarationStatement clientDeclarationStatement, AnalyzerData data) { - analyzeNode(clientDeclarationStatement.clientDeclaration, data); - } - @Override public void visit(BLangResourceFunction funcNode, AnalyzerData data) { visit((BLangFunction) funcNode, data); @@ -476,21 +419,28 @@ public void visit(BLangResourceFunction funcNode, AnalyzerData data) { if (containsClientObjectTypeOrFunctionType(returnType)) { dlog.error(funcNode.returnTypeNode.getPosition(), DiagnosticErrorCode.INVALID_RESOURCE_METHOD_RETURN_TYPE); } - for (BLangType pathParamType : funcNode.resourcePathType.memberTypeNodes) { - symResolver.resolveTypeNode(pathParamType, data.env); - if (!types.isAssignable(pathParamType.getBType(), symTable.pathParamAllowedType)) { - dlog.error(pathParamType.getPosition(), DiagnosticErrorCode.UNSUPPORTED_PATH_PARAM_TYPE, - pathParamType.getBType()); + + List resourcePathSegments = funcNode.resourcePathSegments; + int pathSegmentCount = resourcePathSegments.size(); + BLangResourcePathSegment lastPathSegment = resourcePathSegments.get(resourcePathSegments.size() - 1); + if (lastPathSegment.kind == NodeKind.RESOURCE_ROOT_PATH_SEGMENT) { + return; + } + + if (lastPathSegment.kind == NodeKind.RESOURCE_PATH_REST_PARAM_SEGMENT) { + if (!types.isAssignable(lastPathSegment.getBType(), symTable.pathParamAllowedType)) { + dlog.error(lastPathSegment.typeNode.getPosition(), DiagnosticErrorCode.UNSUPPORTED_REST_PATH_PARAM_TYPE, + lastPathSegment.getBType()); } + pathSegmentCount--; } - if (funcNode.resourcePathType.restParamType != null) { - BLangType restParamType = funcNode.resourcePathType.restParamType; - symResolver.resolveTypeNode(restParamType, data.env); - if (!types.isAssignable(restParamType.getBType(), symTable.pathParamAllowedType)) { - dlog.error(restParamType.getPosition(), DiagnosticErrorCode.UNSUPPORTED_REST_PATH_PARAM_TYPE, - restParamType.getBType()); - } + if (pathSegmentCount > 0) { + resourcePathSegments.subList(0, pathSegmentCount).stream() + .filter(pathSeg -> !types.isAssignable(pathSeg.typeNode.getBType(), symTable.pathParamAllowedType)) + .forEach(pathSeg -> + dlog.error(pathSeg.typeNode.getPosition(), DiagnosticErrorCode.UNSUPPORTED_PATH_PARAM_TYPE, + pathSeg.getBType())); } } @@ -1070,15 +1020,6 @@ public void visit(BLangAnnotation annotationNode, AnalyzerData data) { } }); validateAnnotationAttachmentCount(annotationNode.annAttachments); - - BType attachedType = symbol.attachedType; - if (attachedType != null && - attachedType != symTable.semanticError && - Symbols.isAttachPointPresent(symbol.maskedPoints, AttachPoints.CLIENT) && - !types.isAnydata(attachedType)) { - dlog.error(annotationNode.typeNode.pos, DiagnosticErrorCode.INVALID_NON_ANYDATA_CLIENT_DECL_ANNOTATION, - attachedType); - } } @Override @@ -1123,7 +1064,7 @@ public void visit(BLangSimpleVariable varNode, AnalyzerData data) { return; } SymbolEnv currentEnv = data.env; - int ownerSymTag = currentEnv.scope.owner.tag; + long ownerSymTag = currentEnv.scope.owner.tag; boolean isListenerDecl = varNode.flagSet.contains(Flag.LISTENER); if ((ownerSymTag & SymTag.INVOKABLE) == SymTag.INVOKABLE || (ownerSymTag & SymTag.LET) == SymTag.LET || currentEnv.node.getKind() == NodeKind.LET_CLAUSE) { @@ -1479,7 +1420,7 @@ public void visit(BLangRecordVariable varNode, AnalyzerData data) { varNode.setBType(symResolver.resolveTypeNode(varNode.typeNode, currentEnv)); } - int ownerSymTag = currentEnv.scope.owner.tag; + long ownerSymTag = currentEnv.scope.owner.tag; // If this is a module record variable, checkTypeAndVarCountConsistency already done at symbolEnter. if ((ownerSymTag & SymTag.PACKAGE) != SymTag.PACKAGE && !(this.symbolEnter.symbolEnterAndValidateRecordVariable(varNode, currentEnv))) { @@ -1533,7 +1474,7 @@ public void visit(BLangTupleVariable varNode, AnalyzerData data) { varNode.setBType(symResolver.resolveTypeNode(varNode.typeNode, currentEnv)); } - int ownerSymTag = currentEnv.scope.owner.tag; + long ownerSymTag = currentEnv.scope.owner.tag; // If this is a module tuple variable, checkTypeAndVarCountConsistency already done at symbolEnter. if ((ownerSymTag & SymTag.PACKAGE) != SymTag.PACKAGE && !(this.symbolEnter.checkTypeAndVarCountConsistency(varNode, currentEnv))) { @@ -1709,7 +1650,7 @@ public void visit(BLangErrorVariable varNode, AnalyzerData data) { } } - int ownerSymTag = currentEnv.scope.owner.tag; + long ownerSymTag = currentEnv.scope.owner.tag; // If this is a module error variable, checkTypeAndVarCountConsistency already done at symbolEnter. if ((ownerSymTag & SymTag.PACKAGE) != SymTag.PACKAGE && !(this.symbolEnter.symbolEnterAndValidateErrorVariable(varNode, currentEnv))) { @@ -1815,7 +1756,7 @@ private void handleDeclaredWithVar(BLangVariable variable, AnalyzerData data) { handleWildCardBindingVariable(simpleVariable, currentEnv); - int ownerSymTag = currentEnv.scope.owner.tag; + long ownerSymTag = currentEnv.scope.owner.tag; if ((ownerSymTag & SymTag.INVOKABLE) == SymTag.INVOKABLE || (ownerSymTag & SymTag.LET) == SymTag.LET) { // This is a variable declared in a function, an action or a resource // If the variable is parameter then the variable symbol is already defined @@ -1993,7 +1934,7 @@ void handleDeclaredVarInForeach(BLangVariable variable, BType rhsType, SymbolEnv handleWildCardBindingVariable(simpleVariable, blockEnv); - int ownerSymTag = blockEnv.scope.owner.tag; + long ownerSymTag = blockEnv.scope.owner.tag; if ((ownerSymTag & SymTag.INVOKABLE) == SymTag.INVOKABLE || (ownerSymTag & SymTag.PACKAGE) == SymTag.PACKAGE || (ownerSymTag & SymTag.LET) == SymTag.LET) { @@ -3840,7 +3781,7 @@ public void visit(BLangFail failNode, AnalyzerData data) { if (errorExpressionType == symTable.semanticError || !types.isSubTypeOfBaseType(errorExpressionType, symTable.errorType.tag)) { - dlog.error(errorExpression.pos, DiagnosticErrorCode.ERROR_TYPE_EXPECTED, errorExpressionType); + dlog.error(errorExpression.pos, DiagnosticErrorCode.ERROR_TYPE_EXPECTED, errorExpression.toString()); } data.notCompletedNormally = true; } @@ -4938,333 +4879,6 @@ private Map getFieldLocations(List fields return locations; } - private void validateClientDeclarations(BLangPackage bLangPackage, AnalyzerData data) { - for (Map.Entry>>> pkgIdEntry : - this.symTable.clientDeclarations.entrySet()) { - for (Map.Entry>> compUnitEntry : - pkgIdEntry.getValue().entrySet()) { - if (compUnitEntry.getValue().containsValue(Optional.of(bLangPackage.packageID))) { - checkForClientObjectTypeOrClass(bLangPackage); - checkForMutableState(bLangPackage, data); - } - } - } - - checkForPubliclyExposedConstructsFromClientDeclModules(bLangPackage); - } - - private void checkForClientObjectTypeOrClass(BLangPackage bLangPackage) { - for (BLangClassDefinition classDefinition : bLangPackage.classDefinitions) { - if (classDefinition.name.value.equals(Names.CLIENT.value) && - classDefinition.flagSet.contains(Flag.CLIENT)) { - return; - } - } - - for (BLangTypeDefinition typeDefinition : bLangPackage.typeDefinitions) { - BType bType = typeDefinition.typeNode.getBType(); - if (bType.tag != TypeTags.OBJECT) { - continue; - } - - if (Names.CLIENT.value.equals(bType.tsymbol.name.value) && - Symbols.isFlagOn(bType.tsymbol.flags, Flags.CLIENT)) { - return; - } - } - - List compUnits = bLangPackage.compUnits; - dlog.error(compUnits.isEmpty() ? bLangPackage.symbol.pos : compUnits.get(0).pos, - DiagnosticErrorCode.MODULE_GENERATED_FOR_CLIENT_DECL_MUST_HAVE_A_CLIENT_OBJECT_TYPE); - } - - private void checkForMutableState(BLangPackage bLangPackage, AnalyzerData data) { - for (BLangVariable moduleLevelVar : bLangPackage.globalVars) { - if (!moduleLevelVar.flagSet.contains(Flag.FINAL) || - !types.isSubTypeOfReadOnly(moduleLevelVar.getBType(), data.env)) { - dlog.error(moduleLevelVar.pos, - DiagnosticErrorCode.MODULE_GENERATED_FOR_CLIENT_DECL_CANNOT_HAVE_MUTABLE_STATE); - } - } - } - - private void checkForPubliclyExposedConstructsFromClientDeclModules(BLangPackage bLangPackage) { - BClientDeclConstructExposureDisallowingTypeVisitor collector = - new BClientDeclConstructExposureDisallowingTypeVisitor(this.symResolver, this.symTable); - PackageID packageID = bLangPackage.packageID; - - List moduleVarsAndConstants = new ArrayList<>(); - moduleVarsAndConstants.addAll(bLangPackage.globalVars); - moduleVarsAndConstants.addAll(bLangPackage.constants); - - for (BLangVariable construct : moduleVarsAndConstants) { - if (!construct.flagSet.contains(Flag.PUBLIC)) { - continue; - } - - BLangType typeNode = construct.typeNode; - - if (typeNode == null) { - continue; - } - - logErrorForUnsupportedConstructExposureFromClientDeclModule(packageID, collector, construct.pos, - typeNode.getBType()); - } - - for (BLangTypeDefinition typeDefinition : bLangPackage.typeDefinitions) { - Set flagSet = typeDefinition.flagSet; - if (!flagSet.contains(Flag.PUBLIC) || flagSet.contains(Flag.ANONYMOUS)) { - continue; - } - - logErrorForUnsupportedConstructExposureFromClientDeclModule(packageID, collector, typeDefinition.pos, - typeDefinition.typeNode.getBType()); - } - - for (BLangClassDefinition classDefinition : bLangPackage.classDefinitions) { - Set flagSet = classDefinition.flagSet; - if (!flagSet.contains(Flag.PUBLIC) || classDefinition.isServiceDecl || flagSet.contains(Flag.OBJECT_CTOR)) { - continue; - } - - logErrorForUnsupportedConstructExposureFromClientDeclModule(packageID, collector, classDefinition.pos, - classDefinition.getBType()); - } - - for (BLangFunction function : bLangPackage.functions) { - if (!function.flagSet.contains(Flag.PUBLIC) && - (!function.attachedFunction || !function.receiver.flagSet.contains(Flag.PUBLIC))) { - continue; - } - - logErrorForUnsupportedConstructExposureFromClientDeclModule(packageID, collector, function.pos, - function.getBType()); - } - } - - private void logErrorForUnsupportedConstructExposureFromClientDeclModule(PackageID currentPkgId, - BClientDeclConstructExposureDisallowingTypeVisitor collector, Location location, BType type) { - List exposedTypes = new ArrayList<>(1); - collector.visitType(type, exposedTypes, currentPkgId); - if (!exposedTypes.isEmpty()) { - dlog.error(location, - DiagnosticErrorCode.UNSUPPORTED_EXPOSURE_OF_CONSTRUCT_FROM_MODULE_GENERATED_FOR_CLIENT_DECL); - } - } - - private static class BClientDeclConstructExposureDisallowingTypeVisitor implements TypeVisitor { - - Set unresolvedTypes; - SymbolResolver symResolver; - SymbolTable symTable; - List exposedTypes; - PackageID currentPkgId; - - private BClientDeclConstructExposureDisallowingTypeVisitor(SymbolResolver symResolver, SymbolTable symTable) { - this.symResolver = symResolver; - this.symTable = symTable; - this.unresolvedTypes = Collections.emptySet(); - this.exposedTypes = Collections.emptyList(); - } - - private void visitType(BType type, List exposedTypes, PackageID currentPkgId) { - this.unresolvedTypes = new HashSet<>(); - this.exposedTypes = exposedTypes; - this.currentPkgId = currentPkgId; - this.visitType(type); - } - - private void visitType(BType type) { - if (type == null) { - return; - } - - if (!unresolvedTypes.add(type)) { - return; - } - - BTypeSymbol tsymbol = type.tsymbol; - if (tsymbol != null && !this.currentPkgId.equals(tsymbol.pkgID)) { - for (Map.Entry>>> pkgIdEntry : - this.symTable.clientDeclarations.entrySet()) { - for (Map.Entry>> compUnitEntry : - pkgIdEntry.getValue().entrySet()) { - if (compUnitEntry.getValue().containsValue(Optional.of(tsymbol.pkgID))) { - this.exposedTypes.add(type); - return; - } - } - - } - } - - type.accept(this); - } - - @Override - public void visit(BAnnotationType bAnnotationType) { - } - - @Override - public void visit(BArrayType bArrayType) { - visitType(bArrayType.eType); - } - - @Override - public void visit(BBuiltInRefType bBuiltInRefType) { - } - - @Override - public void visit(BAnyType bAnyType) { - } - - @Override - public void visit(BAnydataType bAnydataType) { - } - - @Override - public void visit(BErrorType bErrorType) { - visitType(bErrorType.detailType); - } - - @Override - public void visit(BFiniteType bFiniteType) { - } - - @Override - public void visit(BInvokableType bInvokableType) { - if (Symbols.isFlagOn(bInvokableType.flags, Flags.ANY_FUNCTION)) { - return; - } - - for (BType paramType : bInvokableType.paramTypes) { - visitType(paramType); - } - visitType(bInvokableType.restType); - visitType(bInvokableType.retType); - } - - @Override - public void visit(BJSONType bjsonType) { - } - - @Override - public void visit(BMapType bMapType) { - visitType(bMapType.constraint); - } - - @Override - public void visit(BStreamType bStreamType) { - visitType(bStreamType.constraint); - visitType(bStreamType.completionType); - } - - @Override - public void visit(BTypedescType bTypedescType) { - visitType(bTypedescType.constraint); - } - - @Override - public void visit(BTypeReferenceType bTypeReferenceType) { - visitType(bTypeReferenceType.referredType); - } - - @Override - public void visit(BParameterizedType bTypedescType) { - } - - @Override - public void visit(BNeverType bNeverType) { - } - - @Override - public void visit(BNilType bNilType) { - } - - @Override - public void visit(BNoType bNoType) { - } - - @Override - public void visit(BPackageType bPackageType) { - } - - @Override - public void visit(BStructureType bStructureType) { - } - - @Override - public void visit(BTupleType bTupleType) { - for (BType memType : bTupleType.tupleTypes) { - visitType(memType); - } - - visitType(bTupleType.restType); - } - - @Override - public void visit(BUnionType bUnionType) { - for (BType memType : bUnionType.getOriginalMemberTypes()) { - visitType(memType); - } - } - - @Override - public void visit(BIntersectionType bIntersectionType) { - for (BType constituentType : bIntersectionType.getConstituentTypes()) { - visitType(constituentType); - } - visitType(bIntersectionType.effectiveType); - } - - @Override - public void visit(BXMLType bXmlType) { - visitType(bXmlType.constraint); - } - - @Override - public void visit(BTableType bTableType) { - visitType(bTableType.constraint); - visitType(bTableType.keyTypeConstraint); - } - - @Override - public void visit(BRecordType bRecordType) { - for (BField field : bRecordType.fields.values()) { - visitType(field.type); - } - - if (!bRecordType.sealed) { - visitType(bRecordType.restFieldType); - } - } - - @Override - public void visit(BObjectType bObjectType) { - for (BField field : bObjectType.fields.values()) { - visitType(field.type); - } - - for (BAttachedFunction attachedFunc : ((BObjectTypeSymbol) bObjectType.tsymbol).attachedFuncs) { - visitType(attachedFunc.type); - } - } - - @Override - public void visit(BType bType) { - } - - @Override - public void visit(BFutureType bFutureType) { - visitType(bFutureType.constraint); - } - - @Override - public void visit(BHandleType bHandleType) { - } - } - /** * @since 2.0.0 */ diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolEnter.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolEnter.java index 5af0b31cbbcc..54c6e1051de4 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolEnter.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolEnter.java @@ -50,7 +50,6 @@ import org.wso2.ballerinalang.compiler.semantics.model.symbols.BAnnotationSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BAttachedFunction; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BClassSymbol; -import org.wso2.ballerinalang.compiler.semantics.model.symbols.BClientDeclarationSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BConstantSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BEnumSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BErrorTypeSymbol; @@ -60,6 +59,7 @@ import org.wso2.ballerinalang.compiler.semantics.model.symbols.BPackageSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BRecordTypeSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BResourceFunction; +import org.wso2.ballerinalang.compiler.semantics.model.symbols.BResourcePathSegmentSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BServiceSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BStructureTypeSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol; @@ -92,7 +92,6 @@ import org.wso2.ballerinalang.compiler.tree.BLangAnnotation; import org.wso2.ballerinalang.compiler.tree.BLangAnnotationAttachment; import org.wso2.ballerinalang.compiler.tree.BLangClassDefinition; -import org.wso2.ballerinalang.compiler.tree.BLangClientDeclaration; import org.wso2.ballerinalang.compiler.tree.BLangCompilationUnit; import org.wso2.ballerinalang.compiler.tree.BLangErrorVariable; import org.wso2.ballerinalang.compiler.tree.BLangFunction; @@ -105,6 +104,7 @@ import org.wso2.ballerinalang.compiler.tree.BLangPackage; import org.wso2.ballerinalang.compiler.tree.BLangRecordVariable; import org.wso2.ballerinalang.compiler.tree.BLangResourceFunction; +import org.wso2.ballerinalang.compiler.tree.BLangResourcePathSegment; import org.wso2.ballerinalang.compiler.tree.BLangService; import org.wso2.ballerinalang.compiler.tree.BLangSimpleVariable; import org.wso2.ballerinalang.compiler.tree.BLangTableKeyTypeConstraint; @@ -127,7 +127,6 @@ import org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLAttribute; import org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLQName; import org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment; -import org.wso2.ballerinalang.compiler.tree.statements.BLangClientDeclarationStatement; import org.wso2.ballerinalang.compiler.tree.statements.BLangXMLNSStatement; import org.wso2.ballerinalang.compiler.tree.types.BLangArrayType; import org.wso2.ballerinalang.compiler.tree.types.BLangBuiltInRefTypeNode; @@ -205,6 +204,7 @@ import static org.ballerinalang.model.symbols.SymbolOrigin.SOURCE; import static org.ballerinalang.model.symbols.SymbolOrigin.VIRTUAL; import static org.ballerinalang.model.tree.NodeKind.IMPORT; +import static org.ballerinalang.model.tree.NodeKind.RECORD_TYPE; import static org.ballerinalang.util.diagnostic.DiagnosticErrorCode.DEFAULTABLE_PARAM_DEFINED_AFTER_INCLUDED_RECORD_PARAM; import static org.ballerinalang.util.diagnostic.DiagnosticErrorCode.EXPECTED_RECORD_TYPE_AS_INCLUDED_PARAMETER; import static org.ballerinalang.util.diagnostic.DiagnosticErrorCode.REDECLARED_SYMBOL; @@ -239,6 +239,7 @@ public class SymbolEnter extends BLangNodeVisitor { private BLangMissingNodesHelper missingNodesHelper; private PackageCache packageCache; private List intersectionTypes; + private Map typeToTypeDef; private SymbolEnv env; private final boolean projectAPIInitiatedCompilation; @@ -412,11 +413,6 @@ private void defineConstructs(BLangPackage pkgNode, SymbolEnv pkgEnv) { if (!PackageID.ANNOTATIONS.equals(pkgNode.packageID)) { initPredeclaredModules(symTable.predeclaredModules, pkgNode.compUnits, pkgEnv); } - - for (BLangClientDeclaration clientDeclaration : pkgNode.clientDeclarations) { - defineNode(clientDeclaration, pkgEnv); - } - // Define type definitions. this.typePrecedence = 0; @@ -443,6 +439,7 @@ private void defineConstructs(BLangPackage pkgNode, SymbolEnv pkgEnv) { // Define type def fields (if any) defineFields(typeAndClassDefs, pkgEnv); + populateTypeToTypeDefMap(typeAndClassDefs); defineDependentFields(typeAndClassDefs, pkgEnv); // Calculate error intersections types. @@ -499,6 +496,17 @@ private void defineConstructs(BLangPackage pkgNode, SymbolEnv pkgEnv) { } } + private void populateTypeToTypeDefMap(List typeDefNodes) { + typeToTypeDef = new HashMap<>(typeDefNodes.size()); + for (BLangNode typeDef : typeDefNodes) { + if (typeDef.getKind() == NodeKind.TYPE_DEFINITION) { + BLangTypeDefinition typeDefNode = (BLangTypeDefinition) typeDef; + BType type = typeDefNode.typeNode.getBType(); + typeToTypeDef.put(type, typeDefNode); + } + } + } + private void defineDependentFields(List typeDefNodes, SymbolEnv pkgEnv) { for (BLangNode typeDef : typeDefNodes) { if (typeDef.getKind() == NodeKind.CLASS_DEFN) { @@ -1075,11 +1083,6 @@ public void visit(BLangImportPackage importPkgNode) { } } - if (symResolver.isModuleGeneratedForClientDeclaration(enclPackageID, pkgId)) { - dlog.error(importPkgNode.pos, DiagnosticErrorCode.CANNOT_IMPORT_MODULE_GENERATED_FOR_CLIENT_DECL); - return; - } - // Detect cyclic module dependencies. This will not detect cycles which starts with the entry package because // entry package has a version. So we check import cycles which starts with the entry package in next step. if (importedPackages.contains(pkgId)) { @@ -1234,53 +1237,6 @@ private boolean nullOrEmpty(String value) { public void visit(BLangXMLNSStatement xmlnsStmtNode) { defineNode(xmlnsStmtNode.xmlnsDecl, env); } - - @Override - public void visit(BLangClientDeclaration clientDeclaration) { - BLangIdentifier prefix = clientDeclaration.prefix; - - if (!symTable.clientDeclarations.containsKey(this.env.enclPkg.packageID) || - !symTable.clientDeclarations.get(this.env.enclPkg.packageID) - .containsKey(clientDeclaration.pos.lineRange().filePath())) { - dlog.error(clientDeclaration.pos, DiagnosticErrorCode.NO_MODULE_GENERATED_FOR_CLIENT_DECL); - } else { - Map> lineRangeMap = - symTable.clientDeclarations.get(this.env.enclPkg.packageID) - .get(clientDeclaration.pos.lineRange().filePath()); - if (!lineRangeMap.containsKey(prefix.pos.lineRange())) { - dlog.error(clientDeclaration.pos, DiagnosticErrorCode.NO_MODULE_GENERATED_FOR_CLIENT_DECL); - } - } - - Name prefixName = names.fromIdNode(prefix); - - BClientDeclarationSymbol clientDeclarationSymbol = - Symbols.createClientDeclarationSymbol(prefixName, (String) clientDeclaration.uri.value, - env.enclPkg.symbol.pkgID, env.scope.owner, prefix.pos, - getOrigin(prefixName)); - clientDeclaration.symbol = clientDeclarationSymbol; - - // Check for module imports with the same prefix separately since the owner for a module is not the current - // module. - BSymbol foundSym = symResolver.lookupSymbolInPrefixSpace(env, clientDeclarationSymbol.name); - if ((foundSym.tag & SymTag.PACKAGE) != SymTag.PACKAGE) { - foundSym = symTable.notFoundSymbol; - } - - if (foundSym != symTable.notFoundSymbol) { - dlog.error(prefix.pos, DiagnosticErrorCode.REDECLARED_SYMBOL, clientDeclarationSymbol.name); - return; - } - - // Define it in the enclosing scope. This will check for the owner equality. - defineSymbol(prefix.pos, clientDeclarationSymbol); - } - - @Override - public void visit(BLangClientDeclarationStatement clientDeclarationStatement) { - defineNode(clientDeclarationStatement.clientDeclaration, env); - } - private void defineTypeNodes(List typeDefs, SymbolEnv env) { if (typeDefs.isEmpty()) { return; @@ -3526,7 +3482,7 @@ private boolean isRestDetailBindingAvailable(BLangErrorVariable errorVariable) { !errorVariable.restDetail.name.value.equals(Names.IGNORE.value); } - private BTypeSymbol createTypeSymbol(int type, SymbolEnv env) { + private BTypeSymbol createTypeSymbol(long type, SymbolEnv env) { return new BTypeSymbol(type, Flags.PUBLIC, Names.EMPTY, env.enclPkg.packageID, null, env.scope.owner, symTable.builtinPos, VIRTUAL); } @@ -3913,9 +3869,6 @@ private void addTopLevelNode(BLangPackage pkgNode, TopLevelNode node) { break; case CLASS_DEFN: pkgNode.classDefinitions.add((BLangClassDefinition) node); - break; - case CLIENT_DECL: - pkgNode.clientDeclarations.add((BLangClientDeclaration) node); } } @@ -4982,11 +4935,9 @@ private void validateFunctionsAttachedToObject(BLangFunction funcNode, BInvokabl private BAttachedFunction createResourceFunction(BLangFunction funcNode, BInvokableSymbol funcSymbol, BInvokableType funcType) { + BObjectTypeSymbol objectTypeSymbol = (BObjectTypeSymbol) funcNode.receiver.getBType().tsymbol; BLangResourceFunction resourceFunction = (BLangResourceFunction) funcNode; Name accessor = names.fromIdNode(resourceFunction.methodName); - List resourcePath = resourceFunction.resourcePath.stream() - .map(names::fromIdNode) - .collect(Collectors.toList()); List pathParamSymbols = resourceFunction.pathParams.stream() .map(p -> { @@ -5001,10 +4952,32 @@ private BAttachedFunction createResourceFunction(BLangFunction funcNode, BInvoka restPathParamSym.kind = SymbolKind.PATH_REST_PARAMETER; } - symResolver.resolveTypeNode(resourceFunction.resourcePathType, env); - return new BResourceFunction(names.fromIdNode(funcNode.name), funcSymbol, funcType, resourcePath, - accessor, pathParamSymbols, restPathParamSym, - (BTupleType) resourceFunction.resourcePathType.getBType(), funcNode.pos); + BResourceFunction bResourceFunction = new BResourceFunction(names.fromIdNode(funcNode.name), funcSymbol, + funcType, accessor, pathParamSymbols, restPathParamSym, funcNode.pos); + + List pathSegments = resourceFunction.resourcePathSegments; + int resourcePathCount = pathSegments.size(); + List pathSegmentSymbols = new ArrayList<>(resourcePathCount); + BResourcePathSegmentSymbol parentResource = null; + for (int i = 0; i < resourcePathCount; i++) { + BLangResourcePathSegment pathSegment = pathSegments.get(i); + Name resourcePathSymbolName = Names.fromString(pathSegment.name.value); + BType resourcePathSegmentType = pathSegment.typeNode == null ? + symTable.noType : symResolver.resolveTypeNode(pathSegment.typeNode, env); + pathSegment.setBType(resourcePathSegmentType); + + BResourcePathSegmentSymbol pathSym = Symbols.createResourcePathSegmentSymbol(resourcePathSymbolName, + env.enclPkg.symbol.pkgID, resourcePathSegmentType, objectTypeSymbol, pathSegment.pos, + parentResource, bResourceFunction, SOURCE); + + objectTypeSymbol.resourcePathSegmentScope.define(pathSym.name, pathSym); + pathSegmentSymbols.add(pathSym); + pathSegment.symbol = pathSym; + parentResource = pathSym; + } + + bResourceFunction.pathSegmentSymbols = pathSegmentSymbols; + return bResourceFunction; } private void validateRemoteFunctionAttachedToObject(BLangFunction funcNode, BObjectTypeSymbol objectSymbol) { @@ -5159,6 +5132,26 @@ private void resolveIncludedFields(BLangStructureTypeNode structureTypeNode) { fieldNames.put(fieldVariable.name.value, fieldVariable); } + for (BLangType typeRef : typeRefs) { + BType referredType = symResolver.resolveTypeNode(typeRef, typeDefEnv); + referredType = Types.getReferredType(referredType); + if (referredType == symTable.semanticError) { + continue; + } + if (referredType.tag != TypeTags.RECORD) { + continue; + } + var fields = ((BStructureType) referredType).fields.values(); + for (BField field : fields) { + BType type = field.type; + BLangTypeDefinition typeDefinition = typeToTypeDef.get(type); + if (typeDefinition != null && typeDefinition.typeNode != null && + typeDefinition.typeNode.getKind() == RECORD_TYPE) { + defineReferencedFieldsOfRecordTypeDef(typeDefinition); + } + } + } + structureTypeNode.includedFields = typeRefs.stream().flatMap(typeRef -> { BType referredType = symResolver.resolveTypeNode(typeRef, typeDefEnv); referredType = Types.getReferredType(referredType); @@ -5299,10 +5292,11 @@ private void defineReferencedFunction(Location location, Set flagSet, Symb BAttachedFunction attachedFunc; if (referencedFunc instanceof BResourceFunction) { BResourceFunction resourceFunction = (BResourceFunction) referencedFunc; - attachedFunc = new BResourceFunction(referencedFunc.funcName, - funcSymbol, (BInvokableType) funcSymbol.type, resourceFunction.resourcePath, - resourceFunction.accessor, resourceFunction.pathParams, resourceFunction.restPathParam, - resourceFunction.resourcePathType, referencedFunc.pos); + BResourceFunction cacheFunc = new BResourceFunction(referencedFunc.funcName, funcSymbol, + (BInvokableType) funcSymbol.type, resourceFunction.accessor, resourceFunction.pathParams, + resourceFunction.restPathParam, referencedFunc.pos); + cacheFunc.pathSegmentSymbols = resourceFunction.pathSegmentSymbols; + attachedFunc = cacheFunc; } else { attachedFunc = new BAttachedFunction(referencedFunc.funcName, funcSymbol, (BInvokableType) funcSymbol.type, referencedFunc.pos); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolResolver.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolResolver.java index 0b3fcae1e2cd..02ee6f7510e0 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolResolver.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolResolver.java @@ -19,7 +19,6 @@ import io.ballerina.tools.diagnostics.DiagnosticCode; import io.ballerina.tools.diagnostics.Location; -import io.ballerina.tools.text.LineRange; import org.ballerinalang.model.TreeBuilder; import org.ballerinalang.model.elements.Flag; import org.ballerinalang.model.elements.PackageID; @@ -39,7 +38,6 @@ import org.wso2.ballerinalang.compiler.semantics.model.SymbolTable; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BAnnotationAttachmentSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BAnnotationSymbol; -import org.wso2.ballerinalang.compiler.semantics.model.symbols.BClientDeclarationSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BConstantSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BErrorTypeSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableTypeSymbol; @@ -474,14 +472,10 @@ public BSymbol resolvePrefixSymbol(SymbolEnv env, Name pkgAlias, Name compUnit) return symbol; } - if ((tag & SymTag.CLIENT_DECL) == SymTag.CLIENT_DECL) { - return resolveClientDeclPrefix(symbol); - } - - if ((tag & SymTag.IMPORT) == SymTag.IMPORT && - ((BPackageSymbol) symbol).compUnit.equals(compUnit)) { - ((BPackageSymbol) symbol).isUsed = true; - return symbol; + if ((entry.symbol.tag & SymTag.IMPORT) == SymTag.IMPORT && + ((BPackageSymbol) entry.symbol).compUnit.equals(compUnit)) { + ((BPackageSymbol) entry.symbol).isUsed = true; + return entry.symbol; } entry = entry.next; @@ -1611,8 +1605,6 @@ public BType transform(BLangUserDefinedType userDefinedTypeNode, AnalyzerData da // 2) Resolve the package scope using the package alias. // If the package alias is not empty or null, then find the package scope, if (symbol == symTable.notFoundSymbol) { - validateUnquotedClientKeywordUsageInQualifiedIdentifier(userDefinedTypeNode, data.env, pkgAliasIdentifier, - pkgAlias, typeNameIdentifier, typeName); BSymbol tempSymbol = lookupMainSpaceSymbolInPackage(userDefinedTypeNode.pos, env, pkgAlias, typeName); @@ -1731,25 +1723,6 @@ public BType transform(BLangUserDefinedType userDefinedTypeNode, AnalyzerData da return symbol.type; } - private void validateUnquotedClientKeywordUsageInQualifiedIdentifier(BLangUserDefinedType userDefinedTypeNode, - SymbolEnv env, - BLangIdentifier pkgAliasIdentifier, - Name pkgAlias, - BLangIdentifier typeNameIdentifier, - Name typeName) { - if (pkgAliasIdentifier == null || !Names.CLIENT.value.equals(typeName.value) || typeNameIdentifier.isLiteral) { - return; - } - - Location pos = userDefinedTypeNode.pos; - - BSymbol pkgSymbol = this.resolvePrefixSymbol(env, pkgAlias, Names.fromString(pos.lineRange().filePath())); - if (pkgSymbol != symTable.notFoundSymbol && - !this.isModuleGeneratedForClientDeclaration(env.enclPkg.packageID, pkgSymbol.pkgID)) { - dlog.error(pos, DiagnosticErrorCode.INVALID_USAGE_OF_THE_CLIENT_KEYWORD_AS_UNQUOTED_IDENTIFIER); - } - } - private ParameterizedTypeInfo getTypedescParamValueType(List params, AnalyzerData data, BSymbol varSym) { for (int i = 0; i < params.size(); i++) { @@ -2623,8 +2596,8 @@ public BPackageSymbol getModuleForPackageId(PackageID packageID) { .get(); } - public List getListOfInterpolations(List sequenceList) { - List interpolationsList = new ArrayList<>(); + public List getListOfInterpolations(List sequenceList, + List interpolationsList) { for (BLangExpression seq : sequenceList) { if (seq.getKind() != NodeKind.REG_EXP_SEQUENCE) { continue; @@ -2642,7 +2615,8 @@ public List getListOfInterpolations(List seque } if (kind == NodeKind.REG_EXP_CAPTURING_GROUP) { interpolationsList.addAll( - getListOfInterpolations(((BLangReCapturingGroups) atom).disjunction.sequenceList)); + getListOfInterpolations(((BLangReCapturingGroups) atom).disjunction.sequenceList, + interpolationsList)); } } } @@ -2674,46 +2648,6 @@ private ParameterizedTypeInfo(BType paramValueType, int index) { } } - public BSymbol resolveClientDeclPrefix(BSymbol symbol) { - LineRange lineRange = symbol.pos.lineRange(); - if (!symTable.clientDeclarations.containsKey(symbol.pkgID) || - !symTable.clientDeclarations.get(symbol.pkgID).containsKey(symbol.pos.lineRange().filePath())) { - return symTable.notFoundSymbol; - } - Map> clientDeclarations = - symTable.clientDeclarations.get(symbol.pkgID).get(symbol.pos.lineRange().filePath()); - if (!clientDeclarations.containsKey(lineRange) || clientDeclarations.get(lineRange).isEmpty()) { - return symTable.notFoundSymbol; - } - - Optional optionalPackageID = clientDeclarations.get(lineRange); - if (optionalPackageID.isEmpty()) { - return symTable.notFoundSymbol; - } - - ((BClientDeclarationSymbol) symbol).used = true; - return getModuleForPackageId(optionalPackageID.get()); - } - - public boolean isModuleGeneratedForClientDeclaration(PackageID currentPackageId, PackageID packageIdToCheck) { - if (!symTable.clientDeclarations.containsKey(currentPackageId)) { - return false; - } - - for (Map> fileClientDecls : - symTable.clientDeclarations.get(currentPackageId).values()) { - for (Optional optionalPackageID : fileClientDecls.values()) { - if (optionalPackageID.isPresent()) { - if (packageIdToCheck.equals(optionalPackageID.get())) { - return true; - } - } - } - } - - return false; - } - /** * @since 2.0.0 */ diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java index e048ad6829bf..c8a5d51751e4 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java @@ -60,6 +60,7 @@ import org.wso2.ballerinalang.compiler.semantics.model.symbols.BPackageSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BRecordTypeSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BResourceFunction; +import org.wso2.ballerinalang.compiler.semantics.model.symbols.BResourcePathSegmentSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BTypeSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol; @@ -444,11 +445,7 @@ private void validateAndSetExprExpectedType(BLangExpression expr, AnalyzerData d public void visit(BLangLiteral literalExpr, AnalyzerData data) { BType literalType = setLiteralValueAndGetType(literalExpr, data.expType, data); - if (literalType == symTable.semanticError) { - data.resultType = symTable.semanticError; - return; - } - if (literalExpr.isFiniteContext) { + if (literalType == symTable.semanticError || literalExpr.isFiniteContext) { return; } data.resultType = types.checkType(literalExpr, literalType, data.expType); @@ -492,7 +489,7 @@ private void checkXMLNamespacePrefixes(List filters, Anal Name nsName = names.fromString(filter.namespace); BSymbol nsSymbol = symResolver.lookupSymbolInPrefixSpace(data.env, nsName); filter.namespaceSymbol = nsSymbol; - if (nsSymbol.getKind() != SymbolKind.XMLNS) { + if (nsSymbol == symTable.notFoundSymbol) { dlog.error(filter.nsPos, DiagnosticErrorCode.CANNOT_FIND_XML_NAMESPACE, nsName); } } @@ -615,6 +612,7 @@ private BType getIntegerLiteralType(BLangLiteral literalExpr, Object literalValu if (literalValue instanceof String) { dlog.error(literalExpr.pos, DiagnosticErrorCode.OUT_OF_RANGE, literalExpr.originalValue, expectedType); + data.resultType = symTable.semanticError; return symTable.semanticError; } if (literalValue instanceof Double) { @@ -630,6 +628,7 @@ private BType getIntegerLiteralType(BLangLiteral literalExpr, Object literalValu BFiniteType finiteType = (BFiniteType) expectedType; BType compatibleType = checkIfOutOfRangeAndReturnType(finiteType, literalExpr, literalValue, data); if (compatibleType == symTable.semanticError) { + data.resultType = symTable.semanticError; return compatibleType; } else { return getFiniteTypeMatchWithIntLiteral(literalExpr, finiteType, literalValue, data); @@ -677,6 +676,7 @@ private BType getIntegerLiteralType(BLangLiteral literalExpr, Object literalValu if (!(literalValue instanceof Long)) { dlog.error(literalExpr.pos, DiagnosticErrorCode.OUT_OF_RANGE, literalExpr.originalValue, literalExpr.getBType()); + data.resultType = symTable.semanticError; return symTable.semanticError; } return symTable.intType; @@ -686,6 +686,7 @@ private BType getTypeOfLiteralWithFloatDiscriminator(BLangLiteral literalExpr, O BType expType, AnalyzerData data) { String numericLiteral = NumericLiteralSupport.stripDiscriminator(String.valueOf(literalValue)); if (!types.validateFloatLiteral(literalExpr.pos, numericLiteral)) { + data.resultType = symTable.semanticError; return symTable.semanticError; } literalExpr.value = Double.parseDouble(numericLiteral); @@ -709,9 +710,6 @@ private BType getTypeOfLiteralWithFloatDiscriminator(BLangLiteral literalExpr, O private BType getTypeOfLiteralWithDecimalDiscriminator(BLangLiteral literalExpr, Object literalValue, BType expType, AnalyzerData data) { literalExpr.value = NumericLiteralSupport.stripDiscriminator(String.valueOf(literalValue)); - if (!types.isValidDecimalNumber(literalExpr.pos, literalExpr.value.toString())) { - return symTable.semanticError; - } BType referredType = Types.getReferredType(expType); if (referredType.tag == TypeTags.FINITE) { BFiniteType finiteType = (BFiniteType) referredType; @@ -734,10 +732,7 @@ private BType getTypeOfDecimalFloatingPointLiteral(BLangLiteral literalExpr, Obj BType expectedType = Types.getReferredType(expType); String numericLiteral = String.valueOf(literalValue); if (expectedType.tag == TypeTags.DECIMAL) { - if (types.isValidDecimalNumber(literalExpr.pos, literalExpr.value.toString())) { - return symTable.decimalType; - } - return symTable.semanticError; + return symTable.decimalType; } else if (expectedType.tag == TypeTags.FLOAT) { if (!types.validateFloatLiteral(literalExpr.pos, numericLiteral)) { data.resultType = symTable.semanticError; @@ -759,20 +754,25 @@ private BType getTypeOfDecimalFloatingPointLiteral(BLangLiteral literalExpr, Obj BType unionMember = getAndSetAssignableUnionMember(literalExpr, unionType, symTable.getTypeFromTag(tag), data); if (unionMember == symTable.floatType && !types.validateFloatLiteral(literalExpr.pos, numericLiteral)) { + data.resultType = symTable.semanticError; return symTable.semanticError; } else if (unionMember != symTable.noType) { return unionMember; } } } - return types.validateFloatLiteral(literalExpr.pos, numericLiteral) - ? symTable.floatType : symTable.semanticError; + if (!types.validateFloatLiteral(literalExpr.pos, numericLiteral)) { + data.resultType = symTable.semanticError; + return symTable.semanticError; + } + return symTable.floatType; } private BType getTypeOfHexFloatingPointLiteral(BLangLiteral literalExpr, Object literalValue, BType expType, AnalyzerData data) { String numericLiteral = String.valueOf(literalValue); if (!types.validateFloatLiteral(literalExpr.pos, numericLiteral)) { + data.resultType = symTable.semanticError; return symTable.semanticError; } literalExpr.value = Double.parseDouble(numericLiteral); @@ -2820,14 +2820,13 @@ public void visit(BLangSimpleVarRef varRefExpr, AnalyzerData data) { // Set error type as the actual type. BType actualType = symTable.semanticError; - BLangIdentifier identifier = varRefExpr.variableName; - Name varName = names.fromIdNode(identifier); + Name varName = names.fromIdNode(varRefExpr.variableName); if (varName == Names.IGNORE) { varRefExpr.setBType(this.symTable.anyType); // If the variable name is a wildcard('_'), the symbol should be ignorable. varRefExpr.symbol = new BVarSymbol(0, true, varName, - names.originalNameFromIdNode(identifier), + names.originalNameFromIdNode(varRefExpr.variableName), data.env.enclPkg.symbol.pkgID, varRefExpr.getBType(), data.env.scope.owner, varRefExpr.pos, VIRTUAL); @@ -2836,23 +2835,16 @@ public void visit(BLangSimpleVarRef varRefExpr, AnalyzerData data) { } Name compUnitName = getCurrentCompUnit(varRefExpr); - BSymbol pkgSymbol = symResolver.resolvePrefixSymbol(data.env, names.fromIdNode(varRefExpr.pkgAlias), - compUnitName); - varRefExpr.pkgSymbol = pkgSymbol; - if (pkgSymbol == symTable.notFoundSymbol) { + varRefExpr.pkgSymbol = + symResolver.resolvePrefixSymbol(data.env, names.fromIdNode(varRefExpr.pkgAlias), compUnitName); + if (varRefExpr.pkgSymbol == symTable.notFoundSymbol) { varRefExpr.symbol = symTable.notFoundSymbol; dlog.error(varRefExpr.pos, DiagnosticErrorCode.UNDEFINED_MODULE, varRefExpr.pkgAlias); - } else if (Names.CLIENT.equals(varName) && !identifier.isLiteral) { - if (pkgSymbol != symTable.notFoundSymbol && - !symResolver.isModuleGeneratedForClientDeclaration(data.env.enclPkg.packageID, pkgSymbol.pkgID)) { - dlog.error(varRefExpr.pos, - DiagnosticErrorCode.INVALID_USAGE_OF_THE_CLIENT_KEYWORD_AS_UNQUOTED_IDENTIFIER); - } } - if (pkgSymbol.tag == SymTag.XMLNS) { + if (varRefExpr.pkgSymbol.tag == SymTag.XMLNS) { actualType = symTable.stringType; - } else if (pkgSymbol != symTable.notFoundSymbol) { + } else if (varRefExpr.pkgSymbol != symTable.notFoundSymbol) { BSymbol symbol = symResolver.lookupMainSpaceSymbolInPackage(varRefExpr.pos, data.env, names.fromIdNode(varRefExpr.pkgAlias), varName); // if no symbol, check same for object attached function @@ -3710,7 +3702,8 @@ public void visit(BLangInvocation.BLangResourceAccessInvocation resourceAccessIn BResourceFunction resourceFunction = (BResourceFunction) targetFunc; BLangExpression clonedResourceAccPathSeg = nodeCloner.cloneNode(resourceAccessInvocation.resourceAccessPathSegments); - BType resolvedType = checkExprSilent(clonedResourceAccPathSeg, resourceFunction.resourcePathType, data); + BType resolvedType = checkExprSilent(clonedResourceAccPathSeg, + getResourcePathType(resourceFunction.pathSegmentSymbols), data); if (resolvedType != symTable.semanticError) { resourceFunctions.add(resourceFunction); } @@ -3736,13 +3729,35 @@ public void visit(BLangInvocation.BLangResourceAccessInvocation resourceAccessIn data.resultType = symTable.semanticError; } else { BResourceFunction targetResourceFunc = resourceFunctions.get(0); - checkExpr(resourceAccessInvocation.resourceAccessPathSegments, targetResourceFunc.resourcePathType, data); + checkExpr(resourceAccessInvocation.resourceAccessPathSegments, + getResourcePathType(targetResourceFunc.pathSegmentSymbols), data); resourceAccessInvocation.symbol = targetResourceFunc.symbol; resourceAccessInvocation.targetResourceFunc = targetResourceFunc; checkResourceAccessParamAndReturnType(resourceAccessInvocation, targetResourceFunc, data); } } + private BTupleType getResourcePathType(List pathSegmentSymbols) { + BType restType = null; + int pathSegmentCount = pathSegmentSymbols.size(); + BResourcePathSegmentSymbol lastPathSegmentSym = pathSegmentSymbols.get(pathSegmentCount - 1); + if (lastPathSegmentSym.kind == SymbolKind.RESOURCE_PATH_REST_PARAM_SEGMENT) { + restType = lastPathSegmentSym.type; + pathSegmentCount--; + } + + BTupleType resourcePathType; + if (pathSegmentCount > 0 && lastPathSegmentSym.kind != SymbolKind.RESOURCE_ROOT_PATH_SEGMENT) { + resourcePathType = new BTupleType(pathSegmentSymbols.subList(0, pathSegmentCount).stream() + .map(s -> s.type).collect(Collectors.toList())); + } else { + resourcePathType = new BTupleType(new ArrayList<>()); + } + + resourcePathType.restType = restType; + return resourcePathType; + } + /** * Validate resource access path segment types. * @@ -5426,11 +5441,7 @@ public void visit(BLangTypeConversionExpr conversionExpr, AnalyzerData data) { this.dlog.unmute(); } - if ((errorCount == 0 && exprCompatibleType != symTable.semanticError) || - (requireTypeInference(expr, false) && - // Temporary workaround for backward compatibility with `object {}` for - // https://github.com/ballerina-platform/ballerina-lang/issues/38105. - isNotObjectConstructorWithObjectSuperTypeInTypeCastExpr(expr, targetType))) { + if ((errorCount == 0 && exprCompatibleType != symTable.semanticError) || requireTypeInference(expr, false)) { checkExpr(expr, targetType, data); } else { checkExpr(expr, symTable.noType, data); @@ -5559,15 +5570,7 @@ public void visit(BLangXMLQName bLangXMLQName, AnalyzerData data) { return; } - SymbolKind kind = xmlnsSymbol.getKind(); - - if (kind == SymbolKind.CLIENT_DECL) { - dlog.error(bLangXMLQName.pos, DiagnosticErrorCode.CANNOT_FIND_XML_NAMESPACE, prefix); - data.resultType = symTable.semanticError; - return; - } - - if (kind == SymbolKind.PACKAGE) { + if (xmlnsSymbol.getKind() == SymbolKind.PACKAGE) { xmlnsSymbol = findXMLNamespaceFromPackageConst(bLangXMLQName.localname.value, bLangXMLQName.prefix.value, (BPackageSymbol) xmlnsSymbol, bLangXMLQName.pos, data); } @@ -5826,7 +5829,8 @@ public void visit(BLangStringTemplateLiteral stringTemplateLiteral, AnalyzerData public void visit(BLangRegExpTemplateLiteral regExpTemplateLiteral, AnalyzerData data) { // Check expr with insertions to resolve its type. List interpolationsList = - symResolver.getListOfInterpolations(regExpTemplateLiteral.reDisjunction.sequenceList); + symResolver.getListOfInterpolations(regExpTemplateLiteral.reDisjunction.sequenceList, + new ArrayList<>()); interpolationsList.forEach(interpolation -> checkExpr(interpolation, data)); data.resultType = types.checkType(regExpTemplateLiteral, symTable.regExpType, data.expType); } @@ -6018,9 +6022,6 @@ public void visit(BLangCheckedExpr checkedExpr, AnalyzerData data) { Types.CommonAnalyzerData typeCheckerData = data.commonAnalyzerData; typeCheckerData.checkWithinQueryExpr = isWithinQuery(data); visitCheckAndCheckPanicExpr(checkedExpr, data); - if (typeCheckerData.checkWithinQueryExpr && checkedExpr.equivalentErrorTypeList != null) { - data.commonAnalyzerData.checkedErrorList.addAll(checkedExpr.equivalentErrorTypeList); - } } @Override @@ -6033,15 +6034,9 @@ public void visit(BLangQueryExpr queryExpr, AnalyzerData data) { Types.CommonAnalyzerData typeCheckerData = data.commonAnalyzerData; //reset common analyzer data - boolean prevQueryCompletesEarly = typeCheckerData.queryCompletesEarly; - typeCheckerData.queryCompletesEarly = false; - boolean prevCheckWithinQueryExpr = typeCheckerData.checkWithinQueryExpr; typeCheckerData.checkWithinQueryExpr = false; - HashSet prevCompleteEarlyErrorList = typeCheckerData.completeEarlyErrorList; - typeCheckerData.completeEarlyErrorList = new HashSet<>(); - HashSet prevCheckedErrorList = typeCheckerData.checkedErrorList; typeCheckerData.checkedErrorList = new HashSet<>(); @@ -6059,11 +6054,11 @@ public void visit(BLangQueryExpr queryExpr, AnalyzerData data) { } typeCheckerData.queryFinalClauses.push(queryExpr.getSelectClause()); List clauses = queryExpr.getQueryClauses(); + BLangExpression collectionNode = (BLangExpression) ((BLangFromClause) clauses.get(0)).getCollection(); clauses.forEach(clause -> clause.accept(this, data)); - BType actualType = resolveQueryType(typeCheckerData.queryEnvs.peek(), - ((BLangSelectClause) typeCheckerData.queryFinalClauses.peek()).expression, - data.expType, queryExpr, clauses, data); + ((BLangSelectClause) typeCheckerData.queryFinalClauses.peek()).expression, + collectionNode.getBType(), data.expType, queryExpr, data); actualType = (actualType == symTable.semanticError) ? actualType : types.checkType(queryExpr.pos, actualType, data.expType, DiagnosticErrorCode.INCOMPATIBLE_TYPES); typeCheckerData.queryFinalClauses.pop(); @@ -6084,9 +6079,7 @@ public void visit(BLangQueryExpr queryExpr, AnalyzerData data) { } //re-assign common analyzer data - typeCheckerData.queryCompletesEarly = prevQueryCompletesEarly; typeCheckerData.checkWithinQueryExpr = prevCheckWithinQueryExpr; - typeCheckerData.completeEarlyErrorList = prevCompleteEarlyErrorList; typeCheckerData.checkedErrorList = prevCheckedErrorList; typeCheckerData.queryFinalClauses = prevQueryFinalClauses; typeCheckerData.letCount = prevLetCount; @@ -6099,8 +6092,8 @@ private boolean isWithinQuery(AnalyzerData data) { && !data.commonAnalyzerData.queryFinalClauses.isEmpty(); } - private BType resolveQueryType(SymbolEnv env, BLangExpression selectExp, BType targetType, - BLangQueryExpr queryExpr, List clauses, AnalyzerData data) { + private BType resolveQueryType(SymbolEnv env, BLangExpression selectExp, BType collectionType, + BType targetType, BLangQueryExpr queryExpr, AnalyzerData data) { List safeResultTypes = types.getAllTypes(targetType, true).stream() .filter(t -> !types.isAssignable(t, symTable.errorType)) .filter(t -> !types.isAssignable(t, symTable.nilType)) @@ -6113,14 +6106,15 @@ private BType resolveQueryType(SymbolEnv env, BLangExpression selectExp, BType t List selectTypes = new ArrayList<>(); List resolvedTypes = new ArrayList<>(); BType selectType; - BLangExpression collectionNode = (BLangExpression) ((BLangFromClause) clauses.get(0)).getCollection(); + LinkedHashSet memberTypes = new LinkedHashSet<>(); + for (BType type : safeResultTypes) { - solveSelectTypeAndResolveType(queryExpr, selectExp, type, collectionNode.getBType(), selectTypes, - resolvedTypes, env, data, false); + solveSelectTypeAndResolveType(queryExpr, selectExp, type, collectionType, selectTypes, resolvedTypes, env, + data, false, memberTypes); } + if (selectTypes.size() == 1) { - List collectionTypes = getCollectionTypes(clauses); - BType completionType = getCompletionType(collectionTypes, types.getQueryConstructType(queryExpr), data); + BType completionType = getCompletionType(collectionType, queryExpr, data); selectType = selectTypes.get(0); if (queryExpr.isStream) { return new BStreamType(TypeTags.STREAM, selectType, completionType, null); @@ -6153,16 +6147,10 @@ private BType resolveQueryType(SymbolEnv env, BLangExpression selectExp, BType t } } - private List getCollectionTypes(List clauses) { - return clauses.stream() - .filter(clause -> (clause.getKind() == NodeKind.FROM || clause.getKind() == NodeKind.JOIN)) - .map(clause -> ((BLangInputClause) clause).collection.getBType()) - .collect(Collectors.toList()); - } - void solveSelectTypeAndResolveType(BLangQueryExpr queryExpr, BLangExpression selectExp, BType type, BType collectionType, List selectTypes, List resolvedTypes, - SymbolEnv env, AnalyzerData data, boolean isReadonly) { + SymbolEnv env, AnalyzerData data, boolean isReadonly, + LinkedHashSet memberTypes) { BType selectType, resolvedType; type = Types.getReferredType(type); switch (type.tag) { @@ -6202,7 +6190,7 @@ void solveSelectTypeAndResolveType(BLangQueryExpr queryExpr, BLangExpression sel case TypeTags.INTERSECTION: type = ((BIntersectionType) type).effectiveType; solveSelectTypeAndResolveType(queryExpr, selectExp, type, collectionType, selectTypes, - resolvedTypes, env, data, Symbols.isFlagOn(type.flags, Flags.READONLY)); + resolvedTypes, env, data, Symbols.isFlagOn(type.flags, Flags.READONLY), memberTypes); return; case TypeTags.NONE: default: @@ -6319,54 +6307,45 @@ private void markReadOnlyForConstraintType(BType constraintType) { } } - private BType getCompletionType(List collectionTypes, Types.QueryConstructType queryConstructType, - AnalyzerData data) { - Set completionTypes = new LinkedHashSet<>(); + private BType getCompletionType(BType collectionType, BLangQueryExpr queryExpr, AnalyzerData data) { + if (collectionType.tag == TypeTags.SEMANTIC_ERROR) { + return null; + } BType returnType = null, completionType = null; - for (BType collectionType : collectionTypes) { - if (collectionType.tag == TypeTags.SEMANTIC_ERROR) { - return null; - } - collectionType = Types.getReferredType(collectionType); - switch (collectionType.tag) { - case TypeTags.STREAM: - completionType = ((BStreamType) collectionType).completionType; - returnType = completionType; - break; - case TypeTags.OBJECT: - returnType = types.getVarTypeFromIterableObject((BObjectType) collectionType); - break; - default: - BSymbol itrSymbol = symResolver.lookupLangLibMethod(collectionType, - names.fromString(BLangCompilerConstants.ITERABLE_COLLECTION_ITERATOR_FUNC), data.env); - if (itrSymbol == this.symTable.notFoundSymbol) { - return null; - } - BInvokableSymbol invokableSymbol = (BInvokableSymbol) itrSymbol; - returnType = types.getResultTypeOfNextInvocation( - (BObjectType) Types.getReferredType(invokableSymbol.retType)); - } - if (returnType != null) { - if (queryConstructType == Types.QueryConstructType.STREAM) { - types.getAllTypes(returnType, true).stream() - .filter(t -> (types.isAssignable(t, symTable.errorType) - || types.isAssignable(t, symTable.nilType))) - .forEach(completionTypes::add); - } else { - types.getAllTypes(returnType, true).stream() - .filter(t -> types.isAssignable(t, symTable.errorType)) - .forEach(completionTypes::add); + collectionType = Types.getReferredType(collectionType); + switch (collectionType.tag) { + case TypeTags.STREAM: + completionType = ((BStreamType) collectionType).completionType; + break; + case TypeTags.OBJECT: + returnType = types.getVarTypeFromIterableObject((BObjectType) collectionType); + break; + default: + BSymbol itrSymbol = symResolver.lookupLangLibMethod(collectionType, + names.fromString(BLangCompilerConstants.ITERABLE_COLLECTION_ITERATOR_FUNC), data.env); + if (itrSymbol == this.symTable.notFoundSymbol) { + return null; } + BInvokableSymbol invokableSymbol = (BInvokableSymbol) itrSymbol; + returnType = types.getResultTypeOfNextInvocation( + (BObjectType) Types.getReferredType(invokableSymbol.retType)); + } + Set completionTypes = new LinkedHashSet<>(); + if (returnType != null) { + if (queryExpr.isStream) { + types.getAllTypes(returnType, true).stream() + .filter(t -> (types.isAssignable(t, symTable.errorType) + || types.isAssignable(t, symTable.nilType))) + .forEach(completionTypes::add); + } else { + types.getAllTypes(returnType, true).stream() + .filter(t -> types.isAssignable(t, symTable.errorType)) + .forEach(completionTypes::add); } } - if (data.commonAnalyzerData.queryCompletesEarly) { - if (queryConstructType == Types.QueryConstructType.TABLE || - queryConstructType == Types.QueryConstructType.MAP) { - completionTypes.addAll(data.commonAnalyzerData.completeEarlyErrorList); - } - } else if (queryConstructType == Types.QueryConstructType.STREAM) { - if (data.commonAnalyzerData.checkWithinQueryExpr) { + if (data.commonAnalyzerData.checkWithinQueryExpr) { + if (queryExpr.isTable || queryExpr.isMap) { completionTypes.addAll(data.commonAnalyzerData.checkedErrorList); } if (completionTypes.isEmpty()) { @@ -6375,7 +6354,6 @@ private BType getCompletionType(List collectionTypes, Types.QueryConstruc completionTypes.add(symTable.nilType); } } - if (!completionTypes.isEmpty()) { if (completionTypes.size() == 1) { completionType = completionTypes.iterator().next(); @@ -6413,8 +6391,8 @@ public void visit(BLangQueryAction queryAction, AnalyzerData data) { Types.CommonAnalyzerData typeCheckerData = data.commonAnalyzerData; //reset common analyzer data - boolean prevCheckWithinQueryExpr = typeCheckerData.queryCompletesEarly; - typeCheckerData.queryCompletesEarly = false; + boolean prevCheckWithinQueryExpr = typeCheckerData.checkWithinQueryExpr; + typeCheckerData.checkWithinQueryExpr = false; Stack prevQueryFinalClauses = typeCheckerData.queryFinalClauses; typeCheckerData.queryFinalClauses = new Stack<>(); @@ -6432,12 +6410,10 @@ public void visit(BLangQueryAction queryAction, AnalyzerData data) { typeCheckerData.queryFinalClauses.push(doClause); List clauses = queryAction.getQueryClauses(); clauses.forEach(clause -> clause.accept(this, data)); - List collectionTypes = getCollectionTypes(clauses); - BType completionType = getCompletionType(collectionTypes, Types.QueryConstructType.DEFAULT, data); // Analyze foreach node's statements. semanticAnalyzer.analyzeNode(doClause.body, SymbolEnv.createBlockEnv(doClause.body, typeCheckerData.queryEnvs.peek()), data.prevEnvs, typeCheckerData); - BType actualType = completionType == null ? symTable.nilType : completionType; + BType actualType = BUnionType.create(null, symTable.errorType, symTable.nilType); data.resultType = types.checkType(doClause.pos, actualType, data.expType, DiagnosticErrorCode.INCOMPATIBLE_TYPES); typeCheckerData.queryFinalClauses.pop(); @@ -6447,7 +6423,7 @@ public void visit(BLangQueryAction queryAction, AnalyzerData data) { } //re-assign common analyzer data - typeCheckerData.queryCompletesEarly = prevCheckWithinQueryExpr; + typeCheckerData.checkWithinQueryExpr = prevCheckWithinQueryExpr; typeCheckerData.queryFinalClauses = prevQueryFinalClauses; typeCheckerData.letCount = prevLetCount; } @@ -6486,14 +6462,6 @@ public void visit(BLangJoinClause joinClause, AnalyzerData data) { checkExpr(joinClause.collection, data.commonAnalyzerData.queryEnvs.peek(), data); // Set the type of the foreach node's type node. types.setInputClauseTypedBindingPatternType(joinClause); - if (joinClause.isOuterJoin) { - if (!joinClause.isDeclaredWithVar) { - this.dlog.error(joinClause.variableDefinitionNode.getPosition(), - DiagnosticErrorCode.OUTER_JOIN_MUST_BE_DECLARED_WITH_VAR); - return; - } - joinClause.varType = types.addNilForNillableAccessType(joinClause.varType); - } handleInputClauseVariables(joinClause, data.commonAnalyzerData.queryEnvs.peek()); if (joinClause.onClause != null) { ((BLangOnClause) joinClause.onClause).accept(this, data); @@ -6537,12 +6505,12 @@ public void visit(BLangOnConflictClause onConflictClause, AnalyzerData data) { BType type = checkExpr(onConflictClause.expression, data.commonAnalyzerData.queryEnvs.peek(), symTable.errorOrNilType, data); if (types.containsErrorType(type)) { - data.commonAnalyzerData.queryCompletesEarly = true; - if (typeCheckerData.completeEarlyErrorList != null) { + data.commonAnalyzerData.checkWithinQueryExpr = true; + if (typeCheckerData.checkedErrorList != null) { BType possibleErrorType = type.tag == TypeTags.UNION ? types.getErrorType((BUnionType) type) : types.getErrorType(BUnionType.create(null, type)); - typeCheckerData.completeEarlyErrorList.add(possibleErrorType); + typeCheckerData.checkedErrorList.add(possibleErrorType); } } } @@ -7935,11 +7903,6 @@ private boolean requireTypeInference(BLangExpression expr, boolean inferTypeForN case ARROW_EXPR: case LIST_CONSTRUCTOR_EXPR: case RECORD_LITERAL_EXPR: - case OBJECT_CTOR_EXPRESSION: - case RAW_TEMPLATE_LITERAL: - case TABLE_CONSTRUCTOR_EXPR: - case TYPE_INIT_EXPR: - case ERROR_CONSTRUCTOR_EXPRESSION: return true; case ELVIS_EXPR: case TERNARY_EXPR: @@ -7950,36 +7913,6 @@ private boolean requireTypeInference(BLangExpression expr, boolean inferTypeForN } } - private boolean isNotObjectConstructorWithObjectSuperTypeInTypeCastExpr(BLangExpression expression, - BType targetType) { - if (expression.getKind() != NodeKind.OBJECT_CTOR_EXPRESSION) { - return true; - } - - targetType = Types.getEffectiveType(Types.getReferredType(targetType)); - int tag = targetType.tag; - - if (tag == TypeTags.OBJECT) { - return !isAllObjectsObjectType((BObjectType) targetType); - } - - if (tag != TypeTags.UNION) { - return false; - } - - for (BType memberType : ((BUnionType) targetType).getMemberTypes()) { - memberType = Types.getEffectiveType(Types.getReferredType(memberType)); - if (memberType.tag == TypeTags.OBJECT && isAllObjectsObjectType((BObjectType) memberType)) { - return false; - } - } - return true; - } - - private boolean isAllObjectsObjectType(BObjectType objectType) { - return objectType.fields.isEmpty() && ((BObjectTypeSymbol) objectType.tsymbol).attachedFuncs.isEmpty(); - } - private BType checkMappingField(RecordLiteralNode.RecordField field, BType mappingType, AnalyzerData data) { BType fieldType = symTable.semanticError; boolean keyValueField = field.isKeyValueField(); @@ -8303,12 +8236,6 @@ private BType checkObjectFieldAccess(BLangFieldBasedAccess bLangFieldBasedAccess return symTable.semanticError; } - if (Symbols.isFlagOn(fieldSymbol.flags, Flags.REMOTE)) { - dlog.error(bLangFieldBasedAccess.field.pos, - DiagnosticErrorCode.CANNOT_USE_FIELD_ACCESS_TO_ACCESS_A_REMOTE_METHOD); - return symTable.semanticError; - } - if (Symbols.isFlagOn(fieldSymbol.type.flags, Flags.ISOLATED) && !Symbols.isFlagOn(objectType.flags, Flags.ISOLATED)) { fieldSymbol = ASTBuilderUtil.duplicateInvokableSymbol((BInvokableSymbol) fieldSymbol); @@ -8828,7 +8755,7 @@ private void resolveXMLNamespace(BLangFieldBasedAccess.BLangNSPrefixedFieldBased String nsPrefix = nsPrefixedFieldAccess.nsPrefix.value; BSymbol nsSymbol = symResolver.lookupSymbolInPrefixSpace(data.env, names.fromString(nsPrefix)); - if (nsSymbol == symTable.notFoundSymbol || nsSymbol.getKind() == SymbolKind.CLIENT_DECL) { + if (nsSymbol == symTable.notFoundSymbol) { dlog.error(nsPrefixedFieldAccess.nsPrefix.pos, DiagnosticErrorCode.CANNOT_FIND_XML_NAMESPACE, nsPrefixedFieldAccess.nsPrefix); } else if (nsSymbol.getKind() == SymbolKind.PACKAGE) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/SymbolTable.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/SymbolTable.java index 738209d072db..fd2026392b8f 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/SymbolTable.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/SymbolTable.java @@ -18,7 +18,6 @@ package org.wso2.ballerinalang.compiler.semantics.model; import io.ballerina.tools.diagnostics.Location; -import io.ballerina.tools.text.LineRange; import org.ballerinalang.model.TreeBuilder; import org.ballerinalang.model.elements.PackageID; import org.ballerinalang.model.symbols.SymbolOrigin; @@ -224,7 +223,6 @@ public class SymbolTable { public Map pkgEnvMap = new HashMap<>(); public Map predeclaredModules = new HashMap<>(); public Map> immutableTypeMaps = new HashMap<>(); - public Map>>> clientDeclarations; public static SymbolTable getInstance(CompilerContext context) { SymbolTable symTable = context.get(SYM_TABLE_KEY); @@ -325,8 +323,6 @@ private SymbolTable(CompilerContext context) { this.invokableType.tsymbol = tSymbol; defineReadonlyCompoundType(); - - this.clientDeclarations = new HashMap<>(); } private void defineReadonlyCompoundType() { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/BClientDeclarationSymbol.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/BClientDeclarationSymbol.java deleted file mode 100644 index 44aa350c04cf..000000000000 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/BClientDeclarationSymbol.java +++ /dev/null @@ -1,74 +0,0 @@ -/* -* Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ -package org.wso2.ballerinalang.compiler.semantics.model.symbols; - -import io.ballerina.tools.diagnostics.Location; -import org.ballerinalang.model.elements.PackageID; -import org.ballerinalang.model.symbols.Annotatable; -import org.ballerinalang.model.symbols.AnnotationAttachmentSymbol; -import org.ballerinalang.model.symbols.SymbolKind; -import org.ballerinalang.model.symbols.SymbolOrigin; -import org.wso2.ballerinalang.compiler.semantics.model.types.BNoType; -import org.wso2.ballerinalang.compiler.util.Name; -import org.wso2.ballerinalang.compiler.util.TypeTags; - -import java.util.ArrayList; -import java.util.List; - -/** - * Symbol for client declarations. - * - * @since 2201.3.0 - */ -public class BClientDeclarationSymbol extends BSymbol implements Annotatable { - - private List annotationAttachments = new ArrayList<>(); - - public String uri; - public boolean used = false; - - public BClientDeclarationSymbol(Name prefix, String uri, PackageID pkgID, BSymbol owner, Location pos, - SymbolOrigin origin) { - super(SymTag.CLIENT_DECL, 0, prefix, pkgID, new BNoType(TypeTags.NONE), owner, pos, origin); - this.uri = uri; - this.kind = SymbolKind.CLIENT_DECL; - } - - @Override - public SymbolKind getKind() { - return SymbolKind.CLIENT_DECL; - } - - @Override - public void addAnnotation(AnnotationAttachmentSymbol symbol) { - if (symbol == null) { - return; - } - - this.annotationAttachments.add((BAnnotationAttachmentSymbol) symbol); - } - - @Override - public List getAnnotations() { - return this.annotationAttachments; - } - - public String getUri() { - return this.uri; - } -} diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/SymTag.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/SymTag.java index 0d4600c0fea6..09847c91eca0 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/SymTag.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/SymTag.java @@ -53,5 +53,5 @@ public class SymTag { public static final int ENUM = 1 << 28 | TYPE_DEF; public static final int TYPE_REF = 1 << 29; public static final int ANNOTATION_ATTACHMENT = 1 << 30; - public static final int CLIENT_DECL = 1 << 31 | IMPORT; + public static final long RESOURCE_PATH_SEGMENT = 1 << 32; } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/Symbols.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/Symbols.java index 0fc9327a6ce6..bc81d1f9056a 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/Symbols.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/Symbols.java @@ -151,7 +151,7 @@ public static BInvokableSymbol createFunctionSymbol(long flags, return symbol; } - public static BTypeSymbol createTypeSymbol(int symTag, + public static BTypeSymbol createTypeSymbol(long symTag, long flags, Name name, PackageID pkgID, @@ -162,7 +162,7 @@ public static BTypeSymbol createTypeSymbol(int symTag, return createTypeSymbol(symTag, flags, name, name, pkgID, type, owner, pos, origin); } - public static BTypeSymbol createTypeSymbol(int symTag, + public static BTypeSymbol createTypeSymbol(long symTag, long flags, Name name, Name originalName, @@ -191,7 +191,7 @@ public static BTypeDefinitionSymbol createTypeDefinitionSymbol(long flags, } - public static BInvokableTypeSymbol createInvokableTypeSymbol(int symTag, + public static BInvokableTypeSymbol createInvokableTypeSymbol(long symTag, long flags, PackageID pkgID, BType type, @@ -201,7 +201,7 @@ public static BInvokableTypeSymbol createInvokableTypeSymbol(int symTag, return new BInvokableTypeSymbol(symTag, flags, pkgID, type, owner, pos, origin); } - public static BInvokableSymbol createInvokableSymbol(int kind, + public static BInvokableSymbol createInvokableSymbol(long kind, long flags, Name name, Name originalName, @@ -221,14 +221,17 @@ public static BXMLNSSymbol createXMLNSSymbol(Name name, SymbolOrigin origin) { return new BXMLNSSymbol(name, nsURI, pkgID, owner, pos, origin); } - - public static BClientDeclarationSymbol createClientDeclarationSymbol(Name name, - String nsURI, - PackageID pkgID, - BSymbol owner, - Location pos, - SymbolOrigin origin) { - return new BClientDeclarationSymbol(name, nsURI, pkgID, owner, pos, origin); + + public static BResourcePathSegmentSymbol createResourcePathSegmentSymbol(Name name, + PackageID pkgID, + BType type, + BSymbol owner, + Location location, + BResourcePathSegmentSymbol parentResource, + BResourceFunction resourceMethod, + SymbolOrigin origin) { + return new BResourcePathSegmentSymbol(name, pkgID, type, owner, location, parentResource, resourceMethod, + origin); } public static String getAttachedFuncSymbolName(String typeName, String funcName) { @@ -271,7 +274,7 @@ public static boolean isFunctionDeclaration(BSymbol sym) { return (sym.flags & Flags.INTERFACE) == Flags.INTERFACE; } - public static boolean isTagOn(BSymbol symbol, int symTag) { + public static boolean isTagOn(BSymbol symbol, long symTag) { return (symbol.tag & symTag) == symTag; } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/types/BNeverType.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/types/BNeverType.java index fd43d8e3d06f..8c1d28a85ec7 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/types/BNeverType.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/types/BNeverType.java @@ -17,7 +17,6 @@ */ package org.wso2.ballerinalang.compiler.semantics.model.types; -import org.wso2.ballerinalang.compiler.semantics.model.TypeVisitor; import org.wso2.ballerinalang.compiler.util.Names; import org.wso2.ballerinalang.compiler.util.TypeTags; import org.wso2.ballerinalang.util.Flags; @@ -44,9 +43,4 @@ public boolean isNullable() { public String toString() { return Names.NEVER.value; } - - @Override - public void accept(TypeVisitor visitor) { - visitor.visit(this); - } } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangClientDeclaration.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangClientDeclaration.java deleted file mode 100644 index 03d9260113ae..000000000000 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangClientDeclaration.java +++ /dev/null @@ -1,85 +0,0 @@ -/* -* Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ -package org.wso2.ballerinalang.compiler.tree; - -import org.ballerinalang.model.tree.ClientDeclarationNode; -import org.ballerinalang.model.tree.IdentifierNode; -import org.ballerinalang.model.tree.NodeKind; -import org.ballerinalang.model.tree.expressions.LiteralNode; -import org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol; -import org.wso2.ballerinalang.compiler.tree.expressions.BLangLiteral; - -import java.util.ArrayList; -import java.util.List; - -/** - * Represent a client declaration. - * - * @since 2201.3.0 - */ -public class BLangClientDeclaration extends BLangNode implements ClientDeclarationNode { - - public BLangLiteral uri; - public BLangIdentifier prefix; - public List annAttachments = new ArrayList<>(); - - public BSymbol symbol; - - public LiteralNode getUri() { - return uri; - } - - @Override - public BLangIdentifier getPrefix() { - return prefix; - } - - @Override - public void accept(BLangNodeVisitor visitor) { - visitor.visit(this); - } - - @Override - public void accept(BLangNodeAnalyzer analyzer, T props) { - analyzer.visit(this, props); - } - - @Override - public R apply(BLangNodeTransformer modifier, T props) { - return modifier.transform(this, props); - } - - public void setUri(LiteralNode uri) { - this.uri = (BLangLiteral) uri; - } - - @Override - public void setPrefix(IdentifierNode prefix) { - this.prefix = (BLangIdentifier) prefix; - } - - @Override - public NodeKind getKind() { - return NodeKind.CLIENT_DECL; - } - - @Override - public String toString() { - return "BLangClientDeclaration: " + prefix + "[" + uri + "]"; - } -} diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangNodeAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangNodeAnalyzer.java index 5661b1beeac1..07a43bb9ace9 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangNodeAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangNodeAnalyzer.java @@ -255,8 +255,6 @@ public abstract class BLangNodeAnalyzer { public abstract void visit(BLangXMLNS.BLangPackageXMLNS node, T data); - public abstract void visit(BLangClientDeclaration node, T data); - // Binding-patterns public abstract void visit(BLangCaptureBindingPattern node, T data); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangNodeTransformer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangNodeTransformer.java index 3d39d41170bf..9ff775f53e1c 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangNodeTransformer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangNodeTransformer.java @@ -314,10 +314,6 @@ public R transform(BLangXMLNS.BLangPackageXMLNS node, T data) { return transformNode(node, data); } - public R transform(BLangClientDeclaration node, T data) { - return transformNode(node, data); - } - // Binding-patterns public R transform(BLangCaptureBindingPattern node, T data) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangNodeVisitor.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangNodeVisitor.java index 0cd2748d1d58..ed3fb31d44fc 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangNodeVisitor.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangNodeVisitor.java @@ -234,10 +234,6 @@ public void visit(BLangXMLNS xmlnsNode) { throw new AssertionError(); } - public void visit(BLangClientDeclaration clientDeclaration) { - throw new AssertionError(); - } - public void visit(BLangFunction funcNode) { throw new AssertionError(); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangPackage.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangPackage.java index 3dba6a61f305..ab4ed0bfde87 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangPackage.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangPackage.java @@ -70,7 +70,6 @@ public class BLangPackage extends BLangNode implements PackageNode { public List topLevelNodes; public List testablePkgs; public List classDefinitions; - public List clientDeclarations; // Parser Flags and Data public List objAttachedFunctions; @@ -104,7 +103,6 @@ public BLangPackage() { this.typeDefinitions = new ArrayList<>(); this.annotations = new ArrayList<>(); this.classDefinitions = new ArrayList<>(); - this.clientDeclarations = new ArrayList<>(); this.objAttachedFunctions = new ArrayList<>(); this.topLevelNodes = new ArrayList<>(); @@ -134,11 +132,6 @@ public List getNamespaceDeclarations() { return xmlnsList; } - @Override - public List getClientDeclarations() { - return this.clientDeclarations; - } - @Override public List getConstants() { return constants; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/SimpleBLangNodeAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/SimpleBLangNodeAnalyzer.java index 1055308038aa..774cceb4d5f3 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/SimpleBLangNodeAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/SimpleBLangNodeAnalyzer.java @@ -410,12 +410,6 @@ public void visit(BLangXMLNS.BLangPackageXMLNS node, T data) { visit((BLangXMLNS) node, data); } - public void visit(BLangClientDeclaration node, T data) { - analyzeNode(node, data); - visitNode(node.uri, data); - visitNode(node.prefix, data); - } - // Binding-patterns public void visit(BLangCaptureBindingPattern node, T data) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/util/Names.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/util/Names.java index cc6da7a6ba58..163a81e6a517 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/util/Names.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/util/Names.java @@ -151,8 +151,6 @@ public class Names { public static final Name DEFAULT_VERSION = new Name("0.0.0"); public static final Name DEFAULT_MAJOR_VERSION = new Name("0"); - public static final Name CLIENT = new Name("client"); - public CompilerContext context; public static Names getInstance(CompilerContext context) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/util/AttachPoints.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/util/AttachPoints.java index 8a144d1ebc01..07ccac533675 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/util/AttachPoints.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/util/AttachPoints.java @@ -45,7 +45,6 @@ public class AttachPoints { public static final int CONST = VAR << 1; public static final int WORKER = CONST << 1; public static final int CLASS = WORKER << 1; - public static final int CLIENT = CLASS << 1; public static int asMask(Set attachPoints) { int mask = 0; @@ -104,9 +103,6 @@ public static int asMask(Set attachPoints) { break; case CLASS: mask |= CLASS; - break; - case CLIENT: - mask |= CLIENT; } } return mask; diff --git a/compiler/ballerina-lang/src/main/resources/compiler.properties b/compiler/ballerina-lang/src/main/resources/compiler.properties index e7a9f16259c2..78fe58f04a3b 100644 --- a/compiler/ballerina-lang/src/main/resources/compiler.properties +++ b/compiler/ballerina-lang/src/main/resources/compiler.properties @@ -201,9 +201,6 @@ error.cyclic.type.reference=\ error.attempt.refer.non.accessible.symbol=\ attempt to refer to non-accessible symbol ''{0}'' -error.cannot.use.field.access.to.access.a.remote.method=\ - ''remote'' methods of an object cannot be accessed using the field access expression - error.invokable.must.return=\ this {0} must return a result @@ -1600,13 +1597,8 @@ error.invalid.dependently.typed.return.type.with.inferred.typedesc.param=\ invalid return type: members of a dependently-typed union type with an inferred typedesc parameter should have \ disjoint basic types -error.cannot.infer.typedesc.argument.from.cet=\ - cannot infer the ''typedesc'' argument for parameter ''{0}'' with ''{1}'' as the contextually-expected \ - type mapping to return type ''{2}'' - -error.cannot.infer.typedesc.argument.without.cet=\ - cannot infer the ''typedesc'' argument for parameter ''{0}'': expected an argument for the parameter or a \ - contextually-expected type to infer the argument +error.cannot.infer.type.for.param=\ + cannot infer type for parameter ''{0}'' error.cannot.use.inferred.typedesc.default.with.unreferenced.param=\ cannot use an inferred typedesc default with a parameter on which the return type does not depend on @@ -1937,30 +1929,5 @@ error.invalid.quantifier.minimum=\ error.duplicate.flags=\ duplicate flag ''{0}'' -error.invalid.usage.of.the.client.keyword.as.an.unquoted.identifier=\ - invalid usage of the ''client'' keyword as an unquoted identifier in a qualified identifier: allowed only with \ - client declarations - -error.invalid.non.anydata.client.decl.annotation=\ - invalid type ''{0}'' for annotation with ''client'' attachment point: expected a subtype of ''anydata'' - -error.no.module.generated.for.client.decl=\ - no module generated for the client declaration - -error.unused.client.decl.prefix=\ - unused client declaration prefix ''{0}'' - -error.unsupported.exposure.of.construct.from.module.generated.for.client.decl=\ - exposing a construct from a module generated for a client declaration is not yet supported - -error.module.generated.for.client.decl.must.have.a.client.object.type=\ - a module generated for a client declaration must have an object type or class named ''client'' - -error.module.generated.for.client.decl.cannot.have.mutable.state=\ - a module generated for a client declaration cannot have mutable state - -error.outer.join.must.be.declared.with.var=\ - outer join must be declared with ''var'' - error.cannot.import.module.generated.for.a.client.decl=\ a module generated for a client declaration cannot be imported diff --git a/compiler/ballerina-lang/src/test/java/io/ballerina/projects/ProjectPathsTest.java b/compiler/ballerina-lang/src/test/java/io/ballerina/projects/ProjectPathsTest.java index 445610f80c5a..681c6facbc9b 100644 --- a/compiler/ballerina-lang/src/test/java/io/ballerina/projects/ProjectPathsTest.java +++ b/compiler/ballerina-lang/src/test/java/io/ballerina/projects/ProjectPathsTest.java @@ -37,7 +37,6 @@ public class ProjectPathsTest { Path tempDir; Path tempStandAloneFileInTmpDir; Path buildProjectPath; - Path buildProjectPathWithGeneratedModules; Path balaProjectPath; @BeforeClass @@ -58,18 +57,6 @@ public void setUp() throws IOException { Files.createFile( buildProjectPath.resolve("modules").resolve("module1").resolve("tests").resolve("main_test.bal")); - // Create a build project with a generated module - buildProjectPathWithGeneratedModules = tempDir.resolve("testProj2"); - Files.createDirectories(buildProjectPathWithGeneratedModules); - - Files.createFile(buildProjectPathWithGeneratedModules.resolve(ProjectConstants.BALLERINA_TOML)); - Files.createFile(buildProjectPathWithGeneratedModules.resolve("main.bal")); - - // Create a generated module - Files.createDirectories(buildProjectPathWithGeneratedModules.resolve("generated").resolve("module1")); - Files.createFile(buildProjectPathWithGeneratedModules.resolve("generated").resolve("module1") - .resolve("main.bal")); - // Create standalone files outside project directory Files.createFile(tempDir.resolve("test.bal")); // path - /tmp/ballerina-test-223233/test.bal tempStandAloneFileInTmpDir = Files.createTempFile("temp-test", ".bal"); // path - /tmp/temp-test.bal @@ -106,30 +93,6 @@ public void testPackageRoot() { .resolve("modules").resolve("mod1").resolve("mod1.bal")), balaProjectPath); } - @Test - public void testPackageRootWithGeneratedModules() throws IOException { - Assert.assertEquals(ProjectPaths.packageRoot(buildProjectPathWithGeneratedModules - .resolve(ProjectConstants.BALLERINA_TOML)), buildProjectPathWithGeneratedModules); - Assert.assertEquals(ProjectPaths.packageRoot(buildProjectPathWithGeneratedModules - .resolve("main.bal")), buildProjectPathWithGeneratedModules); - - Assert.assertEquals(ProjectPaths.packageRoot(buildProjectPathWithGeneratedModules - .resolve("generated")), buildProjectPathWithGeneratedModules); - Assert.assertEquals(ProjectPaths.packageRoot(buildProjectPathWithGeneratedModules - .resolve("generated").resolve("module1")), buildProjectPathWithGeneratedModules); - - Files.createDirectories( - buildProjectPathWithGeneratedModules.resolve("generated").resolve("module1").resolve("tests")); - Files.createFile( - buildProjectPathWithGeneratedModules.resolve("generated").resolve("module1") - .resolve("tests").resolve("main_test.bal")); - Assert.assertEquals(ProjectPaths.packageRoot(buildProjectPathWithGeneratedModules - .resolve("generated").resolve("module1").resolve("tests")), buildProjectPathWithGeneratedModules); - Assert.assertEquals(ProjectPaths.packageRoot(buildProjectPathWithGeneratedModules - .resolve("generated").resolve("module1").resolve("tests").resolve("main_test.bal")), - buildProjectPathWithGeneratedModules); - } - @Test public void testPackageRootWithDirectory() { // test package root of build project @@ -142,6 +105,7 @@ public void testPackageRootWithDirectory() { .resolve("modules").resolve("module1").resolve("tests")), buildProjectPath); Assert.assertEquals(ProjectPaths.packageRoot(buildProjectPath .resolve("modules")), buildProjectPath); + // test package root of bala project Assert.assertEquals(ProjectPaths.packageRoot(balaProjectPath), balaProjectPath); Assert.assertEquals(ProjectPaths.packageRoot(balaProjectPath @@ -181,13 +145,6 @@ public void testPackageRootNegative6() { ProjectPaths.packageRoot(tempDir); } - @Test(expectedExceptions = ProjectException.class) - public void testPackageRootNegativeGenerated() throws IOException { - // Create a random file - Files.createFile(buildProjectPathWithGeneratedModules.resolve("generated").resolve("foo.bal")); - ProjectPaths.packageRoot(buildProjectPathWithGeneratedModules.resolve("generated").resolve("foo.bal")); - } - @Test public void testIsBallerinaSourceFile() { Assert.assertTrue(ProjectPaths.isBalFile(buildProjectPath.resolve("main.bal"))); diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/diagnostics/DiagnosticErrorCode.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/diagnostics/DiagnosticErrorCode.java index 23eadfc1202c..303422812310 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/diagnostics/DiagnosticErrorCode.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/diagnostics/DiagnosticErrorCode.java @@ -282,7 +282,6 @@ public enum DiagnosticErrorCode implements DiagnosticCode { ERROR_INVALID_METADATA("BCE0621", "error.invalid.metadata"), ERROR_INVALID_QUALIFIER("BCE0622", "error.invalid.qualifier"), ERROR_ANNOTATIONS_ATTACHED_TO_STATEMENT("BCE0623", "error.annotations.attached.to.statement"), - ERROR_INVALID_DOCUMENTATION("BCE0624", "error.invalid.documentation"), ERROR_ACTION_AS_A_WAIT_EXPR("BCE0625", "error.action.as.a.wait.expr"), ERROR_INVALID_USAGE_OF_VAR("BCE0626", "error.invalid.usage.of.var"), ERROR_MATCH_PATTERN_AFTER_REST_MATCH_PATTERN("BCE0627", "error.match.pattern.after.rest.match.pattern"), diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java index fdbe7d3b0a54..d16e8c5633f4 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java @@ -511,12 +511,11 @@ private STNode parseTopLevelNode(STNode metadata) { case XMLNS_KEYWORD: case ENUM_KEYWORD: case CLASS_KEYWORD: - // Top level qualifier or client declaration - case CLIENT_KEYWORD: // Top level qualifiers case TRANSACTIONAL_KEYWORD: case ISOLATED_KEYWORD: case DISTINCT_KEYWORD: + case CLIENT_KEYWORD: case READONLY_KEYWORD: case SERVICE_KEYWORD: case CONFIGURABLE_KEYWORD: @@ -1085,10 +1084,6 @@ private STNode parseTopLevelNode(STNode metadata, STNode publicQualifier, List nodeList) { return false; } } - - private boolean isPossibleClientDecl(List qualifiers) { - if (qualifiers.isEmpty()) { - return false; - } - - return qualifiers.get(qualifiers.size() - 1).kind == SyntaxKind.CLIENT_KEYWORD; - } private STNode parseParameterRhs() { return parseParameterRhs(peek().kind); @@ -2952,15 +2939,8 @@ private STNode parseTypeDescStartWithPredeclPrefix(STToken preDeclaredPrefix, Li } private STNode parseQualifiedIdentifierWithPredeclPrefix(STToken preDeclaredPrefix, boolean isInConditionalExpr) { - STNode identifier; - if (preDeclaredPrefix.isMissing()) { - identifier = SyntaxErrors.createMissingTokenWithDiagnostics(SyntaxKind.IDENTIFIER_TOKEN, - DiagnosticErrorCode.ERROR_MISSING_IDENTIFIER); - } else { - identifier = STNodeFactory.createIdentifierToken(preDeclaredPrefix.text(), - preDeclaredPrefix.leadingMinutiae(), - preDeclaredPrefix.trailingMinutiae()); - } + STNode identifier = STNodeFactory.createIdentifierToken(preDeclaredPrefix.text(), + preDeclaredPrefix.leadingMinutiae(), preDeclaredPrefix.trailingMinutiae()); return parseQualifiedIdentifier(identifier, isInConditionalExpr); } @@ -4238,11 +4218,10 @@ private STNode parseQualifiedIdentifier(STNode identifier, boolean isInCondition STNode varOrFuncName = consume(); return createQualifiedNameReferenceNode(identifier, colon, varOrFuncName); case MAP_KEYWORD: - case CLIENT_KEYWORD: colon = consume(); - STToken keyword = consume(); - STNode refName = STNodeFactory.createIdentifierToken(keyword.text(), keyword.leadingMinutiae(), - keyword.trailingMinutiae(), keyword.diagnostics()); + STToken mapKeyword = consume(); + STNode refName = STNodeFactory.createIdentifierToken(mapKeyword.text(), mapKeyword.leadingMinutiae(), + mapKeyword.trailingMinutiae(), mapKeyword.diagnostics()); return createQualifiedNameReferenceNode(identifier, colon, refName); case COLON_TOKEN: // specially handle cases where there are more than one colon. @@ -4462,11 +4441,6 @@ private STNode parseStatement(STNode annots) { private STNode parseStatement(STNode annots, List qualifiers) { parseTypeDescQualifiers(qualifiers); STToken nextToken = peek(); - - if (isPossibleClientDecl(qualifiers)) { - return parseClientDeclOrVarDeclStatement(annots, qualifiers); - } - if (isPredeclaredIdentifier(nextToken.kind)) { return parseStmtStartsWithTypeOrExpr(getAnnotations(annots), qualifiers); } @@ -9715,7 +9689,6 @@ private STNode parseAnnotationAttachPoint() { case CONST_KEYWORD: case LISTENER_KEYWORD: case WORKER_KEYWORD: - case CLIENT_KEYWORD: // fall through case SOURCE_KEYWORD: @@ -9760,7 +9733,7 @@ private STNode parseSourceKeyword() { * Parse attach point ident gievn. *

* - * source-only-attach-point-ident := annotation | external | var | const | listener | worker | client + * source-only-attach-point-ident := annotation | external | var | const | listener | worker *

* dual-attach-point-ident := type | class | [object|service remote] function | parameter * | return | service | [object|record] field @@ -9777,7 +9750,6 @@ private STNode parseAttachPointIdent(STNode sourceKeyword) { case CONST_KEYWORD: case LISTENER_KEYWORD: case WORKER_KEYWORD: - case CLIENT_KEYWORD: STNode firstIdent = consume(); STNode identList = STNodeFactory.createNodeList(firstIdent); return STNodeFactory.createAnnotationAttachPointNode(sourceKeyword, identList); @@ -10063,101 +10035,6 @@ private STNode parseNamespacePrefix() { } } - private STNode parseClientDeclOrVarDeclStatement(STNode metadata, List qualifiers) { - return parseClientDeclOrVarDecl(metadata, STNodeFactory.createEmptyNode(), qualifiers, false); - } - - private STNode parseClientDeclOrVarDecl(STNode metadata, STNode publicQualifier, List qualifiers, - boolean moduleDecl) { - STToken nextToken = peek(); - switch (nextToken.kind) { - case STRING_LITERAL_TOKEN: - reportInvalidQualifiersOnClientDecl(publicQualifier, qualifiers); - STNode clientKeyword = qualifiers.get(qualifiers.size() - 1); - - if (metadata != null && metadata.kind == SyntaxKind.METADATA) { - return parseModuleClientDeclaration((STMetadataNode) metadata, clientKeyword); - } - - return parseClientDeclaration(getAnnotations(metadata), clientKeyword, moduleDecl); - case OBJECT_KEYWORD: - if (moduleDecl) { - return parseModuleVarDecl(metadata, publicQualifier, qualifiers); - } - - return parseVariableDecl(getAnnotations(metadata), publicQualifier, new ArrayList<>(), qualifiers, - false); - default: - recover(nextToken, ParserRuleContext.CLIENT_DECL_OR_CLIENT_OBJECT_VAR_DECL); - return parseClientDeclOrVarDecl(metadata, publicQualifier, qualifiers, moduleDecl); - } - } - - private STNode parseModuleClientDeclaration(STMetadataNode metadata, STNode clientKeyword) { - STNode annotations = getAnnotations(metadata.annotations); - STNode documentationString = metadata.documentationString; - - if (documentationString == null) { - return parseClientDeclaration(annotations, clientKeyword, true); - } - - if (isNodeListEmpty(annotations)) { - clientKeyword = SyntaxErrors.cloneWithLeadingInvalidNodeMinutiae(clientKeyword, documentationString, - DiagnosticErrorCode.ERROR_INVALID_DOCUMENTATION); - } else { - annotations = SyntaxErrors.cloneWithLeadingInvalidNodeMinutiae(annotations, documentationString, - DiagnosticErrorCode.ERROR_INVALID_DOCUMENTATION); - } - return parseClientDeclaration(annotations, clientKeyword, true); - } - - private void reportInvalidQualifiersOnClientDecl(STNode publicQualifier, List qualifiers) { - reportInvalidQualifier(publicQualifier); - for (STNode qualifier : qualifiers) { - if (qualifier.kind != SyntaxKind.CLIENT_KEYWORD) { - reportInvalidQualifier(qualifier); - } - } - } - - /** - * Parse client declaration. - *

- * client-decl := client client-decl-uri as client-decl-prefix; - *
- * client-decl-uri := string-literal - *
- * client-decl-prefix := identifier - *
- * - * @return client declaration node - */ - private STNode parseClientDeclaration(STNode annotations, STNode clientKeyword, boolean moduleDecl) { - startContext(ParserRuleContext.CLIENT_DECLARATION); - STNode clientDeclUri = parseStringLiteral(); - STNode asKeyword = parseAsKeyword(); - STNode prefix = parseClientDeclPrefix(); - STNode semicolon = parseSemicolon(); - endContext(); - - if (moduleDecl) { - return STNodeFactory.createModuleClientDeclarationNode(annotations, clientKeyword, clientDeclUri, asKeyword, - prefix, semicolon); - } - return STNodeFactory.createClientDeclarationNode(annotations, clientKeyword, clientDeclUri, asKeyword, prefix, - semicolon); - } - - private STNode parseClientDeclPrefix() { - STToken nextToken = peek(); - if (nextToken.kind == SyntaxKind.IDENTIFIER_TOKEN) { - return consume(); - } else { - recover(peek(), ParserRuleContext.CLIENT_DECL_PREFIX); - return parseClientDeclPrefix(); - } - } - /** * Parse named worker declaration. *

diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParserErrorHandler.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParserErrorHandler.java index 65059889108b..3457227b238d 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParserErrorHandler.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParserErrorHandler.java @@ -130,7 +130,7 @@ public class BallerinaParserErrorHandler extends AbstractParserErrorHandler { ParserRuleContext.LISTENER_DECL, ParserRuleContext.MODULE_TYPE_DEFINITION, ParserRuleContext.CONSTANT_DECL, ParserRuleContext.ANNOTATION_DECL, ParserRuleContext.XML_NAMESPACE_DECLARATION, ParserRuleContext.MODULE_ENUM_DECLARATION, - ParserRuleContext.IMPORT_DECL, ParserRuleContext.CLIENT_DECLARATION }; + ParserRuleContext.IMPORT_DECL }; private static final ParserRuleContext[] FUNC_DEF_START = { ParserRuleContext.FUNCTION_KEYWORD, ParserRuleContext.FUNC_DEF_FIRST_QUALIFIER }; @@ -508,8 +508,8 @@ public class BallerinaParserErrorHandler extends AbstractParserErrorHandler { { ParserRuleContext.CLOSE_PARENTHESIS, ParserRuleContext.COMMA }; private static final ParserRuleContext[] REMOTE_OR_RESOURCE_CALL_OR_ASYNC_SEND_RHS = - { ParserRuleContext.DEFAULT_WORKER_NAME_IN_ASYNC_SEND, - ParserRuleContext.RESOURCE_METHOD_CALL_SLASH_TOKEN, + { ParserRuleContext.DEFAULT_WORKER_NAME_IN_ASYNC_SEND, + ParserRuleContext.RESOURCE_METHOD_CALL_SLASH_TOKEN, ParserRuleContext.PEER_WORKER_NAME, ParserRuleContext.METHOD_NAME }; private static final ParserRuleContext[] REMOTE_CALL_OR_ASYNC_SEND_END = @@ -737,8 +737,8 @@ public class BallerinaParserErrorHandler extends AbstractParserErrorHandler { private static final ParserRuleContext[] PATH_PARAM_ELLIPSIS = { ParserRuleContext.OPTIONAL_PATH_PARAM_NAME, ParserRuleContext.ELLIPSIS }; - - private static final ParserRuleContext[] OPTIONAL_PATH_PARAM_NAME = + + private static final ParserRuleContext[] OPTIONAL_PATH_PARAM_NAME = { ParserRuleContext.VARIABLE_NAME, ParserRuleContext.CLOSE_BRACKET }; private static final ParserRuleContext[] RELATIVE_RESOURCE_PATH_END = @@ -816,32 +816,28 @@ public class BallerinaParserErrorHandler extends AbstractParserErrorHandler { private static final ParserRuleContext[] ANNOTATION_DECL_START = { ParserRuleContext.ANNOTATION_KEYWORD, ParserRuleContext.CONST_KEYWORD }; - + private static final ParserRuleContext[] OPTIONAL_RESOURCE_ACCESS_PATH = { ParserRuleContext.RESOURCE_ACCESS_PATH_SEGMENT, ParserRuleContext.OPTIONAL_RESOURCE_ACCESS_METHOD }; - - private static final ParserRuleContext[] RESOURCE_ACCESS_PATH_SEGMENT = + + private static final ParserRuleContext[] RESOURCE_ACCESS_PATH_SEGMENT = { ParserRuleContext.IDENTIFIER, ParserRuleContext.OPEN_BRACKET }; - - private static final ParserRuleContext[] COMPUTED_SEGMENT_OR_REST_SEGMENT = + + private static final ParserRuleContext[] COMPUTED_SEGMENT_OR_REST_SEGMENT = { ParserRuleContext.EXPRESSION, ParserRuleContext.ELLIPSIS }; - - private static final ParserRuleContext[] RESOURCE_ACCESS_SEGMENT_RHS = + + private static final ParserRuleContext[] RESOURCE_ACCESS_SEGMENT_RHS = { ParserRuleContext.SLASH, ParserRuleContext.OPTIONAL_RESOURCE_ACCESS_METHOD }; - - private static final ParserRuleContext[] OPTIONAL_RESOURCE_ACCESS_METHOD = + + private static final ParserRuleContext[] OPTIONAL_RESOURCE_ACCESS_METHOD = { ParserRuleContext.DOT, ParserRuleContext.OPTIONAL_RESOURCE_ACCESS_ACTION_ARG_LIST}; - - private static final ParserRuleContext[] OPTIONAL_RESOURCE_ACCESS_ACTION_ARG_LIST = + + private static final ParserRuleContext[] OPTIONAL_RESOURCE_ACCESS_ACTION_ARG_LIST = { ParserRuleContext.ARG_LIST_OPEN_PAREN, ParserRuleContext.ACTION_END }; private static final ParserRuleContext[] OPTIONAL_TOP_LEVEL_SEMICOLON = { ParserRuleContext.TOP_LEVEL_NODE, ParserRuleContext.SEMICOLON }; - private static final ParserRuleContext[] CLIENT_DECL_OR_CLIENT_OBJECT_VAR_DECL = - { ParserRuleContext.STRING_LITERAL_TOKEN_AFTER_CLIENT_KEYWORD, - ParserRuleContext.OBJECT_KEYWORD_AFTER_CLIENT_KEYWORD }; - public BallerinaParserErrorHandler(AbstractTokenReader tokenReader) { super(tokenReader); } @@ -919,7 +915,6 @@ protected Result seekMatch(ParserRuleContext currentCtx, int lookahead, int curr case MODULE_ENUM_NAME: case ENUM_MEMBER_NAME: case NAMED_ARG_BINDING_PATTERN: - case CLIENT_DECL_PREFIX: hasMatch = nextToken.kind == SyntaxKind.IDENTIFIER_TOKEN; break; case IMPORT_PREFIX: @@ -1016,7 +1011,7 @@ protected Result seekMatch(ParserRuleContext currentCtx, int lookahead, int curr break; case SLASH: case ABSOLUTE_PATH_SINGLE_SLASH: - case RESOURCE_METHOD_CALL_SLASH_TOKEN: + case RESOURCE_METHOD_CALL_SLASH_TOKEN: hasMatch = nextToken.kind == SyntaxKind.SLASH_TOKEN; break; case BASIC_LITERAL: @@ -1555,7 +1550,7 @@ protected boolean hasAlternativePaths(ParserRuleContext currentCtx) { case RESOURCE_PATH_SEGMENT: case PATH_PARAM_OPTIONAL_ANNOTS: case PATH_PARAM_ELLIPSIS: - case OPTIONAL_PATH_PARAM_NAME: + case OPTIONAL_PATH_PARAM_NAME: case OBJECT_CONS_WITHOUT_FIRST_QUALIFIER: case OBJECT_TYPE_WITHOUT_FIRST_QUALIFIER: case CONFIG_VAR_DECL_RHS: @@ -1595,12 +1590,11 @@ protected boolean hasAlternativePaths(ParserRuleContext currentCtx) { case ON_FAIL_OPTIONAL_BINDING_PATTERN: case OPTIONAL_RESOURCE_ACCESS_PATH: case RESOURCE_ACCESS_PATH_SEGMENT: - case COMPUTED_SEGMENT_OR_REST_SEGMENT: - case RESOURCE_ACCESS_SEGMENT_RHS: + case COMPUTED_SEGMENT_OR_REST_SEGMENT: + case RESOURCE_ACCESS_SEGMENT_RHS: case OPTIONAL_RESOURCE_ACCESS_METHOD: case OPTIONAL_RESOURCE_ACCESS_ACTION_ARG_LIST: case OPTIONAL_TOP_LEVEL_SEMICOLON: - case CLIENT_DECL_OR_CLIENT_OBJECT_VAR_DECL: return true; default: return false; @@ -2063,8 +2057,6 @@ protected ParserRuleContext getShortestAlternative(ParserRuleContext currentCtx) return ParserRuleContext.ACTION_END; case OPTIONAL_TOP_LEVEL_SEMICOLON: return ParserRuleContext.TOP_LEVEL_NODE; - case CLIENT_DECL_OR_CLIENT_OBJECT_VAR_DECL: - return ParserRuleContext.STRING_LITERAL_TOKEN_AFTER_CLIENT_KEYWORD; default: throw new IllegalStateException("Alternative path entry not found"); } @@ -2416,9 +2408,6 @@ private Result seekMatchInAlternativePaths(ParserRuleContext currentCtx, int loo case OPTIONAL_TOP_LEVEL_SEMICOLON: alternativeRules = OPTIONAL_TOP_LEVEL_SEMICOLON; break; - case CLIENT_DECL_OR_CLIENT_OBJECT_VAR_DECL: - alternativeRules = CLIENT_DECL_OR_CLIENT_OBJECT_VAR_DECL; - break; default: return seekMatchInStmtRelatedAlternativePaths(currentCtx, lookahead, currentDepth, matchingRulesCount, isEntryPoint); @@ -3273,7 +3262,6 @@ protected ParserRuleContext getNextRule(ParserRuleContext currentCtx, int nextLo return ParserRuleContext.IMPORT_PREFIX; case IMPORT_PREFIX: case NAMESPACE_PREFIX: - case CLIENT_DECL_PREFIX: return ParserRuleContext.SEMICOLON; case VERSION_NUMBER: case VERSION_KEYWORD: @@ -3326,11 +3314,6 @@ protected ParserRuleContext getNextRule(ParserRuleContext currentCtx, int nextLo if (parentCtx == ParserRuleContext.SERVICE_DECL) { return ParserRuleContext.ON_KEYWORD; } - - if (parentCtx == ParserRuleContext.CLIENT_DECLARATION) { - return ParserRuleContext.AS_KEYWORD; - } - return ParserRuleContext.COLON; // mapping constructor key case COMPUTED_FIELD_NAME: return ParserRuleContext.OPEN_BRACKET; @@ -3420,8 +3403,6 @@ protected ParserRuleContext getNextRule(ParserRuleContext currentCtx, int nextLo return ParserRuleContext.ANNOTATION_DECL_START; case XML_NAMESPACE_DECLARATION: return ParserRuleContext.XMLNS_KEYWORD; - case CLIENT_DECLARATION: - return ParserRuleContext.CLIENT_KEYWORD; case CONSTANT_EXPRESSION: return ParserRuleContext.CONSTANT_EXPRESSION_START; case NAMED_WORKER_DECL: @@ -3954,8 +3935,6 @@ private ParserRuleContext getNextRuleForKeywords(ParserRuleContext currentCtx, i return ParserRuleContext.IMPORT_PREFIX; } else if (parentCtx == ParserRuleContext.XML_NAMESPACE_DECLARATION) { return ParserRuleContext.NAMESPACE_PREFIX; - } else if (parentCtx == ParserRuleContext.CLIENT_DECLARATION) { - return ParserRuleContext.CLIENT_DECL_PREFIX; } throw new IllegalStateException("next rule of as keyword found: " + parentCtx); case CONTINUE_KEYWORD: @@ -3991,22 +3970,8 @@ private ParserRuleContext getNextRuleForKeywords(ParserRuleContext currentCtx, i // If we reach here context for object type desc is not started yet, hence start context. startContext(ParserRuleContext.OBJECT_TYPE_DESCRIPTOR); return ParserRuleContext.OPEN_BRACE; - case OBJECT_KEYWORD_AFTER_CLIENT_KEYWORD: - // If we reach here context for object type desc is not started yet, hence start context. - startContext(ParserRuleContext.TYPE_DESC_IN_TYPE_BINDING_PATTERN); - startContext(ParserRuleContext.OBJECT_TYPE_DESCRIPTOR); - return ParserRuleContext.OBJECT_KEYWORD; - case STRING_LITERAL_TOKEN_AFTER_CLIENT_KEYWORD: - // If we reach here context for client decl is not started yet, hence start context. - startContext(ParserRuleContext.CLIENT_DECLARATION); - return ParserRuleContext.STRING_LITERAL_TOKEN; case ABSTRACT_KEYWORD: - return ParserRuleContext.OBJECT_KEYWORD; case CLIENT_KEYWORD: - if (getParentContext() == ParserRuleContext.CLIENT_DECLARATION) { - return ParserRuleContext.STRING_LITERAL_TOKEN; - } - return ParserRuleContext.OBJECT_KEYWORD; case FORK_KEYWORD: return ParserRuleContext.OPEN_BRACE; @@ -4263,8 +4228,7 @@ private void startContextIfRequired(ParserRuleContext currentCtx) { case ERROR_CONSTRUCTOR: case CLASS_DESCRIPTOR_IN_NEW_EXPR: case BRACED_EXPRESSION: - case CLIENT_RESOURCE_ACCESS_ACTION: - case CLIENT_DECLARATION: + case CLIENT_RESOURCE_ACCESS_ACTION: // Contexts that expect a type case TYPE_DESC_IN_ANNOTATION_DECL: @@ -5057,8 +5021,7 @@ private ParserRuleContext getNextRuleForSemicolon(int nextLookahead) { } else if (parentCtx == ParserRuleContext.RECORD_FIELD) { endContext(); // end record field return ParserRuleContext.RECORD_FIELD_OR_RECORD_END; - } else if (parentCtx == ParserRuleContext.XML_NAMESPACE_DECLARATION || - parentCtx == ParserRuleContext.CLIENT_DECLARATION) { + } else if (parentCtx == ParserRuleContext.XML_NAMESPACE_DECLARATION) { endContext(); parentCtx = getParentContext(); if (parentCtx == ParserRuleContext.COMP_UNIT) { @@ -5583,7 +5546,7 @@ private ParserRuleContext getNextRuleForFuncTypeFuncKeywordRhs() { startContext(ParserRuleContext.FUNC_TYPE_DESC); return ParserRuleContext.FUNC_TYPE_FUNC_KEYWORD_RHS_START; } - + private ParserRuleContext getNextRuleForAction() { ParserRuleContext parentCtx = getParentContext(); switch (parentCtx) { @@ -5784,7 +5747,6 @@ protected SyntaxKind getExpectedTokenKind(ParserRuleContext ctx) { case PATH_SEGMENT_IDENT: case TYPE_DESCRIPTOR: case NAMED_ARG_BINDING_PATTERN: - case CLIENT_DECL_PREFIX: return SyntaxKind.IDENTIFIER_TOKEN; case VERSION_NUMBER: case MAJOR_VERSION: @@ -5868,7 +5830,7 @@ protected SyntaxKind getExpectedSeperatorTokenKind(ParserRuleContext ctx) { return SyntaxKind.OPEN_BRACKET_TOKEN; case SLASH: case ABSOLUTE_PATH_SINGLE_SLASH: - case RESOURCE_METHOD_CALL_SLASH_TOKEN: + case RESOURCE_METHOD_CALL_SLASH_TOKEN: return SyntaxKind.SLASH_TOKEN; case COLON: case TYPE_REF_COLON: @@ -6199,7 +6161,6 @@ private boolean isSingleKeywordAttachPointIdent(SyntaxKind tokenKind) { case CONST_KEYWORD: case LISTENER_KEYWORD: case WORKER_KEYWORD: - case CLIENT_KEYWORD: case TYPE_KEYWORD: case FUNCTION_KEYWORD: case PARAMETER_KEYWORD: diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/ParserRuleContext.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/ParserRuleContext.java index dd9bb8c87d86..a5196164e2d2 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/ParserRuleContext.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/ParserRuleContext.java @@ -190,11 +190,6 @@ public enum ParserRuleContext { ATTACH_POINT_IDENT("attach-point-ident"), SINGLE_KEYWORD_ATTACH_POINT_IDENT("single-keyword-attach-point-ident"), IDENT_AFTER_OBJECT_IDENT("ident-after-object-ident"), - CLIENT_DECLARATION("client-decl"), - CLIENT_DECL_PREFIX("client-decl-prefix"), - CLIENT_DECL_OR_CLIENT_OBJECT_VAR_DECL("client-decl-or-client-object-var-decl"), - OBJECT_KEYWORD_AFTER_CLIENT_KEYWORD("object-keyword-after-client-keyword"), - STRING_LITERAL_TOKEN_AFTER_CLIENT_KEYWORD("object-keyword-after-client-keyword"), XML_NAMESPACE_DECLARATION("xml-namespace-decl"), XML_NAMESPACE_PREFIX_DECL("namespace-prefix-decl"), DEFAULT_WORKER_INIT("default-worker-init"), diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/SyntaxErrors.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/SyntaxErrors.java index edaab7ca9b5f..58062db5ad45 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/SyntaxErrors.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/SyntaxErrors.java @@ -178,7 +178,6 @@ private static DiagnosticCode getErrorCode(ParserRuleContext currentCtx) { case MODULE_VAR_SECOND_QUAL: case MODULE_VAR_THIRD_QUAL: case OBJECT_MEMBER_VISIBILITY_QUAL: - case CLIENT_DECL_PREFIX: return DiagnosticErrorCode.ERROR_MISSING_IDENTIFIER; case EXPRESSION: case TERMINAL_EXPRESSION: diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STModuleClientDeclarationNode.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STModuleClientDeclarationNode.java deleted file mode 100644 index fbb1e3bdc378..000000000000 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STModuleClientDeclarationNode.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package io.ballerina.compiler.internal.parser.tree; - -import io.ballerina.compiler.syntax.tree.ModuleClientDeclarationNode; -import io.ballerina.compiler.syntax.tree.Node; -import io.ballerina.compiler.syntax.tree.NonTerminalNode; -import io.ballerina.compiler.syntax.tree.SyntaxKind; - -import java.util.Collection; -import java.util.Collections; - -/** - * This is a generated internal syntax tree node. - * - * @since 2201.3.0 - */ -public class STModuleClientDeclarationNode extends STModuleMemberDeclarationNode { - public final STNode annotations; - public final STNode clientKeyword; - public final STNode clientUri; - public final STNode asKeyword; - public final STNode clientPrefix; - public final STNode semicolonToken; - - STModuleClientDeclarationNode( - STNode annotations, - STNode clientKeyword, - STNode clientUri, - STNode asKeyword, - STNode clientPrefix, - STNode semicolonToken) { - this( - annotations, - clientKeyword, - clientUri, - asKeyword, - clientPrefix, - semicolonToken, - Collections.emptyList()); - } - - STModuleClientDeclarationNode( - STNode annotations, - STNode clientKeyword, - STNode clientUri, - STNode asKeyword, - STNode clientPrefix, - STNode semicolonToken, - Collection diagnostics) { - super(SyntaxKind.MODULE_CLIENT_DECLARATION, diagnostics); - this.annotations = annotations; - this.clientKeyword = clientKeyword; - this.clientUri = clientUri; - this.asKeyword = asKeyword; - this.clientPrefix = clientPrefix; - this.semicolonToken = semicolonToken; - - addChildren( - annotations, - clientKeyword, - clientUri, - asKeyword, - clientPrefix, - semicolonToken); - } - - public STNode modifyWith(Collection diagnostics) { - return new STModuleClientDeclarationNode( - this.annotations, - this.clientKeyword, - this.clientUri, - this.asKeyword, - this.clientPrefix, - this.semicolonToken, - diagnostics); - } - - public STModuleClientDeclarationNode modify( - STNode annotations, - STNode clientKeyword, - STNode clientUri, - STNode asKeyword, - STNode clientPrefix, - STNode semicolonToken) { - if (checkForReferenceEquality( - annotations, - clientKeyword, - clientUri, - asKeyword, - clientPrefix, - semicolonToken)) { - return this; - } - - return new STModuleClientDeclarationNode( - annotations, - clientKeyword, - clientUri, - asKeyword, - clientPrefix, - semicolonToken, - diagnostics); - } - - public Node createFacade(int position, NonTerminalNode parent) { - return new ModuleClientDeclarationNode(this, position, parent); - } - - @Override - public void accept(STNodeVisitor visitor) { - visitor.visit(this); - } - - @Override - public T apply(STNodeTransformer transformer) { - return transformer.transform(this); - } -} diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STNodeFactory.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STNodeFactory.java index 7e3f3bf61d9f..3d6ca86c7470 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STNodeFactory.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STNodeFactory.java @@ -958,40 +958,6 @@ public static STNode createModuleXMLNamespaceDeclarationNode( semicolonToken); } - public static STNode createClientDeclarationNode( - STNode annotations, - STNode clientKeyword, - STNode clientUri, - STNode asKeyword, - STNode clientPrefix, - STNode semicolonToken) { - - return new STClientDeclarationNode( - annotations, - clientKeyword, - clientUri, - asKeyword, - clientPrefix, - semicolonToken); - } - - public static STNode createModuleClientDeclarationNode( - STNode annotations, - STNode clientKeyword, - STNode clientUri, - STNode asKeyword, - STNode clientPrefix, - STNode semicolonToken) { - - return new STModuleClientDeclarationNode( - annotations, - clientKeyword, - clientUri, - asKeyword, - clientPrefix, - semicolonToken); - } - public static STNode createFunctionBodyBlockNode( STNode openBraceToken, STNode namedWorkerDeclarator, diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STNodeTransformer.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STNodeTransformer.java index d34546b1d138..c6c7f8c4ba52 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STNodeTransformer.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STNodeTransformer.java @@ -309,14 +309,6 @@ public T transform(STModuleXMLNamespaceDeclarationNode moduleXMLNamespaceDeclara return transformSyntaxNode(moduleXMLNamespaceDeclarationNode); } - public T transform(STClientDeclarationNode clientDeclarationNode) { - return transformSyntaxNode(clientDeclarationNode); - } - - public T transform(STModuleClientDeclarationNode moduleClientDeclarationNode) { - return transformSyntaxNode(moduleClientDeclarationNode); - } - public T transform(STFunctionBodyBlockNode functionBodyBlockNode) { return transformSyntaxNode(functionBodyBlockNode); } diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STNodeVisitor.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STNodeVisitor.java index 417c044f7016..6d27501b91c6 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STNodeVisitor.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STNodeVisitor.java @@ -308,15 +308,6 @@ public void visit(STXMLNamespaceDeclarationNode xMLNamespaceDeclarationNode) { public void visit(STModuleXMLNamespaceDeclarationNode moduleXMLNamespaceDeclarationNode) { visitSyntaxNode(moduleXMLNamespaceDeclarationNode); } - - public void visit(STClientDeclarationNode clientDeclarationNode) { - visitSyntaxNode(clientDeclarationNode); - } - - public void visit(STModuleClientDeclarationNode moduleClientDeclarationNode) { - visitSyntaxNode(moduleClientDeclarationNode); - } - public void visit(STFunctionBodyBlockNode functionBodyBlockNode) { visitSyntaxNode(functionBodyBlockNode); } diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STTreeModifier.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STTreeModifier.java index 8726b02315d5..9592139cc2a7 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STTreeModifier.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STTreeModifier.java @@ -1014,42 +1014,6 @@ public STModuleXMLNamespaceDeclarationNode transform( semicolonToken); } - @Override - public STClientDeclarationNode transform( - STClientDeclarationNode clientDeclarationNode) { - STNode annotations = modifyNode(clientDeclarationNode.annotations); - STNode clientKeyword = modifyNode(clientDeclarationNode.clientKeyword); - STNode clientUri = modifyNode(clientDeclarationNode.clientUri); - STNode asKeyword = modifyNode(clientDeclarationNode.asKeyword); - STNode clientPrefix = modifyNode(clientDeclarationNode.clientPrefix); - STNode semicolonToken = modifyNode(clientDeclarationNode.semicolonToken); - return clientDeclarationNode.modify( - annotations, - clientKeyword, - clientUri, - asKeyword, - clientPrefix, - semicolonToken); - } - - @Override - public STModuleClientDeclarationNode transform( - STModuleClientDeclarationNode moduleClientDeclarationNode) { - STNode annotations = modifyNode(moduleClientDeclarationNode.annotations); - STNode clientKeyword = modifyNode(moduleClientDeclarationNode.clientKeyword); - STNode clientUri = modifyNode(moduleClientDeclarationNode.clientUri); - STNode asKeyword = modifyNode(moduleClientDeclarationNode.asKeyword); - STNode clientPrefix = modifyNode(moduleClientDeclarationNode.clientPrefix); - STNode semicolonToken = modifyNode(moduleClientDeclarationNode.semicolonToken); - return moduleClientDeclarationNode.modify( - annotations, - clientKeyword, - clientUri, - asKeyword, - clientPrefix, - semicolonToken); - } - @Override public STFunctionBodyBlockNode transform( STFunctionBodyBlockNode functionBodyBlockNode) { diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/ModuleClientDeclarationNode.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/ModuleClientDeclarationNode.java deleted file mode 100644 index 2141835c7680..000000000000 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/ModuleClientDeclarationNode.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package io.ballerina.compiler.syntax.tree; - -import io.ballerina.compiler.internal.parser.tree.STNode; - -import java.util.Objects; - -/** - * This is a generated syntax tree node. - * - * @since 2201.3.0 - */ -public class ModuleClientDeclarationNode extends ModuleMemberDeclarationNode { - - public ModuleClientDeclarationNode(STNode internalNode, int position, NonTerminalNode parent) { - super(internalNode, position, parent); - } - - public NodeList annotations() { - return new NodeList<>(childInBucket(0)); - } - - public Token clientKeyword() { - return childInBucket(1); - } - - public BasicLiteralNode clientUri() { - return childInBucket(2); - } - - public Token asKeyword() { - return childInBucket(3); - } - - public IdentifierToken clientPrefix() { - return childInBucket(4); - } - - public Token semicolonToken() { - return childInBucket(5); - } - - @Override - public void accept(NodeVisitor visitor) { - visitor.visit(this); - } - - @Override - public T apply(NodeTransformer visitor) { - return visitor.transform(this); - } - - @Override - protected String[] childNames() { - return new String[]{ - "annotations", - "clientKeyword", - "clientUri", - "asKeyword", - "clientPrefix", - "semicolonToken"}; - } - - public ModuleClientDeclarationNode modify( - NodeList annotations, - Token clientKeyword, - BasicLiteralNode clientUri, - Token asKeyword, - IdentifierToken clientPrefix, - Token semicolonToken) { - if (checkForReferenceEquality( - annotations.underlyingListNode(), - clientKeyword, - clientUri, - asKeyword, - clientPrefix, - semicolonToken)) { - return this; - } - - return NodeFactory.createModuleClientDeclarationNode( - annotations, - clientKeyword, - clientUri, - asKeyword, - clientPrefix, - semicolonToken); - } - - public ModuleClientDeclarationNodeModifier modify() { - return new ModuleClientDeclarationNodeModifier(this); - } - - /** - * This is a generated tree node modifier utility. - * - * @since 2.0.0 - */ - public static class ModuleClientDeclarationNodeModifier { - private final ModuleClientDeclarationNode oldNode; - private NodeList annotations; - private Token clientKeyword; - private BasicLiteralNode clientUri; - private Token asKeyword; - private IdentifierToken clientPrefix; - private Token semicolonToken; - - public ModuleClientDeclarationNodeModifier(ModuleClientDeclarationNode oldNode) { - this.oldNode = oldNode; - this.annotations = oldNode.annotations(); - this.clientKeyword = oldNode.clientKeyword(); - this.clientUri = oldNode.clientUri(); - this.asKeyword = oldNode.asKeyword(); - this.clientPrefix = oldNode.clientPrefix(); - this.semicolonToken = oldNode.semicolonToken(); - } - - public ModuleClientDeclarationNodeModifier withAnnotations( - NodeList annotations) { - Objects.requireNonNull(annotations, "annotations must not be null"); - this.annotations = annotations; - return this; - } - - public ModuleClientDeclarationNodeModifier withClientKeyword( - Token clientKeyword) { - Objects.requireNonNull(clientKeyword, "clientKeyword must not be null"); - this.clientKeyword = clientKeyword; - return this; - } - - public ModuleClientDeclarationNodeModifier withClientUri( - BasicLiteralNode clientUri) { - Objects.requireNonNull(clientUri, "clientUri must not be null"); - this.clientUri = clientUri; - return this; - } - - public ModuleClientDeclarationNodeModifier withAsKeyword( - Token asKeyword) { - Objects.requireNonNull(asKeyword, "asKeyword must not be null"); - this.asKeyword = asKeyword; - return this; - } - - public ModuleClientDeclarationNodeModifier withClientPrefix( - IdentifierToken clientPrefix) { - Objects.requireNonNull(clientPrefix, "clientPrefix must not be null"); - this.clientPrefix = clientPrefix; - return this; - } - - public ModuleClientDeclarationNodeModifier withSemicolonToken( - Token semicolonToken) { - Objects.requireNonNull(semicolonToken, "semicolonToken must not be null"); - this.semicolonToken = semicolonToken; - return this; - } - - public ModuleClientDeclarationNode apply() { - return oldNode.modify( - annotations, - clientKeyword, - clientUri, - asKeyword, - clientPrefix, - semicolonToken); - } - } -} diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeFactory.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeFactory.java index 5b0f27b66de2..6eda40233e78 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeFactory.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeFactory.java @@ -1251,54 +1251,6 @@ public static ModuleXMLNamespaceDeclarationNode createModuleXMLNamespaceDeclarat return stModuleXMLNamespaceDeclarationNode.createUnlinkedFacade(); } - public static ClientDeclarationNode createClientDeclarationNode( - NodeList annotations, - Token clientKeyword, - BasicLiteralNode clientUri, - Token asKeyword, - IdentifierToken clientPrefix, - Token semicolonToken) { - Objects.requireNonNull(annotations, "annotations must not be null"); - Objects.requireNonNull(clientKeyword, "clientKeyword must not be null"); - Objects.requireNonNull(clientUri, "clientUri must not be null"); - Objects.requireNonNull(asKeyword, "asKeyword must not be null"); - Objects.requireNonNull(clientPrefix, "clientPrefix must not be null"); - Objects.requireNonNull(semicolonToken, "semicolonToken must not be null"); - - STNode stClientDeclarationNode = STNodeFactory.createClientDeclarationNode( - annotations.underlyingListNode().internalNode(), - clientKeyword.internalNode(), - clientUri.internalNode(), - asKeyword.internalNode(), - clientPrefix.internalNode(), - semicolonToken.internalNode()); - return stClientDeclarationNode.createUnlinkedFacade(); - } - - public static ModuleClientDeclarationNode createModuleClientDeclarationNode( - NodeList annotations, - Token clientKeyword, - BasicLiteralNode clientUri, - Token asKeyword, - IdentifierToken clientPrefix, - Token semicolonToken) { - Objects.requireNonNull(annotations, "annotations must not be null"); - Objects.requireNonNull(clientKeyword, "clientKeyword must not be null"); - Objects.requireNonNull(clientUri, "clientUri must not be null"); - Objects.requireNonNull(asKeyword, "asKeyword must not be null"); - Objects.requireNonNull(clientPrefix, "clientPrefix must not be null"); - Objects.requireNonNull(semicolonToken, "semicolonToken must not be null"); - - STNode stModuleClientDeclarationNode = STNodeFactory.createModuleClientDeclarationNode( - annotations.underlyingListNode().internalNode(), - clientKeyword.internalNode(), - clientUri.internalNode(), - asKeyword.internalNode(), - clientPrefix.internalNode(), - semicolonToken.internalNode()); - return stModuleClientDeclarationNode.createUnlinkedFacade(); - } - public static FunctionBodyBlockNode createFunctionBodyBlockNode( Token openBraceToken, NamedWorkerDeclarator namedWorkerDeclarator, diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeTransformer.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeTransformer.java index 6e8ec616e472..e4e0edbbf97b 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeTransformer.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeTransformer.java @@ -320,14 +320,6 @@ public T transform(ModuleXMLNamespaceDeclarationNode moduleXMLNamespaceDeclarati return transformSyntaxNode(moduleXMLNamespaceDeclarationNode); } - public T transform(ClientDeclarationNode clientDeclarationNode) { - return transformSyntaxNode(clientDeclarationNode); - } - - public T transform(ModuleClientDeclarationNode moduleClientDeclarationNode) { - return transformSyntaxNode(moduleClientDeclarationNode); - } - public T transform(FunctionBodyBlockNode functionBodyBlockNode) { return transformSyntaxNode(functionBodyBlockNode); } diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeVisitor.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeVisitor.java index a9a9d163da39..8572f3cffb5c 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeVisitor.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeVisitor.java @@ -318,15 +318,6 @@ public void visit(XMLNamespaceDeclarationNode xMLNamespaceDeclarationNode) { public void visit(ModuleXMLNamespaceDeclarationNode moduleXMLNamespaceDeclarationNode) { visitSyntaxNode(moduleXMLNamespaceDeclarationNode); } - - public void visit(ClientDeclarationNode clientDeclarationNode) { - visitSyntaxNode(clientDeclarationNode); - } - - public void visit(ModuleClientDeclarationNode moduleClientDeclarationNode) { - visitSyntaxNode(moduleClientDeclarationNode); - } - public void visit(FunctionBodyBlockNode functionBodyBlockNode) { visitSyntaxNode(functionBodyBlockNode); } diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/SyntaxKind.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/SyntaxKind.java index 5d2c19e9669f..3e5fb81c440e 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/SyntaxKind.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/SyntaxKind.java @@ -254,7 +254,6 @@ public enum SyntaxKind { MODULE_XML_NAMESPACE_DECLARATION(2008), ENUM_DECLARATION(2009), CLASS_DEFINITION(2010), - MODULE_CLIENT_DECLARATION(2011), // Statements BLOCK_STATEMENT(1200), diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/TreeModifier.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/TreeModifier.java index 652defccfcbe..b14a9b210032 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/TreeModifier.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/TreeModifier.java @@ -1299,54 +1299,6 @@ public ModuleXMLNamespaceDeclarationNode transform( semicolonToken); } - @Override - public ClientDeclarationNode transform( - ClientDeclarationNode clientDeclarationNode) { - NodeList annotations = - modifyNodeList(clientDeclarationNode.annotations()); - Token clientKeyword = - modifyToken(clientDeclarationNode.clientKeyword()); - BasicLiteralNode clientUri = - modifyNode(clientDeclarationNode.clientUri()); - Token asKeyword = - modifyToken(clientDeclarationNode.asKeyword()); - IdentifierToken clientPrefix = - modifyNode(clientDeclarationNode.clientPrefix()); - Token semicolonToken = - modifyToken(clientDeclarationNode.semicolonToken()); - return clientDeclarationNode.modify( - annotations, - clientKeyword, - clientUri, - asKeyword, - clientPrefix, - semicolonToken); - } - - @Override - public ModuleClientDeclarationNode transform( - ModuleClientDeclarationNode moduleClientDeclarationNode) { - NodeList annotations = - modifyNodeList(moduleClientDeclarationNode.annotations()); - Token clientKeyword = - modifyToken(moduleClientDeclarationNode.clientKeyword()); - BasicLiteralNode clientUri = - modifyNode(moduleClientDeclarationNode.clientUri()); - Token asKeyword = - modifyToken(moduleClientDeclarationNode.asKeyword()); - IdentifierToken clientPrefix = - modifyNode(moduleClientDeclarationNode.clientPrefix()); - Token semicolonToken = - modifyToken(moduleClientDeclarationNode.semicolonToken()); - return moduleClientDeclarationNode.modify( - annotations, - clientKeyword, - clientUri, - asKeyword, - clientPrefix, - semicolonToken); - } - @Override public FunctionBodyBlockNode transform( FunctionBodyBlockNode functionBodyBlockNode) { diff --git a/compiler/ballerina-parser/src/main/resources/syntax_diagnostic_message.properties b/compiler/ballerina-parser/src/main/resources/syntax_diagnostic_message.properties index f6a05b54b230..f5c0f42bd744 100644 --- a/compiler/ballerina-parser/src/main/resources/syntax_diagnostic_message.properties +++ b/compiler/ballerina-parser/src/main/resources/syntax_diagnostic_message.properties @@ -253,7 +253,6 @@ error.invalid.expr.in.compound.assignment.lhs=invalid expr in compound assignmen error.invalid.metadata=documentation and annotations are not allowed for ''{0}'' error.invalid.qualifier=invalid qualifier ''{0}'' error.annotations.attached.to.statement=annotations attached to statement -error.invalid.documentation=documentation not allowed on client declaration error.action.as.a.wait.expr=''wait'' cannot be used with actions error.invalid.usage.of.var='var' is not a valid type descriptor error.match.pattern.after.rest.match.pattern=match pattern after rest match pattern diff --git a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/ParserTestUtils.java b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/ParserTestUtils.java index abf02d4d8852..fe3d51d7caf1 100644 --- a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/ParserTestUtils.java +++ b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/ParserTestUtils.java @@ -459,10 +459,6 @@ private static SyntaxKind getNodeKind(String kind) { return SyntaxKind.XML_NAMESPACE_DECLARATION; case "MODULE_XML_NAMESPACE_DECLARATION": return SyntaxKind.MODULE_XML_NAMESPACE_DECLARATION; - case "CLIENT_DECLARATION": - return SyntaxKind.CLIENT_DECLARATION; - case "MODULE_CLIENT_DECLARATION": - return SyntaxKind.MODULE_CLIENT_DECLARATION; case "ANNOTATION_DECLARATION": return SyntaxKind.ANNOTATION_DECLARATION; case "ENUM_DECLARATION": diff --git a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/declarations/ClientDeclarationTest.java b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/declarations/ClientDeclarationTest.java deleted file mode 100644 index 5c8ef7191557..000000000000 --- a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/declarations/ClientDeclarationTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package io.ballerinalang.compiler.parser.test.syntax.declarations; - -import org.testng.annotations.Test; - -/** - * Test parsing client declarations. - * - * @since 2201.3.0 - */ -public class ClientDeclarationTest extends AbstractDeclarationTest { - - // Valid syntax tests - - @Test - public void testClientDecl() { - testFile("client-decl/client_decl_source_01.bal", "client-decl/client_decl_assert_01.json"); - } - - @Test - public void testClientDeclWithAnnotations() { - testFile("client-decl/client_decl_source_02.bal", "client-decl/client_decl_assert_02.json"); - } - - // Recovery tests - - @Test - public void testMissingAliasAndSemicolon() { - testFile("client-decl/client_decl_source_03.bal", "client-decl/client_decl_assert_03.json"); - } - - @Test - public void testMissingAsKeyword() { - testFile("client-decl/client_decl_source_04.bal", "client-decl/client_decl_assert_04.json"); - } - - @Test - public void testMissingClientAndXmlnsKeyword() { - testFile("client-decl/client_decl_source_05.bal", "client-decl/client_decl_assert_05.json"); - } - - @Test - public void testMissingUri() { - testFile("client-decl/client_decl_source_06.bal", "client-decl/client_decl_assert_06.json"); - } - - @Test - public void testIdentifierAsUri() { - testFile("client-decl/client_decl_source_07.bal", "client-decl/client_decl_assert_07.json"); - } - - @Test - public void testMultipleAliases() { - testFile("client-decl/client_decl_source_08.bal", "client-decl/client_decl_assert_08.json"); - } - - @Test - public void testOnlyClientKeyword() { - testFile("client-decl/client_decl_source_09.bal", "client-decl/client_decl_assert_09.json"); - } - - @Test - public void testMissingAlias() { - testFile("client-decl/client_decl_source_10.bal", "client-decl/client_decl_assert_10.json"); - } - - @Test - public void testMissingSemicolon() { - testFile("client-decl/client_decl_source_11.bal", "client-decl/client_decl_assert_11.json"); - } - - @Test - public void testRecoveryWithMultipleClientDecls() { - testFile("client-decl/client_decl_source_12.bal", "client-decl/client_decl_assert_12.json"); - } - - @Test - public void testInvalidQualifiers() { - testFile("client-decl/client_decl_source_13.bal", "client-decl/client_decl_assert_13.json"); - } - - @Test - public void testInvalidDocumentation() { - testFile("client-decl/client_decl_source_14.bal", "client-decl/client_decl_assert_14.json"); - } -} diff --git a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/misc/IdentifierTest.java b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/misc/IdentifierTest.java index d4fa5c85cf38..d73dfa6834d2 100644 --- a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/misc/IdentifierTest.java +++ b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/misc/IdentifierTest.java @@ -56,12 +56,6 @@ public void testKeywordsAsIdentifiers() { "identifiers/keywords_as_identifiers_assert.json"); } - @Test - public void testClientKeywordAsIdentifierInQualifiedIdentifier() { - testFile("identifiers/client_keyword_as_identifier_in_qualified_identifier_source.bal", - "identifiers/client_keyword_as_identifier_in_qualified_identifier_assert.json"); - } - // Invalid Syntax @Test @@ -81,10 +75,4 @@ public void testIncompleteQuotedIdentifier() { testFile("identifiers/incomplete_identifier_source.bal", "identifiers/incomplete_identifier_assert.json"); } - - @Test - public void testInvalidUsageOfClientKeywordAsIdentifier() { - testFile("identifiers/invalid_usage_of_client_keyword_as_identifier_source.bal", - "identifiers/invalid_usage_of_client_keyword_as_identifier_assert.json"); - } } diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_01.json b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_01.json deleted file mode 100644 index 538340b5813d..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_01.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "kind": "MODULE_PART", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "MODULE_CLIENT_DECLARATION", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "http://www.example.com/apis/myapi.yaml", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "EOF_TOKEN" - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_02.json b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_02.json deleted file mode 100644 index ef7cc122c0ac..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_02.json +++ /dev/null @@ -1,248 +0,0 @@ -{ - "kind": "MODULE_PART", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "MODULE_CLIENT_DECLARATION", - "children": [ - { - "kind": "LIST", - "children": [ - { - "kind": "ANNOTATION", - "children": [ - { - "kind": "AT_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "AnnotationOne", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "MAPPING_CONSTRUCTOR", - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "SPECIFIC_FIELD", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "x", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NUMERIC_LITERAL", - "children": [ - { - "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", - "value": "1", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - } - ] - }, - { - "kind": "CLIENT_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "http://www.example.com/apis/myapi.yaml", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "MODULE_CLIENT_DECLARATION", - "children": [ - { - "kind": "LIST", - "children": [ - { - "kind": "ANNOTATION", - "children": [ - { - "kind": "AT_TOKEN", - "leadingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "AnnotationTwo", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - } - ] - }, - { - "kind": "CLIENT_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "http://www.example.com/apis/myapi.yaml", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi2" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "EOF_TOKEN" - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_03.json b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_03.json deleted file mode 100644 index d2fd33d5ac08..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_03.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "kind": "MODULE_PART", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "MODULE_CLIENT_DECLARATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "http://www.example.com/apis/myapi.yaml", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_SEMICOLON_TOKEN" - ] - } - ] - } - ] - }, - { - "kind": "EOF_TOKEN" - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_04.json b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_04.json deleted file mode 100644 index 41bdf9435818..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_04.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "kind": "MODULE_PART", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "MODULE_CLIENT_DECLARATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "http://www.example.com/apis/myapi.yaml", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_AS_KEYWORD" - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "EOF_TOKEN" - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_05.json b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_05.json deleted file mode 100644 index 993adaae4e23..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_05.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "kind": "MODULE_PART", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "MODULE_VAR_DECL", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "SINGLETON_TYPE_DESC", - "children": [ - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "http://www.example.com/apis/myapi.yaml", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "hasDiagnostics": true, - "value": "myapi", - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "AS_KEYWORD", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ] - } - ] - } - }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "EOF_TOKEN" - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_06.json b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_06.json deleted file mode 100644 index 7d52af38e070..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_06.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "kind": "MODULE_PART", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "MODULE_CLIENT_DECLARATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "hasDiagnostics": true, - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_STRING_LITERAL" - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "EOF_TOKEN" - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_07.json b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_07.json deleted file mode 100644 index 437858b09e3f..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_07.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "kind": "MODULE_PART", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "MODULE_CLIENT_DECLARATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "hasDiagnostics": true, - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_STRING_LITERAL" - ], - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ], - "value": "constRef" - } - ] - } - }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi1" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "EOF_TOKEN" - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_08.json b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_08.json deleted file mode 100644 index 51fa32e328f0..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_08.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "kind": "MODULE_PART", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "MODULE_CLIENT_DECLARATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "http://www.example.com/apis/myapi.yaml", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "hasDiagnostics": true, - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ], - "value": "myapi" - } - ] - } - } - ], - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "EOF_TOKEN" - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_09.json b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_09.json deleted file mode 100644 index 9a7c64f128c7..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_09.json +++ /dev/null @@ -1,88 +0,0 @@ -{ - "kind": "MODULE_PART", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "MODULE_VAR_DECL", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "hasDiagnostics": true, - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_TYPE_DESC" - ], - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "children": [ - { - "kind": "CLIENT_KEYWORD" - } - ] - } - }, - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_VARIABLE_NAME" - ] - } - ] - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_SEMICOLON_TOKEN" - ] - } - ] - } - ] - }, - { - "kind": "EOF_TOKEN" - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_10.json b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_10.json deleted file mode 100644 index 3483d80ecbbb..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_10.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "kind": "MODULE_PART", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "MODULE_CLIENT_DECLARATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "http://www.example.com/apis/myapi.yaml", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "EOF_TOKEN" - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_11.json b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_11.json deleted file mode 100644 index 6b7b173e264d..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_11.json +++ /dev/null @@ -1,80 +0,0 @@ -{ - "kind": "MODULE_PART", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "MODULE_CLIENT_DECLARATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "http://www.example.com/apis/myapi.yaml", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_SEMICOLON_TOKEN" - ] - } - ] - } - ] - }, - { - "kind": "EOF_TOKEN" - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_12.json b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_12.json deleted file mode 100644 index 343bda5bd08f..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_12.json +++ /dev/null @@ -1,207 +0,0 @@ -{ - "kind": "MODULE_PART", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "MODULE_CLIENT_DECLARATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "http://www.example.com/apis/myapi.yaml", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_SEMICOLON_TOKEN" - ] - } - ] - }, - { - "kind": "MODULE_CLIENT_DECLARATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "leadingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "http://www.example.com/apis/myapi.yaml", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_AS_KEYWORD" - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_SEMICOLON_TOKEN" - ] - } - ] - }, - { - "kind": "MODULE_CLIENT_DECLARATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "leadingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "hasDiagnostics": true, - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_STRING_LITERAL" - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi2" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "EOF_TOKEN" - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_13.json b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_13.json deleted file mode 100644 index 35c7ba7fafe3..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_13.json +++ /dev/null @@ -1,287 +0,0 @@ -{ - "kind": "MODULE_PART", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "MODULE_CLIENT_DECLARATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "hasDiagnostics": true, - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "hasDiagnostics": true, - "value": "http://www.example.com/apis/myapi1.yaml", - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "PUBLIC_KEYWORD", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_QUALIFIER" - ] - } - ] - } - }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi1" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "MODULE_CLIENT_DECLARATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "hasDiagnostics": true, - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "hasDiagnostics": true, - "value": "http://www.example.com/apis/myapi2.yaml", - "leadingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - }, - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "PUBLIC_KEYWORD", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_QUALIFIER" - ] - } - ] - } - }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - }, - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "ISOLATED_KEYWORD", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_QUALIFIER" - ] - } - ] - } - }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi2" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "MODULE_CLIENT_DECLARATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "hasDiagnostics": true, - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "hasDiagnostics": true, - "value": "http://www.example.com/apis/myapi3.yaml", - "leadingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - }, - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "ISOLATED_KEYWORD", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_QUALIFIER" - ] - } - ] - } - }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi3" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "EOF_TOKEN" - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_14.json b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_14.json deleted file mode 100644 index 5f06631e8186..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_assert_14.json +++ /dev/null @@ -1,239 +0,0 @@ -{ - "kind": "MODULE_PART", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "MODULE_CLIENT_DECLARATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "ANNOTATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "AT_TOKEN", - "hasDiagnostics": true, - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "HASH_TOKEN", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_DOCUMENTATION" - ] - } - ] - } - }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - }, - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "children": [ - { - "kind": "DOCUMENTATION_DESCRIPTION", - "value": "Docs for Foo" - } - ] - } - }, - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "Annot", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - } - ] - }, - { - "kind": "CLIENT_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "http://www.example.com/apis/one.yaml", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "foo" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "MODULE_CLIENT_DECLARATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "hasDiagnostics": true, - "leadingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - }, - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "HASH_TOKEN", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_DOCUMENTATION" - ] - } - ] - } - }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - }, - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "children": [ - { - "kind": "DOCUMENTATION_DESCRIPTION", - "value": "Docs for bar" - } - ] - } - }, - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "http://www.example.com/apis/one.yaml", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "foo" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "EOF_TOKEN" - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_01.bal b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_01.bal deleted file mode 100644 index 775b2c3786e6..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_01.bal +++ /dev/null @@ -1 +0,0 @@ -client "http://www.example.com/apis/myapi.yaml" as myapi; diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_02.bal b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_02.bal deleted file mode 100644 index 142742c4d472..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_02.bal +++ /dev/null @@ -1,7 +0,0 @@ -@AnnotationOne { - x: 1 -} -client "http://www.example.com/apis/myapi.yaml" as myapi; - -@AnnotationTwo -client "http://www.example.com/apis/myapi.yaml" as myapi2; diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_03.bal b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_03.bal deleted file mode 100644 index 95d754f79646..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_03.bal +++ /dev/null @@ -1 +0,0 @@ -client "http://www.example.com/apis/myapi.yaml" as diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_04.bal b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_04.bal deleted file mode 100644 index fdaf3703858f..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_04.bal +++ /dev/null @@ -1 +0,0 @@ -client "http://www.example.com/apis/myapi.yaml" myapi; diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_05.bal b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_05.bal deleted file mode 100644 index debf94cafeac..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_05.bal +++ /dev/null @@ -1 +0,0 @@ -"http://www.example.com/apis/myapi.yaml" as myapi; diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_06.bal b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_06.bal deleted file mode 100644 index a4d8cd722bc6..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_06.bal +++ /dev/null @@ -1 +0,0 @@ -client as myapi; diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_07.bal b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_07.bal deleted file mode 100644 index 9a204c04df2b..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_07.bal +++ /dev/null @@ -1 +0,0 @@ -client constRef as myapi1; diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_08.bal b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_08.bal deleted file mode 100644 index b51338039011..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_08.bal +++ /dev/null @@ -1 +0,0 @@ -client "http://www.example.com/apis/myapi.yaml" as myapi myapi; diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_09.bal b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_09.bal deleted file mode 100644 index b051c6c57fa8..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_09.bal +++ /dev/null @@ -1 +0,0 @@ -client diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_10.bal b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_10.bal deleted file mode 100644 index ca390d329caa..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_10.bal +++ /dev/null @@ -1 +0,0 @@ -client "http://www.example.com/apis/myapi.yaml" as ; diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_11.bal b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_11.bal deleted file mode 100644 index 89f526e1de85..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_11.bal +++ /dev/null @@ -1 +0,0 @@ -client "http://www.example.com/apis/myapi.yaml" as myapi diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_12.bal b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_12.bal deleted file mode 100644 index d65cc43a1286..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_12.bal +++ /dev/null @@ -1,5 +0,0 @@ -client "http://www.example.com/apis/myapi.yaml" as myapi - -client "http://www.example.com/apis/myapi.yaml" myapi - -client as myapi2; diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_13.bal b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_13.bal deleted file mode 100644 index 08a47d1ffc96..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_13.bal +++ /dev/null @@ -1,5 +0,0 @@ -public client "http://www.example.com/apis/myapi1.yaml" as myapi1; - -public isolated client "http://www.example.com/apis/myapi2.yaml" as myapi2; - -isolated client "http://www.example.com/apis/myapi3.yaml" as myapi3; diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_14.bal b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_14.bal deleted file mode 100644 index 80515dae2b87..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_14.bal +++ /dev/null @@ -1,6 +0,0 @@ -# Docs for Foo -@Annot -client "http://www.example.com/apis/one.yaml" as foo; - -# Docs for bar -client "http://www.example.com/apis/one.yaml" as foo; diff --git a/compiler/ballerina-parser/src/test/resources/misc/identifiers/client_keyword_as_identifier_in_qualified_identifier_assert.json b/compiler/ballerina-parser/src/test/resources/misc/identifiers/client_keyword_as_identifier_in_qualified_identifier_assert.json deleted file mode 100644 index ffb65ba26355..000000000000 --- a/compiler/ballerina-parser/src/test/resources/misc/identifiers/client_keyword_as_identifier_in_qualified_identifier_assert.json +++ /dev/null @@ -1,322 +0,0 @@ -{ - "kind": "MODULE_PART", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "MODULE_VAR_DECL", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi" - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "client", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "c1", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IMPLICIT_NEW_EXPRESSION", - "children": [ - { - "kind": "NEW_KEYWORD" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "FUNCTION_DEFINITION", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_KEYWORD", - "leadingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "fn" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_SIGNATURE", - "children": [ - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "FUNCTION_BODY_BLOCK", - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "LOCAL_VAR_DECL", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "client", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "c2" - } - ] - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "LOCAL_VAR_DECL", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "children": [ - { - "kind": "ANY_TYPE_DESC", - "children": [ - { - "kind": "ANY_KEYWORD", - "leadingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "t", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi" - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "client" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - } - ] - }, - { - "kind": "EOF_TOKEN" - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/misc/identifiers/client_keyword_as_identifier_in_qualified_identifier_source.bal b/compiler/ballerina-parser/src/test/resources/misc/identifiers/client_keyword_as_identifier_in_qualified_identifier_source.bal deleted file mode 100644 index fae82c27f33e..000000000000 --- a/compiler/ballerina-parser/src/test/resources/misc/identifiers/client_keyword_as_identifier_in_qualified_identifier_source.bal +++ /dev/null @@ -1,7 +0,0 @@ -myapi:client c1 = new; - -function fn() { - myapi:client c2; - - any t = myapi:client; -} diff --git a/compiler/ballerina-parser/src/test/resources/misc/identifiers/invalid_usage_of_client_keyword_as_identifier_assert.json b/compiler/ballerina-parser/src/test/resources/misc/identifiers/invalid_usage_of_client_keyword_as_identifier_assert.json deleted file mode 100644 index 6eefc6ca8564..000000000000 --- a/compiler/ballerina-parser/src/test/resources/misc/identifiers/invalid_usage_of_client_keyword_as_identifier_assert.json +++ /dev/null @@ -1,484 +0,0 @@ -{ - "kind": "MODULE_PART", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "MODULE_VAR_DECL", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "INT_TYPE_DESC", - "children": [ - { - "kind": "INT_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" - ], - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "CLIENT_KEYWORD", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ] - } - ] - } - }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NUMERIC_LITERAL", - "children": [ - { - "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", - "value": "1" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "MODULE_VAR_DECL", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "hasDiagnostics": true, - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" - ] - }, - { - "kind": "COLON_TOKEN", - "hasDiagnostics": true, - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "CLIENT_KEYWORD", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_QUALIFIER_NOT_ALLOWED" - ] - } - ] - } - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "x", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "a", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NUMERIC_LITERAL", - "children": [ - { - "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", - "value": "2" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "FUNCTION_DEFINITION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_KEYWORD", - "leadingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "fn" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_SIGNATURE", - "children": [ - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "FUNCTION_BODY_BLOCK", - "hasDiagnostics": true, - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "STRING_TYPE_DESC", - "children": [ - { - "kind": "STRING_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" - ], - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "CLIENT_KEYWORD", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ] - } - ] - } - } - ] - } - ] - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "children": [ - { - "kind": "ANY_TYPE_DESC", - "children": [ - { - "kind": "ANY_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "b", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "QUALIFIED_NAME_REFERENCE", - "hasDiagnostics": true, - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" - ], - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "CLIENT_KEYWORD", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_QUALIFIER_NOT_ALLOWED" - ] - } - ] - } - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "y" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - } - ] - }, - { - "kind": "EOF_TOKEN" - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/misc/identifiers/invalid_usage_of_client_keyword_as_identifier_source.bal b/compiler/ballerina-parser/src/test/resources/misc/identifiers/invalid_usage_of_client_keyword_as_identifier_source.bal deleted file mode 100644 index f2a3608a56ff..000000000000 --- a/compiler/ballerina-parser/src/test/resources/misc/identifiers/invalid_usage_of_client_keyword_as_identifier_source.bal +++ /dev/null @@ -1,7 +0,0 @@ -int client = 1; -client:x a = 2; - -function fn() { - string client; - any b = client:y; -} diff --git a/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/FormattingTreeModifier.java b/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/FormattingTreeModifier.java index 754647f0ebe8..ac6c9f89b41d 100644 --- a/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/FormattingTreeModifier.java +++ b/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/FormattingTreeModifier.java @@ -123,7 +123,6 @@ import io.ballerina.compiler.syntax.tree.MethodDeclarationNode; import io.ballerina.compiler.syntax.tree.Minutiae; import io.ballerina.compiler.syntax.tree.MinutiaeList; -import io.ballerina.compiler.syntax.tree.ModuleClientDeclarationNode; import io.ballerina.compiler.syntax.tree.ModuleMemberDeclarationNode; import io.ballerina.compiler.syntax.tree.ModulePartNode; import io.ballerina.compiler.syntax.tree.ModuleVariableDeclarationNode; diff --git a/tests/ballerina-compiler-api-test/build.gradle b/tests/ballerina-compiler-api-test/build.gradle index 5299e51a8b09..0390001ca0ef 100644 --- a/tests/ballerina-compiler-api-test/build.gradle +++ b/tests/ballerina-compiler-api-test/build.gradle @@ -25,8 +25,6 @@ dependencies { testCompile 'org.testng:testng' testCompile project(path: ':ballerina-test-utils', configuration: 'shadow') - testRuntime project(':project-api-test-artifact:idl-client-gen-plugin') - testRuntime project(':project-api-test-artifact:idl-import-simple-compiler-plugin') distributionBala project(path: ':testerina:testerina-core', configuration: 'distributionBala') } diff --git a/tests/ballerina-compiler-api-test/src/test/resources/test-src/symbols/client_decl_proj/Ballerina.toml b/tests/ballerina-compiler-api-test/src/test/resources/test-src/symbols/client_decl_proj/Ballerina.toml deleted file mode 100644 index baea0671d42b..000000000000 --- a/tests/ballerina-compiler-api-test/src/test/resources/test-src/symbols/client_decl_proj/Ballerina.toml +++ /dev/null @@ -1,7 +0,0 @@ -[package] -org = "testorg" -name = "clientdecl" -version = "0.1.0" - -[build-options] -observabilityIncluded = true diff --git a/tests/ballerina-compiler-api-test/src/test/resources/test-src/symbols/client_decl_proj/main.bal b/tests/ballerina-compiler-api-test/src/test/resources/test-src/symbols/client_decl_proj/main.bal deleted file mode 100644 index 5f7e82090286..000000000000 --- a/tests/ballerina-compiler-api-test/src/test/resources/test-src/symbols/client_decl_proj/main.bal +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2022 WSO2 LLC. (http://www.wso2.org) All Rights Reserved. -// -// WSO2 LLC. licenses this file to you under the Apache License, -// Version 2.0 (the "License"); you may not use this file except -// in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -@ClientAnnot { - i: 1 -} -client "https://postman-echo.com/get?name=projectapiclientplugin" as myapi; - -public function main() { - myapi:client x; -} - -function testClientDeclStmt() { - @ClientAnnot { - i: 2 - } - client "https://postman-echo.com/get?name=simpleclienttest" as bar; - bar:ClientConfiguration config = {'limit: 5}; - bar:client cl = new (config); - int 'limit = cl->getLimit(); - cl1:Config config2 = {url: "http://www.example.com"}; -} - -public const annotation record { int i; }[] ClientAnnot on source client; diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/module/declarations/ClientDeclarationTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/module/declarations/ClientDeclarationTest.java deleted file mode 100644 index f587f9a58cc0..000000000000 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/module/declarations/ClientDeclarationTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.ballerinalang.test.module.declarations; - -import org.ballerinalang.model.tree.ClientDeclarationNode; -import org.ballerinalang.test.BAssertUtil; -import org.ballerinalang.test.BCompileUtil; -import org.ballerinalang.test.CompileResult; -import org.testng.Assert; -import org.testng.annotations.Test; -import org.wso2.ballerinalang.compiler.tree.BLangClientDeclaration; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * Tests for module-level client declarations. - * - * @since 2201.3.0 - */ -public class ClientDeclarationTest { - - private static final String REDECLARED_PREFIX_ERROR = "redeclared symbol '%s'"; - @Test - public void testUndefinedPrefixNegative() { - CompileResult result = BCompileUtil.compile( - "test-src/module.declarations/client-decl/client_decl_undefined_prefix_negative_test.bal"); - int index = 0; - BAssertUtil.validateError(result, index++, "undefined module 'foo'", 18, 15); - Assert.assertEquals(result.getErrorCount(), index); - } - - @Test - public void testClientDecl() { - CompileResult result = BCompileUtil.compile( - "test-src/module.declarations/client-decl/client_decl_test.bal"); - List clientDeclarations = result.getAST().getClientDeclarations(); - Assert.assertEquals(clientDeclarations.size(), 3); - - final Map expectedDeclDetails = Map.ofEntries( - Map.entry("foo", "http://www.example.com/apis/one.yaml"), - Map.entry("bar", "http://www.example.com/apis/two.yaml"), - Map.entry("baz", "http://www.example.com/apis/two.yaml") - ); - final Set expectedPrefixes = expectedDeclDetails.keySet(); - - for (ClientDeclarationNode clientDeclaration : clientDeclarations) { - BLangClientDeclaration bLangClientDeclaration = (BLangClientDeclaration) clientDeclaration; - - String prefix = bLangClientDeclaration.prefix.value; - Assert.assertTrue(expectedPrefixes.contains(prefix)); - Assert.assertEquals(bLangClientDeclaration.uri.value, expectedDeclDetails.get(prefix)); - } - } - - private String getRedeclaredSymbolError(String prefix) { - return String.format(REDECLARED_PREFIX_ERROR, prefix); - } -} From d8db1c3a051db8607ad32032b98456cc4aae2922 Mon Sep 17 00:00:00 2001 From: Sasindu Alahakoon Date: Fri, 11 Nov 2022 19:05:31 +0530 Subject: [PATCH 078/450] Fix unit tests afer removing client decalarations --- .../declarations/client-decl/client_decl_source_15.bal | 3 +++ .../test/annotations/AnnotationDeclarationTest.java | 5 ++--- .../java/org/ballerinalang/test/types/xml/XMLAccessTest.java | 2 -- .../annotations/source_annot_without_const_negative.bal | 1 - .../source_only_annot_without_source_negative.bal | 1 - 5 files changed, 5 insertions(+), 7 deletions(-) create mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_15.bal diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_15.bal b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_15.bal new file mode 100644 index 000000000000..429d96243406 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_15.bal @@ -0,0 +1,3 @@ +function fn() { +client "http://www.example.com/apis/one.yaml" as foo; +} diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/annotations/AnnotationDeclarationTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/annotations/AnnotationDeclarationTest.java index 4875bf60d58f..9f836322e19d 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/annotations/AnnotationDeclarationTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/annotations/AnnotationDeclarationTest.java @@ -43,7 +43,6 @@ public void testSourceOnlyAnnotDeclWithoutSource() { BAssertUtil.validateError(compileResult, index++, "missing source keyword", 19, 22); BAssertUtil.validateError(compileResult, index++, "missing source keyword", 20, 45); BAssertUtil.validateError(compileResult, index++, "missing source keyword", 21, 37); - BAssertUtil.validateError(compileResult, index++, "missing source keyword", 22, 37); Assert.assertEquals(compileResult.getErrorCount(), index); } @@ -51,9 +50,9 @@ public void testSourceOnlyAnnotDeclWithoutSource() { public void testSourceAnnotDeclWithoutConst() { CompileResult compileResult = BCompileUtil.compile( "test-src/annotations/source_annot_without_const_negative.bal"); - Assert.assertEquals(compileResult.getErrorCount(), 11); + Assert.assertEquals(compileResult.getErrorCount(), 10); String errorMessage = "annotation declaration with 'source' attach point(s) should be a 'const' declaration"; - for (int index = 0; index < 10; index++) { + for (int index = 0; index < 9; index++) { BAssertUtil.validateError(compileResult, index, errorMessage, index + 17, 1); } } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/xml/XMLAccessTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/xml/XMLAccessTest.java index dbc1765eb724..566175b44340 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/xml/XMLAccessTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/xml/XMLAccessTest.java @@ -293,8 +293,6 @@ void testXMLFilterExpressionsNegative() { "incompatible types: expected 'xml', found 'any'", 6, 14); BAssertUtil.validateError(navigationFilterNegative, index++, "incompatible types: expected 'xml', found 'int'", 8, 14); - BAssertUtil.validateError(navigationFilterNegative, index++, - "cannot find xml namespace prefix 'foo'", 13, 16); Assert.assertEquals(navigationFilterNegative.getErrorCount(), index); } } diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/annotations/source_annot_without_const_negative.bal b/tests/jballerina-unit-test/src/test/resources/test-src/annotations/source_annot_without_const_negative.bal index 790cb01f549b..380e7d77655b 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/annotations/source_annot_without_const_negative.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/annotations/source_annot_without_const_negative.bal @@ -24,7 +24,6 @@ annotation Bar v6 on source listener, return; annotation Bar v7 on class, source function; annotation Bar v8 on source object function, source parameter; annotation map v9 on source worker; -annotation map v10 on source client; type Foo record { string val1; diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/annotations/source_only_annot_without_source_negative.bal b/tests/jballerina-unit-test/src/test/resources/test-src/annotations/source_only_annot_without_source_negative.bal index 00be3bbcaacf..960b1d2655be 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/annotations/source_only_annot_without_source_negative.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/annotations/source_only_annot_without_source_negative.bal @@ -19,7 +19,6 @@ const annotation Foo v1 on annotation; annotation Bar v2 on const, type; const annotation map v3 on return, external; const annotation map v4 on listener; -const annotation map v5 on client; type Foo record { string val1; From 984b16205fbf0852e14c019eca37f955e30238da Mon Sep 17 00:00:00 2001 From: Sasindu Alahakoon Date: Sun, 13 Nov 2022 02:24:45 +0530 Subject: [PATCH 079/450] Fix project api and ls server tests --- .../modules/langserver-core/build.gradle | 1 - .../config/moduleLevelAnnotation1.json | 653 +++++++++++------- .../config/moduleLevelAnnotation2.json | 501 -------------- .../source/moduleLevelAnnotation1.bal | 15 +- .../source/moduleLevelAnnotation2.bal | 14 - project-api/project-api-test/build.gradle | 2 - .../idl-client-gen-plugin/build.gradle | 38 - .../idlclient/OpenApiIDLGenPlugin.java | 145 ---- .../src/main/java/module-info.java | 7 - ...lerina.projects.plugins.IDLGeneratorPlugin | 1 - .../build.gradle | 40 -- .../SimpleClientGeneratorPlugin.java | 240 ------- .../src/main/java/module-info.java | 7 - ...lerina.projects.plugins.IDLGeneratorPlugin | 1 - settings.gradle | 4 - 15 files changed, 401 insertions(+), 1268 deletions(-) delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleLevelAnnotation2.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleLevelAnnotation2.bal delete mode 100644 project-api/test-artifacts/idl-client-gen-plugin/build.gradle delete mode 100644 project-api/test-artifacts/idl-client-gen-plugin/src/main/java/io/asmaj/plugins/idlclient/OpenApiIDLGenPlugin.java delete mode 100644 project-api/test-artifacts/idl-client-gen-plugin/src/main/java/module-info.java delete mode 100644 project-api/test-artifacts/idl-client-gen-plugin/src/main/resources/META-INF/services/io.ballerina.projects.plugins.IDLGeneratorPlugin delete mode 100644 project-api/test-artifacts/idl-import-simple-compiler-plugin/build.gradle delete mode 100644 project-api/test-artifacts/idl-import-simple-compiler-plugin/src/main/java/io/idl/plugins/simpleclient/SimpleClientGeneratorPlugin.java delete mode 100644 project-api/test-artifacts/idl-import-simple-compiler-plugin/src/main/java/module-info.java delete mode 100644 project-api/test-artifacts/idl-import-simple-compiler-plugin/src/main/resources/META-INF/services/io.ballerina.projects.plugins.IDLGeneratorPlugin diff --git a/language-server/modules/langserver-core/build.gradle b/language-server/modules/langserver-core/build.gradle index bd94847d7cd2..1bcaad9d1822 100644 --- a/language-server/modules/langserver-core/build.gradle +++ b/language-server/modules/langserver-core/build.gradle @@ -83,7 +83,6 @@ dependencies { testCompile 'org.awaitility:awaitility' testImplementation 'org.powermock:powermock-mockito-release-full' testImplementation 'org.powermock:powermock-module-testng-common' - } description = 'Ballerina - Language server - Core' diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleLevelAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleLevelAnnotation1.json index 0261e1d85e23..4a8799408e42 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleLevelAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleLevelAnnotation1.json @@ -1,205 +1,326 @@ { "position": { - "line": 2, - "character": 9 + "line": 13, + "character": 1 }, "source": "annotation_ctx/source/moduleLevelAnnotation1.bal", "items": [ { - "label": "typeAnnotation2", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "typeAnnotation2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "typeAnnotation3", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "typeAnnotation3", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "classAnnotation2", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "classAnnotation2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "classAnnotation3", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "classAnnotation3", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "functionAnnotation2", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "functionAnnotation2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] + "label": "ballerina/jballerina.java", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "java", + "insertText": "java", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/jballerina.java;\n" + } + ] + }, + { + "label": "ballerina/lang.value", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "value", + "insertText": "value", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.value;\n" + } + ] + }, + { + "label": "ballerina/lang.runtime", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "runtime", + "insertText": "runtime", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.runtime;\n" + } + ] + }, + { + "label": "ballerina/module1", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "module1", + "insertText": "module1", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/module1;\n" + } + ] + }, + { + "label": "ballerina/lang.test", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "test", + "insertText": "test", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.test;\n" + } + ] + }, + { + "label": "ballerina/lang.array", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "array", + "insertText": "array", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.array;\n" + } + ] + }, + { + "label": "boolean", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" }, { - "label": "objectFunctionAnnotation2", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "objectFunctionAnnotation2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] + "label": "future", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" }, { - "label": "parameterAnnotation2", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "parameterAnnotation2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] + "label": "int", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" }, { - "label": "returnAnnotation2", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "returnAnnotation2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] + "label": "map", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "map", + "insertTextFormat": "Snippet" }, { - "label": "serviceAnnotation2", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "serviceAnnotation2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] + "label": "object", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "object", + "insertTextFormat": "Snippet" }, { - "label": "fieldAnnotation2", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "fieldAnnotation2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] + "label": "stream", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "stream", + "insertTextFormat": "Snippet" }, { - "label": "objectFieldAnnotation2", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "objectFieldAnnotation2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] + "label": "string", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" }, { - "label": "recordFieldAnnotation2", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "recordFieldAnnotation2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] + "label": "table", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "table", + "insertTextFormat": "Snippet" }, { - "label": "sourceAnnotationAnnotation2", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "sourceAnnotationAnnotation2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] + "label": "transaction", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "transaction", + "insertTextFormat": "Snippet" }, { - "label": "sourceExternalAnnotation2", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "sourceExternalAnnotation2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] + "label": "typedesc", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" }, { - "label": "sourceVarAnnotation2", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "sourceVarAnnotation2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] + "label": "xml", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" }, { - "label": "sourceConstAnnotation2", + "label": "tainted", "kind": "Property", "detail": "Annotation", "sortText": "B", - "insertText": "sourceConstAnnotation2", + "insertText": "tainted", "insertTextFormat": "Snippet", "additionalTextEdits": [] }, { - "label": "sourceListenerAnnotation2", + "label": "builtinSubtype", "kind": "Property", "detail": "Annotation", "sortText": "B", - "insertText": "sourceListenerAnnotation2", + "insertText": "builtinSubtype", "insertTextFormat": "Snippet", "additionalTextEdits": [] }, { - "label": "sourceWorkerAnnotation2", + "label": "typeParam", "kind": "Property", "detail": "Annotation", "sortText": "B", - "insertText": "sourceWorkerAnnotation2", + "insertText": "typeParam", "insertTextFormat": "Snippet", "additionalTextEdits": [] }, { - "label": "commonAnnotation1", + "label": "isolatedParam", "kind": "Property", "detail": "Annotation", "sortText": "B", - "insertText": "commonAnnotation1", + "insertText": "isolatedParam", "insertTextFormat": "Snippet", "additionalTextEdits": [] }, { - "label": "serviceRemoteFunctionAnnotation2", + "label": "deprecated", "kind": "Property", "detail": "Annotation", "sortText": "B", - "insertText": "serviceRemoteFunctionAnnotation2", + "insertText": "deprecated", "insertTextFormat": "Snippet", "additionalTextEdits": [] }, { - "label": "annotationCommon", + "label": "untainted", "kind": "Property", "detail": "Annotation", "sortText": "B", - "insertText": "annotationCommon {\n\tfoo: ${1:\"\"}\n}", + "insertText": "untainted", "insertTextFormat": "Snippet", "additionalTextEdits": [] }, { - "label": "a1", + "label": "strand", "kind": "Property", "detail": "Annotation", "sortText": "B", - "insertText": "a1 {\n\tfoo: ${1:\"\"}\n}", + "insertText": "strand", "insertTextFormat": "Snippet", "additionalTextEdits": [] }, @@ -207,172 +328,174 @@ "label": "a2", "kind": "Property", "detail": "Annotation", - "sortText": "B", + "sortText": "A", "insertText": "a2 {\n\tfoo: ${1:\"\"}\n}", "insertTextFormat": "Snippet", "additionalTextEdits": [] }, { - "label": "typeAnnotation1", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "typeAnnotation1 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "classAnnotation1", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "classAnnotation1 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "functionAnnotation1", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "functionAnnotation1 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "objectFunctionAnnotation1", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "objectFunctionAnnotation1 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "parameterAnnotation1", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "parameterAnnotation1 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "returnAnnotation1", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "returnAnnotation1 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "serviceAnnotation1", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "serviceAnnotation1 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "fieldAnnotation1", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "fieldAnnotation1 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "objectFieldAnnotation1", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "objectFieldAnnotation1 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "recordFieldAnnotation1", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "recordFieldAnnotation1 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "sourceAnnotationAnnotation1", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "sourceAnnotationAnnotation1 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "sourceExternalAnnotation1", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "sourceExternalAnnotation1 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "sourceVarAnnotation1", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "sourceVarAnnotation1 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "sourceConstAnnotation1", + "label": "annotationCommon", "kind": "Property", "detail": "Annotation", - "sortText": "B", - "insertText": "sourceConstAnnotation1 {\n\tfoo: ${1:\"\"}\n}", + "sortText": "A", + "insertText": "annotationCommon {\n\tfoo: ${1:\"\"}\n}", "insertTextFormat": "Snippet", "additionalTextEdits": [] }, { - "label": "sourceListenerAnnotation1", + "label": "a3", "kind": "Property", "detail": "Annotation", - "sortText": "B", - "insertText": "sourceListenerAnnotation1 {\n\tfoo: ${1:\"\"}\n}", + "sortText": "A", + "insertText": "a3 {\n\tfoo: ${1:\"\"}\n}", "insertTextFormat": "Snippet", "additionalTextEdits": [] }, { - "label": "sourceWorkerAnnotation1", + "label": "display", "kind": "Property", "detail": "Annotation", "sortText": "B", - "insertText": "sourceWorkerAnnotation1 {\n\tfoo: ${1:\"\"}\n}", + "insertText": "display {\n\tlabel: ${1:\"\"}\n}", "insertTextFormat": "Snippet", "additionalTextEdits": [] }, { - "label": "commonAnnotation2", + "label": "a1", "kind": "Property", "detail": "Annotation", - "sortText": "B", - "insertText": "commonAnnotation2 {\n\tfoo: ${1:\"\"}\n}", + "sortText": "A", + "insertText": "a1 {\n\tfoo: ${1:\"\"}\n}", "insertTextFormat": "Snippet", "additionalTextEdits": [] }, { - "label": "serviceRemoteFunctionAnnotation1", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "serviceRemoteFunctionAnnotation1 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] + "label": "test/project2", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "project2", + "insertText": "project2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/project2;\n" + } + ] + }, + { + "label": "test/project1", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "project1", + "insertText": "project1", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/project1;\n" + } + ] + }, + { + "label": "test/local_project2", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "local_project2", + "insertText": "local_project2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/local_project2;\n" + } + ] + }, + { + "label": "test/local_project1", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "local_project1", + "insertText": "local_project1", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/local_project1;\n" + } + ] + }, + { + "label": "function", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "ballerina/lang.regexp", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "regexp", + "insertText": "regexp", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.regexp;\n" + } + ] } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleLevelAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleLevelAnnotation2.json deleted file mode 100644 index b5f0e4dde164..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleLevelAnnotation2.json +++ /dev/null @@ -1,501 +0,0 @@ -{ - "position": { - "line": 13, - "character": 1 - }, - "source": "annotation_ctx/source/moduleLevelAnnotation2.bal", - "items": [ - { - "label": "ballerina/jballerina.java", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "java", - "insertText": "java", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/jballerina.java;\n" - } - ] - }, - { - "label": "ballerina/lang.value", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "value", - "insertText": "value", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.value;\n" - } - ] - }, - { - "label": "ballerina/lang.runtime", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "runtime", - "insertText": "runtime", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.runtime;\n" - } - ] - }, - { - "label": "ballerina/module1", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "module1", - "insertText": "module1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/module1;\n" - } - ] - }, - { - "label": "ballerina/lang.test", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "test", - "insertText": "test", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.test;\n" - } - ] - }, - { - "label": "ballerina/lang.array", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "array", - "insertText": "array", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.array;\n" - } - ] - }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, - { - "label": "map", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "map", - "insertTextFormat": "Snippet" - }, - { - "label": "object", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "object", - "insertTextFormat": "Snippet" - }, - { - "label": "stream", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "stream", - "insertTextFormat": "Snippet" - }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, - { - "label": "table", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "table", - "insertTextFormat": "Snippet" - }, - { - "label": "transaction", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "transaction", - "insertTextFormat": "Snippet" - }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, - { - "label": "tainted", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "tainted", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "builtinSubtype", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "builtinSubtype", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "typeParam", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "typeParam", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "isolatedParam", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "isolatedParam", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "deprecated", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "deprecated", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "untainted", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "untainted", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "strand", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "strand", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "a2", - "kind": "Property", - "detail": "Annotation", - "sortText": "A", - "insertText": "a2 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "annotationCommon", - "kind": "Property", - "detail": "Annotation", - "sortText": "A", - "insertText": "annotationCommon {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "a3", - "kind": "Property", - "detail": "Annotation", - "sortText": "A", - "insertText": "a3 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "display", - "kind": "Property", - "detail": "Annotation", - "sortText": "B", - "insertText": "display {\n\tlabel: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "a1", - "kind": "Property", - "detail": "Annotation", - "sortText": "A", - "insertText": "a1 {\n\tfoo: ${1:\"\"}\n}", - "insertTextFormat": "Snippet", - "additionalTextEdits": [] - }, - { - "label": "test/project2", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "project2", - "insertText": "project2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/project2;\n" - } - ] - }, - { - "label": "test/project1", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "project1", - "insertText": "project1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/project1;\n" - } - ] - }, - { - "label": "test/local_project2", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "local_project2", - "insertText": "local_project2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/local_project2;\n" - } - ] - }, - { - "label": "test/local_project1", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "local_project1", - "insertText": "local_project1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/local_project1;\n" - } - ] - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] - } - ] -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleLevelAnnotation1.bal b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleLevelAnnotation1.bal index 5c1fdf887cd2..73c7bf5a12c7 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleLevelAnnotation1.bal +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleLevelAnnotation1.bal @@ -1,3 +1,14 @@ -import ballerina/module1; +public type AnnotationType record { + string foo; + int bar?; +}; -@module1: \ No newline at end of file +public annotation AnnotationType annotationCommon; + +public annotation AnnotationType a1 on service; + +public annotation AnnotationType a2 on function; + +annotation AnnotationType a3 on service; + +@ \ No newline at end of file diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleLevelAnnotation2.bal b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleLevelAnnotation2.bal deleted file mode 100644 index 73c7bf5a12c7..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleLevelAnnotation2.bal +++ /dev/null @@ -1,14 +0,0 @@ -public type AnnotationType record { - string foo; - int bar?; -}; - -public annotation AnnotationType annotationCommon; - -public annotation AnnotationType a1 on service; - -public annotation AnnotationType a2 on function; - -annotation AnnotationType a3 on service; - -@ \ No newline at end of file diff --git a/project-api/project-api-test/build.gradle b/project-api/project-api-test/build.gradle index 76b1c4829a8c..e5e2d3b25fba 100644 --- a/project-api/project-api-test/build.gradle +++ b/project-api/project-api-test/build.gradle @@ -44,8 +44,6 @@ dependencies { testCompile project(':ballerina-lang') testRuntime project(':ballerina-runtime') testRuntime project(':project-api-test-artifact:logging-file-appender-plugin') - testRuntime project(':project-api-test-artifact:idl-client-gen-plugin') - testRuntime project(':project-api-test-artifact:idl-import-simple-compiler-plugin') testRuntime project(':compiler-plugins:package-semantic-analyzer') compilerPluginJar project(':project-api-test-artifact:event-logger-compiler-plugin') diff --git a/project-api/test-artifacts/idl-client-gen-plugin/build.gradle b/project-api/test-artifacts/idl-client-gen-plugin/build.gradle deleted file mode 100644 index f6404271646b..000000000000 --- a/project-api/test-artifacts/idl-client-gen-plugin/build.gradle +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -apply from: "$rootDir/gradle/javaProject.gradle" - -description = 'Compiler Plugin Tests - IDL Client Generator Plugin' -version = '1.0.0' - -dependencies { - implementation project(':ballerina-lang') - implementation project(':ballerina-parser') - implementation project(':ballerina-tools-api') -} - -ext.moduleName = 'compiler.plugin.test.idlclient.codegen' - -compileJava { - doFirst { - options.compilerArgs = [ - '--module-path', classpath.asPath, - ] - classpath = files() - } -} diff --git a/project-api/test-artifacts/idl-client-gen-plugin/src/main/java/io/asmaj/plugins/idlclient/OpenApiIDLGenPlugin.java b/project-api/test-artifacts/idl-client-gen-plugin/src/main/java/io/asmaj/plugins/idlclient/OpenApiIDLGenPlugin.java deleted file mode 100644 index f333b3fc5a1a..000000000000 --- a/project-api/test-artifacts/idl-client-gen-plugin/src/main/java/io/asmaj/plugins/idlclient/OpenApiIDLGenPlugin.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.asmaj.plugins.idlclient; - -import io.ballerina.compiler.syntax.tree.AnnotationNode; -import io.ballerina.compiler.syntax.tree.BasicLiteralNode; -import io.ballerina.compiler.syntax.tree.ClientDeclarationNode; -import io.ballerina.compiler.syntax.tree.ModuleClientDeclarationNode; -import io.ballerina.compiler.syntax.tree.Node; -import io.ballerina.compiler.syntax.tree.NodeList; -import io.ballerina.compiler.syntax.tree.SyntaxKind; -import io.ballerina.projects.DocumentConfig; -import io.ballerina.projects.DocumentId; -import io.ballerina.projects.ModuleConfig; -import io.ballerina.projects.ModuleDescriptor; -import io.ballerina.projects.ModuleId; -import io.ballerina.projects.ModuleName; -import io.ballerina.projects.plugins.IDLClientGenerator; -import io.ballerina.projects.plugins.IDLGeneratorPlugin; -import io.ballerina.projects.plugins.IDLPluginContext; -import io.ballerina.projects.plugins.IDLSourceGeneratorContext; - -import java.nio.file.Files; -import java.util.ArrayList; -import java.util.Collections; - -/** - * Simple IDL client generation test class. - * - * @since 2.3.0 - */ -public class OpenApiIDLGenPlugin extends IDLGeneratorPlugin { - @Override - public void init(IDLPluginContext pluginContext) { - pluginContext.addCodeGenerator(new OpenAPIClientGenerator()); - } - - private static class OpenAPIClientGenerator extends IDLClientGenerator { - - @Override - public boolean canHandle(IDLSourceGeneratorContext idlSourceGeneratorContext) { - String uri = getUri(idlSourceGeneratorContext.clientNode()); - if (Files.notExists(idlSourceGeneratorContext.resourcePath())) { - return false; - } - if (uri.endsWith("throwNPE")) { - throw new NullPointerException(); - } - if (uri.endsWith("throwRuntimeEx")) { - throw new RuntimeException("canHandle crashed"); - } - if (uri.endsWith("projectapiclientplugin.json")) { - return true; - } - if (uri.endsWith("throwUnhandledExInPerform")) { - return true; - } - return uri.equals("https://postman-echo.com/get?name=projectapiclientplugin"); - } - - public void perform(IDLSourceGeneratorContext idlSourceGeneratorContext) { - if (getUri(idlSourceGeneratorContext.clientNode()).endsWith("throwUnhandledExInPerform")) { - throw new RuntimeException("perform crashed"); - } - String moduleName = getAlias(idlSourceGeneratorContext.clientNode()); - ModuleId moduleId = ModuleId.create(moduleName, idlSourceGeneratorContext.currentPackage().packageId()); - DocumentId documentId = DocumentId.create("idl_client.bal", moduleId); - DocumentConfig documentConfig = getClientCode(documentId); - ModuleDescriptor moduleDescriptor = ModuleDescriptor.from( - ModuleName.from(idlSourceGeneratorContext.currentPackage().packageName(), moduleName), - idlSourceGeneratorContext.currentPackage().descriptor()); - ModuleConfig moduleConfig = ModuleConfig.from( - moduleId, moduleDescriptor, Collections.singletonList(documentConfig), - Collections.emptyList(), null, new ArrayList<>()); - - Node clientNode = idlSourceGeneratorContext.clientNode(); - NodeList annotations; - if (clientNode.kind() == SyntaxKind.MODULE_CLIENT_DECLARATION) { - annotations = ((ModuleClientDeclarationNode) clientNode).annotations(); - } else { - annotations = ((ClientDeclarationNode) clientNode).annotations(); - } - - idlSourceGeneratorContext.addClient(moduleConfig, annotations); - } - - private String getAlias(Node clientNode) { - if (clientNode.kind() == SyntaxKind.MODULE_CLIENT_DECLARATION) { - return ((ModuleClientDeclarationNode) clientNode).clientPrefix().toString(); - } - return ((ClientDeclarationNode) clientNode).clientPrefix().toString(); - } - - private String getUri(Node clientNode) { - BasicLiteralNode clientUri; - - if (clientNode.kind() == SyntaxKind.MODULE_CLIENT_DECLARATION) { - clientUri = ((ModuleClientDeclarationNode) clientNode).clientUri(); - } else { - clientUri = ((ClientDeclarationNode) clientNode).clientUri(); - } - - String text = clientUri.literalToken().text(); - return text.substring(1, text.length() - 1); - } - - private DocumentConfig getClientCode(DocumentId documentId) { - return DocumentConfig.from( - documentId, "public type ClientConfiguration record {\n" + - " string specVersion;\n" + - "};\n" + - "\n" + - "public isolated client class 'client {\n" + - " public final string specVersion;\n" + - "\n" + - " public function init(*ClientConfiguration config) {\n" + - " self.specVersion = config.specVersion;\n" + - " }\n" + - "\n" + - " remote function getSpecVersion() returns string {\n" + - " lock {\n" + - " return self.specVersion;\n" + - " }\n" + - " }\n" + - "\n" + - "}", "idl_client.bal"); - } - } -} diff --git a/project-api/test-artifacts/idl-client-gen-plugin/src/main/java/module-info.java b/project-api/test-artifacts/idl-client-gen-plugin/src/main/java/module-info.java deleted file mode 100644 index ed222d5772dd..000000000000 --- a/project-api/test-artifacts/idl-client-gen-plugin/src/main/java/module-info.java +++ /dev/null @@ -1,7 +0,0 @@ -module compiler.plugin.test.init.func.codemodify { - requires io.ballerina.lang; - requires io.ballerina.parser; - requires io.ballerina.tools.api; - - exports io.asmaj.plugins.idlclient; -} diff --git a/project-api/test-artifacts/idl-client-gen-plugin/src/main/resources/META-INF/services/io.ballerina.projects.plugins.IDLGeneratorPlugin b/project-api/test-artifacts/idl-client-gen-plugin/src/main/resources/META-INF/services/io.ballerina.projects.plugins.IDLGeneratorPlugin deleted file mode 100644 index 2751817b0955..000000000000 --- a/project-api/test-artifacts/idl-client-gen-plugin/src/main/resources/META-INF/services/io.ballerina.projects.plugins.IDLGeneratorPlugin +++ /dev/null @@ -1 +0,0 @@ -io.asmaj.plugins.idlclient.OpenApiIDLGenPlugin diff --git a/project-api/test-artifacts/idl-import-simple-compiler-plugin/build.gradle b/project-api/test-artifacts/idl-import-simple-compiler-plugin/build.gradle deleted file mode 100644 index a95ba77f100b..000000000000 --- a/project-api/test-artifacts/idl-import-simple-compiler-plugin/build.gradle +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -apply from: "$rootDir/gradle/javaProject.gradle" - -description = 'IDL Import Tests - Simple Client Plugin' -version = '1.0.0' - -dependencies { - implementation project(':ballerina-lang') - implementation project(':ballerina-parser') - implementation project(':ballerina-tools-api') -} - -ext.moduleName = 'simple.idl.client.plugin' - -compileJava { - doFirst { - options.compilerArgs = [ - '--module-path', classpath.asPath, - ] - classpath = files() - } -} - - diff --git a/project-api/test-artifacts/idl-import-simple-compiler-plugin/src/main/java/io/idl/plugins/simpleclient/SimpleClientGeneratorPlugin.java b/project-api/test-artifacts/idl-import-simple-compiler-plugin/src/main/java/io/idl/plugins/simpleclient/SimpleClientGeneratorPlugin.java deleted file mode 100644 index 28c542ce1660..000000000000 --- a/project-api/test-artifacts/idl-import-simple-compiler-plugin/src/main/java/io/idl/plugins/simpleclient/SimpleClientGeneratorPlugin.java +++ /dev/null @@ -1,240 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.idl.plugins.simpleclient; - -import io.ballerina.compiler.syntax.tree.AnnotationNode; -import io.ballerina.compiler.syntax.tree.BasicLiteralNode; -import io.ballerina.compiler.syntax.tree.ClientDeclarationNode; -import io.ballerina.compiler.syntax.tree.ModuleClientDeclarationNode; -import io.ballerina.compiler.syntax.tree.Node; -import io.ballerina.compiler.syntax.tree.NodeList; -import io.ballerina.compiler.syntax.tree.SyntaxKind; -import io.ballerina.projects.DocumentConfig; -import io.ballerina.projects.DocumentId; -import io.ballerina.projects.ModuleConfig; -import io.ballerina.projects.ModuleDescriptor; -import io.ballerina.projects.ModuleId; -import io.ballerina.projects.ModuleName; -import io.ballerina.projects.plugins.IDLClientGenerator; -import io.ballerina.projects.plugins.IDLGeneratorPlugin; -import io.ballerina.projects.plugins.IDLPluginContext; -import io.ballerina.projects.plugins.IDLSourceGeneratorContext; - -import java.util.ArrayList; -import java.util.Collections; - -/** - * Simple client generator plugin for compiler tests with client declarations. - * - * @since 2201.3.0 - */ -public class SimpleClientGeneratorPlugin extends IDLGeneratorPlugin { - @Override - public void init(IDLPluginContext pluginContext) { - pluginContext.addCodeGenerator(new SimpleClientGenerator()); - } - - private static class SimpleClientGenerator extends IDLClientGenerator { - - private int id = 1; - - @Override - public boolean canHandle(IDLSourceGeneratorContext idlSourceGeneratorContext) { - String uri = getUri(idlSourceGeneratorContext.clientNode()); - - if (uri.startsWith("https://postman-echo.com/get?name=simpleclienttest-disallow")) { - return false; - } - - return uri.startsWith("https://postman-echo.com/get?name=simpleclienttest"); - } - - @Override - public void perform(IDLSourceGeneratorContext idlSourceGeneratorContext) { - String module = "client" + id++; - ModuleId moduleId = ModuleId.create(module, idlSourceGeneratorContext.currentPackage().packageId()); - DocumentId documentId = DocumentId.create("simple_client", moduleId); - DocumentConfig documentConfig = getClientCode(documentId, getUri(idlSourceGeneratorContext.clientNode())); - ModuleDescriptor moduleDescriptor = ModuleDescriptor.from( - ModuleName.from(idlSourceGeneratorContext.currentPackage().packageName(), module), - idlSourceGeneratorContext.currentPackage().descriptor()); - ModuleConfig moduleConfig = ModuleConfig.from( - moduleId, moduleDescriptor, Collections.singletonList(documentConfig), - Collections.emptyList(), null, new ArrayList<>()); - - Node clientNode = idlSourceGeneratorContext.clientNode(); - NodeList annotations; - if (clientNode.kind() == SyntaxKind.MODULE_CLIENT_DECLARATION) { - annotations = ((ModuleClientDeclarationNode) clientNode).annotations(); - } else { - annotations = ((ClientDeclarationNode) clientNode).annotations(); - } - idlSourceGeneratorContext.addClient(moduleConfig, annotations); - } - - private String getUri(Node clientNode) { - BasicLiteralNode clientUri; - - if (clientNode.kind() == SyntaxKind.MODULE_CLIENT_DECLARATION) { - clientUri = ((ModuleClientDeclarationNode) clientNode).clientUri(); - } else { - clientUri = ((ClientDeclarationNode) clientNode).clientUri(); - } - - String text = clientUri.literalToken().text(); - return text.substring(1, text.length() - 1); - } - - private DocumentConfig getClientCode(DocumentId documentId, String uri) { - if (uri.startsWith("https://postman-echo.com/get?name=simpleclienttest-invalidgeneratedcode")) { - return getInvalidCode(documentId, uri); - } - - if ("https://postman-echo.com/get?name=simpleclienttest.yaml".equals(uri)) { - return DocumentConfig.from( - documentId, "public const DEFAULT_URL = \"http://www.example.com\";\n" + - "\n" + - "public type IntMap map;\n" + - "\n" + - "public type XmlElement xml:Element;\n" + - "\n" + - "public type ClientConfiguration record {\n" + - " string url?;\n" + - " int 'limit;\n" + - "};\n" + - "\n" + - "public isolated client class 'client {\n" + - " public final string url;\n" + - " private int 'limit;\n" + - "\n" + - " public function init(*ClientConfiguration config) {\n" + - " self.url = config.url ?: DEFAULT_URL;\n" + - " self.'limit = config.'limit;\n" + - " }\n" + - "\n" + - " remote function getLimit() returns int {\n" + - " lock {\n" + - " return self.'limit;\n" + - " }\n" + - " }\n" + - "\n" + - " remote function setLimit(int 'limit) {\n" + - " lock {\n" + - " self.'limit = 'limit;\n" + - " }\n" + - " }\n" + - "}", "simple_client.bal"); - } - - if ("https://postman-echo.com/get?name=simpleclienttest-clientobjecttype.yaml".equals(uri)) { - return DocumentConfig.from( - documentId, "public type 'client client object {\n" + - " int index;\n" + - "\n" + - " remote function getIndex() returns int;\n" + - "};\n" + - "\n" + - "public function fn() returns 'client {\n" + - " return client object {\n" + - " int index = 10;\n" + - "\n" + - " remote function getIndex() returns int => self.index;\n" + - " };\n" + - "}", "simple_client.bal"); - } - - return DocumentConfig.from( - documentId, "public type Config record {\n" + - " string url;\n" + - "};\n" + - "\n" + - "public isolated client class 'client {\n" + - " private string url;\n" + - "\n" + - " public function init(*Config config) {\n" + - " self.url = config.url;\n" + - " }\n" + - "\n" + - " remote function getUrl() returns string {\n" + - " lock {\n" + - " return self.url;\n" + - " }\n" + - " }\n" + - "}", "simple_client.bal"); - } - - private DocumentConfig getInvalidCode(DocumentId documentId, String uri) { - if (uri.equals("https://postman-echo.com/get?name=simpleclienttest-invalidgeneratedcode-one.yaml")) { - return DocumentConfig.from( - documentId, "public client class MyClientClass {\n" + - " remote function fn() {\n" + - "\n" + - " }\n" + - "}\n" + - "\n" + - "public type Client client object {\n" + - " remote function getId();\n" + - "};", "simple_client.bal"); - } - - if (uri.equals("https://postman-echo.com/get?name=simpleclienttest-invalidgeneratedcode-two.yaml")) { - return DocumentConfig.from( - documentId, "public class 'client { // Not a client class\n" + - " function fn() {\n" + - " \n" + - " }\n" + - "}", "simple_client.bal"); - } - - if (uri.equals("https://postman-echo.com/get?name=simpleclienttest-invalidgeneratedcode-three.yaml")) { - return DocumentConfig.from( - documentId, "public type 'client object { // Not a client object\n" + - " function fn();\n" + - "};", "simple_client.bal"); - } - - return DocumentConfig.from( - documentId, "const int A = 1; // OK\n" + - "\n" + - "const map B = {a: 1, b: A}; // OK\n" + - "\n" + - "final int c = 2; // OK\n" + - "\n" + - "final int[] & readonly d = [1, 2]; // OK\n" + - "\n" + - "final int[] e = [1, 2]; // error\n" + - "\n" + - "readonly & int[] f = [1, 2]; // error\n" + - "\n" + - "final var g = e; // error\n" + - "\n" + - "var h = f; // error\n" + - "\n" + - "final var i = d; // OK\n" + - "\n" + - "var j = d; // error\n" + - "\n" + - "public client class 'client {\n" + - " remote function fn() {\n" + - " \n" + - " }\n" + - "}\n", "simple_client.bal"); - } - } -} diff --git a/project-api/test-artifacts/idl-import-simple-compiler-plugin/src/main/java/module-info.java b/project-api/test-artifacts/idl-import-simple-compiler-plugin/src/main/java/module-info.java deleted file mode 100644 index 181b277ce378..000000000000 --- a/project-api/test-artifacts/idl-import-simple-compiler-plugin/src/main/java/module-info.java +++ /dev/null @@ -1,7 +0,0 @@ -module simple.idl.client.plugin { - requires io.ballerina.lang; - requires io.ballerina.parser; - requires io.ballerina.tools.api; - - exports io.idl.plugins.simpleclient; -} diff --git a/project-api/test-artifacts/idl-import-simple-compiler-plugin/src/main/resources/META-INF/services/io.ballerina.projects.plugins.IDLGeneratorPlugin b/project-api/test-artifacts/idl-import-simple-compiler-plugin/src/main/resources/META-INF/services/io.ballerina.projects.plugins.IDLGeneratorPlugin deleted file mode 100644 index f75930650d68..000000000000 --- a/project-api/test-artifacts/idl-import-simple-compiler-plugin/src/main/resources/META-INF/services/io.ballerina.projects.plugins.IDLGeneratorPlugin +++ /dev/null @@ -1 +0,0 @@ -io.idl.plugins.simpleclient.SimpleClientGeneratorPlugin diff --git a/settings.gradle b/settings.gradle index f11f02d5a257..5804057a2fed 100644 --- a/settings.gradle +++ b/settings.gradle @@ -128,8 +128,6 @@ include(':project-api-test-artifact:init-function-codegen-compiler-plugin') include(':project-api-test-artifact:init-function-code-modify-compiler-plugin') include(':project-api-test-artifact:simple-code-gen-plugin-with-resource-gen') include(':project-api-test-artifact:init-function-diagnostic-compiler-plugin') -include(':project-api-test-artifact:idl-client-gen-plugin') -include(':project-api-test-artifact:idl-import-simple-compiler-plugin') include(':identifier-util') //include(':ballerina-libs') @@ -154,8 +152,6 @@ project(':project-api-test-artifact:init-function-codegen-compiler-plugin').proj project(':project-api-test-artifact:init-function-code-modify-compiler-plugin').projectDir = file('project-api/test-artifacts/init-function-code-modify-compiler-plugin') project(':project-api-test-artifact:simple-code-gen-plugin-with-resource-gen').projectDir = file('project-api/test-artifacts/simple-code-gen-plugin-with-resource-gen') project(':project-api-test-artifact:init-function-diagnostic-compiler-plugin').projectDir = file('project-api/test-artifacts/init-function-diagnostic-compiler-plugin') -project(':project-api-test-artifact:idl-client-gen-plugin').projectDir = file('project-api/test-artifacts/idl-client-gen-plugin') -project(':project-api-test-artifact:idl-import-simple-compiler-plugin').projectDir = file('project-api/test-artifacts/idl-import-simple-compiler-plugin') project(':ballerina-lang:internal').projectDir = file('langlib/lang.__internal') project(':ballerina-lang:annotations').projectDir = file('langlib/lang.annotations') project(':ballerina-lang:jballerina.java').projectDir = file('langlib/jballerina.java') From c0e19efc7c583d89b9b2a39c5b030523fbc0ea40 Mon Sep 17 00:00:00 2001 From: Sasindu Alahakoon Date: Mon, 14 Nov 2022 11:00:17 +0530 Subject: [PATCH 080/450] Fix regex related changes and ls tests --- .../compiler/desugar/ClosureDesugar.java | 3 +- .../compiler/desugar/ParameterDesugar.java | 3 +- .../semantics/analyzer/CodeAnalyzer.java | 3 +- .../semantics/analyzer/DataflowAnalyzer.java | 3 +- .../semantics/analyzer/IsolationAnalyzer.java | 3 +- .../semantics/analyzer/SymbolResolver.java | 15 +- .../semantics/analyzer/TypeChecker.java | 3 +- .../semantics/model/types/BNeverType.java | 6 + .../client-decl/client_decl_source_15.bal | 3 - .../config/moduleLevelAnnotation1.json | 653 +++++++----------- .../config/moduleLevelAnnotation2.json | 501 ++++++++++++++ .../source/moduleLevelAnnotation1.bal | 15 +- .../source/moduleLevelAnnotation2.bal | 14 + 13 files changed, 801 insertions(+), 424 deletions(-) delete mode 100644 compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_15.bal create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleLevelAnnotation2.json create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleLevelAnnotation2.bal diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ClosureDesugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ClosureDesugar.java index 1982e7795f4e..8cbd27935aed 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ClosureDesugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ClosureDesugar.java @@ -1611,8 +1611,7 @@ public void visit(BLangDynamicArgExpr dynamicParamExpr) { @Override public void visit(BLangRegExpTemplateLiteral regExpTemplateLiteral) { List interpolationsList = - symResolver.getListOfInterpolations(regExpTemplateLiteral.reDisjunction.sequenceList, - new ArrayList<>()); + symResolver.getListOfInterpolations(regExpTemplateLiteral.reDisjunction.sequenceList); interpolationsList.forEach(this::rewriteExpr); result = regExpTemplateLiteral; } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ParameterDesugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ParameterDesugar.java index 3d2972c02064..03e0ff5f385b 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ParameterDesugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ParameterDesugar.java @@ -1463,8 +1463,7 @@ public void visit(BLangXMLSequenceLiteral xmlSequenceLiteral) { @Override public void visit(BLangRegExpTemplateLiteral regExpTemplateLiteral) { List interpolationsList = - symResolver.getListOfInterpolations(regExpTemplateLiteral.reDisjunction.sequenceList, - new ArrayList<>()); + symResolver.getListOfInterpolations(regExpTemplateLiteral.reDisjunction.sequenceList); interpolationsList.forEach(this::rewriteExpr); result = regExpTemplateLiteral; } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java index 097610841e40..88344d0d1a2a 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java @@ -3407,8 +3407,7 @@ public void visit(BLangAnnotAccessExpr annotAccessExpr, AnalyzerData data) { @Override public void visit(BLangRegExpTemplateLiteral regExpTemplateLiteral, AnalyzerData data) { List interpolationsList = - symResolver.getListOfInterpolations(regExpTemplateLiteral.reDisjunction.sequenceList, - new ArrayList<>()); + symResolver.getListOfInterpolations(regExpTemplateLiteral.reDisjunction.sequenceList); interpolationsList.forEach(interpolation -> analyzeExpr(interpolation, data)); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java index 1d6097399b95..4c2d217481f6 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java @@ -2195,8 +2195,7 @@ private void addUninitializedVar(BLangVariable variable) { @Override public void visit(BLangRegExpTemplateLiteral regExpTemplateLiteral) { List interpolationsList = - symResolver.getListOfInterpolations(regExpTemplateLiteral.reDisjunction.sequenceList, - new ArrayList<>()); + symResolver.getListOfInterpolations(regExpTemplateLiteral.reDisjunction.sequenceList); interpolationsList.forEach(interpolation -> analyzeNode(interpolation, env)); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/IsolationAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/IsolationAnalyzer.java index fdfa9bf93071..521ffe93eced 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/IsolationAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/IsolationAnalyzer.java @@ -2018,8 +2018,7 @@ public void visit(BLangClientDeclarationStatement clientDeclarationStatement) { @Override public void visit(BLangRegExpTemplateLiteral regExpTemplateLiteral) { List interpolationsList = - symResolver.getListOfInterpolations(regExpTemplateLiteral.reDisjunction.sequenceList, - new ArrayList<>()); + symResolver.getListOfInterpolations(regExpTemplateLiteral.reDisjunction.sequenceList); interpolationsList.forEach(interpolation -> analyzeNode(interpolation, env)); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolResolver.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolResolver.java index 02ee6f7510e0..7210b645853a 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolResolver.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolResolver.java @@ -472,10 +472,10 @@ public BSymbol resolvePrefixSymbol(SymbolEnv env, Name pkgAlias, Name compUnit) return symbol; } - if ((entry.symbol.tag & SymTag.IMPORT) == SymTag.IMPORT && - ((BPackageSymbol) entry.symbol).compUnit.equals(compUnit)) { - ((BPackageSymbol) entry.symbol).isUsed = true; - return entry.symbol; + if ((tag & SymTag.IMPORT) == SymTag.IMPORT && + ((BPackageSymbol) symbol).compUnit.equals(compUnit)) { + ((BPackageSymbol) symbol).isUsed = true; + return symbol; } entry = entry.next; @@ -2596,8 +2596,8 @@ public BPackageSymbol getModuleForPackageId(PackageID packageID) { .get(); } - public List getListOfInterpolations(List sequenceList, - List interpolationsList) { + public List getListOfInterpolations(List sequenceList) { + List interpolationsList = new ArrayList<>(); for (BLangExpression seq : sequenceList) { if (seq.getKind() != NodeKind.REG_EXP_SEQUENCE) { continue; @@ -2615,8 +2615,7 @@ public List getListOfInterpolations(List seque } if (kind == NodeKind.REG_EXP_CAPTURING_GROUP) { interpolationsList.addAll( - getListOfInterpolations(((BLangReCapturingGroups) atom).disjunction.sequenceList, - interpolationsList)); + getListOfInterpolations(((BLangReCapturingGroups) atom).disjunction.sequenceList)); } } } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java index c8a5d51751e4..23c9a0a08524 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java @@ -5829,8 +5829,7 @@ public void visit(BLangStringTemplateLiteral stringTemplateLiteral, AnalyzerData public void visit(BLangRegExpTemplateLiteral regExpTemplateLiteral, AnalyzerData data) { // Check expr with insertions to resolve its type. List interpolationsList = - symResolver.getListOfInterpolations(regExpTemplateLiteral.reDisjunction.sequenceList, - new ArrayList<>()); + symResolver.getListOfInterpolations(regExpTemplateLiteral.reDisjunction.sequenceList); interpolationsList.forEach(interpolation -> checkExpr(interpolation, data)); data.resultType = types.checkType(regExpTemplateLiteral, symTable.regExpType, data.expType); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/types/BNeverType.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/types/BNeverType.java index 8c1d28a85ec7..fd43d8e3d06f 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/types/BNeverType.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/types/BNeverType.java @@ -17,6 +17,7 @@ */ package org.wso2.ballerinalang.compiler.semantics.model.types; +import org.wso2.ballerinalang.compiler.semantics.model.TypeVisitor; import org.wso2.ballerinalang.compiler.util.Names; import org.wso2.ballerinalang.compiler.util.TypeTags; import org.wso2.ballerinalang.util.Flags; @@ -43,4 +44,9 @@ public boolean isNullable() { public String toString() { return Names.NEVER.value; } + + @Override + public void accept(TypeVisitor visitor) { + visitor.visit(this); + } } diff --git a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_15.bal b/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_15.bal deleted file mode 100644 index 429d96243406..000000000000 --- a/compiler/ballerina-parser/src/test/resources/declarations/client-decl/client_decl_source_15.bal +++ /dev/null @@ -1,3 +0,0 @@ -function fn() { -client "http://www.example.com/apis/one.yaml" as foo; -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleLevelAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleLevelAnnotation1.json index 4a8799408e42..0261e1d85e23 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleLevelAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleLevelAnnotation1.json @@ -1,326 +1,205 @@ { "position": { - "line": 13, - "character": 1 + "line": 2, + "character": 9 }, "source": "annotation_ctx/source/moduleLevelAnnotation1.bal", "items": [ { - "label": "ballerina/jballerina.java", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "java", - "insertText": "java", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/jballerina.java;\n" - } - ] - }, - { - "label": "ballerina/lang.value", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "value", - "insertText": "value", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.value;\n" - } - ] - }, - { - "label": "ballerina/lang.runtime", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "runtime", - "insertText": "runtime", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.runtime;\n" - } - ] - }, - { - "label": "ballerina/module1", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "module1", - "insertText": "module1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/module1;\n" - } - ] - }, - { - "label": "ballerina/lang.test", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "test", - "insertText": "test", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.test;\n" - } - ] - }, - { - "label": "ballerina/lang.array", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "array", - "insertText": "array", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.array;\n" - } - ] - }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" + "label": "typeAnnotation2", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "typeAnnotation2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "typeAnnotation3", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "typeAnnotation3", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "classAnnotation2", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "classAnnotation2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "classAnnotation3", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "classAnnotation3", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "functionAnnotation2", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "functionAnnotation2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] }, { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" + "label": "objectFunctionAnnotation2", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "objectFunctionAnnotation2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] }, { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" + "label": "parameterAnnotation2", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "parameterAnnotation2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] }, { - "label": "map", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "map", - "insertTextFormat": "Snippet" + "label": "returnAnnotation2", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "returnAnnotation2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] }, { - "label": "object", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "object", - "insertTextFormat": "Snippet" + "label": "serviceAnnotation2", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "serviceAnnotation2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] }, { - "label": "stream", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "stream", - "insertTextFormat": "Snippet" + "label": "fieldAnnotation2", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "fieldAnnotation2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] }, { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" + "label": "objectFieldAnnotation2", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "objectFieldAnnotation2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] }, { - "label": "table", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "table", - "insertTextFormat": "Snippet" + "label": "recordFieldAnnotation2", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "recordFieldAnnotation2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] }, { - "label": "transaction", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "transaction", - "insertTextFormat": "Snippet" + "label": "sourceAnnotationAnnotation2", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "sourceAnnotationAnnotation2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] }, { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" + "label": "sourceExternalAnnotation2", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "sourceExternalAnnotation2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] }, { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" + "label": "sourceVarAnnotation2", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "sourceVarAnnotation2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] }, { - "label": "tainted", + "label": "sourceConstAnnotation2", "kind": "Property", "detail": "Annotation", "sortText": "B", - "insertText": "tainted", + "insertText": "sourceConstAnnotation2", "insertTextFormat": "Snippet", "additionalTextEdits": [] }, { - "label": "builtinSubtype", + "label": "sourceListenerAnnotation2", "kind": "Property", "detail": "Annotation", "sortText": "B", - "insertText": "builtinSubtype", + "insertText": "sourceListenerAnnotation2", "insertTextFormat": "Snippet", "additionalTextEdits": [] }, { - "label": "typeParam", + "label": "sourceWorkerAnnotation2", "kind": "Property", "detail": "Annotation", "sortText": "B", - "insertText": "typeParam", + "insertText": "sourceWorkerAnnotation2", "insertTextFormat": "Snippet", "additionalTextEdits": [] }, { - "label": "isolatedParam", + "label": "commonAnnotation1", "kind": "Property", "detail": "Annotation", "sortText": "B", - "insertText": "isolatedParam", + "insertText": "commonAnnotation1", "insertTextFormat": "Snippet", "additionalTextEdits": [] }, { - "label": "deprecated", + "label": "serviceRemoteFunctionAnnotation2", "kind": "Property", "detail": "Annotation", "sortText": "B", - "insertText": "deprecated", + "insertText": "serviceRemoteFunctionAnnotation2", "insertTextFormat": "Snippet", "additionalTextEdits": [] }, { - "label": "untainted", + "label": "annotationCommon", "kind": "Property", "detail": "Annotation", "sortText": "B", - "insertText": "untainted", + "insertText": "annotationCommon {\n\tfoo: ${1:\"\"}\n}", "insertTextFormat": "Snippet", "additionalTextEdits": [] }, { - "label": "strand", + "label": "a1", "kind": "Property", "detail": "Annotation", "sortText": "B", - "insertText": "strand", + "insertText": "a1 {\n\tfoo: ${1:\"\"}\n}", "insertTextFormat": "Snippet", "additionalTextEdits": [] }, @@ -328,174 +207,172 @@ "label": "a2", "kind": "Property", "detail": "Annotation", - "sortText": "A", + "sortText": "B", "insertText": "a2 {\n\tfoo: ${1:\"\"}\n}", "insertTextFormat": "Snippet", "additionalTextEdits": [] }, { - "label": "annotationCommon", + "label": "typeAnnotation1", "kind": "Property", "detail": "Annotation", - "sortText": "A", - "insertText": "annotationCommon {\n\tfoo: ${1:\"\"}\n}", + "sortText": "B", + "insertText": "typeAnnotation1 {\n\tfoo: ${1:\"\"}\n}", "insertTextFormat": "Snippet", "additionalTextEdits": [] }, { - "label": "a3", + "label": "classAnnotation1", "kind": "Property", "detail": "Annotation", - "sortText": "A", - "insertText": "a3 {\n\tfoo: ${1:\"\"}\n}", + "sortText": "B", + "insertText": "classAnnotation1 {\n\tfoo: ${1:\"\"}\n}", "insertTextFormat": "Snippet", "additionalTextEdits": [] }, { - "label": "display", + "label": "functionAnnotation1", "kind": "Property", "detail": "Annotation", "sortText": "B", - "insertText": "display {\n\tlabel: ${1:\"\"}\n}", + "insertText": "functionAnnotation1 {\n\tfoo: ${1:\"\"}\n}", "insertTextFormat": "Snippet", "additionalTextEdits": [] }, { - "label": "a1", + "label": "objectFunctionAnnotation1", "kind": "Property", "detail": "Annotation", - "sortText": "A", - "insertText": "a1 {\n\tfoo: ${1:\"\"}\n}", + "sortText": "B", + "insertText": "objectFunctionAnnotation1 {\n\tfoo: ${1:\"\"}\n}", "insertTextFormat": "Snippet", "additionalTextEdits": [] }, { - "label": "test/project2", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "project2", - "insertText": "project2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/project2;\n" - } - ] - }, - { - "label": "test/project1", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "project1", - "insertText": "project1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/project1;\n" - } - ] - }, - { - "label": "test/local_project2", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "local_project2", - "insertText": "local_project2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/local_project2;\n" - } - ] - }, - { - "label": "test/local_project1", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "local_project1", - "insertText": "local_project1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/local_project1;\n" - } - ] - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] + "label": "parameterAnnotation1", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "parameterAnnotation1 {\n\tfoo: ${1:\"\"}\n}", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "returnAnnotation1", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "returnAnnotation1 {\n\tfoo: ${1:\"\"}\n}", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "serviceAnnotation1", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "serviceAnnotation1 {\n\tfoo: ${1:\"\"}\n}", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "fieldAnnotation1", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "fieldAnnotation1 {\n\tfoo: ${1:\"\"}\n}", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "objectFieldAnnotation1", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "objectFieldAnnotation1 {\n\tfoo: ${1:\"\"}\n}", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "recordFieldAnnotation1", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "recordFieldAnnotation1 {\n\tfoo: ${1:\"\"}\n}", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "sourceAnnotationAnnotation1", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "sourceAnnotationAnnotation1 {\n\tfoo: ${1:\"\"}\n}", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "sourceExternalAnnotation1", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "sourceExternalAnnotation1 {\n\tfoo: ${1:\"\"}\n}", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "sourceVarAnnotation1", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "sourceVarAnnotation1 {\n\tfoo: ${1:\"\"}\n}", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "sourceConstAnnotation1", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "sourceConstAnnotation1 {\n\tfoo: ${1:\"\"}\n}", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "sourceListenerAnnotation1", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "sourceListenerAnnotation1 {\n\tfoo: ${1:\"\"}\n}", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "sourceWorkerAnnotation1", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "sourceWorkerAnnotation1 {\n\tfoo: ${1:\"\"}\n}", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "commonAnnotation2", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "commonAnnotation2 {\n\tfoo: ${1:\"\"}\n}", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "serviceRemoteFunctionAnnotation1", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "serviceRemoteFunctionAnnotation1 {\n\tfoo: ${1:\"\"}\n}", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleLevelAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleLevelAnnotation2.json new file mode 100644 index 000000000000..b5f0e4dde164 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleLevelAnnotation2.json @@ -0,0 +1,501 @@ +{ + "position": { + "line": 13, + "character": 1 + }, + "source": "annotation_ctx/source/moduleLevelAnnotation2.bal", + "items": [ + { + "label": "ballerina/jballerina.java", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "java", + "insertText": "java", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/jballerina.java;\n" + } + ] + }, + { + "label": "ballerina/lang.value", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "value", + "insertText": "value", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.value;\n" + } + ] + }, + { + "label": "ballerina/lang.runtime", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "runtime", + "insertText": "runtime", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.runtime;\n" + } + ] + }, + { + "label": "ballerina/module1", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "module1", + "insertText": "module1", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/module1;\n" + } + ] + }, + { + "label": "ballerina/lang.test", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "test", + "insertText": "test", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.test;\n" + } + ] + }, + { + "label": "ballerina/lang.array", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "array", + "insertText": "array", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.array;\n" + } + ] + }, + { + "label": "boolean", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "map", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "map", + "insertTextFormat": "Snippet" + }, + { + "label": "object", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "object", + "insertTextFormat": "Snippet" + }, + { + "label": "stream", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "stream", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "table", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "table", + "insertTextFormat": "Snippet" + }, + { + "label": "transaction", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "transaction", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "tainted", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "tainted", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "builtinSubtype", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "builtinSubtype", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "typeParam", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "typeParam", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "isolatedParam", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "isolatedParam", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "deprecated", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "deprecated", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "untainted", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "untainted", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "strand", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "strand", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "a2", + "kind": "Property", + "detail": "Annotation", + "sortText": "A", + "insertText": "a2 {\n\tfoo: ${1:\"\"}\n}", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "annotationCommon", + "kind": "Property", + "detail": "Annotation", + "sortText": "A", + "insertText": "annotationCommon {\n\tfoo: ${1:\"\"}\n}", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "a3", + "kind": "Property", + "detail": "Annotation", + "sortText": "A", + "insertText": "a3 {\n\tfoo: ${1:\"\"}\n}", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "display", + "kind": "Property", + "detail": "Annotation", + "sortText": "B", + "insertText": "display {\n\tlabel: ${1:\"\"}\n}", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "a1", + "kind": "Property", + "detail": "Annotation", + "sortText": "A", + "insertText": "a1 {\n\tfoo: ${1:\"\"}\n}", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "test/project2", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "project2", + "insertText": "project2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/project2;\n" + } + ] + }, + { + "label": "test/project1", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "project1", + "insertText": "project1", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/project1;\n" + } + ] + }, + { + "label": "test/local_project2", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "local_project2", + "insertText": "local_project2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/local_project2;\n" + } + ] + }, + { + "label": "test/local_project1", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "local_project1", + "insertText": "local_project1", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/local_project1;\n" + } + ] + }, + { + "label": "function", + "kind": "Unit", + "detail": "type", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "ballerina/lang.regexp", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "regexp", + "insertText": "regexp", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.regexp;\n" + } + ] + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleLevelAnnotation1.bal b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleLevelAnnotation1.bal index 73c7bf5a12c7..5c1fdf887cd2 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleLevelAnnotation1.bal +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleLevelAnnotation1.bal @@ -1,14 +1,3 @@ -public type AnnotationType record { - string foo; - int bar?; -}; +import ballerina/module1; -public annotation AnnotationType annotationCommon; - -public annotation AnnotationType a1 on service; - -public annotation AnnotationType a2 on function; - -annotation AnnotationType a3 on service; - -@ \ No newline at end of file +@module1: \ No newline at end of file diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleLevelAnnotation2.bal b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleLevelAnnotation2.bal new file mode 100644 index 000000000000..73c7bf5a12c7 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/source/moduleLevelAnnotation2.bal @@ -0,0 +1,14 @@ +public type AnnotationType record { + string foo; + int bar?; +}; + +public annotation AnnotationType annotationCommon; + +public annotation AnnotationType a1 on service; + +public annotation AnnotationType a2 on function; + +annotation AnnotationType a3 on service; + +@ \ No newline at end of file From 42c9a8c0649c6e9499a9ad2376e24be84576c2af Mon Sep 17 00:00:00 2001 From: Gayal Dassanayake Date: Tue, 22 Nov 2022 17:38:19 +0530 Subject: [PATCH 081/450] Add tests for Function Mocking negative test cases --- .../core/MockAnnotationProcessor.java | 2 +- .../InvalidFunctionMockingTestCase.java | 69 +++++++++++++++++++ .../incompatible-type-mock/Ballerina.toml | 5 ++ .../incompatible-type-mock/main.bal | 6 ++ .../incompatible-type-mock/tests/test.bal | 8 +++ .../non-existent-function-mock/Ballerina.toml | 5 ++ .../non-existent-function-mock/main.bal | 2 + .../non-existent-function-mock/tests/test.bal | 8 +++ .../non-existent-module-mock/Ballerina.toml | 4 ++ .../non-existent-module-mock/main.bal | 6 ++ .../non-existent-module-mock/tests/test.bal | 9 +++ .../src/test/resources/testng.xml | 1 + 12 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/negative/InvalidFunctionMockingTestCase.java create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/incompatible-type-mock/Ballerina.toml create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/incompatible-type-mock/main.bal create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/incompatible-type-mock/tests/test.bal create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-function-mock/Ballerina.toml create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-function-mock/main.bal create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-function-mock/tests/test.bal create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-module-mock/Ballerina.toml create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-module-mock/main.bal create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-module-mock/tests/test.bal diff --git a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java index b5f1900f1ea2..beaaa093b3ea 100644 --- a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java +++ b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java @@ -207,7 +207,7 @@ public void process(FunctionNode functionNode, List an PackageID functionToMockID = getPackageID(vals[0]); if (functionToMockID == null) { diagnosticLog.logDiagnostic(DiagnosticSeverity.ERROR, attachmentNode.getPosition(), - "could not find module specified "); + "could not find module specified"); break; } diff --git a/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/negative/InvalidFunctionMockingTestCase.java b/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/negative/InvalidFunctionMockingTestCase.java new file mode 100644 index 000000000000..372ce44c02e4 --- /dev/null +++ b/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/negative/InvalidFunctionMockingTestCase.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.ballerinalang.testerina.test.negative; + +import org.ballerinalang.test.context.BMainInstance; +import org.ballerinalang.test.context.BallerinaTestException; +import org.ballerinalang.testerina.test.BaseTestCase; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.util.HashMap; + +import static org.testng.Assert.assertEquals; + +/** + * Negative test cases for function mocking. + */ +public class InvalidFunctionMockingTestCase extends BaseTestCase { + private BMainInstance balClient; + + @BeforeClass + public void setup() throws BallerinaTestException { + balClient = new BMainInstance(balServer); + } + + @Test + public void testMockingNonExistingFunction() throws BallerinaTestException { + String projectPath = projectBasedTestsPath.resolve("non-existent-function-mock").toString(); + String output = balClient.runMainAndReadStdOut("test", new String[0], new HashMap<>(), projectPath, true); + assertEquals(output.replaceAll("\r", ""), + "ERROR [tests/test.bal:(3:1,5:2)] could not find functions in module\n" + + "error: compilation contains errors"); + } + + @Test + public void testMockingAFunctionInNonExistingModule() throws BallerinaTestException { + String projectPath = projectBasedTestsPath.resolve("non-existent-module-mock").toString(); + String output = balClient.runMainAndReadStdOut("test", new String[0], new HashMap<>(), projectPath, true); + assertEquals(output.replaceAll("\r", ""), + "ERROR [tests/test.bal:(3:1,6:2)] could not find module specified\n" + + "error: compilation contains errors"); + } + + @Test + public void testMockingAFunctionWithIncompatibleTypes() throws BallerinaTestException { + String projectPath = projectBasedTestsPath.resolve("incompatible-type-mock").toString(); + String output = balClient.runMainAndReadStdOut("test", new String[0], new HashMap<>(), projectPath, true); + assertEquals(output.replaceAll("\r", ""), + "ERROR [tests/test.bal:(6:1,8:2)] incompatible types: expected isolated function () returns (string) " + + "but found isolated function () returns (int)\n" + + "error: compilation contains errors"); + } +} diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/incompatible-type-mock/Ballerina.toml b/tests/testerina-integration-test/src/test/resources/project-based-tests/incompatible-type-mock/Ballerina.toml new file mode 100644 index 000000000000..41726bc3705a --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/incompatible-type-mock/Ballerina.toml @@ -0,0 +1,5 @@ +[package] +org = "intg_tests" +name = "incompatible_type_mock" +version = "0.1.0" + diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/incompatible-type-mock/main.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/incompatible-type-mock/main.bal new file mode 100644 index 000000000000..c89f90dcf480 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/incompatible-type-mock/main.bal @@ -0,0 +1,6 @@ +public function main() { +} + +function createJdbcClient() returns string { + return "real client"; +} diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/incompatible-type-mock/tests/test.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/incompatible-type-mock/tests/test.bal new file mode 100644 index 000000000000..41a42c1db85f --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/incompatible-type-mock/tests/test.bal @@ -0,0 +1,8 @@ +import ballerina/test; + +@test:Mock { + functionName: "createJdbcClient" +} +function getMockClient() returns int { + return 1; +} diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-function-mock/Ballerina.toml b/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-function-mock/Ballerina.toml new file mode 100644 index 000000000000..0408e0d7c8c3 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-function-mock/Ballerina.toml @@ -0,0 +1,5 @@ +[package] +org = "intg_tests" +name = "non_existent_function_mock" +version = "0.1.0" + diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-function-mock/main.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-function-mock/main.bal new file mode 100644 index 000000000000..6b71ef415c69 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-function-mock/main.bal @@ -0,0 +1,2 @@ +public function main() { +} diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-function-mock/tests/test.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-function-mock/tests/test.bal new file mode 100644 index 000000000000..1e6f0b860dd7 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-function-mock/tests/test.bal @@ -0,0 +1,8 @@ +import ballerina/test; + +@test:Mock { + functionName: "createJdbcClient" +} +function getMockClient() returns string { + return "client"; +} diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-module-mock/Ballerina.toml b/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-module-mock/Ballerina.toml new file mode 100644 index 000000000000..3779a856faa1 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-module-mock/Ballerina.toml @@ -0,0 +1,4 @@ +[package] +org = "intg_tests" +name = "non_existent_module_mock" +version = "0.1.0" diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-module-mock/main.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-module-mock/main.bal new file mode 100644 index 000000000000..c89f90dcf480 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-module-mock/main.bal @@ -0,0 +1,6 @@ +public function main() { +} + +function createJdbcClient() returns string { + return "real client"; +} diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-module-mock/tests/test.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-module-mock/tests/test.bal new file mode 100644 index 000000000000..198438bf1b6c --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-module-mock/tests/test.bal @@ -0,0 +1,9 @@ +import ballerina/test; + +@test:Mock { + moduleName: "module1", + functionName: "createJdbcClient" +} +function getMockClient() returns string { + return "client"; +} diff --git a/tests/testerina-integration-test/src/test/resources/testng.xml b/tests/testerina-integration-test/src/test/resources/testng.xml index baf72311373e..1b14658d945d 100644 --- a/tests/testerina-integration-test/src/test/resources/testng.xml +++ b/tests/testerina-integration-test/src/test/resources/testng.xml @@ -32,6 +32,7 @@ under the License. + From 240221d2d79385a63ca23f906083a3dcaa420e83 Mon Sep 17 00:00:00 2001 From: gabilang Date: Tue, 22 Nov 2022 20:59:40 +0530 Subject: [PATCH 082/450] Add missing visitTypedesc instruction --- .../ballerinalang/compiler/bir/BIRGen.java | 15 +- .../bir/codegen/JvmInstructionGen.java | 4 +- .../compiler/bir/emit/InstructionEmitter.java | 10 +- .../compiler/bir/model/BIRNonTerminator.java | 16 +- .../compiler/bir/optimizer/BIROptimizer.java | 4 +- .../bir/writer/BIRInstructionWriter.java | 4 +- .../test-src/bir/bir-dump/failLockWithinLock | 7 +- .../resources/test-src/bir/bir-dump/mapInits | 177 +++++++++--------- 8 files changed, 129 insertions(+), 108 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java index f99a65284b7f..df4bfd79dccf 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java @@ -1647,6 +1647,10 @@ public void visit(BLangSimpleVarRef.BLangFieldVarRef fieldVarRef) { @Override public void visit(BLangArrayLiteral astArrayLiteralExpr) { + BType bType = astArrayLiteralExpr.getBType(); + if (bType.tag == TypeTags.TUPLE) { + visitTypedesc(astArrayLiteralExpr.pos, bType, Collections.emptyList()); + } generateListConstructorExpr(astArrayLiteralExpr); } @@ -1663,6 +1667,10 @@ public void visit(BLangGroupExpr groupExpr) { @Override public void visit(BLangJSONArrayLiteral jsonArrayLiteralExpr) { + BType bType = jsonArrayLiteralExpr.getBType(); + if (bType.tag == TypeTags.TUPLE) { + visitTypedesc(jsonArrayLiteralExpr.pos, bType, Collections.emptyList()); + } generateListConstructorExpr(jsonArrayLiteralExpr); } @@ -2653,16 +2661,17 @@ private void generateListConstructorExpr(BLangListConstructorExpr listConstructo BIROperand toVarRef = new BIROperand(tempVarDcl); long size = -1L; + BIROperand typedescOp = null; List exprs = listConstructorExpr.exprs; BType listConstructorExprType = Types.getReferredType(listConstructorExpr.getBType()); if (listConstructorExprType.tag == TypeTags.ARRAY && ((BArrayType) listConstructorExprType).state != BArrayState.OPEN) { size = ((BArrayType) listConstructorExprType).size; } else if (listConstructorExprType.tag == TypeTags.TUPLE) { + typedescOp = this.env.targetOperand; size = exprs.size(); } - BIROperand rhsOp = this.env.targetOperand; BLangLiteral literal = new BLangLiteral(); literal.pos = listConstructorExpr.pos; literal.value = size; @@ -2685,8 +2694,8 @@ private void generateListConstructorExpr(BLangListConstructorExpr listConstructo if (listConstructorExprType.tag == TypeTags.TUPLE) { setScopeAndEmit( - new BIRNonTerminator.NewArray(listConstructorExpr.pos, listConstructorExprType, toVarRef, rhsOp, - sizeOp, initialValues)); + new BIRNonTerminator.NewArray(listConstructorExpr.pos, listConstructorExprType, toVarRef, + typedescOp, sizeOp, initialValues)); } else { setScopeAndEmit( new BIRNonTerminator.NewArray(listConstructorExpr.pos, listConstructorExprType, toVarRef, sizeOp, diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java index 3466511ec679..8396c0881c3d 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java @@ -157,7 +157,6 @@ import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TABLE_UTILS; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TABLE_VALUE; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TABLE_VALUE_IMPL; -import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TUPLE_VALUE_IMPL; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TYPEDESC_VALUE; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TYPEDESC_VALUE_IMPL; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TYPE_CHECKER; @@ -221,7 +220,6 @@ import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.INIT_LIST_INITIAL_SPREAD_ENTRY; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.INIT_MAPPING_INITIAL_SPREAD_FIELD_ENTRY; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.INIT_TABLE_VALUE_IMPL; -import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.INIT_TUPLE; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.INIT_WITH_STRING; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.INIT_XML_QNAME; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.INSTANTIATE; @@ -1532,7 +1530,7 @@ void generateArrayNewIns(BIRNonTerminator.NewArray inst, int localVarOffset) { } this.storeToVar(inst.lhsOp.variableDcl); } else { - this.loadVar(inst.rhsOp.variableDcl); + this.loadVar(inst.typedescOp.variableDcl); this.mv.visitVarInsn(ALOAD, localVarOffset); loadListInitialValues(inst); this.mv.visitMethodInsn(INVOKEINTERFACE, TYPEDESC_VALUE, "instantiate", INSTANTIATE, true); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/emit/InstructionEmitter.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/emit/InstructionEmitter.java index b5ed9368d5e9..ce9840ef83f4 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/emit/InstructionEmitter.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/emit/InstructionEmitter.java @@ -23,6 +23,9 @@ import org.wso2.ballerinalang.compiler.bir.model.BIROperand; import org.wso2.ballerinalang.compiler.bir.model.BIRTerminator; import org.wso2.ballerinalang.compiler.bir.model.InstructionKind; +import org.wso2.ballerinalang.compiler.semantics.analyzer.Types; +import org.wso2.ballerinalang.compiler.semantics.model.types.BType; +import org.wso2.ballerinalang.compiler.util.TypeTags; import java.util.List; import java.util.stream.Collectors; @@ -206,7 +209,12 @@ private static String emitInsNewArray(BIRNonTerminator.NewArray ins, int tabs) { str += emitSpaces(1); str += "newArray"; str += emitSpaces(1); - str += emitTypeRef(ins.type, 0); + BType type = Types.getReferredType(ins.type); + if (type.tag == TypeTags.TUPLE) { + str += emitVarRef(ins.typedescOp); + } else { + str += emitTypeRef(ins.type, 0); + } str += "["; str += emitVarRef(ins.sizeOp); str += "]"; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/model/BIRNonTerminator.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/model/BIRNonTerminator.java index 0f08f1fd1b2a..acf2df8dcfca 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/model/BIRNonTerminator.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/model/BIRNonTerminator.java @@ -284,10 +284,10 @@ public BIROperand[] getRhsOperands() { * @since 0.980.0 */ public static class NewArray extends BIRNonTerminator { + public BIROperand typedescOp; public BIROperand sizeOp; public BType type; public List values; - public BIROperand rhsOp; public NewArray(Location location, BType type, BIROperand lhsOp, BIROperand sizeOp, List values) { @@ -298,10 +298,10 @@ public NewArray(Location location, BType type, BIROperand lhsOp, BIROperand size this.values = values; } - public NewArray(Location location, BType type, BIROperand lhsOp, BIROperand rhsOp, BIROperand sizeOp, + public NewArray(Location location, BType type, BIROperand lhsOp, BIROperand typedescOp, BIROperand sizeOp, List values) { this(location, type, lhsOp, sizeOp, values); - this.rhsOp = rhsOp; + this.typedescOp = typedescOp; } @Override @@ -311,14 +311,18 @@ public void accept(BIRVisitor visitor) { @Override public BIROperand[] getRhsOperands() { - BIROperand[] operands = new BIROperand[values.size() + 1]; int i = 0; - operands[i++] = rhsOp; + BIROperand[] operands; + if (typedescOp != null) { + operands = new BIROperand[values.size() + 2]; + operands[i++] = typedescOp; + } else { + operands = new BIROperand[values.size() + 1]; + } operands[i++] = sizeOp; for (BIRListConstructorEntry listValueEntry : values) { operands[i++] = listValueEntry.exprOp; } - operands = Arrays.copyOf(operands, i); return operands; } } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/optimizer/BIROptimizer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/optimizer/BIROptimizer.java index c329fed2c0c6..e2c200f3264a 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/optimizer/BIROptimizer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/optimizer/BIROptimizer.java @@ -525,8 +525,8 @@ public void visit(BIRNonTerminator.NewArray birNewArray) { for (BIRNode.BIRListConstructorEntry listValueEntry : birNewArray.values) { this.optimizeNode(listValueEntry.exprOp, this.env); } - if (birNewArray.rhsOp != null) { - birNewArray.rhsOp.accept(this); + if (birNewArray.typedescOp != null) { + birNewArray.typedescOp.accept(this); } } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/writer/BIRInstructionWriter.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/writer/BIRInstructionWriter.java index 1a58d5ad829e..e86f7060684b 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/writer/BIRInstructionWriter.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/writer/BIRInstructionWriter.java @@ -386,8 +386,8 @@ public void visit(BIRNonTerminator.NewInstance newInstance) { public void visit(NewArray birNewArray) { writeType(birNewArray.type); - if (birNewArray.rhsOp != null) { - birNewArray.rhsOp.accept(this); + if (birNewArray.typedescOp != null) { + birNewArray.typedescOp.accept(this); } birNewArray.lhsOp.accept(this); birNewArray.sizeOp.accept(this); diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/bir/bir-dump/failLockWithinLock b/tests/jballerina-unit-test/src/test/resources/test-src/bir/bir-dump/failLockWithinLock index 167553340ef2..b1ddbf4699f7 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/bir/bir-dump/failLockWithinLock +++ b/tests/jballerina-unit-test/src/test/resources/test-src/bir/bir-dump/failLockWithinLock @@ -14,7 +14,7 @@ failLockWithinLock function() -> (int, string) { %22(TEMP) string; %23(TEMP) map; %24(LOCAL) error; - %40(TEMP) int; + %41(TEMP) int; bb0 { lock -> bb1; @@ -100,8 +100,9 @@ failLockWithinLock function() -> (int, string) { panic %12; } bb19 { - %40 = ConstLoad 2; - %0 = newArray (int, string)[%40]; + %19 = newType (int, string); + %41 = ConstLoad 2; + %0 = newArray %19[%41]; GOTO bb20; } bb20 { diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/bir/bir-dump/mapInits b/tests/jballerina-unit-test/src/test/resources/test-src/bir/bir-dump/mapInits index e095c1ac1c48..eb8f90d74fb2 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/bir/bir-dump/mapInits +++ b/tests/jballerina-unit-test/src/test/resources/test-src/bir/bir-dump/mapInits @@ -10,31 +10,31 @@ mapInits function() -> (string|(), int|()) { %11(TEMP) string; %12(TEMP) string; %13(TEMP) Employee; - %19(SYNTHETIC) string|(); - %20(SYNTHETIC) Employee|(); - %24(SYNTHETIC) Employee|(); - %26(SYNTHETIC) boolean; + %20(SYNTHETIC) string|(); + %21(SYNTHETIC) Employee|(); + %25(SYNTHETIC) Employee|(); %27(SYNTHETIC) boolean; - %28(SYNTHETIC) any|error; - %29(TEMP) boolean; - %41(SYNTHETIC) boolean; + %28(SYNTHETIC) boolean; + %29(SYNTHETIC) any|error; + %30(TEMP) boolean; %42(SYNTHETIC) boolean; - %43(SYNTHETIC) any|error; - %59(SYNTHETIC) boolean; + %43(SYNTHETIC) boolean; + %44(SYNTHETIC) any|error; %60(SYNTHETIC) boolean; - %70(TEMP) (); - %72(SYNTHETIC) int|(); - %73(SYNTHETIC) Employee|(); - %77(SYNTHETIC) Employee|(); - %79(SYNTHETIC) boolean; + %61(SYNTHETIC) boolean; + %71(TEMP) (); + %73(SYNTHETIC) int|(); + %74(SYNTHETIC) Employee|(); + %78(SYNTHETIC) Employee|(); %80(SYNTHETIC) boolean; - %81(SYNTHETIC) any|error; - %94(SYNTHETIC) boolean; + %81(SYNTHETIC) boolean; + %82(SYNTHETIC) any|error; %95(SYNTHETIC) boolean; - %96(SYNTHETIC) any|error; - %108(TEMP) int; - %112(SYNTHETIC) boolean; + %96(SYNTHETIC) boolean; + %97(SYNTHETIC) any|error; + %109(TEMP) int; %113(SYNTHETIC) boolean; + %114(SYNTHETIC) boolean; bb0 { %2 = newType map; @@ -50,206 +50,207 @@ mapInits function() -> (string|(), int|()) { %13 = %4; %7 = ConstLoad jack; %1[%7] = %13; + %2 = newType (string|(), int|()); %10 = ConstLoad 2; %8 = ConstLoad jack; - %20 = %1[%8]; - %24 = %20; - %29 = ConstLoad true; - %29? bb1 : bb2; + %21 = %1[%8]; + %25 = %21; + %30 = ConstLoad true; + %30? bb1 : bb2; } bb1 { - %27 = ConstLoad true; - %28 = %24; + %28 = ConstLoad true; + %29 = %25; GOTO bb3; } bb2 { - %27 = ConstLoad false; + %28 = ConstLoad false; GOTO bb3; } bb3 { - %27? bb4 : bb5; + %28? bb4 : bb5; } bb4 { - %26 = %28 is (); + %27 = %29 is (); GOTO bb6; } bb5 { - %26 = ConstLoad false; + %27 = ConstLoad false; GOTO bb6; } bb6 { - %26? bb7 : bb8; + %27? bb7 : bb8; } bb7 { - %19 = %28; + %20 = %29; GOTO bb24; } bb8 { - %29 = ConstLoad true; - %29? bb9 : bb10; + %30 = ConstLoad true; + %30? bb9 : bb10; } bb9 { - %42 = ConstLoad true; - %43 = %24; + %43 = ConstLoad true; + %44 = %25; GOTO bb11; } bb10 { - %42 = ConstLoad false; + %43 = ConstLoad false; GOTO bb11; } bb11 { - %42? bb12 : bb13; + %43? bb12 : bb13; } bb12 { - %41 = %43 is Employee; + %42 = %44 is Employee; GOTO bb14; } bb13 { - %41 = ConstLoad false; + %42 = ConstLoad false; GOTO bb14; } bb14 { - %41? bb15 : bb16; + %42? bb15 : bb16; } bb15 { - %13 = %43; + %13 = %44; %9 = ConstLoad name; %11 = %13[%9]; - %19 = %11; + %20 = %11; GOTO bb24; } bb16 { - %29 = ConstLoad true; - %29? bb17 : bb18; + %30 = ConstLoad true; + %30? bb17 : bb18; } bb17 { - %60 = ConstLoad true; + %61 = ConstLoad true; GOTO bb19; } bb18 { - %60 = %24 is any; + %61 = %25 is any; GOTO bb19; } bb19 { - %60? bb20 : bb21; + %61? bb20 : bb21; } bb20 { - %59 = ConstLoad true; + %60 = ConstLoad true; GOTO bb22; } bb21 { - %59 = ConstLoad false; + %60 = ConstLoad false; GOTO bb22; } bb22 { - %59? bb23 : bb24; + %60? bb23 : bb24; } bb23 { - %70 = ConstLoad 0; - %19 = %70; + %71 = ConstLoad 0; + %20 = %71; GOTO bb24; } bb24 { %12 = ConstLoad jack; - %73 = %1[%12]; - %77 = %73; - %29 = ConstLoad true; - %29? bb25 : bb26; + %74 = %1[%12]; + %78 = %74; + %30 = ConstLoad true; + %30? bb25 : bb26; } bb25 { - %80 = ConstLoad true; - %81 = %77; + %81 = ConstLoad true; + %82 = %78; GOTO bb27; } bb26 { - %80 = ConstLoad false; + %81 = ConstLoad false; GOTO bb27; } bb27 { - %80? bb28 : bb29; + %81? bb28 : bb29; } bb28 { - %79 = %81 is (); + %80 = %82 is (); GOTO bb30; } bb29 { - %79 = ConstLoad false; + %80 = ConstLoad false; GOTO bb30; } bb30 { - %79? bb31 : bb32; + %80? bb31 : bb32; } bb31 { - %72 = %81; + %73 = %82; GOTO bb48; } bb32 { - %29 = ConstLoad true; - %29? bb33 : bb34; + %30 = ConstLoad true; + %30? bb33 : bb34; } bb33 { - %95 = ConstLoad true; - %96 = %77; + %96 = ConstLoad true; + %97 = %78; GOTO bb35; } bb34 { - %95 = ConstLoad false; + %96 = ConstLoad false; GOTO bb35; } bb35 { - %95? bb36 : bb37; + %96? bb36 : bb37; } bb36 { - %94 = %96 is Employee; + %95 = %97 is Employee; GOTO bb38; } bb37 { - %94 = ConstLoad false; + %95 = ConstLoad false; GOTO bb38; } bb38 { - %94? bb39 : bb40; + %95? bb39 : bb40; } bb39 { - %13 = %96; + %13 = %97; %7 = ConstLoad age; - %108 = %13[%7]; - %72 = %108; + %109 = %13[%7]; + %73 = %109; GOTO bb48; } bb40 { - %29 = ConstLoad true; - %29? bb41 : bb42; + %30 = ConstLoad true; + %30? bb41 : bb42; } bb41 { - %113 = ConstLoad true; + %114 = ConstLoad true; GOTO bb43; } bb42 { - %113 = %77 is any; + %114 = %78 is any; GOTO bb43; } bb43 { - %113? bb44 : bb45; + %114? bb44 : bb45; } bb44 { - %112 = ConstLoad true; + %113 = ConstLoad true; GOTO bb46; } bb45 { - %112 = ConstLoad false; + %113 = ConstLoad false; GOTO bb46; } bb46 { - %112? bb47 : bb48; + %113? bb47 : bb48; } bb47 { - %70 = ConstLoad 0; - %72 = %70; + %71 = ConstLoad 0; + %73 = %71; GOTO bb48; } bb48 { - %0 = newArray (string|(), int|())[%10]; + %0 = newArray %2[%10]; GOTO bb49; } bb49 { @@ -257,4 +258,4 @@ mapInits function() -> (string|(), int|()) { } -} \ No newline at end of file +} From 54c41ace88f71a1dfdd587931847de2c9976fddc Mon Sep 17 00:00:00 2001 From: Nadeeshan96 Date: Tue, 22 Nov 2022 19:02:25 +0530 Subject: [PATCH 083/450] Fix encoding global var names in other packages --- .../bir/codegen/JvmInstructionGen.java | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java index e087d195e067..39e9dfc9a7c7 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java @@ -427,29 +427,24 @@ public void generateVarLoad(MethodVisitor mv, BIRNode.BIRVariableDcl varDcl, int BType bType = JvmCodeGenUtil.getReferredType(varDcl.type); switch (varDcl.kind) { - case GLOBAL: { - BIRNode.BIRGlobalVariableDcl globalVar = (BIRNode.BIRGlobalVariableDcl) varDcl; - String moduleName = JvmCodeGenUtil.getPackageName(globalVar.pkgId); - - String varName = varDcl.name.value; - String className = jvmPackageGen.lookupGlobalVarClassName(moduleName, varName); - - String typeSig = getTypeDesc(bType); - mv.visitFieldInsn(GETSTATIC, className, varName, typeSig); - return; - } case SELF: mv.visitVarInsn(ALOAD, 0); return; - case CONSTANT: { - String varName = varDcl.name.value; + case CONSTANT: + case GLOBAL: PackageID moduleId = ((BIRNode.BIRGlobalVariableDcl) varDcl).pkgId; String pkgName = JvmCodeGenUtil.getPackageName(moduleId); + String varName = varDcl.name.value; String className = jvmPackageGen.lookupGlobalVarClassName(pkgName, varName); String typeSig = getTypeDesc(bType); + boolean samePackage = pkgName.equals(this.currentPackageName); + if (!samePackage) { + varName = Utils.encodeNonFunctionIdentifier(varName); + } mv.visitFieldInsn(GETSTATIC, className, varName, typeSig); return; - } + default: + break; } generateVarLoadForType(mv, bType, valueIndex); @@ -521,6 +516,10 @@ public void generateVarStore(MethodVisitor mv, BIRNode.BIRVariableDcl varDcl, in String pkgName = JvmCodeGenUtil.getPackageName(moduleId); String className = jvmPackageGen.lookupGlobalVarClassName(pkgName, varName); String typeSig = getTypeDesc(bType); + boolean samePackage = pkgName.equals(this.currentPackageName); + if (!samePackage) { + varName = Utils.encodeNonFunctionIdentifier(varName); + } mv.visitFieldInsn(PUTSTATIC, className, varName, typeSig); return; } From f6afe336f9abbf95cea12d680e3f59f99f8c2210 Mon Sep 17 00:00:00 2001 From: Nadeeshan96 Date: Tue, 22 Nov 2022 20:37:11 +0530 Subject: [PATCH 084/450] Add test for imported module function call --- .../FunctionsWithDefaultableArguments.java | 6 ++++ .../test-src/functions/testPackage/.gitignore | 2 ++ .../functions/testPackage/Ballerina.toml | 7 +++++ .../test-src/functions/testPackage/main.bal | 31 +++++++++++++++++++ .../modules/testModule/testModule.bal | 28 +++++++++++++++++ 5 files changed, 74 insertions(+) create mode 100644 tests/jballerina-unit-test/src/test/resources/test-src/functions/testPackage/.gitignore create mode 100644 tests/jballerina-unit-test/src/test/resources/test-src/functions/testPackage/Ballerina.toml create mode 100644 tests/jballerina-unit-test/src/test/resources/test-src/functions/testPackage/main.bal create mode 100644 tests/jballerina-unit-test/src/test/resources/test-src/functions/testPackage/modules/testModule/testModule.bal diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/functions/FunctionsWithDefaultableArguments.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/functions/FunctionsWithDefaultableArguments.java index 4f18b36ebe03..ff866f53c0bf 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/functions/FunctionsWithDefaultableArguments.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/functions/FunctionsWithDefaultableArguments.java @@ -46,6 +46,12 @@ public void setup() { result = BCompileUtil.compile("test-src/functions/functions_with_default_parameters.bal"); } + @Test + public void testFunctionCallInImportedModuleWithDefaultArguments() { + CompileResult compileResult = BCompileUtil.compile("test-src/functions/testPackage"); + BRunUtil.runMain(compileResult); + } + @Test(description = "Test functions arguments with function calls as default value") public void testFunctionCallAsDefaultExpr() { Object arr = BRunUtil.invoke(result, "testFunctionCallAsDefaultExpr"); diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/functions/testPackage/.gitignore b/tests/jballerina-unit-test/src/test/resources/test-src/functions/testPackage/.gitignore new file mode 100644 index 000000000000..5cf2b2aef30b --- /dev/null +++ b/tests/jballerina-unit-test/src/test/resources/test-src/functions/testPackage/.gitignore @@ -0,0 +1,2 @@ +target +Dependencies.toml diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/functions/testPackage/Ballerina.toml b/tests/jballerina-unit-test/src/test/resources/test-src/functions/testPackage/Ballerina.toml new file mode 100644 index 000000000000..616fa6659a71 --- /dev/null +++ b/tests/jballerina-unit-test/src/test/resources/test-src/functions/testPackage/Ballerina.toml @@ -0,0 +1,7 @@ +[package] +org = "balTests" +name = "testPackage" +version = "0.1.0" + +[build-options] +observabilityIncluded = true diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/functions/testPackage/main.bal b/tests/jballerina-unit-test/src/test/resources/test-src/functions/testPackage/main.bal new file mode 100644 index 000000000000..ec6d5364f9fa --- /dev/null +++ b/tests/jballerina-unit-test/src/test/resources/test-src/functions/testPackage/main.bal @@ -0,0 +1,31 @@ +// Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com) All Rights Reserved. +// +// WSO2 LLC. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +import testPackage.testModule; +import ballerina/test; + +public function main() { + testFunctionDefaultParameterValues(0); + testFunctionDefaultParameterValues(10); +} + +function testFunctionDefaultParameterValues(int x = 20) { + testModule:Client salesClient = new (); + int y = salesClient->/(x); + test:assertEquals(y, x + 1); + y = salesClient->/(x, "val"); + test:assertEquals(y, x + 2); +} diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/functions/testPackage/modules/testModule/testModule.bal b/tests/jballerina-unit-test/src/test/resources/test-src/functions/testPackage/modules/testModule/testModule.bal new file mode 100644 index 000000000000..03adacfc7ed2 --- /dev/null +++ b/tests/jballerina-unit-test/src/test/resources/test-src/functions/testPackage/modules/testModule/testModule.bal @@ -0,0 +1,28 @@ +// Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com) All Rights Reserved. +// +// WSO2 LLC. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +public isolated client class Client { + + resource isolated function get .(int year, string? quarter = ()) returns int { + int result = year; + if (quarter is ()) { + result += 1; + } else { + result += 2; + } + return result; + } +} From 9d0e85af959d85c1c0396c44b9f811a6be635a18 Mon Sep 17 00:00:00 2001 From: SandaruJayawardana Date: Wed, 23 Nov 2022 10:25:26 +0530 Subject: [PATCH 085/450] Fix OOM issue in ConstantValueResolver --- .../compiler/semantics/analyzer/ConstantValueResolver.java | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/ConstantValueResolver.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/ConstantValueResolver.java index d4f6a864a1e5..8dbe08f316ac 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/ConstantValueResolver.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/ConstantValueResolver.java @@ -134,6 +134,7 @@ public void resolve(List constants, PackageID packageID, SymbolEn constants.forEach(constant -> this.unresolvedConstants.put(constant.symbol, constant)); constants.forEach(constant -> constant.accept(this)); constantMap.clear(); + this.createdTypeDefinitions.clear(); } @Override From 3f65604f17ff621cb178ad2f5bdb70eb03a3d283 Mon Sep 17 00:00:00 2001 From: Nadeeshan96 Date: Wed, 23 Nov 2022 12:33:08 +0530 Subject: [PATCH 086/450] Rename type constant classes --- .../wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java index c9f971ecfadc..8dcd8ada020a 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java @@ -293,8 +293,8 @@ public class JvmConstants { // code generation related constants. public static final String MODULE_INIT_CLASS_NAME = "$_init"; - public static final String UNION_TYPE_CONSTANT_CLASS_NAME = "constants/$_bunion_type_constants"; - public static final String ERROR_TYPE_CONSTANT_CLASS_NAME = "constants/$_berror_type_constants"; + public static final String UNION_TYPE_CONSTANT_CLASS_NAME = "constants/$_union_type_constants"; + public static final String ERROR_TYPE_CONSTANT_CLASS_NAME = "constants/$_error_type_constants"; public static final String TUPLE_TYPE_CONSTANT_CLASS_NAME = "constants/$_tuple_type_constants"; public static final String ARRAY_TYPE_CONSTANT_CLASS_NAME = "constants/$_array_type_constants"; public static final String TYPEREF_TYPE_CONSTANT_CLASS_NAME = "constants/$_typeref_type_constants"; From 1350ef4327a23b0b246e48f74478cfc6d09c77ff Mon Sep 17 00:00:00 2001 From: Nadeeshan96 Date: Wed, 23 Nov 2022 11:17:48 +0530 Subject: [PATCH 087/450] Change fix to encode global var during creation --- .../org/wso2/ballerinalang/compiler/bir/BIRGen.java | 12 +++++++++--- .../compiler/bir/codegen/JvmInstructionGen.java | 10 +--------- .../test-src/functions/testPackage/main.bal | 2 +- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java index a0552c05481a..68dae1c30a33 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java @@ -18,6 +18,7 @@ package org.wso2.ballerinalang.compiler.bir; +import io.ballerina.identifier.Utils; import io.ballerina.tools.diagnostics.Location; import io.ballerina.tools.text.LinePosition; import io.ballerina.tools.text.LineRange; @@ -1854,11 +1855,16 @@ public void visit(BLangPackageVarRef astPackageVarRefExpr) { private BIRGlobalVariableDcl getVarRef(BLangPackageVarRef astPackageVarRefExpr) { BSymbol symbol = astPackageVarRefExpr.symbol; - if ((symbol.tag & SymTag.CONSTANT) == SymTag.CONSTANT || - !isInSamePackage(astPackageVarRefExpr.varSymbol, env.enclPkg.packageID)) { + + if (!isInSamePackage(astPackageVarRefExpr.varSymbol, env.enclPkg.packageID)) { + Name encodedGlobalVarDclName = Names.fromString(Utils.encodeNonFunctionIdentifier(symbol.name.getValue())); + return new BIRGlobalVariableDcl(astPackageVarRefExpr.pos, symbol.flags, symbol.type, symbol.pkgID, + encodedGlobalVarDclName, symbol.getOriginalName(), VarScope.GLOBAL, VarKind.CONSTANT, + symbol.name.getValue(), symbol.origin.toBIROrigin()); + } else if ((symbol.tag & SymTag.CONSTANT) == SymTag.CONSTANT) { return new BIRGlobalVariableDcl(astPackageVarRefExpr.pos, symbol.flags, symbol.type, symbol.pkgID, symbol.name, symbol.getOriginalName(), VarScope.GLOBAL, VarKind.CONSTANT, - symbol.name.value, symbol.origin.toBIROrigin()); + symbol.name.getValue(), symbol.origin.toBIROrigin()); } return this.globalVarMap.get(symbol); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java index 39e9dfc9a7c7..2794403e92e3 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java @@ -432,15 +432,11 @@ public void generateVarLoad(MethodVisitor mv, BIRNode.BIRVariableDcl varDcl, int return; case CONSTANT: case GLOBAL: + String varName = varDcl.name.value; PackageID moduleId = ((BIRNode.BIRGlobalVariableDcl) varDcl).pkgId; String pkgName = JvmCodeGenUtil.getPackageName(moduleId); - String varName = varDcl.name.value; String className = jvmPackageGen.lookupGlobalVarClassName(pkgName, varName); String typeSig = getTypeDesc(bType); - boolean samePackage = pkgName.equals(this.currentPackageName); - if (!samePackage) { - varName = Utils.encodeNonFunctionIdentifier(varName); - } mv.visitFieldInsn(GETSTATIC, className, varName, typeSig); return; default: @@ -516,10 +512,6 @@ public void generateVarStore(MethodVisitor mv, BIRNode.BIRVariableDcl varDcl, in String pkgName = JvmCodeGenUtil.getPackageName(moduleId); String className = jvmPackageGen.lookupGlobalVarClassName(pkgName, varName); String typeSig = getTypeDesc(bType); - boolean samePackage = pkgName.equals(this.currentPackageName); - if (!samePackage) { - varName = Utils.encodeNonFunctionIdentifier(varName); - } mv.visitFieldInsn(PUTSTATIC, className, varName, typeSig); return; } diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/functions/testPackage/main.bal b/tests/jballerina-unit-test/src/test/resources/test-src/functions/testPackage/main.bal index ec6d5364f9fa..d902b5c0080c 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/functions/testPackage/main.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/functions/testPackage/main.bal @@ -18,7 +18,7 @@ import testPackage.testModule; import ballerina/test; public function main() { - testFunctionDefaultParameterValues(0); + testFunctionDefaultParameterValues(); testFunctionDefaultParameterValues(10); } From ff6e41c119c1ed3d505de835746de8f403132c87 Mon Sep 17 00:00:00 2001 From: Nadeeshan96 Date: Wed, 23 Nov 2022 12:17:33 +0530 Subject: [PATCH 088/450] Add imported global vars to BIRPackage --- .../ballerinalang/compiler/bir/BIRGen.java | 18 +++++++++++------- .../compiler/bir/codegen/JvmDesugarPhase.java | 2 ++ .../compiler/bir/model/BIRNode.java | 2 ++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java index 68dae1c30a33..1e865bd99da1 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java @@ -1855,21 +1855,25 @@ public void visit(BLangPackageVarRef astPackageVarRefExpr) { private BIRGlobalVariableDcl getVarRef(BLangPackageVarRef astPackageVarRefExpr) { BSymbol symbol = astPackageVarRefExpr.symbol; + Location pos = astPackageVarRefExpr.pos; if (!isInSamePackage(astPackageVarRefExpr.varSymbol, env.enclPkg.packageID)) { - Name encodedGlobalVarDclName = Names.fromString(Utils.encodeNonFunctionIdentifier(symbol.name.getValue())); - return new BIRGlobalVariableDcl(astPackageVarRefExpr.pos, symbol.flags, symbol.type, symbol.pkgID, - encodedGlobalVarDclName, symbol.getOriginalName(), VarScope.GLOBAL, VarKind.CONSTANT, - symbol.name.getValue(), symbol.origin.toBIROrigin()); + BIRGlobalVariableDcl newGlobalVarDcl = getNewGlobalVarDcl(pos, symbol); + this.env.enclPkg.importedGlobalVars.add(newGlobalVarDcl); + return newGlobalVarDcl; } else if ((symbol.tag & SymTag.CONSTANT) == SymTag.CONSTANT) { - return new BIRGlobalVariableDcl(astPackageVarRefExpr.pos, symbol.flags, symbol.type, symbol.pkgID, - symbol.name, symbol.getOriginalName(), VarScope.GLOBAL, VarKind.CONSTANT, - symbol.name.getValue(), symbol.origin.toBIROrigin()); + return getNewGlobalVarDcl(pos, symbol); } return this.globalVarMap.get(symbol); } + private BIRGlobalVariableDcl getNewGlobalVarDcl(Location pos, BSymbol symbol) { + return new BIRGlobalVariableDcl(pos, symbol.flags, + symbol.type, symbol.pkgID, symbol.name, symbol.getOriginalName(), VarScope.GLOBAL, VarKind.CONSTANT, + symbol.name.getValue(), symbol.origin.toBIROrigin()); + } + @Override public void visit(BLangBinaryExpr astBinaryExpr) { astBinaryExpr.lhsExpr.accept(this); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmDesugarPhase.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmDesugarPhase.java index 204b43d4f353..24e3a4d3269f 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmDesugarPhase.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmDesugarPhase.java @@ -171,6 +171,7 @@ static HashMap encodeModuleIdentifiers(BIRNode.BIRPackage module HashMap encodedVsInitialIds = new HashMap<>(); encodePackageIdentifiers(module.packageID, encodedVsInitialIds); encodeGlobalVariableIdentifiers(module.globalVars, encodedVsInitialIds); + encodeGlobalVariableIdentifiers(module.importedGlobalVars, encodedVsInitialIds); encodeFunctionIdentifiers(module.functions, encodedVsInitialIds); encodeTypeDefIdentifiers(module.typeDefs, encodedVsInitialIds); return encodedVsInitialIds; @@ -268,6 +269,7 @@ static void replaceEncodedModuleIdentifiers(BIRNode.BIRPackage module, HashMap encodedVsInitialIds) { replaceEncodedPackageIdentifiers(module.packageID, encodedVsInitialIds); replaceEncodedGlobalVariableIdentifiers(module.globalVars, encodedVsInitialIds); + replaceEncodedGlobalVariableIdentifiers(module.importedGlobalVars, encodedVsInitialIds); replaceEncodedFunctionIdentifiers(module.functions, encodedVsInitialIds); replaceEncodedTypeDefIdentifiers(module.typeDefs, encodedVsInitialIds); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/model/BIRNode.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/model/BIRNode.java index 94069a4c0a4b..6bc024e27895 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/model/BIRNode.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/model/BIRNode.java @@ -58,6 +58,7 @@ public static class BIRPackage extends BIRNode { public final List importModules; public final List typeDefs; public final List globalVars; + public final List importedGlobalVars; public final List functions; public final List annotations; public final List constants; @@ -76,6 +77,7 @@ public BIRPackage(Location pos, Name org, Name pkgName, Name name, Name version, this.importModules = new ArrayList<>(); this.typeDefs = new ArrayList<>(); this.globalVars = new ArrayList<>(); + this.importedGlobalVars = new ArrayList<>(); this.functions = new ArrayList<>(); this.annotations = new ArrayList<>(); this.constants = new ArrayList<>(); From 1f12f788c6e5e5a233896c64fc767b9e64edebcb Mon Sep 17 00:00:00 2001 From: gabilang Date: Wed, 23 Nov 2022 14:12:30 +0530 Subject: [PATCH 089/450] Fix bir-spec for NewArray typedescOp --- .../compiler/bir/writer/BIRInstructionWriter.java | 5 ++++- docs/bir-spec/src/main/resources/kaitai/bir.ksy | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/writer/BIRInstructionWriter.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/writer/BIRInstructionWriter.java index e86f7060684b..8d3de3c2a472 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/writer/BIRInstructionWriter.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/writer/BIRInstructionWriter.java @@ -386,10 +386,13 @@ public void visit(BIRNonTerminator.NewInstance newInstance) { public void visit(NewArray birNewArray) { writeType(birNewArray.type); + birNewArray.lhsOp.accept(this); if (birNewArray.typedescOp != null) { + buf.writeByte(1); birNewArray.typedescOp.accept(this); + } else { + buf.writeByte(0); } - birNewArray.lhsOp.accept(this); birNewArray.sizeOp.accept(this); buf.writeInt(birNewArray.values.size()); for (BIRNode.BIRListConstructorEntry listValueEntry : birNewArray.values) { diff --git a/docs/bir-spec/src/main/resources/kaitai/bir.ksy b/docs/bir-spec/src/main/resources/kaitai/bir.ksy index 9d67d8fc1283..4fb01e09df52 100644 --- a/docs/bir-spec/src/main/resources/kaitai/bir.ksy +++ b/docs/bir-spec/src/main/resources/kaitai/bir.ksy @@ -1417,6 +1417,11 @@ types: type: s4 - id: lhs_operand type: operand + - id: has_typedesc_operand + type: s1 + - id: typedesc_operand + type: operand + if: has_typedesc_operand == 1 - id: size_operand type: operand - id: init_values_count From eac8a71737b2a0d334df22fa2b15caf9cd80429e Mon Sep 17 00:00:00 2001 From: gabilang Date: Wed, 23 Nov 2022 16:21:56 +0530 Subject: [PATCH 090/450] Fix decimal value return type --- .../java/io/ballerina/runtime/internal/TypeConverter.java | 3 ++- .../main/java/io/ballerina/runtime/internal/cli/CliUtil.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeConverter.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeConverter.java index 3d051af330a2..41586961e529 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeConverter.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeConverter.java @@ -27,6 +27,7 @@ import io.ballerina.runtime.api.utils.StringUtils; import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.utils.XmlUtils; +import io.ballerina.runtime.api.values.BDecimal; import io.ballerina.runtime.api.values.BError; import io.ballerina.runtime.api.values.BString; import io.ballerina.runtime.api.values.BXml; @@ -938,7 +939,7 @@ public static Boolean stringToBoolean(String value) throws NumberFormatException throw new NumberFormatException(); } - public static DecimalValue stringToDecimal(String value) throws NumberFormatException { + public static BDecimal stringToDecimal(String value) throws NumberFormatException { return new DecimalValue(value); } diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/CliUtil.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/CliUtil.java index 21f787ddfc33..1323bb903bd7 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/CliUtil.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/CliUtil.java @@ -24,9 +24,9 @@ import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.types.UnionType; import io.ballerina.runtime.api.utils.StringUtils; +import io.ballerina.runtime.api.values.BDecimal; import io.ballerina.runtime.api.values.BError; import io.ballerina.runtime.internal.TypeConverter; -import io.ballerina.runtime.internal.values.DecimalValue; import java.util.List; @@ -116,7 +116,7 @@ private static double getFloatValue(String argument, String parameterName) { } } - private static DecimalValue getDecimalValue(String argument, String parameterName) { + private static BDecimal getDecimalValue(String argument, String parameterName) { try { return TypeConverter.stringToDecimal(argument); } catch (NumberFormatException | BError e) { From a670cce7fdc6b77804ed9077728b07b7877a01b2 Mon Sep 17 00:00:00 2001 From: Nadeeshan96 Date: Wed, 23 Nov 2022 14:35:36 +0530 Subject: [PATCH 091/450] Add imported global var to global var list --- .../wso2/ballerinalang/compiler/bir/BIRGen.java | 3 +-- .../compiler/bir/codegen/JvmDesugarPhase.java | 2 -- .../compiler/bir/codegen/JvmInstructionGen.java | 17 +++++++++++++---- .../compiler/bir/model/BIRNode.java | 2 -- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java index 1e865bd99da1..e99685a2695e 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java @@ -18,7 +18,6 @@ package org.wso2.ballerinalang.compiler.bir; -import io.ballerina.identifier.Utils; import io.ballerina.tools.diagnostics.Location; import io.ballerina.tools.text.LinePosition; import io.ballerina.tools.text.LineRange; @@ -1859,7 +1858,7 @@ private BIRGlobalVariableDcl getVarRef(BLangPackageVarRef astPackageVarRefExpr) if (!isInSamePackage(astPackageVarRefExpr.varSymbol, env.enclPkg.packageID)) { BIRGlobalVariableDcl newGlobalVarDcl = getNewGlobalVarDcl(pos, symbol); - this.env.enclPkg.importedGlobalVars.add(newGlobalVarDcl); + this.env.enclPkg.globalVars.add(newGlobalVarDcl); return newGlobalVarDcl; } else if ((symbol.tag & SymTag.CONSTANT) == SymTag.CONSTANT) { return getNewGlobalVarDcl(pos, symbol); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmDesugarPhase.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmDesugarPhase.java index 24e3a4d3269f..204b43d4f353 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmDesugarPhase.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmDesugarPhase.java @@ -171,7 +171,6 @@ static HashMap encodeModuleIdentifiers(BIRNode.BIRPackage module HashMap encodedVsInitialIds = new HashMap<>(); encodePackageIdentifiers(module.packageID, encodedVsInitialIds); encodeGlobalVariableIdentifiers(module.globalVars, encodedVsInitialIds); - encodeGlobalVariableIdentifiers(module.importedGlobalVars, encodedVsInitialIds); encodeFunctionIdentifiers(module.functions, encodedVsInitialIds); encodeTypeDefIdentifiers(module.typeDefs, encodedVsInitialIds); return encodedVsInitialIds; @@ -269,7 +268,6 @@ static void replaceEncodedModuleIdentifiers(BIRNode.BIRPackage module, HashMap encodedVsInitialIds) { replaceEncodedPackageIdentifiers(module.packageID, encodedVsInitialIds); replaceEncodedGlobalVariableIdentifiers(module.globalVars, encodedVsInitialIds); - replaceEncodedGlobalVariableIdentifiers(module.importedGlobalVars, encodedVsInitialIds); replaceEncodedFunctionIdentifiers(module.functions, encodedVsInitialIds); replaceEncodedTypeDefIdentifiers(module.typeDefs, encodedVsInitialIds); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java index 2794403e92e3..e087d195e067 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java @@ -427,11 +427,21 @@ public void generateVarLoad(MethodVisitor mv, BIRNode.BIRVariableDcl varDcl, int BType bType = JvmCodeGenUtil.getReferredType(varDcl.type); switch (varDcl.kind) { + case GLOBAL: { + BIRNode.BIRGlobalVariableDcl globalVar = (BIRNode.BIRGlobalVariableDcl) varDcl; + String moduleName = JvmCodeGenUtil.getPackageName(globalVar.pkgId); + + String varName = varDcl.name.value; + String className = jvmPackageGen.lookupGlobalVarClassName(moduleName, varName); + + String typeSig = getTypeDesc(bType); + mv.visitFieldInsn(GETSTATIC, className, varName, typeSig); + return; + } case SELF: mv.visitVarInsn(ALOAD, 0); return; - case CONSTANT: - case GLOBAL: + case CONSTANT: { String varName = varDcl.name.value; PackageID moduleId = ((BIRNode.BIRGlobalVariableDcl) varDcl).pkgId; String pkgName = JvmCodeGenUtil.getPackageName(moduleId); @@ -439,8 +449,7 @@ public void generateVarLoad(MethodVisitor mv, BIRNode.BIRVariableDcl varDcl, int String typeSig = getTypeDesc(bType); mv.visitFieldInsn(GETSTATIC, className, varName, typeSig); return; - default: - break; + } } generateVarLoadForType(mv, bType, valueIndex); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/model/BIRNode.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/model/BIRNode.java index 6bc024e27895..94069a4c0a4b 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/model/BIRNode.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/model/BIRNode.java @@ -58,7 +58,6 @@ public static class BIRPackage extends BIRNode { public final List importModules; public final List typeDefs; public final List globalVars; - public final List importedGlobalVars; public final List functions; public final List annotations; public final List constants; @@ -77,7 +76,6 @@ public BIRPackage(Location pos, Name org, Name pkgName, Name name, Name version, this.importModules = new ArrayList<>(); this.typeDefs = new ArrayList<>(); this.globalVars = new ArrayList<>(); - this.importedGlobalVars = new ArrayList<>(); this.functions = new ArrayList<>(); this.annotations = new ArrayList<>(); this.constants = new ArrayList<>(); From de802a07de1179426bef123e5189130067422670 Mon Sep 17 00:00:00 2001 From: Nadeeshan96 Date: Wed, 23 Nov 2022 19:23:05 +0530 Subject: [PATCH 092/450] Encode imported global var name during creation --- .../ballerinalang/compiler/bir/BIRGen.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java index e99685a2695e..1a6a2e9650cf 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java @@ -18,6 +18,7 @@ package org.wso2.ballerinalang.compiler.bir; +import io.ballerina.identifier.Utils; import io.ballerina.tools.diagnostics.Location; import io.ballerina.tools.text.LinePosition; import io.ballerina.tools.text.LineRange; @@ -1854,25 +1855,21 @@ public void visit(BLangPackageVarRef astPackageVarRefExpr) { private BIRGlobalVariableDcl getVarRef(BLangPackageVarRef astPackageVarRefExpr) { BSymbol symbol = astPackageVarRefExpr.symbol; - Location pos = astPackageVarRefExpr.pos; if (!isInSamePackage(astPackageVarRefExpr.varSymbol, env.enclPkg.packageID)) { - BIRGlobalVariableDcl newGlobalVarDcl = getNewGlobalVarDcl(pos, symbol); - this.env.enclPkg.globalVars.add(newGlobalVarDcl); - return newGlobalVarDcl; + Name encodedGlobalVarDclName = Names.fromString(Utils.encodeNonFunctionIdentifier(symbol.name.getValue())); + return new BIRGlobalVariableDcl(astPackageVarRefExpr.pos, symbol.flags, symbol.type, symbol.pkgID, + encodedGlobalVarDclName, symbol.getOriginalName(), VarScope.GLOBAL, VarKind.CONSTANT, + symbol.name.getValue(), symbol.origin.toBIROrigin()); } else if ((symbol.tag & SymTag.CONSTANT) == SymTag.CONSTANT) { - return getNewGlobalVarDcl(pos, symbol); + return new BIRGlobalVariableDcl(astPackageVarRefExpr.pos, symbol.flags, symbol.type, symbol.pkgID, + symbol.name, symbol.getOriginalName(), VarScope.GLOBAL, VarKind.CONSTANT, + symbol.name.getValue(), symbol.origin.toBIROrigin()); } return this.globalVarMap.get(symbol); } - private BIRGlobalVariableDcl getNewGlobalVarDcl(Location pos, BSymbol symbol) { - return new BIRGlobalVariableDcl(pos, symbol.flags, - symbol.type, symbol.pkgID, symbol.name, symbol.getOriginalName(), VarScope.GLOBAL, VarKind.CONSTANT, - symbol.name.getValue(), symbol.origin.toBIROrigin()); - } - @Override public void visit(BLangBinaryExpr astBinaryExpr) { astBinaryExpr.lhsExpr.accept(this); From 6552f11f67acb3b4246ab3dc23368120b7bae6de Mon Sep 17 00:00:00 2001 From: Nadeeshan96 Date: Wed, 23 Nov 2022 21:36:54 +0530 Subject: [PATCH 093/450] Encode imported global vars in varLoad & varStore --- .../ballerinalang/compiler/bir/BIRGen.java | 14 +++-------- .../bir/codegen/JvmInstructionGen.java | 25 +++++++++---------- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java index 1a6a2e9650cf..a0552c05481a 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java @@ -18,7 +18,6 @@ package org.wso2.ballerinalang.compiler.bir; -import io.ballerina.identifier.Utils; import io.ballerina.tools.diagnostics.Location; import io.ballerina.tools.text.LinePosition; import io.ballerina.tools.text.LineRange; @@ -1855,16 +1854,11 @@ public void visit(BLangPackageVarRef astPackageVarRefExpr) { private BIRGlobalVariableDcl getVarRef(BLangPackageVarRef astPackageVarRefExpr) { BSymbol symbol = astPackageVarRefExpr.symbol; - - if (!isInSamePackage(astPackageVarRefExpr.varSymbol, env.enclPkg.packageID)) { - Name encodedGlobalVarDclName = Names.fromString(Utils.encodeNonFunctionIdentifier(symbol.name.getValue())); - return new BIRGlobalVariableDcl(astPackageVarRefExpr.pos, symbol.flags, symbol.type, symbol.pkgID, - encodedGlobalVarDclName, symbol.getOriginalName(), VarScope.GLOBAL, VarKind.CONSTANT, - symbol.name.getValue(), symbol.origin.toBIROrigin()); - } else if ((symbol.tag & SymTag.CONSTANT) == SymTag.CONSTANT) { + if ((symbol.tag & SymTag.CONSTANT) == SymTag.CONSTANT || + !isInSamePackage(astPackageVarRefExpr.varSymbol, env.enclPkg.packageID)) { return new BIRGlobalVariableDcl(astPackageVarRefExpr.pos, symbol.flags, symbol.type, symbol.pkgID, - symbol.name, symbol.getOriginalName(), VarScope.GLOBAL, VarKind.CONSTANT, - symbol.name.getValue(), symbol.origin.toBIROrigin()); + symbol.name, symbol.getOriginalName(), VarScope.GLOBAL, VarKind.CONSTANT, + symbol.name.value, symbol.origin.toBIROrigin()); } return this.globalVarMap.get(symbol); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java index e087d195e067..dac88d3465b5 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java @@ -427,29 +427,24 @@ public void generateVarLoad(MethodVisitor mv, BIRNode.BIRVariableDcl varDcl, int BType bType = JvmCodeGenUtil.getReferredType(varDcl.type); switch (varDcl.kind) { - case GLOBAL: { - BIRNode.BIRGlobalVariableDcl globalVar = (BIRNode.BIRGlobalVariableDcl) varDcl; - String moduleName = JvmCodeGenUtil.getPackageName(globalVar.pkgId); - - String varName = varDcl.name.value; - String className = jvmPackageGen.lookupGlobalVarClassName(moduleName, varName); - - String typeSig = getTypeDesc(bType); - mv.visitFieldInsn(GETSTATIC, className, varName, typeSig); - return; - } case SELF: mv.visitVarInsn(ALOAD, 0); return; - case CONSTANT: { + case CONSTANT: + case GLOBAL: String varName = varDcl.name.value; PackageID moduleId = ((BIRNode.BIRGlobalVariableDcl) varDcl).pkgId; String pkgName = JvmCodeGenUtil.getPackageName(moduleId); String className = jvmPackageGen.lookupGlobalVarClassName(pkgName, varName); String typeSig = getTypeDesc(bType); + boolean samePackage = pkgName.equals(this.currentPackageName); + if (!samePackage) { + varName = Utils.encodeNonFunctionIdentifier(varName); + } mv.visitFieldInsn(GETSTATIC, className, varName, typeSig); return; - } + default: + break; } generateVarLoadForType(mv, bType, valueIndex); @@ -521,6 +516,10 @@ public void generateVarStore(MethodVisitor mv, BIRNode.BIRVariableDcl varDcl, in String pkgName = JvmCodeGenUtil.getPackageName(moduleId); String className = jvmPackageGen.lookupGlobalVarClassName(pkgName, varName); String typeSig = getTypeDesc(bType); + boolean samePackage = pkgName.equals(this.currentPackageName); + if (!samePackage) { + varName = Utils.encodeNonFunctionIdentifier(varName); + } mv.visitFieldInsn(PUTSTATIC, className, varName, typeSig); return; } From cbf72f8fb96f9f16aae84e21864b9e982a850428 Mon Sep 17 00:00:00 2001 From: gabilang Date: Thu, 24 Nov 2022 08:44:19 +0530 Subject: [PATCH 094/450] Remove unnecessary lines --- .../ballerina/runtime/internal/values/TupleValueImpl.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TupleValueImpl.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TupleValueImpl.java index a8531e6a0899..450e5686e6b2 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TupleValueImpl.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TupleValueImpl.java @@ -71,13 +71,6 @@ public class TupleValueImpl extends AbstractArrayValue { private BTypedesc typedesc; // ------------------------ Constructors ------------------------------------------------------------------- - public TupleValueImpl(TypedescValue typedescValue) { - this((TupleType) typedescValue.getDescribingType()); - if (!tupleType.isReadOnly()) { - this.typedesc = typedescValue; - } - } - public TupleValueImpl(Object[] values, TupleType type) { this.refValues = values; this.tupleType = type; From 6dd51c329f340270bb933b0469e2bcdbed705b41 Mon Sep 17 00:00:00 2001 From: aneeshafedo Date: Thu, 24 Nov 2022 11:51:08 +0530 Subject: [PATCH 095/450] Address review suggestions --- .../io/ballerina/projectdesign/ComponentModel.java | 10 +++++----- .../generators/entity/EntityModelGenerator.java | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModel.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModel.java index 07515e7e0bee..8f2e2606dacf 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModel.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModel.java @@ -32,17 +32,17 @@ public class ComponentModel { private final PackageId packageId; - private final boolean hasDiagnosticErrors; + private final boolean hasCompilationErrors; private final Map services; private final Map entities; public ComponentModel(PackageId packageId, Map services, Map entities, - boolean hasDiagnosticErrors) { + boolean hasCompilationErrors) { this.packageId = packageId; this.services = services; this.entities = entities; - this.hasDiagnosticErrors = hasDiagnosticErrors; + this.hasCompilationErrors = hasCompilationErrors; } public PackageId getPackageId() { @@ -60,8 +60,8 @@ public Map getEntities() { return entities; } - public boolean isHasDiagnosticErrors() { - return hasDiagnosticErrors; + public boolean hasCompilationErrors() { + return hasCompilationErrors; } /** diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/entity/EntityModelGenerator.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/entity/EntityModelGenerator.java index 49166a79aebd..e690a62bb300 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/entity/EntityModelGenerator.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/entity/EntityModelGenerator.java @@ -96,8 +96,8 @@ private Entity getType(RecordTypeSymbol recordTypeSymbol, String entityName, Ele List inclusionList = new ArrayList<>(); Map recordFieldSymbolMap = getOriginalFieldMap(recordTypeSymbol, inclusionList, entityName); - for (Map.Entry fieldEntry : recordFieldSymbolMap.entrySet()) { - attributeList.add(getAttribute(fieldEntry.getValue(), entityName)); + for (RecordFieldSymbol recordFieldSymbol : recordFieldSymbolMap.values()) { + attributeList.add(getAttribute(recordFieldSymbol, entityName)); } return new Entity(attributeList, inclusionList, elementLocation, isAnonymous); } From a72eb6f42e9aba52754df2c5d2fe0bfccbface95 Mon Sep 17 00:00:00 2001 From: Thevakumar-Luheerathan Date: Thu, 24 Nov 2022 14:47:49 +0530 Subject: [PATCH 096/450] Modify testable jar for function mocking --- .../cli/task/RunNativeImageTestTask.java | 135 +++++++++++++++++- .../cli/utils/MethodCallReplaceVisitor.java | 63 ++++++++ .../utils/OrigMockFunctionReplaceVisitor.java | 63 ++++++++ .../src/main/java/module-info.java | 1 + .../exceptions/CacheGenException.java | 7 + 5 files changed, 263 insertions(+), 6 deletions(-) create mode 100644 cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/MethodCallReplaceVisitor.java create mode 100644 cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/OrigMockFunctionReplaceVisitor.java create mode 100644 misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/exceptions/CacheGenException.java diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java index ecb8884887c4..69cc940437c2 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java @@ -19,7 +19,11 @@ package io.ballerina.cli.task; import io.ballerina.cli.utils.BuildTime; +import io.ballerina.cli.utils.MethodCallReplaceVisitor; +import io.ballerina.cli.utils.OrigMockFunctionReplaceVisitor; import io.ballerina.cli.utils.TestUtils; +import io.ballerina.projects.Document; +import io.ballerina.projects.DocumentId; import io.ballerina.projects.JBallerinaBackend; import io.ballerina.projects.JarLibrary; import io.ballerina.projects.JarResolver; @@ -35,7 +39,6 @@ import io.ballerina.projects.ProjectKind; import io.ballerina.projects.internal.model.Target; import org.apache.commons.compress.utils.IOUtils; -import org.ballerinalang.test.runtime.entity.MockFunctionReplaceVisitor; import org.ballerinalang.test.runtime.entity.ModuleStatus; import org.ballerinalang.test.runtime.entity.TestReport; import org.ballerinalang.test.runtime.entity.TestSuite; @@ -203,6 +206,93 @@ public static byte[] getModifiedClassBytes(String className, List functi return classFile; } + public static byte[] getModifiedTestClassBytes(String className, List functionNames, TestSuite suite, + ClassLoader classLoader, Class testDocumentClass) { + Class functionToMockClass; + try { + functionToMockClass = classLoader.loadClass(className); + } catch (Throwable e) { + throw createLauncherException("failed to load class: " + className); + } + + byte[] classFile = new byte[0]; + boolean readFromBytes = false; + for (Method method1 : functionToMockClass.getDeclaredMethods()) { + if (functionNames.contains(MOCK_FN_DELIMITER + method1.getName())) { + String desugaredMockFunctionName = MOCK_FUNC_NAME_PREFIX + method1.getName(); + String testClassName = TesterinaUtils.getQualifiedClassName(suite.getOrgName(), + suite.getTestPackageID(), suite.getVersion(), + suite.getPackageID().replace(DOT, FILE_NAME_PERIOD_SEPARATOR)); + Class testClass; + try { + testClass = classLoader.loadClass(testClassName); + } catch (Throwable e) { + throw createLauncherException("failed to load class :" + testClassName); + } + for (Method method2 : testClass.getDeclaredMethods()) { + if (method2.getName().equals(desugaredMockFunctionName)) { + if (!readFromBytes) { + classFile = replaceTestClzMethodBody(testDocumentClass, method2, method1); + readFromBytes = true; + } else { + classFile = replaceTestClzMethodBody(classFile, method2, method1); + } + } + } + } else if (functionNames.contains(MOCK_LEGACY_DELIMITER + method1.getName())) { + String key = className + MOCK_LEGACY_DELIMITER + method1.getName(); + String mockFunctionName = suite.getMockFunctionNamesMap().get(key); + if (mockFunctionName != null) { + String mockFunctionClassName = suite.getTestUtilityFunctions().get(mockFunctionName); + Class mockFunctionClass; + try { + mockFunctionClass = classLoader.loadClass(mockFunctionClassName); + } catch (ClassNotFoundException e) { + throw createLauncherException("failed to load class: " + mockFunctionClassName); + } + for (Method method2 : mockFunctionClass.getDeclaredMethods()) { + if (method2.getName().equals(mockFunctionName)) { + if (!readFromBytes) { + classFile = replaceTestClzMethodBody(testDocumentClass, method1, method2); + readFromBytes = true; + } else { + classFile = replaceTestClzMethodBody(classFile, method1, method2); + } + } + } + } else { + continue; + } + } + } + return classFile; + } + + private static byte[] replaceTestClzMethodBody(Class testDocumentClass, Method toFunc, Method fromFunc) { + Class clazz = testDocumentClass; + ClassReader cr; + try { + InputStream ins; + ins = clazz.getResourceAsStream(clazz.getSimpleName() + CLASS_EXTENSION); + cr = new ClassReader(requireNonNull(ins)); + } catch (IOException e) { + throw createLauncherException("failed to get the class reader object for the class " + + clazz.getSimpleName()); + } + ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); + ClassVisitor cv = new MethodCallReplaceVisitor(Opcodes.ASM7, cw, toFunc, fromFunc); + cr.accept(cv, ClassReader.EXPAND_FRAMES); + return cw.toByteArray(); + } + + private static byte[] replaceTestClzMethodBody(byte[] classFile, Method toFunc, Method fromFunc) { + ClassReader cr = new ClassReader(classFile); + ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); + ClassVisitor cv = new MethodCallReplaceVisitor(Opcodes.ASM7, cw, toFunc, fromFunc); + cr.accept(cv, ClassReader.EXPAND_FRAMES); + return cw.toByteArray(); + } + private static byte[] replaceMethodBody(Method method, Method mockMethod) { Class clazz = method.getDeclaringClass(); ClassReader cr; @@ -215,7 +305,7 @@ private static byte[] replaceMethodBody(Method method, Method mockMethod) { + clazz.getSimpleName()); } ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); - ClassVisitor cv = new MockFunctionReplaceVisitor(Opcodes.ASM7, cw, method.getName(), + ClassVisitor cv = new OrigMockFunctionReplaceVisitor(Opcodes.ASM7, cw, method.getName(), Type.getMethodDescriptor(method), mockMethod); cr.accept(cv, 0); return cw.toByteArray(); @@ -224,7 +314,7 @@ private static byte[] replaceMethodBody(Method method, Method mockMethod) { private static byte[] replaceMethodBody(byte[] classFile, Method method, Method mockMethod) { ClassReader cr = new ClassReader(classFile); ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); - ClassVisitor cv = new MockFunctionReplaceVisitor(Opcodes.ASM7, cw, method.getName(), + ClassVisitor cv = new OrigMockFunctionReplaceVisitor(Opcodes.ASM7, cw, method.getName(), Type.getMethodDescriptor(method), mockMethod); cr.accept(cv, 0); return cw.toByteArray(); @@ -339,7 +429,7 @@ public void execute(Project project) { } suite.setReportRequired(report || coverage); try { - modifyJarForFunctionMock(suite, target, moduleName.toString(), + modifyJarForFunctionMock(suite, target, module, functionMockModuleMapping); } catch (IOException e) { throw createLauncherException("error occurred while running tests", e); @@ -588,8 +678,9 @@ private String getClassPath(JBallerinaBackend jBallerinaBackend, Package current return classPath.toString(); } - private void modifyJarForFunctionMock(TestSuite testSuite, Target target, String moduleName, - Map functionMockModuleMapping) throws IOException { + private void modifyJarForFunctionMock(TestSuite testSuite, Target target, Module module, + Map functionMockModuleMapping) throws IOException { + String moduleName = module.moduleName().toString(); String mainJarName = testSuite.getOrgName() + HYPHEN + moduleName + HYPHEN + testSuite.getVersion() + JAR_EXTENSION; String testJarName = testSuite.getOrgName() + HYPHEN + moduleName + HYPHEN + @@ -629,6 +720,38 @@ private void modifyJarForFunctionMock(TestSuite testSuite, Target target, String (testSuite.getPackageName()).resolve(testSuite.getVersion()).resolve(JAVA_11_DIR)).toString() + PATH_SEPARATOR + modifiedJar; dumpJar(modifiedClassDef, unmodifiedFiles, modifiedJarPath); + + + //Modify testable jar for function mocking + Map modifiedTestClassDef = new HashMap<>(); + for (DocumentId testDocId : module.testDocumentIds()) { + Document testDocument = module.document(testDocId); + String testDocumentName = testDocument.name().replace(".bal", "") + .replace("/", "."); + String testDocumentClassName = TesterinaUtils.getQualifiedClassName(testSuite.getOrgName(), + testSuite.getTestPackageID(), testSuite.getVersion(),testDocumentName); + Class testDocumentClass; + try { + testDocumentClass = classLoader.loadClass(testDocumentClassName); + } catch (Throwable e) { + throw createLauncherException("failed to load class: " + testDocumentClassName); + } + + + for (Map.Entry> entry : classVsMockFunctionsMap.entrySet()) { + String className = entry.getKey(); + List functionNamesList = entry.getValue(); + byte[] classFile = getModifiedTestClassBytes(className, functionNamesList, testSuite, classLoader, + testDocumentClass); + modifiedTestClassDef.put(testDocumentClassName, classFile); + } + } + Map unmodifiedTestFiles = loadUnmodifiedFilesWithinJar(mockFunctionDependencies, testJarName); + String modifiedTestJarPath = (target.path().resolve(CACHE_DIR).resolve(testSuite.getOrgName()).resolve + (testSuite.getPackageName()).resolve(testSuite.getVersion()).resolve(JAVA_11_DIR)).toString() + + PATH_SEPARATOR + testJarName; + dumpJar(modifiedTestClassDef, unmodifiedTestFiles, modifiedTestJarPath); + } private void dumpJar(Map modifiedClassDefs, Map unmodifiedFiles, diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/MethodCallReplaceVisitor.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/MethodCallReplaceVisitor.java new file mode 100644 index 000000000000..6c70b929a409 --- /dev/null +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/MethodCallReplaceVisitor.java @@ -0,0 +1,63 @@ +package io.ballerina.cli.utils; + +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.Type; +import org.objectweb.asm.commons.GeneratorAdapter; + +import java.lang.reflect.Method; + +public class MethodCallReplaceVisitor extends ClassVisitor { + private final Method toFunc; + public final Method fromFunc; + + private final int api; + + public MethodCallReplaceVisitor(int api, ClassWriter cw, Method toFunc, Method fromFunc) { + super(api, cw); + this.toFunc = toFunc; + this.fromFunc = fromFunc; + this.api = api; + } + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + return new MethodReplaceMethodVisitor(super.visitMethod(access, name, desc, signature, exceptions), + access, name, desc); + } + + private final class MethodReplaceMethodVisitor extends GeneratorAdapter { + + public MethodReplaceMethodVisitor( + MethodVisitor mv, int access, String name, String desc) { + super(MethodCallReplaceVisitor.this.api ,mv, access, name, desc); + } + + @Override + public void visitMethodInsn( + int opcode, String owner, String name, String desc, boolean itf) { + + String fromFuncOwner = MethodCallReplaceVisitor.this + .fromFunc.getDeclaringClass().getName().replace(".", "/"); + String fromFuncName = MethodCallReplaceVisitor.this.fromFunc.getName(); + String fromFunDesc = Type.getMethodDescriptor(MethodCallReplaceVisitor.this.fromFunc); + + String toFuncOwner = MethodCallReplaceVisitor.this + .toFunc.getDeclaringClass().getName().replace(".", "/"); + String toFuncName = MethodCallReplaceVisitor.this.toFunc.getName(); + String toFunDesc = Type.getMethodDescriptor(MethodCallReplaceVisitor.this.toFunc); + + if(opcode== Opcodes.INVOKESTATIC && owner.equals(fromFuncOwner) + && name.equals(fromFuncName) && desc.equals(fromFunDesc)) { + super.visitMethodInsn(Opcodes.INVOKESTATIC, toFuncOwner, + toFuncName, toFunDesc, false); + } + else { + super.visitMethodInsn(opcode, owner, name, desc, itf); + } + } + } + +} diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/OrigMockFunctionReplaceVisitor.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/OrigMockFunctionReplaceVisitor.java new file mode 100644 index 000000000000..7377eee29f0f --- /dev/null +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/OrigMockFunctionReplaceVisitor.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.ballerina.cli.utils; + +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.MethodVisitor; + +import java.lang.reflect.Method; + +import static org.ballerinalang.test.runtime.util.TesterinaConstants.ORIGINAL_FUNC_NAME_PREFIX; + +/** + * Remove existing method body and replace it with a method call. + * + * @since 2201.1.0 + */ +public class OrigMockFunctionReplaceVisitor extends ClassVisitor { + + private final String methodName; + private final String methodDesc; + private final Method mockFunc; + + public OrigMockFunctionReplaceVisitor + (int api, ClassWriter cw, String name, String methodDescriptor, Method mockFunc) { + super(api, cw); + this.methodName = name; + this.methodDesc = methodDescriptor; + this.mockFunc = mockFunc; + } + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + MethodVisitor methodVisitor; + if (!name.equals(methodName) || !desc.equals(methodDesc)) { + // reproduce the methods where no changes needed + methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); + } else { + // Rename function as $ORIG_ to restore the original function with a different name. + methodVisitor = super.visitMethod(access, ORIGINAL_FUNC_NAME_PREFIX + name, + desc, signature, exceptions); + + } + + return methodVisitor; + } + +} diff --git a/cli/ballerina-cli/src/main/java/module-info.java b/cli/ballerina-cli/src/main/java/module-info.java index fc930faf636a..47b3a78cd346 100644 --- a/cli/ballerina-cli/src/main/java/module-info.java +++ b/cli/ballerina-cli/src/main/java/module-info.java @@ -20,4 +20,5 @@ requires io.ballerina.toml; requires io.ballerina.identifier; requires org.objectweb.asm; + requires org.objectweb.asm.commons; } diff --git a/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/exceptions/CacheGenException.java b/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/exceptions/CacheGenException.java new file mode 100644 index 000000000000..27a90bb0454a --- /dev/null +++ b/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/exceptions/CacheGenException.java @@ -0,0 +1,7 @@ +package org.ballerinalang.testerina.compiler.exceptions; + +public class CacheGenException extends RuntimeException { + public CacheGenException(String msg) { + super(msg); + } +} From 5b046720ee8bb3b60c36cbc6250e0bf2116b784f Mon Sep 17 00:00:00 2001 From: gabilang Date: Thu, 24 Nov 2022 15:28:48 +0530 Subject: [PATCH 097/450] Update BIR version --- .../ballerinalang/programfile/ProgramFileConstants.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/programfile/ProgramFileConstants.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/programfile/ProgramFileConstants.java index 5b23c9e385b0..845894c5c896 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/programfile/ProgramFileConstants.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/programfile/ProgramFileConstants.java @@ -25,9 +25,9 @@ public class ProgramFileConstants { public static final int MAGIC_NUMBER = 0xBA1DA4CE; public static final short VERSION_NUMBER = 50; - public static final int BIR_VERSION_NUMBER = 67; - public static final short MIN_SUPPORTED_VERSION = 67; - public static final short MAX_SUPPORTED_VERSION = 67; + public static final int BIR_VERSION_NUMBER = 68; + public static final short MIN_SUPPORTED_VERSION = 68; + public static final short MAX_SUPPORTED_VERSION = 68; // todo move this to a proper place public static final String[] SUPPORTED_PLATFORMS = {"java11"}; From ceb2a93c753ebcba7e5eaa2c36c5b91b7050c350 Mon Sep 17 00:00:00 2001 From: gayalkuruppu Date: Thu, 24 Nov 2022 16:19:39 +0530 Subject: [PATCH 098/450] Address review suggestions --- .../context/ErrorConstructorExpressionNodeContext.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ErrorConstructorExpressionNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ErrorConstructorExpressionNodeContext.java index c37bc7105953..74dbbe4af5e9 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ErrorConstructorExpressionNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ErrorConstructorExpressionNodeContext.java @@ -157,10 +157,9 @@ public void sort(BallerinaCompletionContext context, ErrorConstructorExpressionN Covers the following. error(,) */ - TypeSymbol stringTypeSymbol = types.STRING; for (LSCompletionItem completionItem : completionItems) { completionItem.getCompletionItem() - .setSortText(SortingUtil.genSortTextByAssignability(context, completionItem, stringTypeSymbol)); + .setSortText(SortingUtil.genSortTextByAssignability(context, completionItem, types.STRING)); } return; } From 3e447bd90807d1cda8b69c4678bbf168ec93edae Mon Sep 17 00:00:00 2001 From: Nadeeshan96 Date: Fri, 25 Nov 2022 12:57:08 +0530 Subject: [PATCH 099/450] Add dummy imported global varDcls to BIRPackage --- .../wso2/ballerinalang/compiler/bir/BIRGen.java | 16 ++++++++++------ .../compiler/bir/codegen/JvmDesugarPhase.java | 17 +++++++++++++++++ .../compiler/bir/codegen/JvmInstructionGen.java | 8 -------- .../compiler/bir/model/BIRNode.java | 3 +++ 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java index a0552c05481a..f2ae84b05f4d 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java @@ -1854,14 +1854,18 @@ public void visit(BLangPackageVarRef astPackageVarRefExpr) { private BIRGlobalVariableDcl getVarRef(BLangPackageVarRef astPackageVarRefExpr) { BSymbol symbol = astPackageVarRefExpr.symbol; - if ((symbol.tag & SymTag.CONSTANT) == SymTag.CONSTANT || - !isInSamePackage(astPackageVarRefExpr.varSymbol, env.enclPkg.packageID)) { - return new BIRGlobalVariableDcl(astPackageVarRefExpr.pos, symbol.flags, symbol.type, symbol.pkgID, - symbol.name, symbol.getOriginalName(), VarScope.GLOBAL, VarKind.CONSTANT, - symbol.name.value, symbol.origin.toBIROrigin()); + BIRGlobalVariableDcl globalVarDcl = this.globalVarMap.get(symbol); + if (globalVarDcl == null) { + globalVarDcl = new BIRGlobalVariableDcl(astPackageVarRefExpr.pos, symbol.flags, symbol.type, symbol.pkgID, + symbol.name, symbol.getOriginalName(), VarScope.GLOBAL, VarKind.CONSTANT, symbol.name.getValue(), + symbol.origin.toBIROrigin()); + this.globalVarMap.put(symbol, globalVarDcl); } - return this.globalVarMap.get(symbol); + if (!isInSamePackage(astPackageVarRefExpr.varSymbol, env.enclPkg.packageID)) { + this.env.enclPkg.importedGlobalVarsDummyVarDcls.add(globalVarDcl); + } + return globalVarDcl; } @Override diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmDesugarPhase.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmDesugarPhase.java index 204b43d4f353..48a4cc627500 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmDesugarPhase.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmDesugarPhase.java @@ -44,6 +44,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Set; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmCodeGenUtil.toNameString; @@ -171,6 +172,7 @@ static HashMap encodeModuleIdentifiers(BIRNode.BIRPackage module HashMap encodedVsInitialIds = new HashMap<>(); encodePackageIdentifiers(module.packageID, encodedVsInitialIds); encodeGlobalVariableIdentifiers(module.globalVars, encodedVsInitialIds); + encodeImportedGlobalVariableIdentifiers(module.importedGlobalVarsDummyVarDcls, encodedVsInitialIds); encodeFunctionIdentifiers(module.functions, encodedVsInitialIds); encodeTypeDefIdentifiers(module.typeDefs, encodedVsInitialIds); return encodedVsInitialIds; @@ -263,11 +265,19 @@ private static void encodeGlobalVariableIdentifiers(List globalVars, + HashMap encodedVsInitialIds) { + for (BIRNode.BIRGlobalVariableDcl globalVar : globalVars) { + globalVar.name = Names.fromString(encodeNonFunctionIdentifier(globalVar.name.value, encodedVsInitialIds)); + } + } + // Replace encoding identifiers static void replaceEncodedModuleIdentifiers(BIRNode.BIRPackage module, HashMap encodedVsInitialIds) { replaceEncodedPackageIdentifiers(module.packageID, encodedVsInitialIds); replaceEncodedGlobalVariableIdentifiers(module.globalVars, encodedVsInitialIds); + replaceEncodedImportedGlobalVariableIdentifiers(module.importedGlobalVarsDummyVarDcls, encodedVsInitialIds); replaceEncodedFunctionIdentifiers(module.functions, encodedVsInitialIds); replaceEncodedTypeDefIdentifiers(module.typeDefs, encodedVsInitialIds); } @@ -349,6 +359,13 @@ private static void replaceEncodedGlobalVariableIdentifiers(List globalVars, + HashMap encodedVsInitialIds) { + for (BIRNode.BIRGlobalVariableDcl globalVar : globalVars) { + globalVar.name = getInitialIdString(globalVar.name, encodedVsInitialIds); + } + } + private static String encodeFunctionIdentifier(String identifier, HashMap encodedVsInitialIds) { if (encodedVsInitialIds.containsKey(identifier)) { return identifier; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java index dac88d3465b5..2794403e92e3 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java @@ -437,10 +437,6 @@ public void generateVarLoad(MethodVisitor mv, BIRNode.BIRVariableDcl varDcl, int String pkgName = JvmCodeGenUtil.getPackageName(moduleId); String className = jvmPackageGen.lookupGlobalVarClassName(pkgName, varName); String typeSig = getTypeDesc(bType); - boolean samePackage = pkgName.equals(this.currentPackageName); - if (!samePackage) { - varName = Utils.encodeNonFunctionIdentifier(varName); - } mv.visitFieldInsn(GETSTATIC, className, varName, typeSig); return; default: @@ -516,10 +512,6 @@ public void generateVarStore(MethodVisitor mv, BIRNode.BIRVariableDcl varDcl, in String pkgName = JvmCodeGenUtil.getPackageName(moduleId); String className = jvmPackageGen.lookupGlobalVarClassName(pkgName, varName); String typeSig = getTypeDesc(bType); - boolean samePackage = pkgName.equals(this.currentPackageName); - if (!samePackage) { - varName = Utils.encodeNonFunctionIdentifier(varName); - } mv.visitFieldInsn(PUTSTATIC, className, varName, typeSig); return; } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/model/BIRNode.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/model/BIRNode.java index 94069a4c0a4b..8c9156de2b1c 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/model/BIRNode.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/model/BIRNode.java @@ -30,6 +30,7 @@ import org.wso2.ballerinalang.compiler.util.Name; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.TreeSet; @@ -58,6 +59,7 @@ public static class BIRPackage extends BIRNode { public final List importModules; public final List typeDefs; public final List globalVars; + public final Set importedGlobalVarsDummyVarDcls; public final List functions; public final List annotations; public final List constants; @@ -76,6 +78,7 @@ public BIRPackage(Location pos, Name org, Name pkgName, Name name, Name version, this.importModules = new ArrayList<>(); this.typeDefs = new ArrayList<>(); this.globalVars = new ArrayList<>(); + this.importedGlobalVarsDummyVarDcls = new HashSet<>(); this.functions = new ArrayList<>(); this.annotations = new ArrayList<>(); this.constants = new ArrayList<>(); From f3a1d1b61d6b579bc584fc9fc21bbe260acbd74a Mon Sep 17 00:00:00 2001 From: Thevakumar-Luheerathan Date: Fri, 25 Nov 2022 13:02:19 +0530 Subject: [PATCH 100/450] Add mocking support for outside module --- .../cli/task/RunNativeImageTestTask.java | 217 +++++++++++++----- .../io/ballerina/cli/utils/NativeUtils.java | 20 +- .../utils/OrigMockFunctionReplaceVisitor.java | 81 ++++++- 3 files changed, 239 insertions(+), 79 deletions(-) diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java index 69cc940437c2..924ba968d4a3 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java @@ -49,7 +49,6 @@ import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; import org.wso2.ballerinalang.util.Lists; import java.io.File; @@ -145,7 +144,7 @@ public RunNativeImageTestTask(PrintStream out, boolean rerunTests, String groupL } public static byte[] getModifiedClassBytes(String className, List functionNames, TestSuite suite, - ClassLoader classLoader) { + ClassLoader classLoader, List modifiedMethods) { Class functionToMockClass; try { functionToMockClass = classLoader.loadClass(className); @@ -157,6 +156,11 @@ public static byte[] getModifiedClassBytes(String className, List functi boolean readFromBytes = false; for (Method method1 : functionToMockClass.getDeclaredMethods()) { if (functionNames.contains(MOCK_FN_DELIMITER + method1.getName())) { + if (modifiedMethods.contains(className + "-" + method1.getName())) { + continue; + } else { + modifiedMethods.add(className + "-" + method1.getName()); + } String desugaredMockFunctionName = MOCK_FUNC_NAME_PREFIX + method1.getName(); String testClassName = TesterinaUtils.getQualifiedClassName(suite.getOrgName(), suite.getTestPackageID(), suite.getVersion(), @@ -178,6 +182,11 @@ public static byte[] getModifiedClassBytes(String className, List functi } } } else if (functionNames.contains(MOCK_LEGACY_DELIMITER + method1.getName())) { + if (modifiedMethods.contains(className + "-" + method1.getName())) { + continue; + } else { + modifiedMethods.add(className + "-" + method1.getName()); + } String key = className + MOCK_LEGACY_DELIMITER + method1.getName(); String mockFunctionName = suite.getMockFunctionNamesMap().get(key); if (mockFunctionName != null) { @@ -207,7 +216,8 @@ public static byte[] getModifiedClassBytes(String className, List functi } public static byte[] getModifiedTestClassBytes(String className, List functionNames, TestSuite suite, - ClassLoader classLoader, Class testDocumentClass) { + ClassLoader classLoader, Class testDocumentClass, + byte[] classFile) { Class functionToMockClass; try { functionToMockClass = classLoader.loadClass(className); @@ -215,8 +225,13 @@ public static byte[] getModifiedTestClassBytes(String className, List fu throw createLauncherException("failed to load class: " + className); } - byte[] classFile = new byte[0]; - boolean readFromBytes = false; + boolean readFromBytes; + if(classFile.length == 0) { + readFromBytes = false; + } else { + readFromBytes = true; + } + for (Method method1 : functionToMockClass.getDeclaredMethods()) { if (functionNames.contains(MOCK_FN_DELIMITER + method1.getName())) { String desugaredMockFunctionName = MOCK_FUNC_NAME_PREFIX + method1.getName(); @@ -305,8 +320,7 @@ private static byte[] replaceMethodBody(Method method, Method mockMethod) { + clazz.getSimpleName()); } ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); - ClassVisitor cv = new OrigMockFunctionReplaceVisitor(Opcodes.ASM7, cw, method.getName(), - Type.getMethodDescriptor(method), mockMethod); + ClassVisitor cv = new OrigMockFunctionReplaceVisitor(Opcodes.ASM7, cw, method, mockMethod); cr.accept(cv, 0); return cw.toByteArray(); } @@ -314,8 +328,7 @@ private static byte[] replaceMethodBody(Method method, Method mockMethod) { private static byte[] replaceMethodBody(byte[] classFile, Method method, Method mockMethod) { ClassReader cr = new ClassReader(classFile); ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); - ClassVisitor cv = new OrigMockFunctionReplaceVisitor(Opcodes.ASM7, cw, method.getName(), - Type.getMethodDescriptor(method), mockMethod); + ClassVisitor cv = new OrigMockFunctionReplaceVisitor(Opcodes.ASM7, cw, method, mockMethod); cr.accept(cv, 0); return cw.toByteArray(); } @@ -404,7 +417,8 @@ public void execute(Project project) { // Only tests in packages are executed so default packages i.e. single bal files which has the package name // as "." are ignored. This is to be consistent with the "bal test" command which only executes tests // in packages. - Map functionMockModuleMapping = new HashMap<>(); + Map originalVsModifiedJarMap = new HashMap<>(); + List modifiedMethods = new ArrayList<>(); for (ModuleDescriptor moduleDescriptor : project.currentPackage().moduleDependencyGraph().toTopologicallySortedList()) { Module module = project.currentPackage().module(moduleDescriptor.name()); @@ -430,7 +444,7 @@ public void execute(Project project) { suite.setReportRequired(report || coverage); try { modifyJarForFunctionMock(suite, target, module, - functionMockModuleMapping); + originalVsModifiedJarMap, modifiedMethods); } catch (IOException e) { throw createLauncherException("error occurred while running tests", e); } @@ -463,7 +477,7 @@ public void execute(Project project) { int testResult = 1; try { testResult = runTestSuiteWithNativeImage(project.currentPackage(), jBallerinaBackend, target, - functionMockModuleMapping); + originalVsModifiedJarMap); if (report || coverage) { for (String moduleName : moduleNamesList) { @@ -531,14 +545,14 @@ public void execute(Project project) { // } private int runTestSuiteWithNativeImage(Package currentPackage, JBallerinaBackend jBallerinaBackend, Target target, - Map functionMockModuleMappings) + Map originalVsModifiedJarMap) throws IOException, InterruptedException { String packageName = currentPackage.packageName().toString(); String classPath = getClassPath(jBallerinaBackend, currentPackage); String modClassPath; - for (Map.Entry functionMockModuleMapping : functionMockModuleMappings.entrySet()) { + for (Map.Entry functionMockModuleMapping : originalVsModifiedJarMap.entrySet()) { String moduleJar = functionMockModuleMapping.getKey(); - String replacedJar = functionMockModuleMappings.get(moduleJar); + String replacedJar = originalVsModifiedJarMap.get(moduleJar); modClassPath = classPath.replace(moduleJar, replacedJar); classPath = modClassPath; @@ -679,47 +693,130 @@ private String getClassPath(JBallerinaBackend jBallerinaBackend, Package current } private void modifyJarForFunctionMock(TestSuite testSuite, Target target, Module module, - Map functionMockModuleMapping) throws IOException { + Map originalVsModifiedJarMap, + List modifiedMethods) throws IOException { String moduleName = module.moduleName().toString(); - String mainJarName = testSuite.getOrgName() + HYPHEN + moduleName + HYPHEN + - testSuite.getVersion() + JAR_EXTENSION; String testJarName = testSuite.getOrgName() + HYPHEN + moduleName + HYPHEN + testSuite.getVersion() + HYPHEN + TESTABLE + JAR_EXTENSION; - String modifiedJar = testSuite.getOrgName() + HYPHEN + moduleName + HYPHEN + testSuite.getVersion() + HYPHEN + - MODIFIED + JAR_EXTENSION; + String testJarPath = ""; + String modifiedJarName = ""; + String mainJarPath = ""; + String mainJarName = ""; + if (testSuite.getMockFunctionNamesMap().isEmpty()) { return; } - functionMockModuleMapping.put(mainJarName, modifiedJar); - List testExecutionDependencies = testSuite.getTestExecutionDependencies(); - - List mockFunctionDependencies = new ArrayList<>(); + List testExecutionDependencies = testSuite.getTestExecutionDependencies(); + List classLoaderUrlList = new ArrayList<>(); for (String testExecutionDependency : testExecutionDependencies) { - if (testExecutionDependency.endsWith(mainJarName) || testExecutionDependency.endsWith(testJarName)) { - mockFunctionDependencies.add(testExecutionDependency); + if (testExecutionDependency.endsWith(testJarName)) { + testJarPath = testExecutionDependency; + classLoaderUrlList.add(testJarPath); } + } - ClassLoader classLoader = AccessController.doPrivileged( - (PrivilegedAction) () -> new URLClassLoader(getURLList(mockFunctionDependencies). - toArray(new URL[0]), ClassLoader.getSystemClassLoader())); + ClassLoader classLoader = null; Map> classVsMockFunctionsMap = new HashMap<>(); Map mockFunctionMap = testSuite.getMockFunctionNamesMap(); populateClassNameVsFunctionToMockMap(classVsMockFunctionsMap, mockFunctionMap); - Map modifiedClassDef = new HashMap<>(); - for (Map.Entry> entry : classVsMockFunctionsMap.entrySet()) { - String className = entry.getKey(); - List functionNamesList = entry.getValue(); - byte[] classFile = getModifiedClassBytes(className, functionNamesList, testSuite, classLoader); - modifiedClassDef.put(className, classFile); + + Map > mainJarVsClassMapping = new HashMap<>(); + for (Map.Entry> classVsMockFunctionsEntry : classVsMockFunctionsMap.entrySet()) { + String className = classVsMockFunctionsEntry.getKey(); + String[] classMetaData = className.split("\\."); + mainJarName = classMetaData[0] + HYPHEN + classMetaData[1].replace("$0046",".") + + HYPHEN + classMetaData[2]; + + if (mainJarVsClassMapping.containsKey(mainJarName)) { + mainJarVsClassMapping.get(mainJarName).add(className); + } else { + List classList = new ArrayList<>(); + classList.add(className); + mainJarVsClassMapping.put(mainJarName,classList); + } + } + + for (Map.Entry> mainJarVsClassEntry : mainJarVsClassMapping.entrySet()) { + + mainJarName = mainJarVsClassEntry.getKey(); + modifiedJarName = mainJarName + HYPHEN + MODIFIED + JAR_EXTENSION; + + + for (String testExecutionDependency : testExecutionDependencies) { + if (testExecutionDependency.contains(mainJarName) && !testExecutionDependency.contains(TESTABLE)) { + mainJarPath = testExecutionDependency; + if (originalVsModifiedJarMap.containsKey(mainJarPath)) { + mainJarPath= originalVsModifiedJarMap.get(mainJarPath); + } + } + } + classLoaderUrlList.add(mainJarPath); + classLoader = AccessController.doPrivileged( + (PrivilegedAction) () -> new URLClassLoader(getURLList(classLoaderUrlList). + toArray(new URL[0]), ClassLoader.getSystemClassLoader())); + + + Map modifiedClassDef = new HashMap<>(); + for (String className : mainJarVsClassEntry.getValue()) { + List functionNamesList = classVsMockFunctionsMap.get(className); + byte[] classFile = getModifiedClassBytes(className, functionNamesList, testSuite, classLoader, + modifiedMethods); + modifiedClassDef.put(className, classFile); + } + + Map unmodifiedFiles = loadUnmodifiedFilesWithinJar(mainJarPath); + String modifiedJarPath = (target.path().resolve(CACHE_DIR).resolve(testSuite.getOrgName()).resolve + (testSuite.getPackageName()).resolve(testSuite.getVersion()).resolve(JAVA_11_DIR)).toString() + + PATH_SEPARATOR + modifiedJarName; + dumpJar(modifiedClassDef, unmodifiedFiles, modifiedJarPath); + if (!originalVsModifiedJarMap.containsKey(mainJarPath)) { + originalVsModifiedJarMap.put(mainJarPath, modifiedJarPath); + } } - Map unmodifiedFiles = loadUnmodifiedFilesWithinJar(mockFunctionDependencies, mainJarName); - String modifiedJarPath = (target.path().resolve(CACHE_DIR).resolve(testSuite.getOrgName()).resolve - (testSuite.getPackageName()).resolve(testSuite.getVersion()).resolve(JAVA_11_DIR)).toString() - + PATH_SEPARATOR + modifiedJar; - dumpJar(modifiedClassDef, unmodifiedFiles, modifiedJarPath); + +// +// String mainJarName = testSuite.getOrgName() + HYPHEN + moduleName + HYPHEN + +// testSuite.getVersion() + JAR_EXTENSION; +// String testJarName = testSuite.getOrgName() + HYPHEN + moduleName + HYPHEN + +// testSuite.getVersion() + HYPHEN + TESTABLE + JAR_EXTENSION; +// String modifiedJar = testSuite.getOrgName() + HYPHEN + moduleName + HYPHEN + testSuite.getVersion() + HYPHEN + +// MODIFIED + JAR_EXTENSION; +// if (testSuite.getMockFunctionNamesMap().isEmpty()) { +// return; +// } +// functionMockModuleMapping.put(mainJarName, modifiedJar); +// List testExecutionDependencies = testSuite.getTestExecutionDependencies(); +// +// +// List mockFunctionDependencies = new ArrayList<>(); +// for (String testExecutionDependency : testExecutionDependencies) { +// if (testExecutionDependency.endsWith(mainJarName) || testExecutionDependency.endsWith(testJarName)) { +// mockFunctionDependencies.add(testExecutionDependency); +// } +// } +// ClassLoader classLoader = AccessController.doPrivileged( +// (PrivilegedAction) () -> new URLClassLoader(getURLList(mockFunctionDependencies). +// toArray(new URL[0]), ClassLoader.getSystemClassLoader())); +// +// +// Map> classVsMockFunctionsMap = new HashMap<>(); +// Map mockFunctionMap = testSuite.getMockFunctionNamesMap(); +// populateClassNameVsFunctionToMockMap(classVsMockFunctionsMap, mockFunctionMap); +// Map modifiedClassDef = new HashMap<>(); +// for (Map.Entry> entry : classVsMockFunctionsMap.entrySet()) { +// String className = entry.getKey(); +// List functionNamesList = entry.getValue(); +// byte[] classFile = getModifiedClassBytes(className, functionNamesList, testSuite, classLoader); +// modifiedClassDef.put(className, classFile); +// } +// Map unmodifiedFiles = loadUnmodifiedFilesWithinJar(mockFunctionDependencies, mainJarName); +// String modifiedJarPath = (target.path().resolve(CACHE_DIR).resolve(testSuite.getOrgName()).resolve +// (testSuite.getPackageName()).resolve(testSuite.getVersion()).resolve(JAVA_11_DIR)).toString() +// + PATH_SEPARATOR + modifiedJar; +// dumpJar(modifiedClassDef, unmodifiedFiles, modifiedJarPath); //Modify testable jar for function mocking @@ -737,21 +834,21 @@ private void modifyJarForFunctionMock(TestSuite testSuite, Target target, Module throw createLauncherException("failed to load class: " + testDocumentClassName); } - + byte[] classFile = new byte[0]; for (Map.Entry> entry : classVsMockFunctionsMap.entrySet()) { String className = entry.getKey(); List functionNamesList = entry.getValue(); - byte[] classFile = getModifiedTestClassBytes(className, functionNamesList, testSuite, classLoader, - testDocumentClass); - modifiedTestClassDef.put(testDocumentClassName, classFile); + classFile = getModifiedTestClassBytes(className, functionNamesList, testSuite, classLoader, + testDocumentClass, classFile); } + modifiedTestClassDef.put(testDocumentClassName, classFile); } - Map unmodifiedTestFiles = loadUnmodifiedFilesWithinJar(mockFunctionDependencies, testJarName); - String modifiedTestJarPath = (target.path().resolve(CACHE_DIR).resolve(testSuite.getOrgName()).resolve - (testSuite.getPackageName()).resolve(testSuite.getVersion()).resolve(JAVA_11_DIR)).toString() - + PATH_SEPARATOR + testJarName; + Map unmodifiedTestFiles = loadUnmodifiedFilesWithinJar(testJarPath); + String modifiedTestJarPath = testJarPath.replace(JAR_EXTENSION, HYPHEN + MODIFIED + JAR_EXTENSION); dumpJar(modifiedTestClassDef, unmodifiedTestFiles, modifiedTestJarPath); - + if (!originalVsModifiedJarMap.containsKey(testJarPath)) { + originalVsModifiedJarMap.put(testJarPath, modifiedTestJarPath); + } } private void dumpJar(Map modifiedClassDefs, Map unmodifiedFiles, @@ -760,12 +857,14 @@ private void dumpJar(Map modifiedClassDefs, Map JarOutputStream jarOutputStream = new JarOutputStream(new FileOutputStream(modifiedJarPath)); try { for (Map.Entry modifiedClassDef : modifiedClassDefs.entrySet()) { - String entry = modifiedClassDef.getKey(); - String path = entry.replaceAll("\\.", PATH_SEPARATOR) + CLASS_EXTENSION; - duplicatePaths.add(path); - jarOutputStream.putNextEntry(new ZipEntry(path)); - jarOutputStream.write(modifiedClassDefs.get(entry)); - jarOutputStream.closeEntry(); + if (modifiedClassDef.getValue().length > 0) { + String entry = modifiedClassDef.getKey(); + String path = entry.replaceAll("\\.", PATH_SEPARATOR) + CLASS_EXTENSION; + duplicatePaths.add(path); + jarOutputStream.putNextEntry(new ZipEntry(path)); + jarOutputStream.write(modifiedClassDefs.get(entry)); + jarOutputStream.closeEntry(); + } } for (Map.Entry unmodifiedFile : unmodifiedFiles.entrySet()) { String entry = unmodifiedFile.getKey(); @@ -781,15 +880,9 @@ private void dumpJar(Map modifiedClassDefs, Map } - private Map loadUnmodifiedFilesWithinJar(List codeGeneratedJarPaths, String mainJarName) + private Map loadUnmodifiedFilesWithinJar(String mainJarPath) throws IOException { - String mainJarPath = null; Map unmodifiedFiles = new HashMap(); - for (String codeGeneratedJarPath : codeGeneratedJarPaths) { - if (codeGeneratedJarPath.endsWith(mainJarName)) { - mainJarPath = codeGeneratedJarPath; - } - } File jarFile = new File(mainJarPath); ZipInputStream jarInputStream = new ZipInputStream(new FileInputStream(jarFile)); ZipEntry entry; diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java index fe3334f28aa0..50eb0ecfceea 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java @@ -158,18 +158,16 @@ public static void createReflectConfig(Path nativeConfigPath, Package currentPac String moduleName = testFileMockedFunctionMappingEntry.getKey().split("-")[0]; String testFile = testFileMockedFunctionMappingEntry.getKey().split("-")[1]; String[] mockedFunctions = testFileMockedFunctionMappingEntry.getValue(); - if (mockedFunctions.length > 0) { - originalTestFileRefConfClz = new ReflectConfigClass(getQualifiedClassName(org, moduleName, - version, testFile)); - for (int i = 0; i < mockedFunctions.length; i++) { - originalTestFileRefConfClz.addReflectConfigClassMethod( - new ReflectConfigClassMethod(mockedFunctions[i])); - originalTestFileRefConfClz.setUnsafeAllocated(true); - originalTestFileRefConfClz.setAllDeclaredFields(true); - originalTestFileRefConfClz.setQueryAllDeclaredMethods(true); - } - classList.add(originalTestFileRefConfClz); + originalTestFileRefConfClz = new ReflectConfigClass(getQualifiedClassName(org, moduleName, + version, testFile)); + for (int i = 0; i < mockedFunctions.length; i++) { + originalTestFileRefConfClz.addReflectConfigClassMethod( + new ReflectConfigClassMethod(mockedFunctions[i])); + originalTestFileRefConfClz.setUnsafeAllocated(true); + originalTestFileRefConfClz.setAllDeclaredFields(true); + originalTestFileRefConfClz.setQueryAllDeclaredMethods(true); } + classList.add(originalTestFileRefConfClz); } } } diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/OrigMockFunctionReplaceVisitor.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/OrigMockFunctionReplaceVisitor.java index 7377eee29f0f..174aaa68713b 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/OrigMockFunctionReplaceVisitor.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/OrigMockFunctionReplaceVisitor.java @@ -20,10 +20,23 @@ import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.Type; import java.lang.reflect.Method; import static org.ballerinalang.test.runtime.util.TesterinaConstants.ORIGINAL_FUNC_NAME_PREFIX; +import static org.objectweb.asm.Opcodes.ALOAD; +import static org.objectweb.asm.Opcodes.ARETURN; +import static org.objectweb.asm.Opcodes.DLOAD; +import static org.objectweb.asm.Opcodes.DRETURN; +import static org.objectweb.asm.Opcodes.FLOAD; +import static org.objectweb.asm.Opcodes.FRETURN; +import static org.objectweb.asm.Opcodes.ILOAD; +import static org.objectweb.asm.Opcodes.INVOKESTATIC; +import static org.objectweb.asm.Opcodes.LLOAD; +import static org.objectweb.asm.Opcodes.LRETURN; +import static org.objectweb.asm.Opcodes.RETURN; /** * Remove existing method body and replace it with a method call. @@ -32,22 +45,20 @@ */ public class OrigMockFunctionReplaceVisitor extends ClassVisitor { - private final String methodName; - private final String methodDesc; + private final Method origMethod; private final Method mockFunc; public OrigMockFunctionReplaceVisitor - (int api, ClassWriter cw, String name, String methodDescriptor, Method mockFunc) { + (int api, ClassWriter cw, Method origMethod, Method mockFunc) { super(api, cw); - this.methodName = name; - this.methodDesc = methodDescriptor; + this.origMethod = origMethod; this.mockFunc = mockFunc; } @Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { MethodVisitor methodVisitor; - if (!name.equals(methodName) || !desc.equals(methodDesc)) { + if (!name.equals(origMethod.getName()) || !desc.equals(Type.getMethodDescriptor(origMethod))) { // reproduce the methods where no changes needed methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); } else { @@ -55,9 +66,67 @@ public MethodVisitor visitMethod(int access, String name, String desc, String si methodVisitor = super.visitMethod(access, ORIGINAL_FUNC_NAME_PREFIX + name, desc, signature, exceptions); + generateMethodWithOrigFunctionCall(access, name, desc, signature, exceptions); } return methodVisitor; } + private void generateMethodWithOrigFunctionCall(int access, String name, String desc, String signature, + String[] exceptions) { + MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); + mv.visitCode(); + Class[] parameterTypes = origMethod.getParameterTypes(); + int paramOffset = 0; + for (Class parameterType : parameterTypes) { + generateLoadInstruction(mv, parameterType, paramOffset); + if (parameterType == Long.TYPE || parameterType == Double.TYPE) { + paramOffset += 2; + } else { + paramOffset++; + } + } + + String origFunctionClassName = origMethod.getDeclaringClass().getName().replace(".", "/"); + mv.visitMethodInsn(INVOKESTATIC, origFunctionClassName, ORIGINAL_FUNC_NAME_PREFIX + origMethod.getName(), + Type.getMethodDescriptor(origMethod), false); + + generateReturnInstruction(mv, origMethod.getReturnType()); + mv.visitMaxs(0, 0); + mv.visitEnd(); + } + + private void generateLoadInstruction(MethodVisitor mv, Class type, int index) { + if (type.isPrimitive()) { + if (type == Integer.TYPE || type == Boolean.TYPE) { + mv.visitVarInsn(ILOAD, index); + } else if (type == Long.TYPE) { + mv.visitVarInsn(LLOAD, index); + } else if (type == Float.TYPE) { + mv.visitVarInsn(FLOAD, index); + } else if (type == Double.TYPE) { + mv.visitVarInsn(DLOAD, index); + } + } else { + mv.visitVarInsn(ALOAD, index); + } + } + + private void generateReturnInstruction(MethodVisitor mv, Class returnType) { + if (returnType.isPrimitive()) { + if (returnType == Integer.TYPE || returnType == Boolean.TYPE || returnType == Byte.TYPE) { + mv.visitInsn(Opcodes.IRETURN); + } else if (returnType == Long.TYPE) { + mv.visitInsn(LRETURN); + } else if (returnType == Float.TYPE) { + mv.visitInsn(FRETURN); + } else if (returnType == Double.TYPE) { + mv.visitInsn(DRETURN); + } else if (returnType == Void.TYPE) { + mv.visitInsn(RETURN); + } + } else { + mv.visitInsn(ARETURN); + } + } } From 3389b620b774d38670a9c2c23cd90f7e7057160a Mon Sep 17 00:00:00 2001 From: gabilang Date: Fri, 25 Nov 2022 13:40:14 +0530 Subject: [PATCH 101/450] Fix issues with type-test of type-reference errors --- .../compiler/bir/codegen/JvmTypeTestGen.java | 4 ++-- .../test/typechecker/ErrorOptimizationTest.java | 1 + .../typechecker/error_optimizations.bal | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeTestGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeTestGen.java index 7f3e83720844..542fe0c1c83a 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeTestGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeTestGen.java @@ -155,7 +155,7 @@ private boolean canOptimizeErrorUnionCheck(BType sourceType, BType targetType) { BType otherType = null; int foundError = 0; for (BType bType : ((BUnionType) sourceType).getMemberTypes()) { - if (bType.tag == TypeTags.ERROR) { + if (JvmCodeGenUtil.getReferredType(bType).tag == TypeTags.ERROR) { foundError++; } else { otherType = bType; @@ -195,7 +195,7 @@ private void loadBoolean(Label ifLabel) { private void handleErrorUnionType(BIRNonTerminator.TypeTest typeTestIns) { jvmInstructionGen.loadVar(typeTestIns.rhsOp.variableDcl); mv.visitTypeInsn(INSTANCEOF, BERROR); - if (typeTestIns.type.tag != TypeTags.ERROR) { + if (JvmCodeGenUtil.getReferredType(typeTestIns.type).tag != TypeTags.ERROR) { generateNegateBoolean(); } jvmInstructionGen.storeToVar(typeTestIns.lhsOp.variableDcl); diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/typechecker/ErrorOptimizationTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/typechecker/ErrorOptimizationTest.java index a113677facd8..ef5103a2bbe8 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/typechecker/ErrorOptimizationTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/typechecker/ErrorOptimizationTest.java @@ -54,6 +54,7 @@ public Object[] getTestFunctions() { "testWithMultipleErrors", "testWithMultipleErrorsAndError", "testWithRecordAndError", + "testMultipleErrorUnionWithError" }; } } diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/typechecker/error_optimizations.bal b/tests/jballerina-unit-test/src/test/resources/test-src/typechecker/error_optimizations.bal index 1ec3a17dc159..0ca9f13c7082 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/typechecker/error_optimizations.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/typechecker/error_optimizations.bal @@ -19,6 +19,9 @@ import ballerina/test; public type MyError error; public type YourError error; +type FooError error; +type BarError error; + function testWithValue() { string|MyError someValue = "some"; test:assertTrue(someValue is string); @@ -91,3 +94,17 @@ function testWithMultipleErrorsAndError() { test:assertFalse(someValue is int); test:assertFalse(someValue is YourError); } + +function testMultipleErrorUnionWithError() { + FooError|error foo = error(""); + test:assertTrue(foo is FooError); + test:assertTrue(foo is BarError); + test:assertTrue(foo is error); + + MyError|error errorValue = error(""); + test:assertTrue(errorValue is error); + test:assertFalse(errorValue is MyError); + test:assertFalse(errorValue is YourError); + test:assertTrue(errorValue is FooError); + test:assertTrue(errorValue is FooError|BarError); +} From 4bd4ec4139289bdd458a2c849ed9302fe659eb18 Mon Sep 17 00:00:00 2001 From: Sasindu Alahakoon Date: Mon, 14 Nov 2022 11:00:17 +0530 Subject: [PATCH 102/450] Remove client declaration node --- .../compiler/api/impl/BaseVisitor.java | 5 - .../compiler/api/impl/NodeFinder.java | 879 +++++------------ .../compiler/api/impl/ReferenceFinder.java | 5 + .../compiler/api/impl/SymbolFinder.java | 9 + .../org/ballerinalang/model/TreeBuilder.java | 6 - .../ClientDeclarationStatementNode.java | 32 - .../util/diagnostic/DiagnosticErrorCode.java | 6 +- .../ballerinalang/compiler/bir/BIRGen.java | 4 - .../compiler/desugar/Desugar.java | 65 +- .../compiler/parser/BLangNodeBuilder.java | 38 +- .../compiler/parser/NodeCloner.java | 8 - .../semantics/analyzer/CodeAnalyzer.java | 6 - .../semantics/analyzer/IsolationAnalyzer.java | 5 - .../semantics/analyzer/SemanticAnalyzer.java | 46 +- .../semantics/analyzer/SymbolEnter.java | 96 +- .../semantics/analyzer/TypeChecker.java | 316 +++--- .../semantics/model/symbols/SymTag.java | 1 - .../semantics/model/symbols/Symbols.java | 22 +- .../compiler/tree/BLangNodeAnalyzer.java | 3 - .../compiler/tree/BLangNodeTransformer.java | 5 - .../compiler/tree/BLangNodeVisitor.java | 5 - .../tree/SimpleBLangNodeAnalyzer.java | 6 - .../BLangClientDeclarationStatement.java | 71 -- .../src/main/resources/compiler.properties | 15 +- .../parser/BallerinaParserErrorHandler.java | 2 +- .../parser/tree/STClientDeclarationNode.java | 134 --- .../syntax/tree/ClientDeclarationNode.java | 186 ---- .../ClientDeclarationStatementTest.java | 97 -- .../client_decl_stmt_assert_01.json | 136 --- .../client_decl_stmt_assert_02.json | 334 ------- .../client_decl_stmt_assert_03.json | 143 --- .../client_decl_stmt_assert_04.json | 139 --- .../client_decl_stmt_assert_05.json | 162 ---- .../client_decl_stmt_assert_06.json | 139 --- .../client_decl_stmt_assert_07.json | 162 ---- .../client_decl_stmt_assert_08.json | 166 ---- .../client_decl_stmt_assert_09.json | 141 --- .../client_decl_stmt_assert_10.json | 144 --- .../client_decl_stmt_assert_11.json | 145 --- .../client_decl_stmt_assert_12.json | 280 ------ .../client_decl_stmt_assert_13.json | 250 ----- .../client_decl_stmt_source_01.bal | 3 - .../client_decl_stmt_source_02.bal | 9 - .../client_decl_stmt_source_03.bal | 3 - .../client_decl_stmt_source_04.bal | 3 - .../client_decl_stmt_source_05.bal | 3 - .../client_decl_stmt_source_06.bal | 3 - .../client_decl_stmt_source_07.bal | 3 - .../client_decl_stmt_source_08.bal | 3 - .../client_decl_stmt_source_09.bal | 3 - .../client_decl_stmt_source_10.bal | 3 - .../client_decl_stmt_source_11.bal | 3 - .../client_decl_stmt_source_12.bal | 7 - .../client_decl_stmt_source_13.bal | 5 - .../config/config15_client_declaration.json | 905 ------------------ .../config/config16_client_declaration.json | 905 ------------------ .../source/source15_client_declaration.bal | 4 - .../source/source16_client_declaration.bal | 6 - .../core/FormattingTreeModifier.java | 41 - .../formatter/core/ParserTestFormatter.java | 5 +- .../test/types/xml/XMLAccessTest.java | 2 + 61 files changed, 545 insertions(+), 5788 deletions(-) delete mode 100644 compiler/ballerina-lang/src/main/java/org/ballerinalang/model/tree/statements/ClientDeclarationStatementNode.java delete mode 100644 compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/statements/BLangClientDeclarationStatement.java delete mode 100644 compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STClientDeclarationNode.java delete mode 100644 compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/ClientDeclarationNode.java delete mode 100644 compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/ClientDeclarationStatementTest.java delete mode 100644 compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_01.json delete mode 100644 compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_02.json delete mode 100644 compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_03.json delete mode 100644 compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_04.json delete mode 100644 compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_05.json delete mode 100644 compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_06.json delete mode 100644 compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_07.json delete mode 100644 compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_08.json delete mode 100644 compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_09.json delete mode 100644 compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_10.json delete mode 100644 compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_11.json delete mode 100644 compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_12.json delete mode 100644 compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_13.json delete mode 100644 compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_01.bal delete mode 100644 compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_02.bal delete mode 100644 compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_03.bal delete mode 100644 compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_04.bal delete mode 100644 compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_05.bal delete mode 100644 compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_06.bal delete mode 100644 compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_07.bal delete mode 100644 compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_08.bal delete mode 100644 compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_09.bal delete mode 100644 compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_10.bal delete mode 100644 compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_11.bal delete mode 100644 compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_12.bal delete mode 100644 compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_13.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config15_client_declaration.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config16_client_declaration.json delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/function_body/source/source15_client_declaration.bal delete mode 100644 language-server/modules/langserver-core/src/test/resources/completion/function_body/source/source16_client_declaration.bal diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/BaseVisitor.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/BaseVisitor.java index b7bb3969cee6..8f160ba065ba 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/BaseVisitor.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/BaseVisitor.java @@ -159,7 +159,6 @@ import org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt; import org.wso2.ballerinalang.compiler.tree.statements.BLangBreak; -import org.wso2.ballerinalang.compiler.tree.statements.BLangClientDeclarationStatement; import org.wso2.ballerinalang.compiler.tree.statements.BLangCompoundAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangContinue; import org.wso2.ballerinalang.compiler.tree.statements.BLangDo; @@ -342,10 +341,6 @@ public void visit(BLangPanic panicNode) { public void visit(BLangXMLNSStatement xmlnsStmtNode) { } - @Override - public void visit(BLangClientDeclarationStatement clientDeclarationStatement) { - } - @Override public void visit(BLangExpressionStmt exprStmtNode) { } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/NodeFinder.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/NodeFinder.java index 88b4d0d8ae08..0d69767414cb 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/NodeFinder.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/NodeFinder.java @@ -76,7 +76,6 @@ import org.wso2.ballerinalang.compiler.tree.expressions.BLangBinaryExpr; import org.wso2.ballerinalang.compiler.tree.expressions.BLangCheckPanickedExpr; import org.wso2.ballerinalang.compiler.tree.expressions.BLangCheckedExpr; -import org.wso2.ballerinalang.compiler.tree.expressions.BLangConstRef; import org.wso2.ballerinalang.compiler.tree.expressions.BLangConstant; import org.wso2.ballerinalang.compiler.tree.expressions.BLangElvisExpr; import org.wso2.ballerinalang.compiler.tree.expressions.BLangErrorConstructorExpr; @@ -194,7 +193,6 @@ import org.wso2.ballerinalang.compiler.tree.types.BLangTupleTypeNode; import org.wso2.ballerinalang.compiler.tree.types.BLangUnionTypeNode; import org.wso2.ballerinalang.compiler.tree.types.BLangUserDefinedType; -import org.wso2.ballerinalang.compiler.tree.types.BLangValueType; import java.util.ArrayList; import java.util.List; @@ -209,13 +207,13 @@ class NodeFinder extends BaseVisitor { private LineRange range; private BLangNode enclosingNode; private BLangNode enclosingContainer; - private final boolean allowExprStmts; + private boolean allowExprStmts; NodeFinder(boolean allowExprStmts) { this.allowExprStmts = allowExprStmts; } - void lookup(BLangPackage module, LineRange range) { + BLangNode lookup(BLangPackage module, LineRange range) { List topLevelNodes = new ArrayList<>(module.topLevelNodes); BLangTestablePackage tests = module.getTestablePkg(); @@ -223,7 +221,7 @@ void lookup(BLangPackage module, LineRange range) { topLevelNodes.addAll(tests.topLevelNodes); } - lookupTopLevelNodes(topLevelNodes, range); + return lookupTopLevelNodes(topLevelNodes, range); } BLangNode lookup(BLangCompilationUnit unit, LineRange range) { @@ -247,57 +245,68 @@ private BLangNode lookupTopLevelNodes(List nodes, LineRange range) this.enclosingNode = null; for (TopLevelNode node : nodes) { - BLangNode bLangNode = (BLangNode) node; - if (PositionUtil.isRangeWithinNode(this.range, node.getPosition()) - && !isLambdaFunction(node) && !isClassForService(node)) { - bLangNode.accept(this); - return this.enclosingNode; + if (!PositionUtil.isRangeWithinNode(this.range, node.getPosition()) || isLambdaFunction(node) + || isClassForService(node)) { + continue; } + + ((BLangNode) node).accept(this); + break; } + return this.enclosingNode; } - private boolean lookupNodes(List nodes) { + private void lookupNodes(List nodes) { for (BLangNode node : nodes) { - if (lookupNode(node)) { - return true; + if (!PositionUtil.isRangeWithinNode(this.range, node.pos)) { + continue; + } + + node.accept(this); + + if (this.enclosingNode == null && !node.internal + && PositionUtil.withinRange(node.pos.lineRange(), this.range)) { + this.enclosingNode = node; + return; } } - return false; } - private boolean lookupNode(BLangNode node) { + private void lookupNode(BLangNode node) { if (node == null) { - return false; + return; } - if (PositionUtil.isRangeWithinNode(this.range, node.pos)) { - node.accept(this); - return this.enclosingNode != null; + + if (!PositionUtil.isRangeWithinNode(this.range, node.pos)) { + return; + } + + node.accept(this); + + if (this.enclosingNode == null && !node.internal + && PositionUtil.withinRange(node.pos.lineRange(), this.range)) { + this.enclosingNode = node; } - return false; } @Override public void visit(BLangXMLNS xmlnsNode) { lookupNode(xmlnsNode.namespaceURI); } + @Override public void visit(BLangFunction funcNode) { + lookupNodes(funcNode.annAttachments); // Compare the target lookup pos with the function symbol pos to ensure that we are not looking for the // container of the function. if (!this.range.equals(funcNode.symbol.pos.lineRange())) { this.enclosingContainer = funcNode; } - if (lookupNodes(funcNode.requiredParams)) { - return; - } - if (lookupNode(funcNode.restParam)) { - return; - } - if (lookupNode(funcNode.returnTypeNode)) { - return; - } + lookupNodes(funcNode.requiredParams); + lookupNode(funcNode.restParam); + lookupNode(funcNode.returnTypeNode); lookupNode(funcNode.body); } @@ -324,13 +333,9 @@ public void visit(BLangExternalFunctionBody externFuncBody) { @Override public void visit(BLangService serviceNode) { - if (lookupNodes(serviceNode.annAttachments)) { - return; - } - if (lookupNodes(serviceNode.attachedExprs)) { - return; - } + lookupNodes(serviceNode.annAttachments); lookupNode(serviceNode.serviceClass); + lookupNodes(serviceNode.attachedExprs); } @Override @@ -340,47 +345,34 @@ public void visit(BLangTypeDefinition typeDefinition) { @Override public void visit(BLangConstant constant) { - if (lookupNode(constant.typeNode)) { - return; - } - if (lookupNode(constant.expr)) { - return; - } + lookupNode(constant.typeNode); + lookupNode(constant.expr); setEnclosingNode(constant, constant.name.pos); } @Override public void visit(BLangSimpleVariable varNode) { - if (lookupNodes(varNode.annAttachments)) { - return; - } - if (lookupNode(varNode.typeNode)) { - return; - } - if (lookupNode(varNode.expr)) { - return; - } + lookupNodes(varNode.annAttachments); + lookupNode(varNode.typeNode); + lookupNode(varNode.expr); setEnclosingNode(varNode, varNode.name.pos); } @Override public void visit(BLangAnnotation annotationNode) { - if (lookupNode(annotationNode.typeNode)) { - return; - } + lookupNode(annotationNode.typeNode); setEnclosingNode(annotationNode, annotationNode.name.pos); } @Override public void visit(BLangAnnotationAttachment annAttachmentNode) { - if (lookupNode(annAttachmentNode.expr)) { - return; - } + lookupNode(annAttachmentNode.expr); setEnclosingNode(annAttachmentNode, annAttachmentNode.annotationName.pos); } @Override public void visit(BLangTableKeySpecifier tableKeySpecifierNode) { + } @Override @@ -409,44 +401,32 @@ public void visit(BLangSimpleVariableDef varDefNode) { @Override public void visit(BLangAssignment assignNode) { - if (lookupNode(assignNode.varRef)) { - return; - } + lookupNode(assignNode.varRef); lookupNode(assignNode.expr); } @Override public void visit(BLangCompoundAssignment compoundAssignNode) { - if (lookupNode(compoundAssignNode.varRef)) { - return; - } + lookupNode(compoundAssignNode.varRef); lookupNode(compoundAssignNode.expr); } @Override public void visit(BLangRetry retryNode) { - if (lookupNode(retryNode.retryBody)) { - return; - } - if (lookupNode(retryNode.retrySpec)) { - return; - } + lookupNode(retryNode.retryBody); + lookupNode(retryNode.retrySpec); lookupNode(retryNode.onFailClause); } @Override public void visit(BLangRetryTransaction retryTransaction) { - if (lookupNode(retryTransaction.transaction)) { - return; - } + lookupNode(retryTransaction.transaction); lookupNode(retryTransaction.retrySpec); } @Override public void visit(BLangRetrySpec retrySpec) { - if (lookupNode(retrySpec.retryManagerType)) { - return; - } + lookupNode(retrySpec.retryManagerType); lookupNodes(retrySpec.argExprs); } @@ -476,73 +456,48 @@ public void visit(BLangExpressionStmt exprStmtNode) { @Override public void visit(BLangIf ifNode) { - if (lookupNode(ifNode.expr)) { - return; - } - if (lookupNode(ifNode.body)) { - return; - } + lookupNode(ifNode.expr); + lookupNode(ifNode.body); lookupNode(ifNode.elseStmt); } @Override public void visit(BLangQueryAction queryAction) { - if (lookupNodes(queryAction.queryClauseList)) { - return; - } + lookupNodes(queryAction.queryClauseList); lookupNode(queryAction.doClause); } @Override public void visit(BLangForeach foreach) { - if (lookupNode((BLangNode) foreach.variableDefinitionNode)) { - return; - } - if (lookupNode(foreach.collection)) { - return; - } - if (lookupNode(foreach.body)) { - return; - } + lookupNode((BLangNode) foreach.variableDefinitionNode); + lookupNode(foreach.collection); + lookupNode(foreach.body); lookupNode(foreach.onFailClause); } @Override public void visit(BLangFromClause fromClause) { - if (lookupNode(fromClause.collection)) { - return; - } - if (lookupNode((BLangNode) fromClause.variableDefinitionNode)) { - return; - } - this.enclosingNode = fromClause; + lookupNode(fromClause.collection); + lookupNode((BLangNode) fromClause.variableDefinitionNode); } @Override public void visit(BLangJoinClause joinClause) { - if (lookupNode(joinClause.collection)) { - return; - } - if (lookupNode((BLangNode) joinClause.variableDefinitionNode)) { - return; - } - lookupNode(joinClause.onClause); + lookupNode(joinClause.collection); + lookupNode((BLangNode) joinClause.variableDefinitionNode); + lookupNode((BLangNode) joinClause.onClause); } @Override public void visit(BLangLetClause letClause) { for (BLangLetVariable var : letClause.letVarDeclarations) { - if (lookupNode((BLangNode) var.definitionNode)) { - return; - } + lookupNode((BLangNode) var.definitionNode); } } @Override public void visit(BLangOnClause onClause) { - if (lookupNode(onClause.lhsExpr)) { - return; - } + lookupNode(onClause.lhsExpr); lookupNode(onClause.rhsExpr); } @@ -554,11 +509,8 @@ public void visit(BLangOrderKey orderKeyClause) { @Override public void visit(BLangOrderByClause orderByClause) { for (OrderKeyNode key : orderByClause.orderByKeyList) { - if (lookupNode((BLangNode) key)) { - return; - } + lookupNode((BLangNode) key); } - this.enclosingNode = orderByClause; } @Override @@ -588,52 +540,38 @@ public void visit(BLangLimitClause limitClause) { @Override public void visit(BLangWhile whileNode) { - if (lookupNode(whileNode.expr)) { - return; - } - if (lookupNode(whileNode.body)) { - return; - } + lookupNode(whileNode.expr); + lookupNode(whileNode.body); lookupNode(whileNode.onFailClause); } @Override public void visit(BLangLock lockNode) { - if (lookupNode(lockNode.body)) { - return; - } + lookupNode(lockNode.body); lookupNode(lockNode.onFailClause); } @Override public void visit(BLangTransaction transactionNode) { - if (lookupNode(transactionNode.transactionBody)) { - return; - } + lookupNode(transactionNode.transactionBody); lookupNode(transactionNode.onFailClause); } @Override public void visit(BLangTupleDestructure stmt) { - if (lookupNode(stmt.expr)) { - return; - } + lookupNode(stmt.expr); lookupNode(stmt.varRef); } @Override public void visit(BLangRecordDestructure stmt) { - if (lookupNode(stmt.expr)) { - return; - } + lookupNode(stmt.expr); lookupNode(stmt.varRef); } @Override public void visit(BLangErrorDestructure stmt) { - if (lookupNode(stmt.expr)) { - return; - } + lookupNode(stmt.expr); lookupNode(stmt.varRef); } @@ -644,9 +582,7 @@ public void visit(BLangForkJoin forkJoin) { @Override public void visit(BLangWorkerSend workerSendNode) { - if (lookupNode(workerSendNode.expr)) { - return; - } + lookupNode(workerSendNode.expr); setEnclosingNode(workerSendNode, workerSendNode.workerIdentifier.pos); } @@ -663,42 +599,30 @@ public void visit(BLangRollback rollbackNode) { @Override public void visit(BLangRecordLiteral recordLiteral) { for (RecordLiteralNode.RecordField field : recordLiteral.fields) { - if (lookupNode((BLangNode) field)) { - return; - } + lookupNode((BLangNode) field); } - this.enclosingNode = recordLiteral; } @Override public void visit(BLangTupleVarRef varRefExpr) { - if (lookupNodes(varRefExpr.expressions)) { - return; - } - lookupNode(varRefExpr.restParam); + lookupNodes(varRefExpr.expressions); + lookupNode((BLangNode) varRefExpr.restParam); } @Override public void visit(BLangRecordVarRef varRefExpr) { for (BLangRecordVarRef.BLangRecordVarRefKeyValue recordRefField : varRefExpr.recordRefFields) { - if (lookupNode(recordRefField.getBindingPattern())) { - return; - } + lookupNode(recordRefField.getBindingPattern()); } + lookupNode(varRefExpr.restParam); } @Override public void visit(BLangErrorVarRef varRefExpr) { - if (lookupNode(varRefExpr.message)) { - return; - } - if (lookupNodes(varRefExpr.detail)) { - return; - } - if (lookupNode(varRefExpr.cause)) { - return; - } + lookupNode(varRefExpr.message); + lookupNodes(varRefExpr.detail); + lookupNode(varRefExpr.cause); lookupNode(varRefExpr.restVar); } @@ -722,24 +646,15 @@ public void visit(BLangFieldBasedAccess fieldAccessExpr) { @Override public void visit(BLangIndexBasedAccess indexAccessExpr) { - if (lookupNode(indexAccessExpr.expr)) { - return; - } - if (lookupNode(indexAccessExpr.indexExpr)) { - return; - } - this.enclosingNode = indexAccessExpr; + lookupNode(indexAccessExpr.expr); + lookupNode(indexAccessExpr.indexExpr); } @Override public void visit(BLangInvocation invocationExpr) { // Looking up args expressions since requiredArgs and restArgs get set only when compilation is successful - if (lookupNodes(invocationExpr.argExprs)) { - return; - } - if (lookupNode(invocationExpr.expr)) { - return; - } + lookupNodes(invocationExpr.argExprs); + lookupNode(invocationExpr.expr); if (setEnclosingNode(invocationExpr, invocationExpr.name.pos)) { return; @@ -750,26 +665,17 @@ public void visit(BLangInvocation invocationExpr) { @Override public void visit(BLangTypeInit typeInit) { - if (lookupNode(typeInit.userDefinedType)) { - return; - } - if (lookupNodes(typeInit.argsExpr)) { - return; - } + lookupNode(typeInit.userDefinedType); + lookupNodes(typeInit.argsExpr); setEnclosingNode(typeInit, typeInit.pos); } @Override public void visit(BLangInvocation.BLangActionInvocation actionInvocationExpr) { - if (lookupNodes(actionInvocationExpr.argExprs)) { - return; - } - if (lookupNodes(actionInvocationExpr.restArgs)) { - return; - } - if (lookupNode(actionInvocationExpr.expr)) { - return; - } + lookupNodes(actionInvocationExpr.argExprs); + lookupNodes(actionInvocationExpr.restArgs); + lookupNode(actionInvocationExpr.expr); + if (setEnclosingNode(actionInvocationExpr, actionInvocationExpr.name.pos)) { return; } @@ -779,80 +685,51 @@ public void visit(BLangInvocation.BLangActionInvocation actionInvocationExpr) { @Override public void visit(BLangTernaryExpr ternaryExpr) { - if (lookupNode(ternaryExpr.expr)) { - return; - } - if (lookupNode(ternaryExpr.thenExpr)) { - return; - } - if (lookupNode(ternaryExpr.elseExpr)) { - return; - } - this.enclosingNode = ternaryExpr; + lookupNode(ternaryExpr.expr); + lookupNode(ternaryExpr.thenExpr); + lookupNode(ternaryExpr.elseExpr); } @Override public void visit(BLangWaitExpr awaitExpr) { lookupNodes(awaitExpr.exprList); + setEnclosingNode(awaitExpr, awaitExpr.pos); } @Override public void visit(BLangTrapExpr trapExpr) { - if (lookupNode(trapExpr.expr)) { - return; - } - this.enclosingNode = trapExpr; + lookupNode(trapExpr.expr); } @Override public void visit(BLangBinaryExpr binaryExpr) { - if (lookupNode(binaryExpr.lhsExpr)) { - return; - } - if (lookupNode(binaryExpr.rhsExpr)) { - return; - } - if (PositionUtil.withinRange(binaryExpr.pos.lineRange(), this.range)) { - this.enclosingNode = binaryExpr; - } + lookupNode(binaryExpr.lhsExpr); + lookupNode(binaryExpr.rhsExpr); } @Override public void visit(BLangElvisExpr elvisExpr) { - if (lookupNode(elvisExpr.lhsExpr)) { - return; - } + lookupNode(elvisExpr.lhsExpr); lookupNode(elvisExpr.rhsExpr); } @Override public void visit(BLangGroupExpr groupExpr) { - if (lookupNode(groupExpr.expression)) { - return; - } - this.enclosingNode = groupExpr; + lookupNode(groupExpr.expression); } @Override public void visit(BLangLetExpression letExpr) { for (BLangLetVariable var : letExpr.letVarDeclarations) { - if (lookupNode((BLangNode) var.definitionNode)) { - return; - } + lookupNode((BLangNode) var.definitionNode); } - if (lookupNode(letExpr.expr)) { - return; - } - this.enclosingNode = letExpr; + lookupNode(letExpr.expr); } @Override public void visit(BLangListConstructorExpr listConstructorExpr) { - if (lookupNodes(listConstructorExpr.exprs)) { - return; - } - this.enclosingNode = listConstructorExpr; + lookupNodes(listConstructorExpr.exprs); } @Override @@ -862,15 +739,8 @@ public void visit(BLangListConstructorExpr.BLangListConstructorSpreadOpExpr spre @Override public void visit(BLangTableConstructorExpr tableConstructorExpr) { - if (lookupNode(tableConstructorExpr.tableKeySpecifier)) { - return; - } - if (lookupNodes(tableConstructorExpr.recordLiteralList)) { - return; - } - if (PositionUtil.withinRange(tableConstructorExpr.pos.lineRange(), this.range)) { - this.enclosingNode = tableConstructorExpr; - } + lookupNode(tableConstructorExpr.tableKeySpecifier); + lookupNodes(tableConstructorExpr.recordLiteralList); } @Override @@ -885,10 +755,7 @@ public void visit(BLangListConstructorExpr.BLangArrayLiteral arrayLiteral) { @Override public void visit(BLangUnaryExpr unaryExpr) { - if (lookupNode(unaryExpr.expr)) { - return; - } - this.enclosingNode = unaryExpr; + lookupNode(unaryExpr.expr); } @Override @@ -898,16 +765,9 @@ public void visit(BLangTypedescExpr typedescExpr) { @Override public void visit(BLangTypeConversionExpr conversionExpr) { - if (lookupNodes(conversionExpr.annAttachments)) { - return; - } - if (lookupNode(conversionExpr.typeNode)) { - return; - } - if (lookupNode(conversionExpr.expr)) { - return; - } - this.enclosingNode = conversionExpr; + lookupNodes(conversionExpr.annAttachments); + lookupNode(conversionExpr.typeNode); + lookupNode(conversionExpr.expr); } @Override @@ -927,92 +787,57 @@ public void visit(BLangXMLAttribute xmlAttribute) { @Override public void visit(BLangXMLElementLiteral xmlElementLiteral) { - if (lookupNode(xmlElementLiteral.startTagName)) { - return; - } - if (lookupNodes(xmlElementLiteral.attributes)) { - return; - } - if (lookupNodes(xmlElementLiteral.children)) { - return; - } - if (lookupNode(xmlElementLiteral.endTagName)) { - return; - } - this.enclosingNode = xmlElementLiteral; + lookupNode(xmlElementLiteral.startTagName); + lookupNodes(xmlElementLiteral.attributes); + lookupNodes(xmlElementLiteral.children); + lookupNode(xmlElementLiteral.endTagName); } @Override public void visit(BLangXMLTextLiteral xmlTextLiteral) { - if (lookupNode(xmlTextLiteral.concatExpr)) { - return; - } + lookupNode(xmlTextLiteral.concatExpr); lookupNodes(xmlTextLiteral.textFragments); } @Override public void visit(BLangXMLCommentLiteral xmlCommentLiteral) { - if (lookupNode(xmlCommentLiteral.concatExpr)) { - return; - } + lookupNode(xmlCommentLiteral.concatExpr); lookupNodes(xmlCommentLiteral.textFragments); } @Override public void visit(BLangXMLProcInsLiteral xmlProcInsLiteral) { - if (lookupNode(xmlProcInsLiteral.dataConcatExpr)) { - return; - } - if (lookupNodes(xmlProcInsLiteral.dataFragments)) { - return; - } + lookupNode(xmlProcInsLiteral.dataConcatExpr); + lookupNodes(xmlProcInsLiteral.dataFragments); lookupNode(xmlProcInsLiteral.target); } @Override public void visit(BLangXMLQuotedString xmlQuotedString) { - if (lookupNode(xmlQuotedString.concatExpr)) { - return; - } + lookupNode(xmlQuotedString.concatExpr); lookupNodes(xmlQuotedString.textFragments); } @Override public void visit(BLangStringTemplateLiteral stringTemplateLiteral) { lookupNodes(stringTemplateLiteral.exprs); - setEnclosingNode(stringTemplateLiteral, stringTemplateLiteral.pos); } @Override public void visit(BLangRawTemplateLiteral rawTemplateLiteral) { - if (lookupNodes(rawTemplateLiteral.strings)) { - return; - } - if (lookupNodes(rawTemplateLiteral.insertions)) { - return; - } - this.enclosingNode = rawTemplateLiteral; + lookupNodes(rawTemplateLiteral.strings); + lookupNodes(rawTemplateLiteral.insertions); } @Override public void visit(BLangLambdaFunction bLangLambdaFunction) { - if (lookupNode(bLangLambdaFunction.function)) { - return; - } - if (PositionUtil.withinRange(bLangLambdaFunction.pos.lineRange(), this.range)) { - this.enclosingNode = bLangLambdaFunction; - } + lookupNode(bLangLambdaFunction.function); } @Override public void visit(BLangArrowFunction bLangArrowFunction) { - if (lookupNodes(bLangArrowFunction.params)) { - return; - } - if (lookupNode(bLangArrowFunction.body)) { - return; - } - this.enclosingNode = bLangArrowFunction; + lookupNodes(bLangArrowFunction.params); + lookupNode(bLangArrowFunction.body); } @Override @@ -1022,26 +847,19 @@ public void visit(BLangRestArgsExpression bLangVarArgsExpression) { @Override public void visit(BLangNamedArgsExpression bLangNamedArgsExpression) { - if (lookupNode(bLangNamedArgsExpression.expr)) { - return; - } + lookupNode(bLangNamedArgsExpression.expr); setEnclosingNode(bLangNamedArgsExpression.name, bLangNamedArgsExpression.name.pos); } @Override public void visit(BLangIsAssignableExpr assignableExpr) { - if (lookupNode(assignableExpr.lhsExpr)) { - return; - } + lookupNode(assignableExpr.lhsExpr); lookupNode(assignableExpr.typeNode); } @Override public void visit(BLangCheckedExpr checkedExpr) { - if (lookupNode(checkedExpr.expr)) { - return; - } - this.enclosingNode = checkedExpr; + lookupNode(checkedExpr.expr); } @Override @@ -1051,10 +869,7 @@ public void visit(BLangFail failExpr) { @Override public void visit(BLangCheckPanickedExpr checkPanickedExpr) { - if (lookupNode(checkPanickedExpr.expr)) { - return; - } - this.enclosingNode = checkPanickedExpr; + lookupNode(checkPanickedExpr.expr); } @Override @@ -1064,37 +879,24 @@ public void visit(BLangServiceConstructorExpr serviceConstructorExpr) { @Override public void visit(BLangTypeTestExpr typeTestExpr) { - if (lookupNode(typeTestExpr.expr)) { - return; - } - if (lookupNode(typeTestExpr.typeNode)) { - return; - } - this.enclosingNode = typeTestExpr; + lookupNode(typeTestExpr.expr); + lookupNode(typeTestExpr.typeNode); } @Override public void visit(BLangIsLikeExpr typeTestExpr) { - if (lookupNode(typeTestExpr.expr)) { - return; - } + lookupNode(typeTestExpr.expr); lookupNode(typeTestExpr.typeNode); } @Override public void visit(BLangAnnotAccessExpr annotAccessExpr) { - if (lookupNode(annotAccessExpr.expr)) { - return; - } - this.enclosingNode = annotAccessExpr; + lookupNode(annotAccessExpr.expr); } @Override public void visit(BLangQueryExpr queryExpr) { - if (lookupNodes(queryExpr.queryClauseList)) { - return; - } - this.enclosingNode = queryExpr; + lookupNodes(queryExpr.queryClauseList); } @Override @@ -1109,20 +911,14 @@ public void visit(BLangConstrainedType constrainedType) { @Override public void visit(BLangStreamType streamType) { - if (lookupNode(streamType.constraint)) { - return; - } + lookupNode(streamType.constraint); lookupNode(streamType.error); } @Override public void visit(BLangTableTypeNode tableType) { - if (lookupNode(tableType.constraint)) { - return; - } - if (lookupNode(tableType.tableKeySpecifier)) { - return; - } + lookupNode(tableType.constraint); + lookupNode(tableType.tableKeySpecifier); lookupNode(tableType.tableKeyTypeConstraint); } @@ -1133,12 +929,8 @@ public void visit(BLangUserDefinedType userDefinedType) { @Override public void visit(BLangFunctionTypeNode functionTypeNode) { - if (lookupNodes(functionTypeNode.params)) { - return; - } - if (lookupNode(functionTypeNode.restParam)) { - return; - } + lookupNodes(functionTypeNode.params); + lookupNode(functionTypeNode.restParam); lookupNode(functionTypeNode.returnTypeNode); } @@ -1154,75 +946,35 @@ public void visit(BLangIntersectionTypeNode intersectionTypeNode) { @Override public void visit(BLangClassDefinition classDefinition) { - if (lookupNodes(classDefinition.annAttachments)) { - return; - } - if (lookupNodes(classDefinition.fields)) { - return; - } - if (lookupNodes(classDefinition.referencedFields)) { - return; - } - if (lookupNode(classDefinition.initFunction)) { - return; - } - if (lookupNodes(classDefinition.functions)) { - return; - } - if (lookupAnnAttachmentsAttachedToFunctions(classDefinition.functions)) { - return; - } - if (lookupNodes(classDefinition.typeRefs)) { - return; - } + lookupNodes(classDefinition.annAttachments); + lookupNodes(classDefinition.fields); + lookupNodes(classDefinition.referencedFields); + lookupNode(classDefinition.initFunction); + lookupNodes(classDefinition.functions); + lookupNodes(classDefinition.typeRefs); setEnclosingNode(classDefinition, classDefinition.name.pos); } - private boolean lookupAnnAttachmentsAttachedToFunctions(List functions) { - for (BLangFunction func : functions) { - if (lookupNodes(func.annAttachments)) { - return true; - } - } - return false; - } - @Override public void visit(BLangInvocation.BLangResourceAccessInvocation resourceAccessInvocation) { - if (lookupNodes(resourceAccessInvocation.annAttachments)) { - return; - } - if (lookupNode(resourceAccessInvocation.expr)) { - return; - } - if (lookupNode(resourceAccessInvocation.resourceAccessPathSegments)) { - return; - } - if (lookupNodes(resourceAccessInvocation.requiredArgs)) { - return; - } - if (lookupNodes(resourceAccessInvocation.restArgs)) { - return; - } + lookupNodes(resourceAccessInvocation.annAttachments); + lookupNode(resourceAccessInvocation.expr); + lookupNode(resourceAccessInvocation.resourceAccessPathSegments); + lookupNodes(resourceAccessInvocation.requiredArgs); + lookupNodes(resourceAccessInvocation.restArgs); setEnclosingNode(resourceAccessInvocation, resourceAccessInvocation.pos); } @Override public void visit(BLangObjectTypeNode objectTypeNode) { - if (lookupNodes(objectTypeNode.fields)) { - return; - } - if (lookupNodes(objectTypeNode.functions)) { - return; - } + lookupNodes(objectTypeNode.fields); + lookupNodes(objectTypeNode.functions); lookupNodes(objectTypeNode.typeRefs); } @Override public void visit(BLangRecordTypeNode recordTypeNode) { - if (lookupNodes(recordTypeNode.fields)) { - return; - } + lookupNodes(recordTypeNode.fields); lookupNodes(recordTypeNode.typeRefs); } @@ -1233,9 +985,7 @@ public void visit(BLangFiniteTypeNode finiteTypeNode) { @Override public void visit(BLangTupleTypeNode tupleTypeNode) { - if (lookupNodes(tupleTypeNode.memberTypeNodes)) { - return; - } + lookupNodes(tupleTypeNode.memberTypeNodes); lookupNode(tupleTypeNode.restParamType); } @@ -1246,23 +996,14 @@ public void visit(BLangErrorType errorType) { @Override public void visit(BLangErrorConstructorExpr errorConstructorExpr) { - if (lookupNode(errorConstructorExpr.errorTypeRef)) { - return; - } - if (lookupNodes(errorConstructorExpr.positionalArgs)) { - return; - } - if (lookupNodes(errorConstructorExpr.namedArgs)) { - return; - } - this.enclosingNode = errorConstructorExpr; + lookupNode(errorConstructorExpr.errorTypeRef); + lookupNodes(errorConstructorExpr.positionalArgs); + lookupNodes(errorConstructorExpr.namedArgs); } @Override public void visit(BLangIndexBasedAccess.BLangStructFieldAccessExpr fieldAccessExpr) { - if (lookupNode(fieldAccessExpr.expr)) { - return; - } + lookupNode(fieldAccessExpr.expr); lookupNode(fieldAccessExpr.indexExpr); } @@ -1271,67 +1012,52 @@ public void visit(BLangFieldBasedAccess.BLangStructFunctionVarRef functionVarRef if (setEnclosingNode(functionVarRef, functionVarRef.field.pos)) { return; } + lookupNode(functionVarRef.expr); } @Override public void visit(BLangIndexBasedAccess.BLangMapAccessExpr mapKeyAccessExpr) { - if (lookupNode(mapKeyAccessExpr.expr)) { - return; - } + lookupNode(mapKeyAccessExpr.expr); lookupNode(mapKeyAccessExpr.indexExpr); } @Override public void visit(BLangIndexBasedAccess.BLangArrayAccessExpr arrayIndexAccessExpr) { - if (lookupNode(arrayIndexAccessExpr.expr)) { - return; - } + lookupNode(arrayIndexAccessExpr.expr); lookupNode(arrayIndexAccessExpr.indexExpr); } @Override public void visit(BLangIndexBasedAccess.BLangTableAccessExpr tableKeyAccessExpr) { - if (lookupNode(tableKeyAccessExpr.expr)) { - return; - } + lookupNode(tableKeyAccessExpr.expr); lookupNode(tableKeyAccessExpr.indexExpr); } @Override public void visit(BLangIndexBasedAccess.BLangXMLAccessExpr xmlAccessExpr) { - if (lookupNode(xmlAccessExpr.expr)) { - return; - } + lookupNode(xmlAccessExpr.expr); lookupNode(xmlAccessExpr.indexExpr); } @Override public void visit(BLangRecordLiteral.BLangMapLiteral mapLiteral) { for (RecordLiteralNode.RecordField field : mapLiteral.fields) { - if (lookupNode((BLangNode) field)) { - return; - } + lookupNode((BLangNode) field); } } @Override public void visit(BLangRecordLiteral.BLangStructLiteral structLiteral) { for (RecordLiteralNode.RecordField field : structLiteral.fields) { - if (lookupNode((BLangNode) field)) { - return; - } + lookupNode((BLangNode) field); } } @Override public void visit(BLangInvocation.BFunctionPointerInvocation bFunctionPointerInvocation) { - if (lookupNodes(bFunctionPointerInvocation.requiredArgs)) { - return; - } - if (lookupNodes(bFunctionPointerInvocation.restArgs)) { - return; - } + lookupNodes(bFunctionPointerInvocation.requiredArgs); + lookupNodes(bFunctionPointerInvocation.restArgs); setEnclosingNode(bFunctionPointerInvocation, bFunctionPointerInvocation.name.pos); } @@ -1341,12 +1067,8 @@ public void visit(BLangInvocation.BLangAttachedFunctionInvocation iExpr) { return; } - if (lookupNode(iExpr.expr)) { - return; - } - if (lookupNodes(iExpr.requiredArgs)) { - return; - } + lookupNode(iExpr.expr); + lookupNodes(iExpr.requiredArgs); lookupNodes(iExpr.restArgs); } @@ -1357,17 +1079,13 @@ public void visit(BLangListConstructorExpr.BLangJSONArrayLiteral jsonArrayLitera @Override public void visit(BLangIndexBasedAccess.BLangJSONAccessExpr jsonAccessExpr) { - if (lookupNode(jsonAccessExpr.expr)) { - return; - } + lookupNode(jsonAccessExpr.expr); lookupNode(jsonAccessExpr.indexExpr); } @Override public void visit(BLangIndexBasedAccess.BLangStringAccessExpr stringAccessExpr) { - if (lookupNode(stringAccessExpr.expr)) { - return; - } + lookupNode(stringAccessExpr.expr); lookupNode(stringAccessExpr.indexExpr); } @@ -1376,6 +1094,7 @@ public void visit(BLangXMLNS.BLangLocalXMLNS xmlnsNode) { if (setEnclosingNode(xmlnsNode, xmlnsNode.prefix.pos)) { return; } + lookupNode(xmlnsNode.namespaceURI); } @@ -1395,26 +1114,16 @@ public void visit(BLangXMLSequenceLiteral bLangXMLSequenceLiteral) { @Override public void visit(BLangStatementExpression bLangStatementExpression) { - if (lookupNode(bLangStatementExpression.stmt)) { - return; - } + lookupNode(bLangStatementExpression.stmt); lookupNode(bLangStatementExpression.expr); } @Override public void visit(BLangTupleVariable bLangTupleVariable) { - if (lookupNodes(bLangTupleVariable.annAttachments)) { - return; - } - if (lookupNode(bLangTupleVariable.typeNode)) { - return; - } - if (lookupNodes(bLangTupleVariable.memberVariables)) { - return; - } - if (lookupNode(bLangTupleVariable.restVariable)) { - return; - } + lookupNodes(bLangTupleVariable.annAttachments); + lookupNode(bLangTupleVariable.typeNode); + lookupNodes(bLangTupleVariable.memberVariables); + lookupNode(bLangTupleVariable.restVariable); lookupNode(bLangTupleVariable.expr); } @@ -1426,16 +1135,10 @@ public void visit(BLangTupleVariableDef bLangTupleVariableDef) { @Override public void visit(BLangRecordVariable bLangRecordVariable) { for (BLangRecordVariable.BLangRecordVariableKeyValue var : bLangRecordVariable.variableList) { - if (lookupNode(var.valueBindingPattern)) { - return; - } - } - if (lookupNode(bLangRecordVariable.restParam)) { - return; - } - if (lookupNode(bLangRecordVariable.expr)) { - return; + lookupNode(var.valueBindingPattern); } + lookupNode(bLangRecordVariable.restParam); + lookupNode(bLangRecordVariable.expr); lookupNodes(bLangRecordVariable.annAttachments); } @@ -1446,34 +1149,18 @@ public void visit(BLangRecordVariableDef bLangRecordVariableDef) { @Override public void visit(BLangErrorVariable bLangErrorVariable) { - if (lookupNodes(bLangErrorVariable.annAttachments)) { - return; - } - if (lookupNode(bLangErrorVariable.typeNode)) { - return; - } - if (lookupNode(bLangErrorVariable.message)) { - return; - } + lookupNodes(bLangErrorVariable.annAttachments); + lookupNode(bLangErrorVariable.typeNode); + lookupNode(bLangErrorVariable.message); for (BLangErrorVariable.BLangErrorDetailEntry detail : bLangErrorVariable.detail) { - if (lookupNode(detail.valueBindingPattern)) { - return; - } + lookupNode(detail.valueBindingPattern); } - if (lookupNode(bLangErrorVariable.detailExpr)) { - return; - } - if (lookupNode(bLangErrorVariable.cause)) { - return; - } - if (lookupNode(bLangErrorVariable.reasonMatchConst)) { - return; - } - if (lookupNode(bLangErrorVariable.restDetail)) { - return; - } + lookupNode(bLangErrorVariable.detailExpr); + lookupNode(bLangErrorVariable.cause); + lookupNode(bLangErrorVariable.reasonMatchConst); + lookupNode(bLangErrorVariable.restDetail); lookupNode(bLangErrorVariable.expr); } @@ -1489,9 +1176,7 @@ public void visit(BLangWorkerFlushExpr workerFlushExpr) { @Override public void visit(BLangWorkerSyncSendExpr syncSendExpr) { - if (lookupNode(syncSendExpr.expr)) { - return; - } + lookupNode(syncSendExpr.expr); setEnclosingNode(syncSendExpr, syncSendExpr.workerIdentifier.pos); } @@ -1507,9 +1192,7 @@ public void visit(BLangWaitForAllExpr.BLangWaitLiteral waitLiteral) { @Override public void visit(BLangRecordLiteral.BLangRecordKeyValueField recordKeyValue) { - if (lookupNode(recordKeyValue.key)) { - return; - } + lookupNode(recordKeyValue.key); lookupNode(recordKeyValue.valueExpr); } @@ -1525,9 +1208,7 @@ public void visit(BLangRecordLiteral.BLangRecordSpreadOperatorField spreadOperat @Override public void visit(BLangWaitForAllExpr.BLangWaitKeyValue waitKeyValue) { - if (lookupNode(waitKeyValue.keyExpr)) { - return; - } + lookupNode(waitKeyValue.keyExpr); lookupNode(waitKeyValue.valueExpr); } @@ -1538,56 +1219,34 @@ public void visit(BLangXMLElementFilter xmlElementFilter) { @Override public void visit(BLangXMLElementAccess xmlElementAccess) { - if (lookupNode(xmlElementAccess.expr)) { - return; - } - if (lookupNodes(xmlElementAccess.filters)) { - return; - } - this.enclosingNode = xmlElementAccess; + lookupNode(xmlElementAccess.expr); + lookupNodes(xmlElementAccess.filters); } @Override public void visit(BLangXMLNavigationAccess xmlNavigation) { - if (lookupNode(xmlNavigation.expr)) { - return; - } - if (lookupNode(xmlNavigation.childIndex)) { - return; - } - if (lookupNodes(xmlNavigation.filters)) { - return; - } - this.enclosingNode = xmlNavigation; + lookupNode(xmlNavigation.expr); + lookupNode(xmlNavigation.childIndex); + lookupNodes(xmlNavigation.filters); } @Override public void visit(BLangMatchStatement matchStatementNode) { - if (lookupNode(matchStatementNode.expr)) { - return; - } - if (lookupNodes(matchStatementNode.matchClauses)) { - return; - } + lookupNode(matchStatementNode.expr); + lookupNodes(matchStatementNode.matchClauses); lookupNode(matchStatementNode.onFailClause); } @Override public void visit(BLangMatchClause matchClause) { - if (lookupNodes(matchClause.matchPatterns)) { - return; - } - if (lookupNode(matchClause.matchGuard)) { - return; - } + lookupNodes(matchClause.matchPatterns); + lookupNode(matchClause.matchGuard); lookupNode(matchClause.blockStmt); } @Override public void visit(BLangMappingMatchPattern mappingMatchPattern) { - if (lookupNodes(mappingMatchPattern.fieldMatchPatterns)) { - return; - } + lookupNodes(mappingMatchPattern.fieldMatchPatterns); lookupNode(mappingMatchPattern.restMatchPattern); } @@ -1598,23 +1257,15 @@ public void visit(BLangFieldMatchPattern fieldMatchPattern) { @Override public void visit(BLangListMatchPattern listMatchPattern) { - if (lookupNodes(listMatchPattern.matchPatterns)) { - return; - } + lookupNodes(listMatchPattern.matchPatterns); lookupNode(listMatchPattern.restMatchPattern); } @Override public void visit(BLangErrorMatchPattern errorMatchPattern) { - if (lookupNode(errorMatchPattern.errorTypeReference)) { - return; - } - if (lookupNode(errorMatchPattern.errorMessageMatchPattern)) { - return; - } - if (lookupNode(errorMatchPattern.errorCauseMatchPattern)) { - return; - } + lookupNode(errorMatchPattern.errorTypeReference); + lookupNode(errorMatchPattern.errorMessageMatchPattern); + lookupNode(errorMatchPattern.errorCauseMatchPattern); lookupNode(errorMatchPattern.errorFieldMatchPatterns); } @@ -1625,25 +1276,19 @@ public void visit(BLangErrorMessageMatchPattern errorMessageMatchPattern) { @Override public void visit(BLangErrorCauseMatchPattern errorCauseMatchPattern) { - if (lookupNode(errorCauseMatchPattern.simpleMatchPattern)) { - return; - } + lookupNode(errorCauseMatchPattern.simpleMatchPattern); lookupNode(errorCauseMatchPattern.errorMatchPattern); } @Override public void visit(BLangErrorFieldMatchPatterns errorFieldMatchPatterns) { - if (lookupNodes(errorFieldMatchPatterns.namedArgMatchPatterns)) { - return; - } + lookupNodes(errorFieldMatchPatterns.namedArgMatchPatterns); lookupNode(errorFieldMatchPatterns.restMatchPattern); } @Override public void visit(BLangSimpleMatchPattern simpleMatchPattern) { - if (lookupNode(simpleMatchPattern.constPattern)) { - return; - } + lookupNode(simpleMatchPattern.constPattern); lookupNode(simpleMatchPattern.varVariableName); } @@ -1674,9 +1319,7 @@ public void visit(BLangRestMatchPattern restMatchPattern) { @Override public void visit(BLangMappingBindingPattern mappingBindingPattern) { - if (lookupNodes(mappingBindingPattern.fieldBindingPatterns)) { - return; - } + lookupNodes(mappingBindingPattern.fieldBindingPatterns); lookupNode(mappingBindingPattern.restBindingPattern); } @@ -1692,15 +1335,9 @@ public void visit(BLangRestBindingPattern restBindingPattern) { @Override public void visit(BLangErrorBindingPattern errorBindingPattern) { - if (lookupNode(errorBindingPattern.errorMessageBindingPattern)) { - return; - } - if (lookupNode(errorBindingPattern.errorTypeReference)) { - return; - } - if (lookupNode(errorBindingPattern.errorCauseBindingPattern)) { - return; - } + lookupNode(errorBindingPattern.errorMessageBindingPattern); + lookupNode(errorBindingPattern.errorTypeReference); + lookupNode(errorBindingPattern.errorCauseBindingPattern); lookupNode(errorBindingPattern.errorFieldBindingPatterns); } @@ -1711,17 +1348,13 @@ public void visit(BLangErrorMessageBindingPattern errorMessageBindingPattern) { @Override public void visit(BLangErrorCauseBindingPattern errorCauseBindingPattern) { - if (lookupNode(errorCauseBindingPattern.simpleBindingPattern)) { - return; - } + lookupNode(errorCauseBindingPattern.simpleBindingPattern); lookupNode(errorCauseBindingPattern.errorBindingPattern); } @Override public void visit(BLangErrorFieldBindingPatterns errorFieldBindingPatterns) { - if (lookupNodes(errorFieldBindingPatterns.namedArgBindingPatterns)) { - return; - } + lookupNodes(errorFieldBindingPatterns.namedArgBindingPatterns); lookupNode(errorFieldBindingPatterns.restBindingPattern); } @@ -1742,40 +1375,16 @@ public void visit(BLangCaptureBindingPattern captureBindingPattern) { @Override public void visit(BLangListBindingPattern listBindingPattern) { - if (lookupNodes(listBindingPattern.bindingPatterns)) { - return; - } + lookupNodes(listBindingPattern.bindingPatterns); lookupNode(listBindingPattern.restBindingPattern); } @Override public void visit(BLangDo doNode) { - if (lookupNode(doNode.body)) { - return; - } + lookupNode(doNode.body); lookupNode(doNode.onFailClause); } - @Override - public void visit(BLangLiteral literalExpr) { - this.enclosingNode = literalExpr; - } - - @Override - public void visit(BLangValueType valueType) { - this.enclosingNode = valueType; - } - - @Override - public void visit(BLangConstRef constRef) { - this.enclosingNode = constRef; - } - - @Override - public void visit(BLangFieldBasedAccess.BLangNSPrefixedFieldBasedAccess nsPrefixedFieldBasedAccess) { - this.enclosingNode = nsPrefixedFieldBasedAccess; - } - @Override public void visit(BLangOnFailClause onFailClause) { lookupNode((BLangNode) onFailClause.variableDefinitionNode); @@ -1785,6 +1394,11 @@ public void visit(BLangOnFailClause onFailClause) { this.enclosingContainer = onFailClause; } + @Override + public void visit(BLangLiteral literal) { + setEnclosingNode(literal, literal.pos); + } + @Override public void visit(BLangRegExpTemplateLiteral regExpTemplateLiteral) { lookupNode(regExpTemplateLiteral.reDisjunction); @@ -1797,9 +1411,7 @@ public void visit(BLangReSequence reSequence) { @Override public void visit(BLangReAtomQuantifier reAtomQuantifier) { - if (lookupNode(reAtomQuantifier.atom)) { - return; - } + lookupNode(reAtomQuantifier.atom); lookupNode(reAtomQuantifier.quantifier); } @@ -1810,23 +1422,15 @@ public void visit(BLangReAtomCharOrEscape reAtomCharOrEscape) { @Override public void visit(BLangReQuantifier reQuantifier) { - if (lookupNode(reQuantifier.quantifier)) { - return; - } + lookupNode(reQuantifier.quantifier); lookupNode(reQuantifier.nonGreedyChar); } @Override public void visit(BLangReCharacterClass reCharacterClass) { - if (lookupNode(reCharacterClass.characterClassStart)) { - return; - } - if (lookupNode(reCharacterClass.negation)) { - return; - } - if (lookupNode(reCharacterClass.charSet)) { - return; - } + lookupNode(reCharacterClass.characterClassStart); + lookupNode(reCharacterClass.negation); + lookupNode(reCharacterClass.charSet); lookupNode(reCharacterClass.characterClassEnd); } @@ -1837,12 +1441,8 @@ public void visit(BLangReCharSet reCharSet) { @Override public void visit(BLangReCharSetRange reCharSetRange) { - if (lookupNode(reCharSetRange.lhsCharSetAtom)) { - return; - } - if (lookupNode(reCharSetRange.dash)) { - return; - } + lookupNode(reCharSetRange.lhsCharSetAtom); + lookupNode(reCharSetRange.dash); lookupNode(reCharSetRange.rhsCharSetAtom); } @@ -1854,12 +1454,8 @@ public void visit(BLangReAssertion reAssertion) { @Override public void visit(BLangReCapturingGroups reCapturingGroups) { lookupNode(reCapturingGroups.openParen); - if (lookupNode(reCapturingGroups.flagExpr)) { - return; - } - if (lookupNode(reCapturingGroups.disjunction)) { - return; - } + lookupNode(reCapturingGroups.flagExpr); + lookupNode(reCapturingGroups.disjunction); lookupNode(reCapturingGroups.closeParen); } @@ -1875,12 +1471,8 @@ public void visit(BLangReFlagsOnOff reFlagsOnOff) { @Override public void visit(BLangReFlagExpression reFlagExpression) { - if (lookupNode(reFlagExpression.questionMark)) { - return; - } - if (lookupNode(reFlagExpression.flagsOnOff)) { - return; - } + lookupNode(reFlagExpression.questionMark); + lookupNode(reFlagExpression.flagsOnOff); lookupNode(reFlagExpression.colon); } @@ -1891,10 +1483,7 @@ private boolean setEnclosingNode(BLangNode node, Location pos) { this.enclosingNode = node; return true; } - if (this.enclosingNode == null && PositionUtil.withinRange(node.pos.lineRange(), this.range)) { - this.enclosingNode = node; - return true; - } + return false; } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/ReferenceFinder.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/ReferenceFinder.java index 536fdcc3f241..b7c57d4b5b58 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/ReferenceFinder.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/ReferenceFinder.java @@ -1211,6 +1211,11 @@ public void visit(BLangErrorVariableDef bLangErrorVariableDef) { @Override public void visit(BLangWorkerFlushExpr workerFlushExpr) { + // Ignore incomplete worker-flush expressions + // Ex: var a = flush; + if (workerFlushExpr.workerIdentifier == null) { + return; + } addIfSameSymbol(workerFlushExpr.workerSymbol, workerFlushExpr.workerIdentifier.pos); } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFinder.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFinder.java index c7c1f71a34b9..4b893d6477f9 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFinder.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFinder.java @@ -1248,6 +1248,10 @@ public void visit(BLangClassDefinition classDefinition) { lookupNodes(classDefinition.fields); lookupNodes(classDefinition.referencedFields); lookupNode(classDefinition.initFunction); + for (BLangFunction method : classDefinition.functions) { + lookupNodes(method.annAttachments); + } + lookupNodes(classDefinition.functions); lookupNodes(classDefinition.typeRefs); } @@ -1533,6 +1537,11 @@ public void visit(BLangErrorVariableDef bLangErrorVariableDef) { @Override public void visit(BLangWorkerFlushExpr workerFlushExpr) { + // Ignore incomplete worker-flush expressions + // Ex: var a = flush; + if (workerFlushExpr.workerIdentifier == null) { + return; + } setEnclosingNode(workerFlushExpr.workerSymbol, workerFlushExpr.workerIdentifier.pos); } diff --git a/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/TreeBuilder.java b/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/TreeBuilder.java index 3d5af1d78fa9..19e1cefd7540 100644 --- a/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/TreeBuilder.java +++ b/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/TreeBuilder.java @@ -41,7 +41,6 @@ import org.ballerinalang.model.tree.ImportPackageNode; import org.ballerinalang.model.tree.MarkdownDocumentationNode; import org.ballerinalang.model.tree.MarkdownDocumentationReferenceAttributeNode; -import org.ballerinalang.model.tree.NodeKind; import org.ballerinalang.model.tree.PackageNode; import org.ballerinalang.model.tree.RecordVariableNode; import org.ballerinalang.model.tree.RetrySpecNode; @@ -201,7 +200,6 @@ import org.wso2.ballerinalang.compiler.tree.BLangPackage; import org.wso2.ballerinalang.compiler.tree.BLangRecordVariable; import org.wso2.ballerinalang.compiler.tree.BLangResourceFunction; -import org.wso2.ballerinalang.compiler.tree.BLangResourcePathSegment; import org.wso2.ballerinalang.compiler.tree.BLangRetrySpec; import org.wso2.ballerinalang.compiler.tree.BLangService; import org.wso2.ballerinalang.compiler.tree.BLangSimpleVariable; @@ -1138,10 +1136,6 @@ public static FunctionNode createResourceFunctionNode() { return new BLangResourceFunction(); } - public static BLangResourcePathSegment createResourcePathSegmentNode(NodeKind kind) { - return new BLangResourcePathSegment(kind); - } - public static IgnoreNode createIgnoreExprNode() { return new BLangIgnoreExpr(); } diff --git a/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/tree/statements/ClientDeclarationStatementNode.java b/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/tree/statements/ClientDeclarationStatementNode.java deleted file mode 100644 index 08c2a33c0750..000000000000 --- a/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/tree/statements/ClientDeclarationStatementNode.java +++ /dev/null @@ -1,32 +0,0 @@ -/* -* Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ -package org.ballerinalang.model.tree.statements; - -import org.ballerinalang.model.tree.ClientDeclarationNode; - -/** - * Represent a client declaration statement. - * - * @since 2201.3.0 - */ -public interface ClientDeclarationStatementNode extends StatementNode { - - ClientDeclarationNode getClientDeclaration(); - - void setClientDeclaration(ClientDeclarationNode clientDeclarationNode); -} diff --git a/compiler/ballerina-lang/src/main/java/org/ballerinalang/util/diagnostic/DiagnosticErrorCode.java b/compiler/ballerina-lang/src/main/java/org/ballerinalang/util/diagnostic/DiagnosticErrorCode.java index 497687dd93bd..11d9c89b2c36 100644 --- a/compiler/ballerina-lang/src/main/java/org/ballerinalang/util/diagnostic/DiagnosticErrorCode.java +++ b/compiler/ballerina-lang/src/main/java/org/ballerinalang/util/diagnostic/DiagnosticErrorCode.java @@ -782,12 +782,10 @@ public enum DiagnosticErrorCode implements DiagnosticCode { INVALID_START_CHAR_CODE_IN_RANGE("BCE4035", "invalid.start.char.code.in.range"), INVALID_QUANTIFIER_MINIMUM("BCE4036", "invalid.quantifier.minimum"), DUPLICATE_FLAGS("BCE4037", "duplicate.flags"), - CANNOT_IMPORT_MODULE_GENERATED_FOR_CLIENT_DECL( - "BCE4045", "cannot.import.module.generated.for.a.client.decl"), - CANNOT_INFER_TYPEDESC_ARGUMENT_WITHOUT_CET("BCE4046", + CANNOT_INFER_TYPEDESC_ARGUMENT_WITHOUT_CET("BCE4038", "cannot.infer.typedesc.argument.without.cet"), OUTER_JOIN_MUST_BE_DECLARED_WITH_VAR( - "BCE4047", "outer.join.must.be.declared.with.var") + "BCE4039", "outer.join.must.be.declared.with.var") ; private String diagnosticId; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java index 1721dc902286..358522096421 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java @@ -176,7 +176,6 @@ import org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt; import org.wso2.ballerinalang.compiler.tree.statements.BLangBreak; -import org.wso2.ballerinalang.compiler.tree.statements.BLangClientDeclarationStatement; import org.wso2.ballerinalang.compiler.tree.statements.BLangContinue; import org.wso2.ballerinalang.compiler.tree.statements.BLangExpressionStmt; import org.wso2.ballerinalang.compiler.tree.statements.BLangFail; @@ -2135,9 +2134,6 @@ public void visit(BLangXMLNSStatement xmlnsStmtNode) { public void visit(BLangXMLNS xmlnsNode) { // do nothing } - @Override - public void visit(BLangClientDeclarationStatement clientDeclarationStatement) { - } @Override public void visit(BLangLocalXMLNS xmlnsNode) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java index 28efbb5ded08..2097c11342f1 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java @@ -59,7 +59,6 @@ import org.wso2.ballerinalang.compiler.semantics.model.symbols.BPackageSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BRecordTypeSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BResourceFunction; -import org.wso2.ballerinalang.compiler.semantics.model.symbols.BResourcePathSegmentSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BTypeSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol; @@ -3188,8 +3187,7 @@ protected BLangWhile createRetryWhileLoop(Location pos, BLangDo retryDo = wrapStatementWithinDo(pos, retryBody, internalOnFail); - BLangTypeTestExpr isErrorCheck = createTypeCheckExpr(pos, retryResultRef, - getErrorTypeNode()); + BLangTypeTestExpr isErrorCheck = createTypeCheckExpr(pos, retryResultRef, getErrorTypeNode()); BLangBinaryExpr shouldRetryCheck = ASTBuilderUtil.createBinaryExpr(pos, isErrorCheck, shouldRetryRef, symTable.booleanType, OperatorKind.AND, null); BLangGroupExpr rhsCheck = new BLangGroupExpr(); @@ -3377,9 +3375,10 @@ protected BLangNode createExpressionStatement(Location location, } } - protected void createErrorReturn(Location pos, BlockNode blockStmt, BLangSimpleVarRef resultRef) { + void failFastForErrorResult(Location pos, BlockNode blockStmt, BLangTypeTestExpr typeTestExpr, + BLangExpression resultRef) { BLangIf returnError = ASTBuilderUtil.createIfStmt(pos, blockStmt); - returnError.expr = createTypeCheckExpr(pos, resultRef, getErrorTypeNode()); + returnError.expr = typeTestExpr; returnError.body = ASTBuilderUtil.createBlockStmt(pos); BLangFail failExpressionNode = (BLangFail) TreeBuilder.createFailNode(); failExpressionNode.expr = addConversionExprIfRequired(resultRef, symTable.errorType); @@ -6524,7 +6523,7 @@ public void visit(BLangInvocation.BLangResourceAccessInvocation resourceAccessIn reorderArguments(pathParamInvocation); BResourceFunction targetResourceFunc = resourceAccessInvocation.targetResourceFunc; - List pathSegmentSymbols = targetResourceFunc.pathSegmentSymbols; + List resourcePath = targetResourceFunc.resourcePath; int pathParamInvocationRequiredArgCount = pathParamInvocation.requiredArgs.size(); @@ -6543,7 +6542,7 @@ public void visit(BLangInvocation.BLangResourceAccessInvocation resourceAccessIn for (int i = 0; i < pathParamInvocationRequiredArgCount; i++) { BLangExpression requiredArg = pathParamInvocation.requiredArgs.get(i); // Resource path size is always >= pathParamInvocationRequiredArgCount - Name resourcePathName = pathSegmentSymbols.get(i).name; + Name resourcePathName = resourcePath.get(i); if (firstRequiredArgFromRestArg == null && requiredArg.getKind() == NodeKind.STATEMENT_EXPRESSION) { firstRequiredArgFromRestArg = (BLangStatementExpression) requiredArg; if (resourcePathName.value.equals("^")) { @@ -6567,7 +6566,7 @@ public void visit(BLangInvocation.BLangResourceAccessInvocation resourceAccessIn } } - Name lastResourcePathName = pathSegmentSymbols.get(pathSegmentSymbols.size() - 1).name; + Name lastResourcePathName = resourcePath.get(resourcePath.size() - 1); if (lastResourcePathName.value.equals("^^")) { // After reordering pathParamInvocation.restArgs size will always be 0 or 1 for (BLangExpression restArg : pathParamInvocation.restArgs) { @@ -6631,27 +6630,26 @@ private BLangInvocation createInvocationForPathParams( resourceAccessInvocation.symbol.pos, VIRTUAL); BResourceFunction targetResourceFunc = resourceAccessInvocation.targetResourceFunc; - List pathSegmentSymbols = targetResourceFunc.pathSegmentSymbols; + List resourcePath = targetResourceFunc.resourcePath; List resourceAccessPathSegments = resourceAccessInvocation.resourceAccessPathSegments.exprs; - List invocationParams = new ArrayList<>(pathSegmentSymbols.size()); - - int pathSegmentCount = pathSegmentSymbols.size(); - BResourcePathSegmentSymbol lastPathSegmentSym = pathSegmentSymbols.get(pathSegmentSymbols.size() - 1); - if (lastPathSegmentSym.kind == SymbolKind.RESOURCE_PATH_REST_PARAM_SEGMENT) { - invokableSymbol.restParam = new BVarSymbol(0, Names.EMPTY, this.env.scope.owner.pkgID, - new BArrayType(lastPathSegmentSym.type), this.env.scope.owner, lastPathSegmentSym.pos, VIRTUAL); - pathSegmentCount--; - } - - if (pathSegmentCount > 0 && lastPathSegmentSym.kind != SymbolKind.RESOURCE_ROOT_PATH_SEGMENT) { - invocationParams.addAll(pathSegmentSymbols.subList(0, pathSegmentCount).stream() - .map(s -> new BVarSymbol(0, Names.EMPTY, this.env.scope.owner.pkgID, s.type, - this.env.scope.owner, s.pos, VIRTUAL)).collect(Collectors.toList())); + List invocationParams = new ArrayList<>(resourcePath.size()); + BTupleType resourcePathType = targetResourceFunc.resourcePathType; + for (BType type : resourcePathType.tupleTypes) { + BVarSymbol param = new BVarSymbol(0, Names.EMPTY, this.env.scope.owner.pkgID, type, + this.env.scope.owner, type.tsymbol.pos, VIRTUAL); + invocationParams.add(param); } invokableSymbol.params = invocationParams; + BType resourcePathRestType = resourcePathType.restType; + if (resourcePathRestType != null) { + invokableSymbol.restParam = new BVarSymbol(0, Names.EMPTY, this.env.scope.owner.pkgID, + new BArrayType(resourcePathRestType), this.env.scope.owner, + resourcePathRestType.tsymbol.pos, VIRTUAL); + } + bLangInvocation.symbol = invokableSymbol; for (int i = 0; i < resourceAccessPathSegments.size(); i++) { @@ -7247,11 +7245,8 @@ private BLangStatementExpression createStmtExprForNullableBinaryExpr(BLangBinary BLangSimpleVarRef rhsVarRef = ASTBuilderUtil.createVariableRef(binaryExpr.pos, rhsVarDef.var.symbol); blockStmt.addStatement(rhsVarDef); - BLangTypeTestExpr typeTestExprOne = createTypeCheckExpr(binaryExpr.pos, lhsVarRef, getNillTypeNode()); - typeTestExprOne.setBType(symTable.booleanType); - - BLangTypeTestExpr typeTestExprTwo = createTypeCheckExpr(binaryExpr.pos, rhsVarRef, getNillTypeNode()); - typeTestExprTwo.setBType(symTable.booleanType); + BLangTypeTestExpr typeTestExprOne = getNilTypeTestExpr(binaryExpr.pos, lhsVarRef); + BLangTypeTestExpr typeTestExprTwo = getNilTypeTestExpr(binaryExpr.pos, rhsVarRef); BLangBinaryExpr ifBlockCondition = ASTBuilderUtil.createBinaryExpr(binaryExpr.pos, typeTestExprOne, typeTestExprTwo, symTable.booleanType, OperatorKind.OR, binaryExpr.opSymbol); @@ -7282,6 +7277,10 @@ private BLangStatementExpression createStmtExprForNullableBinaryExpr(BLangBinary return stmtExpr; } + BLangTypeTestExpr getNilTypeTestExpr(Location pos, BLangExpression expr) { + return createTypeCheckExpr(pos, expr, getNillTypeNode()); + } + private BType getBinaryExprOperandNonNilType(BType operandType) { return operandType.isNullable() ? types.getSafeType(operandType, true, false) : operandType; } @@ -7540,8 +7539,8 @@ public void visit(BLangElvisExpr elvisExpr) { BLangBlockStmt elseBody = ASTBuilderUtil.createBlockStmt(pos); elseBody.addStatement(notNilAssignment); - BLangIf ifStmt = ASTBuilderUtil.createIfElseStmt(pos, - createTypeCheckExpr(pos, lhsResultVarRef, getNillTypeNode()), ifBody, elseBody); + BLangIf ifStmt = ASTBuilderUtil.createIfElseStmt(pos, getNilTypeTestExpr(pos, lhsResultVarRef), + ifBody, elseBody); BLangBlockStmt blockStmt = ASTBuilderUtil.createBlockStmt(pos, new ArrayList<>() {{ add(resultVarDef); add(lhsResultVarDef); @@ -7647,9 +7646,7 @@ private BLangStatementExpression createStmtExprForNilableUnaryExpr(BLangUnaryExp blockStmt.addStatement(tempVarDef); - BLangTypeTestExpr typeTestExpr = createTypeCheckExpr(unaryExpr.pos, unaryExpr.expr, - getNillTypeNode()); - typeTestExpr.setBType(symTable.booleanType); + BLangTypeTestExpr typeTestExpr = getNilTypeTestExpr(unaryExpr.pos, unaryExpr.expr); BLangBlockStmt ifBody = ASTBuilderUtil.createBlockStmt(unaryExpr.pos); BLangAssignment bLangAssignmentIf = ASTBuilderUtil.createAssignmentStmt(unaryExpr.pos, ifBody); @@ -10069,7 +10066,7 @@ private BLangBinaryExpr getModifiedIntRangeEndExpr(BLangExpression expr) { symTable.intType)); } - private BLangLiteral getBooleanLiteral(boolean value) { + BLangLiteral getBooleanLiteral(boolean value) { BLangLiteral literal = (BLangLiteral) TreeBuilder.createLiteralExpression(); literal.value = value; literal.setBType(symTable.booleanType); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java index 85e293f18a84..7315a7fe4d44 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java @@ -297,7 +297,6 @@ import org.wso2.ballerinalang.compiler.tree.BLangRecordVariable; import org.wso2.ballerinalang.compiler.tree.BLangRecordVariable.BLangRecordVariableKeyValue; import org.wso2.ballerinalang.compiler.tree.BLangResourceFunction; -import org.wso2.ballerinalang.compiler.tree.BLangResourcePathSegment; import org.wso2.ballerinalang.compiler.tree.BLangRetrySpec; import org.wso2.ballerinalang.compiler.tree.BLangService; import org.wso2.ballerinalang.compiler.tree.BLangSimpleVariable; @@ -779,61 +778,50 @@ private BLangFunction createResourceFunctionNode(IdentifierToken accessorName, populateFunctionNode(name, qualifierList, methodSignature, functionBody, bLFunction); bLFunction.methodName = createIdentifier(accessorName); + bLFunction.resourcePath = new ArrayList<>(); List params = new ArrayList<>(); - List resourcePathSegments = new ArrayList<>(); + BLangTupleTypeNode tupleTypeNode = (BLangTupleTypeNode) TreeBuilder.createTupleTypeNode(); for (Node pathSegment : relativeResourcePath) { - BLangResourcePathSegment bLangPathSegment; switch (pathSegment.kind()) { case SLASH_TOKEN: continue; case RESOURCE_PATH_SEGMENT_PARAM: BLangSimpleVariable param = (BLangSimpleVariable) pathSegment.apply(this); - bLangPathSegment = TreeBuilder.createResourcePathSegmentNode(NodeKind.RESOURCE_PATH_PARAM_SEGMENT); if (!param.name.value.equals(Names.EMPTY.value)) { params.add(param); bLFunction.addPathParam(param); - bLangPathSegment.name = createIdentifier(getPosition(pathSegment), "^"); + bLFunction.resourcePath.add(createIdentifier(getPosition(pathSegment), "^")); } else { - bLangPathSegment.name = createIdentifier(getPosition(pathSegment), "$^"); + bLFunction.resourcePath.add(createIdentifier(getPosition(pathSegment), "$^")); } - bLangPathSegment.typeNode = param.typeNode; - bLangPathSegment.pos = param.pos; + tupleTypeNode.memberTypeNodes.add(param.typeNode); break; case RESOURCE_PATH_REST_PARAM: BLangSimpleVariable restParam = (BLangSimpleVariable) pathSegment.apply(this); - bLangPathSegment = - TreeBuilder.createResourcePathSegmentNode(NodeKind.RESOURCE_PATH_REST_PARAM_SEGMENT); if (!restParam.name.value.equals(Names.EMPTY.value)) { params.add(restParam); bLFunction.setRestPathParam(restParam); - bLangPathSegment.name = createIdentifier(getPosition(pathSegment), "^^"); + bLFunction.resourcePath.add(createIdentifier(getPosition(pathSegment), "^^")); } else { - bLangPathSegment.name = createIdentifier(getPosition(pathSegment), "$^^"); + bLFunction.resourcePath.add(createIdentifier(getPosition(pathSegment), "$^^")); } - - bLangPathSegment.typeNode = ((BLangArrayType) restParam.typeNode).elemtype; - bLangPathSegment.pos = restParam.pos; + + tupleTypeNode.restParamType = ((BLangArrayType) restParam.typeNode).elemtype; break; case DOT_TOKEN: - bLangPathSegment = TreeBuilder.createResourcePathSegmentNode(NodeKind.RESOURCE_ROOT_PATH_SEGMENT); - bLangPathSegment.name = createIdentifier((Token) pathSegment); - bLangPathSegment.pos = bLangPathSegment.name.pos; + bLFunction.resourcePath.add(createIdentifier((Token) pathSegment)); break; default: - bLangPathSegment = - TreeBuilder.createResourcePathSegmentNode(NodeKind.RESOURCE_PATH_IDENTIFIER_SEGMENT); - bLangPathSegment.name = createIdentifier((Token) pathSegment); + bLFunction.resourcePath.add(createIdentifier((Token) pathSegment)); BLangFiniteTypeNode bLangFiniteTypeNode = (BLangFiniteTypeNode) TreeBuilder.createFiniteTypeNode(); BLangLiteral simpleLiteral = createSimpleLiteral(pathSegment, true); bLangFiniteTypeNode.valueSpace.add(simpleLiteral); - bLangPathSegment.typeNode = bLangFiniteTypeNode; - bLangPathSegment.pos = bLangPathSegment.name.pos; + tupleTypeNode.memberTypeNodes.add(bLangFiniteTypeNode); } - resourcePathSegments.add(bLangPathSegment); } bLFunction.getParameters().addAll(0, params); - bLFunction.resourcePathSegments = resourcePathSegments; + bLFunction.resourcePathType = tupleTypeNode; return bLFunction; } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/NodeCloner.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/NodeCloner.java index da4b6cdf4d6b..2b65d89f55e0 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/NodeCloner.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/NodeCloner.java @@ -185,7 +185,6 @@ import org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt; import org.wso2.ballerinalang.compiler.tree.statements.BLangBreak; -import org.wso2.ballerinalang.compiler.tree.statements.BLangClientDeclarationStatement; import org.wso2.ballerinalang.compiler.tree.statements.BLangCompoundAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangContinue; import org.wso2.ballerinalang.compiler.tree.statements.BLangDo; @@ -669,13 +668,6 @@ public void visit(BLangXMLNSStatement source) { clone.xmlnsDecl = clone(source.xmlnsDecl); } - @Override - public void visit(BLangClientDeclarationStatement source) { - BLangClientDeclarationStatement clone = new BLangClientDeclarationStatement(); - source.cloneRef = clone; - clone.clientDeclaration = clone(source.clientDeclaration); - } - @Override public void visit(BLangExpressionStmt source) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java index 88344d0d1a2a..c4233bd094d1 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java @@ -191,7 +191,6 @@ import org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt; import org.wso2.ballerinalang.compiler.tree.statements.BLangBreak; -import org.wso2.ballerinalang.compiler.tree.statements.BLangClientDeclarationStatement; import org.wso2.ballerinalang.compiler.tree.statements.BLangCompoundAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangContinue; import org.wso2.ballerinalang.compiler.tree.statements.BLangDo; @@ -1948,11 +1947,6 @@ public void visit(BLangPanic panicNode, AnalyzerData data) { public void visit(BLangXMLNSStatement xmlnsStmtNode, AnalyzerData data) { } - @Override - public void visit(BLangClientDeclarationStatement clientDeclarationStatement, AnalyzerData data) { - analyzeNode(clientDeclarationStatement.clientDeclaration, data); - } - @Override public void visit(BLangExpressionStmt exprStmtNode, AnalyzerData data) { BLangExpression expr = exprStmtNode.expr; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/IsolationAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/IsolationAnalyzer.java index 521ffe93eced..ed417a084d46 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/IsolationAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/IsolationAnalyzer.java @@ -207,7 +207,6 @@ import org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt; import org.wso2.ballerinalang.compiler.tree.statements.BLangBreak; -import org.wso2.ballerinalang.compiler.tree.statements.BLangClientDeclarationStatement; import org.wso2.ballerinalang.compiler.tree.statements.BLangCompoundAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangContinue; import org.wso2.ballerinalang.compiler.tree.statements.BLangDo; @@ -2010,10 +2009,6 @@ public void visit(BLangXMLNavigationAccess xmlNavigation) { analyzeNode(childIndex, env); } } - @Override - public void visit(BLangClientDeclarationStatement clientDeclarationStatement) { - analyzeNode(clientDeclarationStatement.clientDeclaration, env); - } @Override public void visit(BLangRegExpTemplateLiteral regExpTemplateLiteral) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java index 1ec6389d8156..6df5e59dffdd 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java @@ -82,7 +82,6 @@ import org.wso2.ballerinalang.compiler.tree.BLangPackage; import org.wso2.ballerinalang.compiler.tree.BLangRecordVariable; import org.wso2.ballerinalang.compiler.tree.BLangResourceFunction; -import org.wso2.ballerinalang.compiler.tree.BLangResourcePathSegment; import org.wso2.ballerinalang.compiler.tree.BLangRetrySpec; import org.wso2.ballerinalang.compiler.tree.BLangService; import org.wso2.ballerinalang.compiler.tree.BLangSimpleVariable; @@ -419,28 +418,21 @@ public void visit(BLangResourceFunction funcNode, AnalyzerData data) { if (containsClientObjectTypeOrFunctionType(returnType)) { dlog.error(funcNode.returnTypeNode.getPosition(), DiagnosticErrorCode.INVALID_RESOURCE_METHOD_RETURN_TYPE); } - - List resourcePathSegments = funcNode.resourcePathSegments; - int pathSegmentCount = resourcePathSegments.size(); - BLangResourcePathSegment lastPathSegment = resourcePathSegments.get(resourcePathSegments.size() - 1); - if (lastPathSegment.kind == NodeKind.RESOURCE_ROOT_PATH_SEGMENT) { - return; - } - - if (lastPathSegment.kind == NodeKind.RESOURCE_PATH_REST_PARAM_SEGMENT) { - if (!types.isAssignable(lastPathSegment.getBType(), symTable.pathParamAllowedType)) { - dlog.error(lastPathSegment.typeNode.getPosition(), DiagnosticErrorCode.UNSUPPORTED_REST_PATH_PARAM_TYPE, - lastPathSegment.getBType()); + for (BLangType pathParamType : funcNode.resourcePathType.memberTypeNodes) { + symResolver.resolveTypeNode(pathParamType, data.env); + if (!types.isAssignable(pathParamType.getBType(), symTable.pathParamAllowedType)) { + dlog.error(pathParamType.getPosition(), DiagnosticErrorCode.UNSUPPORTED_PATH_PARAM_TYPE, + pathParamType.getBType()); } - pathSegmentCount--; } - if (pathSegmentCount > 0) { - resourcePathSegments.subList(0, pathSegmentCount).stream() - .filter(pathSeg -> !types.isAssignable(pathSeg.typeNode.getBType(), symTable.pathParamAllowedType)) - .forEach(pathSeg -> - dlog.error(pathSeg.typeNode.getPosition(), DiagnosticErrorCode.UNSUPPORTED_PATH_PARAM_TYPE, - pathSeg.getBType())); + if (funcNode.resourcePathType.restParamType != null) { + BLangType restParamType = funcNode.resourcePathType.restParamType; + symResolver.resolveTypeNode(restParamType, data.env); + if (!types.isAssignable(restParamType.getBType(), symTable.pathParamAllowedType)) { + dlog.error(restParamType.getPosition(), DiagnosticErrorCode.UNSUPPORTED_REST_PATH_PARAM_TYPE, + restParamType.getBType()); + } } } @@ -1064,7 +1056,7 @@ public void visit(BLangSimpleVariable varNode, AnalyzerData data) { return; } SymbolEnv currentEnv = data.env; - long ownerSymTag = currentEnv.scope.owner.tag; + int ownerSymTag = currentEnv.scope.owner.tag; boolean isListenerDecl = varNode.flagSet.contains(Flag.LISTENER); if ((ownerSymTag & SymTag.INVOKABLE) == SymTag.INVOKABLE || (ownerSymTag & SymTag.LET) == SymTag.LET || currentEnv.node.getKind() == NodeKind.LET_CLAUSE) { @@ -1420,7 +1412,7 @@ public void visit(BLangRecordVariable varNode, AnalyzerData data) { varNode.setBType(symResolver.resolveTypeNode(varNode.typeNode, currentEnv)); } - long ownerSymTag = currentEnv.scope.owner.tag; + int ownerSymTag = currentEnv.scope.owner.tag; // If this is a module record variable, checkTypeAndVarCountConsistency already done at symbolEnter. if ((ownerSymTag & SymTag.PACKAGE) != SymTag.PACKAGE && !(this.symbolEnter.symbolEnterAndValidateRecordVariable(varNode, currentEnv))) { @@ -1474,7 +1466,7 @@ public void visit(BLangTupleVariable varNode, AnalyzerData data) { varNode.setBType(symResolver.resolveTypeNode(varNode.typeNode, currentEnv)); } - long ownerSymTag = currentEnv.scope.owner.tag; + int ownerSymTag = currentEnv.scope.owner.tag; // If this is a module tuple variable, checkTypeAndVarCountConsistency already done at symbolEnter. if ((ownerSymTag & SymTag.PACKAGE) != SymTag.PACKAGE && !(this.symbolEnter.checkTypeAndVarCountConsistency(varNode, currentEnv))) { @@ -1650,7 +1642,7 @@ public void visit(BLangErrorVariable varNode, AnalyzerData data) { } } - long ownerSymTag = currentEnv.scope.owner.tag; + int ownerSymTag = currentEnv.scope.owner.tag; // If this is a module error variable, checkTypeAndVarCountConsistency already done at symbolEnter. if ((ownerSymTag & SymTag.PACKAGE) != SymTag.PACKAGE && !(this.symbolEnter.symbolEnterAndValidateErrorVariable(varNode, currentEnv))) { @@ -1756,7 +1748,7 @@ private void handleDeclaredWithVar(BLangVariable variable, AnalyzerData data) { handleWildCardBindingVariable(simpleVariable, currentEnv); - long ownerSymTag = currentEnv.scope.owner.tag; + int ownerSymTag = currentEnv.scope.owner.tag; if ((ownerSymTag & SymTag.INVOKABLE) == SymTag.INVOKABLE || (ownerSymTag & SymTag.LET) == SymTag.LET) { // This is a variable declared in a function, an action or a resource // If the variable is parameter then the variable symbol is already defined @@ -1934,7 +1926,7 @@ void handleDeclaredVarInForeach(BLangVariable variable, BType rhsType, SymbolEnv handleWildCardBindingVariable(simpleVariable, blockEnv); - long ownerSymTag = blockEnv.scope.owner.tag; + int ownerSymTag = blockEnv.scope.owner.tag; if ((ownerSymTag & SymTag.INVOKABLE) == SymTag.INVOKABLE || (ownerSymTag & SymTag.PACKAGE) == SymTag.PACKAGE || (ownerSymTag & SymTag.LET) == SymTag.LET) { @@ -3781,7 +3773,7 @@ public void visit(BLangFail failNode, AnalyzerData data) { if (errorExpressionType == symTable.semanticError || !types.isSubTypeOfBaseType(errorExpressionType, symTable.errorType.tag)) { - dlog.error(errorExpression.pos, DiagnosticErrorCode.ERROR_TYPE_EXPECTED, errorExpression.toString()); + dlog.error(errorExpression.pos, DiagnosticErrorCode.ERROR_TYPE_EXPECTED, errorExpressionType); } data.notCompletedNormally = true; } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolEnter.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolEnter.java index 54c6e1051de4..a45ffab5305d 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolEnter.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolEnter.java @@ -59,7 +59,6 @@ import org.wso2.ballerinalang.compiler.semantics.model.symbols.BPackageSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BRecordTypeSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BResourceFunction; -import org.wso2.ballerinalang.compiler.semantics.model.symbols.BResourcePathSegmentSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BServiceSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BStructureTypeSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol; @@ -104,7 +103,6 @@ import org.wso2.ballerinalang.compiler.tree.BLangPackage; import org.wso2.ballerinalang.compiler.tree.BLangRecordVariable; import org.wso2.ballerinalang.compiler.tree.BLangResourceFunction; -import org.wso2.ballerinalang.compiler.tree.BLangResourcePathSegment; import org.wso2.ballerinalang.compiler.tree.BLangService; import org.wso2.ballerinalang.compiler.tree.BLangSimpleVariable; import org.wso2.ballerinalang.compiler.tree.BLangTableKeyTypeConstraint; @@ -204,7 +202,6 @@ import static org.ballerinalang.model.symbols.SymbolOrigin.SOURCE; import static org.ballerinalang.model.symbols.SymbolOrigin.VIRTUAL; import static org.ballerinalang.model.tree.NodeKind.IMPORT; -import static org.ballerinalang.model.tree.NodeKind.RECORD_TYPE; import static org.ballerinalang.util.diagnostic.DiagnosticErrorCode.DEFAULTABLE_PARAM_DEFINED_AFTER_INCLUDED_RECORD_PARAM; import static org.ballerinalang.util.diagnostic.DiagnosticErrorCode.EXPECTED_RECORD_TYPE_AS_INCLUDED_PARAMETER; import static org.ballerinalang.util.diagnostic.DiagnosticErrorCode.REDECLARED_SYMBOL; @@ -239,7 +236,6 @@ public class SymbolEnter extends BLangNodeVisitor { private BLangMissingNodesHelper missingNodesHelper; private PackageCache packageCache; private List intersectionTypes; - private Map typeToTypeDef; private SymbolEnv env; private final boolean projectAPIInitiatedCompilation; @@ -413,6 +409,7 @@ private void defineConstructs(BLangPackage pkgNode, SymbolEnv pkgEnv) { if (!PackageID.ANNOTATIONS.equals(pkgNode.packageID)) { initPredeclaredModules(symTable.predeclaredModules, pkgNode.compUnits, pkgEnv); } + // Define type definitions. this.typePrecedence = 0; @@ -439,7 +436,6 @@ private void defineConstructs(BLangPackage pkgNode, SymbolEnv pkgEnv) { // Define type def fields (if any) defineFields(typeAndClassDefs, pkgEnv); - populateTypeToTypeDefMap(typeAndClassDefs); defineDependentFields(typeAndClassDefs, pkgEnv); // Calculate error intersections types. @@ -496,17 +492,6 @@ private void defineConstructs(BLangPackage pkgNode, SymbolEnv pkgEnv) { } } - private void populateTypeToTypeDefMap(List typeDefNodes) { - typeToTypeDef = new HashMap<>(typeDefNodes.size()); - for (BLangNode typeDef : typeDefNodes) { - if (typeDef.getKind() == NodeKind.TYPE_DEFINITION) { - BLangTypeDefinition typeDefNode = (BLangTypeDefinition) typeDef; - BType type = typeDefNode.typeNode.getBType(); - typeToTypeDef.put(type, typeDefNode); - } - } - } - private void defineDependentFields(List typeDefNodes, SymbolEnv pkgEnv) { for (BLangNode typeDef : typeDefNodes) { if (typeDef.getKind() == NodeKind.CLASS_DEFN) { @@ -881,7 +866,8 @@ public void visit(BLangClassDefinition classDefinition) { Name className = names.fromIdNode(classDefinition.name); Name classOrigName = names.originalNameFromIdNode(classDefinition.name); - BClassSymbol tSymbol = Symbols.createClassSymbol(Flags.asMask(flags), className, env.enclPkg.symbol.pkgID, null, + BClassSymbol tSymbol = Symbols.createClassSymbol(Flags.asMask(flags), + className, env.enclPkg.symbol.pkgID, null, env.scope.owner, classDefinition.name.pos, getOrigin(className, flags), classDefinition.isServiceDecl); tSymbol.originalName = classOrigName; @@ -1237,6 +1223,7 @@ private boolean nullOrEmpty(String value) { public void visit(BLangXMLNSStatement xmlnsStmtNode) { defineNode(xmlnsStmtNode.xmlnsDecl, env); } + private void defineTypeNodes(List typeDefs, SymbolEnv env) { if (typeDefs.isEmpty()) { return; @@ -2470,7 +2457,7 @@ boolean checkTypeAndVarCountConsistency(BLangTupleVariable var, SymbolEnv env) { Name varName = names.fromString(anonymousModelHelper.getNextTupleVarKey(env.enclPkg.packageID)); var.symbol = defineVarSymbol(var.pos, var.flagSet, var.getBType(), varName, env, true); } - + return checkTypeAndVarCountConsistency(var, null, env); } @@ -3482,7 +3469,7 @@ private boolean isRestDetailBindingAvailable(BLangErrorVariable errorVariable) { !errorVariable.restDetail.name.value.equals(Names.IGNORE.value); } - private BTypeSymbol createTypeSymbol(long type, SymbolEnv env) { + private BTypeSymbol createTypeSymbol(int type, SymbolEnv env) { return new BTypeSymbol(type, Flags.PUBLIC, Names.EMPTY, env.enclPkg.packageID, null, env.scope.owner, symTable.builtinPos, VIRTUAL); } @@ -3869,6 +3856,7 @@ private void addTopLevelNode(BLangPackage pkgNode, TopLevelNode node) { break; case CLASS_DEFN: pkgNode.classDefinitions.add((BLangClassDefinition) node); + break; } } @@ -4041,9 +4029,8 @@ private void resolveRestField(BLangTypeDefinition typeDef) { } if (recordType.restFieldType != null && !types.isSameType(recordType.restFieldType, restFieldType)) { recordType.restFieldType = symTable.noType; - dlog.error(recordTypeNode.pos, - DiagnosticErrorCode. - CANNOT_USE_TYPE_INCLUSION_WITH_MORE_THAN_ONE_OPEN_RECORD_WITH_DIFFERENT_REST_DESCRIPTOR_TYPES); + dlog.error(recordTypeNode.pos, DiagnosticErrorCode. + CANNOT_USE_TYPE_INCLUSION_WITH_MORE_THAN_ONE_OPEN_RECORD_WITH_DIFFERENT_REST_DESCRIPTOR_TYPES); return; } recordType.restFieldType = restFieldType; @@ -4935,9 +4922,11 @@ private void validateFunctionsAttachedToObject(BLangFunction funcNode, BInvokabl private BAttachedFunction createResourceFunction(BLangFunction funcNode, BInvokableSymbol funcSymbol, BInvokableType funcType) { - BObjectTypeSymbol objectTypeSymbol = (BObjectTypeSymbol) funcNode.receiver.getBType().tsymbol; BLangResourceFunction resourceFunction = (BLangResourceFunction) funcNode; Name accessor = names.fromIdNode(resourceFunction.methodName); + List resourcePath = resourceFunction.resourcePath.stream() + .map(names::fromIdNode) + .collect(Collectors.toList()); List pathParamSymbols = resourceFunction.pathParams.stream() .map(p -> { @@ -4952,32 +4941,10 @@ private BAttachedFunction createResourceFunction(BLangFunction funcNode, BInvoka restPathParamSym.kind = SymbolKind.PATH_REST_PARAMETER; } - BResourceFunction bResourceFunction = new BResourceFunction(names.fromIdNode(funcNode.name), funcSymbol, - funcType, accessor, pathParamSymbols, restPathParamSym, funcNode.pos); - - List pathSegments = resourceFunction.resourcePathSegments; - int resourcePathCount = pathSegments.size(); - List pathSegmentSymbols = new ArrayList<>(resourcePathCount); - BResourcePathSegmentSymbol parentResource = null; - for (int i = 0; i < resourcePathCount; i++) { - BLangResourcePathSegment pathSegment = pathSegments.get(i); - Name resourcePathSymbolName = Names.fromString(pathSegment.name.value); - BType resourcePathSegmentType = pathSegment.typeNode == null ? - symTable.noType : symResolver.resolveTypeNode(pathSegment.typeNode, env); - pathSegment.setBType(resourcePathSegmentType); - - BResourcePathSegmentSymbol pathSym = Symbols.createResourcePathSegmentSymbol(resourcePathSymbolName, - env.enclPkg.symbol.pkgID, resourcePathSegmentType, objectTypeSymbol, pathSegment.pos, - parentResource, bResourceFunction, SOURCE); - - objectTypeSymbol.resourcePathSegmentScope.define(pathSym.name, pathSym); - pathSegmentSymbols.add(pathSym); - pathSegment.symbol = pathSym; - parentResource = pathSym; - } - - bResourceFunction.pathSegmentSymbols = pathSegmentSymbols; - return bResourceFunction; + symResolver.resolveTypeNode(resourceFunction.resourcePathType, env); + return new BResourceFunction(names.fromIdNode(funcNode.name), funcSymbol, funcType, resourcePath, + accessor, pathParamSymbols, restPathParamSym, + (BTupleType) resourceFunction.resourcePathType.getBType(), funcNode.pos); } private void validateRemoteFunctionAttachedToObject(BLangFunction funcNode, BObjectTypeSymbol objectSymbol) { @@ -5005,7 +4972,7 @@ private void validateResourceFunctionAttachedToObject(BLangFunction funcNode, BO funcNode.symbol.flags |= Flags.PUBLIC; if (!isNetworkQualified(objectSymbol)) { - this.dlog.error(funcNode.pos, + this.dlog.error(funcNode.pos, DiagnosticErrorCode.RESOURCE_METHODS_ARE_ONLY_ALLOWED_IN_SERVICE_OR_CLIENT_OBJECTS); } } @@ -5132,26 +5099,6 @@ private void resolveIncludedFields(BLangStructureTypeNode structureTypeNode) { fieldNames.put(fieldVariable.name.value, fieldVariable); } - for (BLangType typeRef : typeRefs) { - BType referredType = symResolver.resolveTypeNode(typeRef, typeDefEnv); - referredType = Types.getReferredType(referredType); - if (referredType == symTable.semanticError) { - continue; - } - if (referredType.tag != TypeTags.RECORD) { - continue; - } - var fields = ((BStructureType) referredType).fields.values(); - for (BField field : fields) { - BType type = field.type; - BLangTypeDefinition typeDefinition = typeToTypeDef.get(type); - if (typeDefinition != null && typeDefinition.typeNode != null && - typeDefinition.typeNode.getKind() == RECORD_TYPE) { - defineReferencedFieldsOfRecordTypeDef(typeDefinition); - } - } - } - structureTypeNode.includedFields = typeRefs.stream().flatMap(typeRef -> { BType referredType = symResolver.resolveTypeNode(typeRef, typeDefEnv); referredType = Types.getReferredType(referredType); @@ -5292,11 +5239,10 @@ private void defineReferencedFunction(Location location, Set flagSet, Symb BAttachedFunction attachedFunc; if (referencedFunc instanceof BResourceFunction) { BResourceFunction resourceFunction = (BResourceFunction) referencedFunc; - BResourceFunction cacheFunc = new BResourceFunction(referencedFunc.funcName, funcSymbol, - (BInvokableType) funcSymbol.type, resourceFunction.accessor, resourceFunction.pathParams, - resourceFunction.restPathParam, referencedFunc.pos); - cacheFunc.pathSegmentSymbols = resourceFunction.pathSegmentSymbols; - attachedFunc = cacheFunc; + attachedFunc = new BResourceFunction(referencedFunc.funcName, + funcSymbol, (BInvokableType) funcSymbol.type, resourceFunction.resourcePath, + resourceFunction.accessor, resourceFunction.pathParams, resourceFunction.restPathParam, + resourceFunction.resourcePathType, referencedFunc.pos); } else { attachedFunc = new BAttachedFunction(referencedFunc.funcName, funcSymbol, (BInvokableType) funcSymbol.type, referencedFunc.pos); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java index 23c9a0a08524..31c1bd581dbb 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java @@ -60,7 +60,6 @@ import org.wso2.ballerinalang.compiler.semantics.model.symbols.BPackageSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BRecordTypeSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BResourceFunction; -import org.wso2.ballerinalang.compiler.semantics.model.symbols.BResourcePathSegmentSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BTypeSymbol; import org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol; @@ -445,7 +444,11 @@ private void validateAndSetExprExpectedType(BLangExpression expr, AnalyzerData d public void visit(BLangLiteral literalExpr, AnalyzerData data) { BType literalType = setLiteralValueAndGetType(literalExpr, data.expType, data); - if (literalType == symTable.semanticError || literalExpr.isFiniteContext) { + if (literalType == symTable.semanticError) { + data.resultType = symTable.semanticError; + return; + } + if (literalExpr.isFiniteContext) { return; } data.resultType = types.checkType(literalExpr, literalType, data.expType); @@ -489,7 +492,7 @@ private void checkXMLNamespacePrefixes(List filters, Anal Name nsName = names.fromString(filter.namespace); BSymbol nsSymbol = symResolver.lookupSymbolInPrefixSpace(data.env, nsName); filter.namespaceSymbol = nsSymbol; - if (nsSymbol == symTable.notFoundSymbol) { + if (nsSymbol.getKind() != SymbolKind.XMLNS) { dlog.error(filter.nsPos, DiagnosticErrorCode.CANNOT_FIND_XML_NAMESPACE, nsName); } } @@ -612,7 +615,6 @@ private BType getIntegerLiteralType(BLangLiteral literalExpr, Object literalValu if (literalValue instanceof String) { dlog.error(literalExpr.pos, DiagnosticErrorCode.OUT_OF_RANGE, literalExpr.originalValue, expectedType); - data.resultType = symTable.semanticError; return symTable.semanticError; } if (literalValue instanceof Double) { @@ -628,7 +630,6 @@ private BType getIntegerLiteralType(BLangLiteral literalExpr, Object literalValu BFiniteType finiteType = (BFiniteType) expectedType; BType compatibleType = checkIfOutOfRangeAndReturnType(finiteType, literalExpr, literalValue, data); if (compatibleType == symTable.semanticError) { - data.resultType = symTable.semanticError; return compatibleType; } else { return getFiniteTypeMatchWithIntLiteral(literalExpr, finiteType, literalValue, data); @@ -676,7 +677,6 @@ private BType getIntegerLiteralType(BLangLiteral literalExpr, Object literalValu if (!(literalValue instanceof Long)) { dlog.error(literalExpr.pos, DiagnosticErrorCode.OUT_OF_RANGE, literalExpr.originalValue, literalExpr.getBType()); - data.resultType = symTable.semanticError; return symTable.semanticError; } return symTable.intType; @@ -686,7 +686,6 @@ private BType getTypeOfLiteralWithFloatDiscriminator(BLangLiteral literalExpr, O BType expType, AnalyzerData data) { String numericLiteral = NumericLiteralSupport.stripDiscriminator(String.valueOf(literalValue)); if (!types.validateFloatLiteral(literalExpr.pos, numericLiteral)) { - data.resultType = symTable.semanticError; return symTable.semanticError; } literalExpr.value = Double.parseDouble(numericLiteral); @@ -710,6 +709,9 @@ private BType getTypeOfLiteralWithFloatDiscriminator(BLangLiteral literalExpr, O private BType getTypeOfLiteralWithDecimalDiscriminator(BLangLiteral literalExpr, Object literalValue, BType expType, AnalyzerData data) { literalExpr.value = NumericLiteralSupport.stripDiscriminator(String.valueOf(literalValue)); + if (!types.isValidDecimalNumber(literalExpr.pos, literalExpr.value.toString())) { + return symTable.semanticError; + } BType referredType = Types.getReferredType(expType); if (referredType.tag == TypeTags.FINITE) { BFiniteType finiteType = (BFiniteType) referredType; @@ -732,7 +734,10 @@ private BType getTypeOfDecimalFloatingPointLiteral(BLangLiteral literalExpr, Obj BType expectedType = Types.getReferredType(expType); String numericLiteral = String.valueOf(literalValue); if (expectedType.tag == TypeTags.DECIMAL) { - return symTable.decimalType; + if (types.isValidDecimalNumber(literalExpr.pos, literalExpr.value.toString())) { + return symTable.decimalType; + } + return symTable.semanticError; } else if (expectedType.tag == TypeTags.FLOAT) { if (!types.validateFloatLiteral(literalExpr.pos, numericLiteral)) { data.resultType = symTable.semanticError; @@ -754,25 +759,20 @@ private BType getTypeOfDecimalFloatingPointLiteral(BLangLiteral literalExpr, Obj BType unionMember = getAndSetAssignableUnionMember(literalExpr, unionType, symTable.getTypeFromTag(tag), data); if (unionMember == symTable.floatType && !types.validateFloatLiteral(literalExpr.pos, numericLiteral)) { - data.resultType = symTable.semanticError; return symTable.semanticError; } else if (unionMember != symTable.noType) { return unionMember; } } } - if (!types.validateFloatLiteral(literalExpr.pos, numericLiteral)) { - data.resultType = symTable.semanticError; - return symTable.semanticError; - } - return symTable.floatType; + return types.validateFloatLiteral(literalExpr.pos, numericLiteral) + ? symTable.floatType : symTable.semanticError; } private BType getTypeOfHexFloatingPointLiteral(BLangLiteral literalExpr, Object literalValue, BType expType, AnalyzerData data) { String numericLiteral = String.valueOf(literalValue); if (!types.validateFloatLiteral(literalExpr.pos, numericLiteral)) { - data.resultType = symTable.semanticError; return symTable.semanticError; } literalExpr.value = Double.parseDouble(numericLiteral); @@ -2820,13 +2820,14 @@ public void visit(BLangSimpleVarRef varRefExpr, AnalyzerData data) { // Set error type as the actual type. BType actualType = symTable.semanticError; - Name varName = names.fromIdNode(varRefExpr.variableName); + BLangIdentifier identifier = varRefExpr.variableName; + Name varName = names.fromIdNode(identifier); if (varName == Names.IGNORE) { varRefExpr.setBType(this.symTable.anyType); // If the variable name is a wildcard('_'), the symbol should be ignorable. varRefExpr.symbol = new BVarSymbol(0, true, varName, - names.originalNameFromIdNode(varRefExpr.variableName), + names.originalNameFromIdNode(identifier), data.env.enclPkg.symbol.pkgID, varRefExpr.getBType(), data.env.scope.owner, varRefExpr.pos, VIRTUAL); @@ -2835,16 +2836,17 @@ public void visit(BLangSimpleVarRef varRefExpr, AnalyzerData data) { } Name compUnitName = getCurrentCompUnit(varRefExpr); - varRefExpr.pkgSymbol = - symResolver.resolvePrefixSymbol(data.env, names.fromIdNode(varRefExpr.pkgAlias), compUnitName); - if (varRefExpr.pkgSymbol == symTable.notFoundSymbol) { + BSymbol pkgSymbol = symResolver.resolvePrefixSymbol(data.env, names.fromIdNode(varRefExpr.pkgAlias), + compUnitName); + varRefExpr.pkgSymbol = pkgSymbol; + if (pkgSymbol == symTable.notFoundSymbol) { varRefExpr.symbol = symTable.notFoundSymbol; dlog.error(varRefExpr.pos, DiagnosticErrorCode.UNDEFINED_MODULE, varRefExpr.pkgAlias); } - if (varRefExpr.pkgSymbol.tag == SymTag.XMLNS) { + if (pkgSymbol.tag == SymTag.XMLNS) { actualType = symTable.stringType; - } else if (varRefExpr.pkgSymbol != symTable.notFoundSymbol) { + } else if (pkgSymbol != symTable.notFoundSymbol) { BSymbol symbol = symResolver.lookupMainSpaceSymbolInPackage(varRefExpr.pos, data.env, names.fromIdNode(varRefExpr.pkgAlias), varName); // if no symbol, check same for object attached function @@ -2910,7 +2912,7 @@ public void visit(BLangRecordVarRef varRefExpr, AnalyzerData data) { String recordName = this.anonymousModelHelper.getNextAnonymousTypeKey(data.env.enclPkg.symbol.pkgID); BRecordTypeSymbol recordSymbol = Symbols.createRecordSymbol(Flags.ANONYMOUS, names.fromString(recordName), data.env.enclPkg.symbol.pkgID, null, data.env.scope.owner, - varRefExpr.pos, SOURCE); + varRefExpr.pos, SOURCE); symbolEnter.defineSymbol(varRefExpr.pos, recordSymbol, data.env); boolean unresolvedReference = false; @@ -3678,50 +3680,49 @@ public void visit(BLangInvocation.BLangResourceAccessInvocation resourceAccessIn checkExpr(resourceAccessInvocation.expr, data); BType lhsExprType = resourceAccessInvocation.expr.getBType(); BType referredLhsExprType = Types.getReferredType(lhsExprType); - - if (referredLhsExprType.tag != TypeTags.OBJECT || + + if (referredLhsExprType.tag != TypeTags.OBJECT || !Symbols.isFlagOn(referredLhsExprType.tsymbol.flags, Flags.CLIENT)) { - dlog.error(resourceAccessInvocation.expr.pos, + dlog.error(resourceAccessInvocation.expr.pos, DiagnosticErrorCode.CLIENT_RESOURCE_ACCESS_ACTION_IS_ONLY_ALLOWED_ON_CLIENT_OBJECTS); data.resultType = symTable.semanticError; return; } - + BObjectTypeSymbol objectTypeSym = (BObjectTypeSymbol) referredLhsExprType.tsymbol; if (!validateResourceAccessPathSegmentTypes(resourceAccessInvocation.resourceAccessPathSegments, data)) { // Should not resolve the target resource method if the resource path segment types are invalid return; } - + // Filter all the resource methods defined on target resource path List resourceFunctions = new ArrayList<>(); data.isResourceAccessPathSegments = true; for (BAttachedFunction targetFunc : objectTypeSym.attachedFuncs) { if (Symbols.isResource(targetFunc.symbol)) { BResourceFunction resourceFunction = (BResourceFunction) targetFunc; - BLangExpression clonedResourceAccPathSeg = + BLangExpression clonedResourceAccPathSeg = nodeCloner.cloneNode(resourceAccessInvocation.resourceAccessPathSegments); - BType resolvedType = checkExprSilent(clonedResourceAccPathSeg, - getResourcePathType(resourceFunction.pathSegmentSymbols), data); + BType resolvedType = checkExprSilent(clonedResourceAccPathSeg, resourceFunction.resourcePathType, data); if (resolvedType != symTable.semanticError) { resourceFunctions.add(resourceFunction); } } } - + if (resourceFunctions.size() == 0) { dlog.error(resourceAccessInvocation.resourceAccessPathSegments.pos, DiagnosticErrorCode.UNDEFINED_RESOURCE, lhsExprType); data.resultType = symTable.semanticError; return; } - + // Filter the resource methods in the list by resource access method name resourceFunctions.removeIf(func -> !func.accessor.value.equals(resourceAccessInvocation.name.value)); int targetResourceFuncCount = resourceFunctions.size(); if (targetResourceFuncCount == 0) { - dlog.error(resourceAccessInvocation.name.pos, + dlog.error(resourceAccessInvocation.name.pos, DiagnosticErrorCode.UNDEFINED_RESOURCE_METHOD, resourceAccessInvocation.name, lhsExprType); data.resultType = symTable.semanticError; } else if (targetResourceFuncCount > 1) { @@ -3729,38 +3730,16 @@ public void visit(BLangInvocation.BLangResourceAccessInvocation resourceAccessIn data.resultType = symTable.semanticError; } else { BResourceFunction targetResourceFunc = resourceFunctions.get(0); - checkExpr(resourceAccessInvocation.resourceAccessPathSegments, - getResourcePathType(targetResourceFunc.pathSegmentSymbols), data); + checkExpr(resourceAccessInvocation.resourceAccessPathSegments, targetResourceFunc.resourcePathType, data); resourceAccessInvocation.symbol = targetResourceFunc.symbol; resourceAccessInvocation.targetResourceFunc = targetResourceFunc; checkResourceAccessParamAndReturnType(resourceAccessInvocation, targetResourceFunc, data); } } - private BTupleType getResourcePathType(List pathSegmentSymbols) { - BType restType = null; - int pathSegmentCount = pathSegmentSymbols.size(); - BResourcePathSegmentSymbol lastPathSegmentSym = pathSegmentSymbols.get(pathSegmentCount - 1); - if (lastPathSegmentSym.kind == SymbolKind.RESOURCE_PATH_REST_PARAM_SEGMENT) { - restType = lastPathSegmentSym.type; - pathSegmentCount--; - } - - BTupleType resourcePathType; - if (pathSegmentCount > 0 && lastPathSegmentSym.kind != SymbolKind.RESOURCE_ROOT_PATH_SEGMENT) { - resourcePathType = new BTupleType(pathSegmentSymbols.subList(0, pathSegmentCount).stream() - .map(s -> s.type).collect(Collectors.toList())); - } else { - resourcePathType = new BTupleType(new ArrayList<>()); - } - - resourcePathType.restType = restType; - return resourcePathType; - } - /** * Validate resource access path segment types. - * + * * @return true if the path segment types are valid. False otherwise */ public boolean validateResourceAccessPathSegmentTypes(BLangListConstructorExpr rAPathSegments, AnalyzerData data) { @@ -3783,7 +3762,7 @@ public boolean validateResourceAccessPathSegmentTypes(BLangListConstructorExpr r BType pathSegmentType = checkExpr(clonedPathSegment, data); if (!types.isAssignable(pathSegmentType, symTable.pathParamAllowedType)) { - dlog.error(clonedPathSegment.getPosition(), + dlog.error(clonedPathSegment.getPosition(), DiagnosticErrorCode.UNSUPPORTED_COMPUTED_RESOURCE_ACCESS_PATH_SEGMENT_TYPE, pathSegmentType); isValidResourceAccessPathSegmentTypes = false; } @@ -3791,10 +3770,10 @@ public boolean validateResourceAccessPathSegmentTypes(BLangListConstructorExpr r return isValidResourceAccessPathSegmentTypes; } - + public void checkResourceAccessParamAndReturnType(BLangInvocation.BLangResourceAccessInvocation resourceAccessInvoc, BResourceFunction targetResourceFunc, AnalyzerData data) { - // targetResourceFunc symbol params will contain path params and rest path params as well, + // targetResourceFunc symbol params will contain path params and rest path params as well, // hence we need to remove path params from the list before calling to `checkInvocationParamAndReturnType` // method otherwise we get `missing required parameter` error BInvokableSymbol targetResourceSym = targetResourceFunc.symbol; @@ -3858,7 +3837,7 @@ private boolean invalidModuleAliasUsage(BLangInvocation invocation) { public void visit(BLangLetExpression letExpression, AnalyzerData data) { BLetSymbol letSymbol = new BLetSymbol(SymTag.LET, Flags.asMask(new HashSet<>(Lists.of())), new Name(String.format("$let_symbol_%d$", - data.commonAnalyzerData.letCount++)), + data.commonAnalyzerData.letCount++)), data.env.enclPkg.symbol.pkgID, letExpression.getBType(), data.env.scope.owner, letExpression.pos); letExpression.env = SymbolEnv.createExprEnv(letExpression, data.env, letSymbol); @@ -4584,14 +4563,15 @@ private BRecordType getWaitForAllExprReturnType(BLangWaitForAllExpr waitExpr, BField field = new BField(names.fromIdNode(keyVal.key), null, new BVarSymbol(0, names.fromIdNode(keyVal.key), names.originalNameFromIdNode(keyVal.key), - data.env.enclPkg.packageID, fieldType, null, keyVal.pos, VIRTUAL)); + data.env.enclPkg.packageID, fieldType, null, + keyVal.pos, VIRTUAL)); retType.fields.put(field.name.value, field); } retType.restFieldType = symTable.noType; retType.sealed = true; retType.tsymbol = Symbols.createRecordSymbol(Flags.ANONYMOUS, Names.EMPTY, data.env.enclPkg.packageID, retType, - null, pos, VIRTUAL); + null, pos, VIRTUAL); return retType; } @@ -5441,7 +5421,11 @@ public void visit(BLangTypeConversionExpr conversionExpr, AnalyzerData data) { this.dlog.unmute(); } - if ((errorCount == 0 && exprCompatibleType != symTable.semanticError) || requireTypeInference(expr, false)) { + if ((errorCount == 0 && exprCompatibleType != symTable.semanticError) || + (requireTypeInference(expr, false) && + // Temporary workaround for backward compatibility with `object {}` for + // https://github.com/ballerina-platform/ballerina-lang/issues/38105. + isNotObjectConstructorWithObjectSuperTypeInTypeCastExpr(expr, targetType))) { checkExpr(expr, targetType, data); } else { checkExpr(expr, symTable.noType, data); @@ -6021,6 +6005,9 @@ public void visit(BLangCheckedExpr checkedExpr, AnalyzerData data) { Types.CommonAnalyzerData typeCheckerData = data.commonAnalyzerData; typeCheckerData.checkWithinQueryExpr = isWithinQuery(data); visitCheckAndCheckPanicExpr(checkedExpr, data); + if (typeCheckerData.checkWithinQueryExpr && checkedExpr.equivalentErrorTypeList != null) { + data.commonAnalyzerData.checkedErrorList.addAll(checkedExpr.equivalentErrorTypeList); + } } @Override @@ -6033,9 +6020,15 @@ public void visit(BLangQueryExpr queryExpr, AnalyzerData data) { Types.CommonAnalyzerData typeCheckerData = data.commonAnalyzerData; //reset common analyzer data + boolean prevQueryCompletesEarly = typeCheckerData.queryCompletesEarly; + typeCheckerData.queryCompletesEarly = false; + boolean prevCheckWithinQueryExpr = typeCheckerData.checkWithinQueryExpr; typeCheckerData.checkWithinQueryExpr = false; + HashSet prevCompleteEarlyErrorList = typeCheckerData.completeEarlyErrorList; + typeCheckerData.completeEarlyErrorList = new HashSet<>(); + HashSet prevCheckedErrorList = typeCheckerData.checkedErrorList; typeCheckerData.checkedErrorList = new HashSet<>(); @@ -6053,11 +6046,11 @@ public void visit(BLangQueryExpr queryExpr, AnalyzerData data) { } typeCheckerData.queryFinalClauses.push(queryExpr.getSelectClause()); List clauses = queryExpr.getQueryClauses(); - BLangExpression collectionNode = (BLangExpression) ((BLangFromClause) clauses.get(0)).getCollection(); clauses.forEach(clause -> clause.accept(this, data)); + BType actualType = resolveQueryType(typeCheckerData.queryEnvs.peek(), - ((BLangSelectClause) typeCheckerData.queryFinalClauses.peek()).expression, - collectionNode.getBType(), data.expType, queryExpr, data); + ((BLangSelectClause) typeCheckerData.queryFinalClauses.peek()).expression, + data.expType, queryExpr, clauses, data); actualType = (actualType == symTable.semanticError) ? actualType : types.checkType(queryExpr.pos, actualType, data.expType, DiagnosticErrorCode.INCOMPATIBLE_TYPES); typeCheckerData.queryFinalClauses.pop(); @@ -6078,7 +6071,9 @@ public void visit(BLangQueryExpr queryExpr, AnalyzerData data) { } //re-assign common analyzer data + typeCheckerData.queryCompletesEarly = prevQueryCompletesEarly; typeCheckerData.checkWithinQueryExpr = prevCheckWithinQueryExpr; + typeCheckerData.completeEarlyErrorList = prevCompleteEarlyErrorList; typeCheckerData.checkedErrorList = prevCheckedErrorList; typeCheckerData.queryFinalClauses = prevQueryFinalClauses; typeCheckerData.letCount = prevLetCount; @@ -6091,8 +6086,8 @@ private boolean isWithinQuery(AnalyzerData data) { && !data.commonAnalyzerData.queryFinalClauses.isEmpty(); } - private BType resolveQueryType(SymbolEnv env, BLangExpression selectExp, BType collectionType, - BType targetType, BLangQueryExpr queryExpr, AnalyzerData data) { + private BType resolveQueryType(SymbolEnv env, BLangExpression selectExp, BType targetType, + BLangQueryExpr queryExpr, List clauses, AnalyzerData data) { List safeResultTypes = types.getAllTypes(targetType, true).stream() .filter(t -> !types.isAssignable(t, symTable.errorType)) .filter(t -> !types.isAssignable(t, symTable.nilType)) @@ -6105,15 +6100,14 @@ private BType resolveQueryType(SymbolEnv env, BLangExpression selectExp, BType c List selectTypes = new ArrayList<>(); List resolvedTypes = new ArrayList<>(); BType selectType; - LinkedHashSet memberTypes = new LinkedHashSet<>(); - + BLangExpression collectionNode = (BLangExpression) ((BLangFromClause) clauses.get(0)).getCollection(); for (BType type : safeResultTypes) { - solveSelectTypeAndResolveType(queryExpr, selectExp, type, collectionType, selectTypes, resolvedTypes, env, - data, false, memberTypes); + solveSelectTypeAndResolveType(queryExpr, selectExp, type, collectionNode.getBType(), selectTypes, + resolvedTypes, env, data, false); } - if (selectTypes.size() == 1) { - BType completionType = getCompletionType(collectionType, queryExpr, data); + List collectionTypes = getCollectionTypes(clauses); + BType completionType = getCompletionType(collectionTypes, types.getQueryConstructType(queryExpr), data); selectType = selectTypes.get(0); if (queryExpr.isStream) { return new BStreamType(TypeTags.STREAM, selectType, completionType, null); @@ -6146,10 +6140,16 @@ private BType resolveQueryType(SymbolEnv env, BLangExpression selectExp, BType c } } + private List getCollectionTypes(List clauses) { + return clauses.stream() + .filter(clause -> (clause.getKind() == NodeKind.FROM || clause.getKind() == NodeKind.JOIN)) + .map(clause -> ((BLangInputClause) clause).collection.getBType()) + .collect(Collectors.toList()); + } + void solveSelectTypeAndResolveType(BLangQueryExpr queryExpr, BLangExpression selectExp, BType type, BType collectionType, List selectTypes, List resolvedTypes, - SymbolEnv env, AnalyzerData data, boolean isReadonly, - LinkedHashSet memberTypes) { + SymbolEnv env, AnalyzerData data, boolean isReadonly) { BType selectType, resolvedType; type = Types.getReferredType(type); switch (type.tag) { @@ -6189,7 +6189,7 @@ void solveSelectTypeAndResolveType(BLangQueryExpr queryExpr, BLangExpression sel case TypeTags.INTERSECTION: type = ((BIntersectionType) type).effectiveType; solveSelectTypeAndResolveType(queryExpr, selectExp, type, collectionType, selectTypes, - resolvedTypes, env, data, Symbols.isFlagOn(type.flags, Flags.READONLY), memberTypes); + resolvedTypes, env, data, Symbols.isFlagOn(type.flags, Flags.READONLY)); return; case TypeTags.NONE: default: @@ -6306,45 +6306,54 @@ private void markReadOnlyForConstraintType(BType constraintType) { } } - private BType getCompletionType(BType collectionType, BLangQueryExpr queryExpr, AnalyzerData data) { - if (collectionType.tag == TypeTags.SEMANTIC_ERROR) { - return null; - } + private BType getCompletionType(List collectionTypes, Types.QueryConstructType queryConstructType, + AnalyzerData data) { + Set completionTypes = new LinkedHashSet<>(); BType returnType = null, completionType = null; - collectionType = Types.getReferredType(collectionType); - switch (collectionType.tag) { - case TypeTags.STREAM: - completionType = ((BStreamType) collectionType).completionType; - break; - case TypeTags.OBJECT: - returnType = types.getVarTypeFromIterableObject((BObjectType) collectionType); - break; - default: - BSymbol itrSymbol = symResolver.lookupLangLibMethod(collectionType, - names.fromString(BLangCompilerConstants.ITERABLE_COLLECTION_ITERATOR_FUNC), data.env); - if (itrSymbol == this.symTable.notFoundSymbol) { - return null; + for (BType collectionType : collectionTypes) { + if (collectionType.tag == TypeTags.SEMANTIC_ERROR) { + return null; + } + collectionType = Types.getReferredType(collectionType); + switch (collectionType.tag) { + case TypeTags.STREAM: + completionType = ((BStreamType) collectionType).completionType; + returnType = completionType; + break; + case TypeTags.OBJECT: + returnType = types.getVarTypeFromIterableObject((BObjectType) collectionType); + break; + default: + BSymbol itrSymbol = symResolver.lookupLangLibMethod(collectionType, + names.fromString(BLangCompilerConstants.ITERABLE_COLLECTION_ITERATOR_FUNC), data.env); + if (itrSymbol == this.symTable.notFoundSymbol) { + return null; + } + BInvokableSymbol invokableSymbol = (BInvokableSymbol) itrSymbol; + returnType = types.getResultTypeOfNextInvocation( + (BObjectType) Types.getReferredType(invokableSymbol.retType)); + } + if (returnType != null) { + if (queryConstructType == Types.QueryConstructType.STREAM) { + types.getAllTypes(returnType, true).stream() + .filter(t -> (types.isAssignable(t, symTable.errorType) + || types.isAssignable(t, symTable.nilType))) + .forEach(completionTypes::add); + } else { + types.getAllTypes(returnType, true).stream() + .filter(t -> types.isAssignable(t, symTable.errorType)) + .forEach(completionTypes::add); } - BInvokableSymbol invokableSymbol = (BInvokableSymbol) itrSymbol; - returnType = types.getResultTypeOfNextInvocation( - (BObjectType) Types.getReferredType(invokableSymbol.retType)); - } - Set completionTypes = new LinkedHashSet<>(); - if (returnType != null) { - if (queryExpr.isStream) { - types.getAllTypes(returnType, true).stream() - .filter(t -> (types.isAssignable(t, symTable.errorType) - || types.isAssignable(t, symTable.nilType))) - .forEach(completionTypes::add); - } else { - types.getAllTypes(returnType, true).stream() - .filter(t -> types.isAssignable(t, symTable.errorType)) - .forEach(completionTypes::add); } } - if (data.commonAnalyzerData.checkWithinQueryExpr) { - if (queryExpr.isTable || queryExpr.isMap) { + if (data.commonAnalyzerData.queryCompletesEarly) { + if (queryConstructType == Types.QueryConstructType.TABLE || + queryConstructType == Types.QueryConstructType.MAP) { + completionTypes.addAll(data.commonAnalyzerData.completeEarlyErrorList); + } + } else if (queryConstructType == Types.QueryConstructType.STREAM) { + if (data.commonAnalyzerData.checkWithinQueryExpr) { completionTypes.addAll(data.commonAnalyzerData.checkedErrorList); } if (completionTypes.isEmpty()) { @@ -6353,6 +6362,7 @@ private BType getCompletionType(BType collectionType, BLangQueryExpr queryExpr, completionTypes.add(symTable.nilType); } } + if (!completionTypes.isEmpty()) { if (completionTypes.size() == 1) { completionType = completionTypes.iterator().next(); @@ -6390,8 +6400,8 @@ public void visit(BLangQueryAction queryAction, AnalyzerData data) { Types.CommonAnalyzerData typeCheckerData = data.commonAnalyzerData; //reset common analyzer data - boolean prevCheckWithinQueryExpr = typeCheckerData.checkWithinQueryExpr; - typeCheckerData.checkWithinQueryExpr = false; + boolean prevCheckWithinQueryExpr = typeCheckerData.queryCompletesEarly; + typeCheckerData.queryCompletesEarly = false; Stack prevQueryFinalClauses = typeCheckerData.queryFinalClauses; typeCheckerData.queryFinalClauses = new Stack<>(); @@ -6409,10 +6419,12 @@ public void visit(BLangQueryAction queryAction, AnalyzerData data) { typeCheckerData.queryFinalClauses.push(doClause); List clauses = queryAction.getQueryClauses(); clauses.forEach(clause -> clause.accept(this, data)); + List collectionTypes = getCollectionTypes(clauses); + BType completionType = getCompletionType(collectionTypes, Types.QueryConstructType.DEFAULT, data); // Analyze foreach node's statements. semanticAnalyzer.analyzeNode(doClause.body, SymbolEnv.createBlockEnv(doClause.body, typeCheckerData.queryEnvs.peek()), data.prevEnvs, typeCheckerData); - BType actualType = BUnionType.create(null, symTable.errorType, symTable.nilType); + BType actualType = completionType == null ? symTable.nilType : completionType; data.resultType = types.checkType(doClause.pos, actualType, data.expType, DiagnosticErrorCode.INCOMPATIBLE_TYPES); typeCheckerData.queryFinalClauses.pop(); @@ -6422,7 +6434,7 @@ public void visit(BLangQueryAction queryAction, AnalyzerData data) { } //re-assign common analyzer data - typeCheckerData.checkWithinQueryExpr = prevCheckWithinQueryExpr; + typeCheckerData.queryCompletesEarly = prevCheckWithinQueryExpr; typeCheckerData.queryFinalClauses = prevQueryFinalClauses; typeCheckerData.letCount = prevLetCount; } @@ -6461,6 +6473,14 @@ public void visit(BLangJoinClause joinClause, AnalyzerData data) { checkExpr(joinClause.collection, data.commonAnalyzerData.queryEnvs.peek(), data); // Set the type of the foreach node's type node. types.setInputClauseTypedBindingPatternType(joinClause); + if (joinClause.isOuterJoin) { + if (!joinClause.isDeclaredWithVar) { + this.dlog.error(joinClause.variableDefinitionNode.getPosition(), + DiagnosticErrorCode.OUTER_JOIN_MUST_BE_DECLARED_WITH_VAR); + return; + } + joinClause.varType = types.addNilForNillableAccessType(joinClause.varType); + } handleInputClauseVariables(joinClause, data.commonAnalyzerData.queryEnvs.peek()); if (joinClause.onClause != null) { ((BLangOnClause) joinClause.onClause).accept(this, data); @@ -6504,12 +6524,12 @@ public void visit(BLangOnConflictClause onConflictClause, AnalyzerData data) { BType type = checkExpr(onConflictClause.expression, data.commonAnalyzerData.queryEnvs.peek(), symTable.errorOrNilType, data); if (types.containsErrorType(type)) { - data.commonAnalyzerData.checkWithinQueryExpr = true; - if (typeCheckerData.checkedErrorList != null) { + data.commonAnalyzerData.queryCompletesEarly = true; + if (typeCheckerData.completeEarlyErrorList != null) { BType possibleErrorType = type.tag == TypeTags.UNION ? types.getErrorType((BUnionType) type) : types.getErrorType(BUnionType.create(null, type)); - typeCheckerData.checkedErrorList.add(possibleErrorType); + typeCheckerData.completeEarlyErrorList.add(possibleErrorType); } } } @@ -6979,7 +6999,8 @@ protected void markAndRegisterClosureVariable(BSymbol symbol, Location pos, Symb BLangNode bLangNode = env.node; if ((env.enclType != null && env.enclType.getKind() == NodeKind.FUNCTION_TYPE) || (symbol.owner.tag & SymTag.PACKAGE) == SymTag.PACKAGE && - bLangNode.getKind() != NodeKind.ARROW_EXPR && bLangNode.getKind() != NodeKind.EXPR_FUNCTION_BODY && + bLangNode.getKind() != NodeKind.ARROW_EXPR && + bLangNode.getKind() != NodeKind.EXPR_FUNCTION_BODY && encInvokable != null && !encInvokable.flagSet.contains(Flag.LAMBDA) && !encInvokable.flagSet.contains(Flag.OBJECT_CTOR)) { return; @@ -7627,9 +7648,9 @@ private BType checkInvocationArgs(BLangInvocation iExpr, List paramTypes, tupleMemberTypes.add(paramType); boolean required = requiredParams.contains(nonRestParam); fieldSymbol = new BVarSymbol(Flags.asMask(new HashSet() {{ - add(required ? Flag.REQUIRED : Flag.OPTIONAL); }}), paramName, - nonRestParam.getOriginalName(), pkgID, paramType, recordSymbol, - symTable.builtinPos, VIRTUAL); + add(required ? Flag.REQUIRED : Flag.OPTIONAL); }}), paramName, + nonRestParam.getOriginalName(), pkgID, paramType, recordSymbol, + symTable.builtinPos, VIRTUAL); fields.put(paramName.value, new BField(paramName, null, fieldSymbol)); } @@ -7746,7 +7767,7 @@ private void populateIncludedRecordParams(BVarSymbol param, HashSet incl if (paramType.tag != TypeTags.RECORD) { return; } - + Set fields = ((BRecordType) paramType).fields.keySet(); for (String field : fields) { if (includedRecordParamNames.contains(field)) { @@ -7758,7 +7779,7 @@ private void populateIncludedRecordParams(BVarSymbol param, HashSet incl // If there is a named-arg or positional-arg corresponding to an included-record-param, // it is an error for a named-arg to specify a field of that included-record-param. private void checkSameNamedArgsInIncludedRecords(List namedArgs, - HashSet incRecordFields) { + HashSet incRecordFields) { if (incRecordFields.isEmpty()) { return; } @@ -7902,6 +7923,11 @@ private boolean requireTypeInference(BLangExpression expr, boolean inferTypeForN case ARROW_EXPR: case LIST_CONSTRUCTOR_EXPR: case RECORD_LITERAL_EXPR: + case OBJECT_CTOR_EXPRESSION: + case RAW_TEMPLATE_LITERAL: + case TABLE_CONSTRUCTOR_EXPR: + case TYPE_INIT_EXPR: + case ERROR_CONSTRUCTOR_EXPRESSION: return true; case ELVIS_EXPR: case TERNARY_EXPR: @@ -7912,6 +7938,36 @@ private boolean requireTypeInference(BLangExpression expr, boolean inferTypeForN } } + private boolean isNotObjectConstructorWithObjectSuperTypeInTypeCastExpr(BLangExpression expression, + BType targetType) { + if (expression.getKind() != NodeKind.OBJECT_CTOR_EXPRESSION) { + return true; + } + + targetType = Types.getEffectiveType(Types.getReferredType(targetType)); + int tag = targetType.tag; + + if (tag == TypeTags.OBJECT) { + return !isAllObjectsObjectType((BObjectType) targetType); + } + + if (tag != TypeTags.UNION) { + return false; + } + + for (BType memberType : ((BUnionType) targetType).getMemberTypes()) { + memberType = Types.getEffectiveType(Types.getReferredType(memberType)); + if (memberType.tag == TypeTags.OBJECT && isAllObjectsObjectType((BObjectType) memberType)) { + return false; + } + } + return true; + } + + private boolean isAllObjectsObjectType(BObjectType objectType) { + return objectType.fields.isEmpty() && ((BObjectTypeSymbol) objectType.tsymbol).attachedFuncs.isEmpty(); + } + private BType checkMappingField(RecordLiteralNode.RecordField field, BType mappingType, AnalyzerData data) { BType fieldType = symTable.semanticError; boolean keyValueField = field.isKeyValueField(); @@ -8235,6 +8291,12 @@ private BType checkObjectFieldAccess(BLangFieldBasedAccess bLangFieldBasedAccess return symTable.semanticError; } + if (Symbols.isFlagOn(fieldSymbol.flags, Flags.REMOTE)) { + dlog.error(bLangFieldBasedAccess.field.pos, + DiagnosticErrorCode.CANNOT_USE_FIELD_ACCESS_TO_ACCESS_A_REMOTE_METHOD); + return symTable.semanticError; + } + if (Symbols.isFlagOn(fieldSymbol.type.flags, Flags.ISOLATED) && !Symbols.isFlagOn(objectType.flags, Flags.ISOLATED)) { fieldSymbol = ASTBuilderUtil.duplicateInvokableSymbol((BInvokableSymbol) fieldSymbol); @@ -9576,7 +9638,7 @@ private BType defineInferredRecordType(BLangRecordLiteral recordLiteral, BType e } } else if (field.getKind() == NodeKind.RECORD_LITERAL_SPREAD_OP) { BType spreadOpType = checkExpr(((BLangRecordLiteral.BLangRecordSpreadOperatorField) field).expr, - expType, data); + expType, data); BType type = Types.getReferredType(spreadOpType); if (type.tag == TypeTags.MAP) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/SymTag.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/SymTag.java index 09847c91eca0..0f320e2c1710 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/SymTag.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/SymTag.java @@ -53,5 +53,4 @@ public class SymTag { public static final int ENUM = 1 << 28 | TYPE_DEF; public static final int TYPE_REF = 1 << 29; public static final int ANNOTATION_ATTACHMENT = 1 << 30; - public static final long RESOURCE_PATH_SEGMENT = 1 << 32; } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/Symbols.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/Symbols.java index bc81d1f9056a..c2ed153c4acf 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/Symbols.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/Symbols.java @@ -151,7 +151,7 @@ public static BInvokableSymbol createFunctionSymbol(long flags, return symbol; } - public static BTypeSymbol createTypeSymbol(long symTag, + public static BTypeSymbol createTypeSymbol(int symTag, long flags, Name name, PackageID pkgID, @@ -162,7 +162,7 @@ public static BTypeSymbol createTypeSymbol(long symTag, return createTypeSymbol(symTag, flags, name, name, pkgID, type, owner, pos, origin); } - public static BTypeSymbol createTypeSymbol(long symTag, + public static BTypeSymbol createTypeSymbol(int symTag, long flags, Name name, Name originalName, @@ -191,7 +191,7 @@ public static BTypeDefinitionSymbol createTypeDefinitionSymbol(long flags, } - public static BInvokableTypeSymbol createInvokableTypeSymbol(long symTag, + public static BInvokableTypeSymbol createInvokableTypeSymbol(int symTag, long flags, PackageID pkgID, BType type, @@ -201,7 +201,7 @@ public static BInvokableTypeSymbol createInvokableTypeSymbol(long symTag, return new BInvokableTypeSymbol(symTag, flags, pkgID, type, owner, pos, origin); } - public static BInvokableSymbol createInvokableSymbol(long kind, + public static BInvokableSymbol createInvokableSymbol(int kind, long flags, Name name, Name originalName, @@ -221,18 +221,6 @@ public static BXMLNSSymbol createXMLNSSymbol(Name name, SymbolOrigin origin) { return new BXMLNSSymbol(name, nsURI, pkgID, owner, pos, origin); } - - public static BResourcePathSegmentSymbol createResourcePathSegmentSymbol(Name name, - PackageID pkgID, - BType type, - BSymbol owner, - Location location, - BResourcePathSegmentSymbol parentResource, - BResourceFunction resourceMethod, - SymbolOrigin origin) { - return new BResourcePathSegmentSymbol(name, pkgID, type, owner, location, parentResource, resourceMethod, - origin); - } public static String getAttachedFuncSymbolName(String typeName, String funcName) { return typeName + Names.DOT.value + funcName; @@ -274,7 +262,7 @@ public static boolean isFunctionDeclaration(BSymbol sym) { return (sym.flags & Flags.INTERFACE) == Flags.INTERFACE; } - public static boolean isTagOn(BSymbol symbol, long symTag) { + public static boolean isTagOn(BSymbol symbol, int symTag) { return (symbol.tag & symTag) == symTag; } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangNodeAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangNodeAnalyzer.java index 07a43bb9ace9..a5dda671b6af 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangNodeAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangNodeAnalyzer.java @@ -139,7 +139,6 @@ import org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt; import org.wso2.ballerinalang.compiler.tree.statements.BLangBreak; -import org.wso2.ballerinalang.compiler.tree.statements.BLangClientDeclarationStatement; import org.wso2.ballerinalang.compiler.tree.statements.BLangCompoundAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangContinue; import org.wso2.ballerinalang.compiler.tree.statements.BLangDo; @@ -621,8 +620,6 @@ public abstract class BLangNodeAnalyzer { public abstract void visit(BLangXMLNSStatement node, T data); - public abstract void visit(BLangClientDeclarationStatement node, T data); - // Types public abstract void visit(BLangArrayType node, T data); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangNodeTransformer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangNodeTransformer.java index 9ff775f53e1c..8196581debde 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangNodeTransformer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangNodeTransformer.java @@ -139,7 +139,6 @@ import org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt; import org.wso2.ballerinalang.compiler.tree.statements.BLangBreak; -import org.wso2.ballerinalang.compiler.tree.statements.BLangClientDeclarationStatement; import org.wso2.ballerinalang.compiler.tree.statements.BLangCompoundAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangContinue; import org.wso2.ballerinalang.compiler.tree.statements.BLangDo; @@ -1032,10 +1031,6 @@ public R transform(BLangXMLNSStatement node, T data) { return transformNode(node, data); } - public R transform(BLangClientDeclarationStatement node, T data) { - return transformNode(node, data); - } - // Types public R transform(BLangArrayType node, T data) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangNodeVisitor.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangNodeVisitor.java index ed3fb31d44fc..68d90b9ef48a 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangNodeVisitor.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangNodeVisitor.java @@ -163,7 +163,6 @@ import org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt; import org.wso2.ballerinalang.compiler.tree.statements.BLangBreak; -import org.wso2.ballerinalang.compiler.tree.statements.BLangClientDeclarationStatement; import org.wso2.ballerinalang.compiler.tree.statements.BLangCompoundAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangContinue; import org.wso2.ballerinalang.compiler.tree.statements.BLangDo; @@ -343,10 +342,6 @@ public void visit(BLangXMLNSStatement xmlnsStmtNode) { throw new AssertionError(); } - public void visit(BLangClientDeclarationStatement clientDeclarationStatement) { - throw new AssertionError(); - } - public void visit(BLangExpressionStmt exprStmtNode) { throw new AssertionError(); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/SimpleBLangNodeAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/SimpleBLangNodeAnalyzer.java index 774cceb4d5f3..18bd91b1e22b 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/SimpleBLangNodeAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/SimpleBLangNodeAnalyzer.java @@ -144,7 +144,6 @@ import org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt; import org.wso2.ballerinalang.compiler.tree.statements.BLangBreak; -import org.wso2.ballerinalang.compiler.tree.statements.BLangClientDeclarationStatement; import org.wso2.ballerinalang.compiler.tree.statements.BLangCompoundAssignment; import org.wso2.ballerinalang.compiler.tree.statements.BLangContinue; import org.wso2.ballerinalang.compiler.tree.statements.BLangDo; @@ -1354,11 +1353,6 @@ public void visit(BLangXMLNSStatement node, T data) { visitNode(node.xmlnsDecl, data); } - public void visit(BLangClientDeclarationStatement node, T data) { - analyzeNode(node, data); - visitNode(node.clientDeclaration, data); - } - public void visit(BLangRegExpTemplateLiteral node, T data) { analyzeNode(node, data); visitNode(node.reDisjunction, data); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/statements/BLangClientDeclarationStatement.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/statements/BLangClientDeclarationStatement.java deleted file mode 100644 index e3e923157e1f..000000000000 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/statements/BLangClientDeclarationStatement.java +++ /dev/null @@ -1,71 +0,0 @@ -/* -* Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ -package org.wso2.ballerinalang.compiler.tree.statements; - -import org.ballerinalang.model.tree.ClientDeclarationNode; -import org.ballerinalang.model.tree.NodeKind; -import org.ballerinalang.model.tree.statements.ClientDeclarationStatementNode; -import org.wso2.ballerinalang.compiler.tree.BLangClientDeclaration; -import org.wso2.ballerinalang.compiler.tree.BLangNodeAnalyzer; -import org.wso2.ballerinalang.compiler.tree.BLangNodeTransformer; -import org.wso2.ballerinalang.compiler.tree.BLangNodeVisitor; - -/** - * Represent a client declaration statement. - * - * @since 2201.3.0 - */ -public class BLangClientDeclarationStatement extends BLangStatement implements ClientDeclarationStatementNode { - - public BLangClientDeclaration clientDeclaration; - - @Override - public void setClientDeclaration(ClientDeclarationNode clientDeclaration) { - this.clientDeclaration = (BLangClientDeclaration) clientDeclaration; - } - - @Override - public BLangClientDeclaration getClientDeclaration() { - return clientDeclaration; - } - - @Override - public void accept(BLangNodeVisitor visitor) { - visitor.visit(this); - } - - @Override - public void accept(BLangNodeAnalyzer analyzer, T props) { - analyzer.visit(this, props); - } - - @Override - public R apply(BLangNodeTransformer modifier, T props) { - return modifier.transform(this, props); - } - - @Override - public NodeKind getKind() { - return NodeKind.CLIENT_DECL; - } - - @Override - public String toString() { - return clientDeclaration.toString(); - } -} diff --git a/compiler/ballerina-lang/src/main/resources/compiler.properties b/compiler/ballerina-lang/src/main/resources/compiler.properties index 78fe58f04a3b..f1622c279a78 100644 --- a/compiler/ballerina-lang/src/main/resources/compiler.properties +++ b/compiler/ballerina-lang/src/main/resources/compiler.properties @@ -201,6 +201,9 @@ error.cyclic.type.reference=\ error.attempt.refer.non.accessible.symbol=\ attempt to refer to non-accessible symbol ''{0}'' +error.cannot.use.field.access.to.access.a.remote.method=\ + ''remote'' methods of an object cannot be accessed using the field access expression + error.invokable.must.return=\ this {0} must return a result @@ -1597,8 +1600,13 @@ error.invalid.dependently.typed.return.type.with.inferred.typedesc.param=\ invalid return type: members of a dependently-typed union type with an inferred typedesc parameter should have \ disjoint basic types -error.cannot.infer.type.for.param=\ - cannot infer type for parameter ''{0}'' +error.cannot.infer.typedesc.argument.from.cet=\ + cannot infer the ''typedesc'' argument for parameter ''{0}'' with ''{1}'' as the contextually-expected \ + type mapping to return type ''{2}'' + +error.cannot.infer.typedesc.argument.without.cet=\ + cannot infer the ''typedesc'' argument for parameter ''{0}'': expected an argument for the parameter or a \ + contextually-expected type to infer the argument error.cannot.use.inferred.typedesc.default.with.unreferenced.param=\ cannot use an inferred typedesc default with a parameter on which the return type does not depend on @@ -1929,5 +1937,8 @@ error.invalid.quantifier.minimum=\ error.duplicate.flags=\ duplicate flag ''{0}'' +error.outer.join.must.be.declared.with.var=\ + outer join must be declared with ''var'' + error.cannot.import.module.generated.for.a.client.decl=\ a module generated for a client declaration cannot be imported diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParserErrorHandler.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParserErrorHandler.java index 3457227b238d..ea7e08f25eef 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParserErrorHandler.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParserErrorHandler.java @@ -109,7 +109,7 @@ public class BallerinaParserErrorHandler extends AbstractParserErrorHandler { ParserRuleContext.NAMED_WORKER_DECL, ParserRuleContext.FORK_STMT, ParserRuleContext.FOREACH_STMT, ParserRuleContext.XML_NAMESPACE_DECLARATION, ParserRuleContext.TRANSACTION_STMT, ParserRuleContext.RETRY_STMT, ParserRuleContext.ROLLBACK_STMT, ParserRuleContext.DO_BLOCK, - ParserRuleContext.FAIL_STATEMENT, ParserRuleContext.BLOCK_STMT, ParserRuleContext.CLIENT_DECLARATION }; + ParserRuleContext.FAIL_STATEMENT, ParserRuleContext.BLOCK_STMT }; private static final ParserRuleContext[] ASSIGNMENT_STMT_RHS = { ParserRuleContext.ASSIGN_OP, ParserRuleContext.COMPOUND_BINARY_OPERATOR }; diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STClientDeclarationNode.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STClientDeclarationNode.java deleted file mode 100644 index bc276370fa16..000000000000 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STClientDeclarationNode.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package io.ballerina.compiler.internal.parser.tree; - -import io.ballerina.compiler.syntax.tree.ClientDeclarationNode; -import io.ballerina.compiler.syntax.tree.Node; -import io.ballerina.compiler.syntax.tree.NonTerminalNode; -import io.ballerina.compiler.syntax.tree.SyntaxKind; - -import java.util.Collection; -import java.util.Collections; - -/** - * This is a generated internal syntax tree node. - * - * @since 2201.3.0 - */ -public class STClientDeclarationNode extends STStatementNode { - public final STNode annotations; - public final STNode clientKeyword; - public final STNode clientUri; - public final STNode asKeyword; - public final STNode clientPrefix; - public final STNode semicolonToken; - - STClientDeclarationNode( - STNode annotations, - STNode clientKeyword, - STNode clientUri, - STNode asKeyword, - STNode clientPrefix, - STNode semicolonToken) { - this( - annotations, - clientKeyword, - clientUri, - asKeyword, - clientPrefix, - semicolonToken, - Collections.emptyList()); - } - - STClientDeclarationNode( - STNode annotations, - STNode clientKeyword, - STNode clientUri, - STNode asKeyword, - STNode clientPrefix, - STNode semicolonToken, - Collection diagnostics) { - super(SyntaxKind.CLIENT_DECLARATION, diagnostics); - this.annotations = annotations; - this.clientKeyword = clientKeyword; - this.clientUri = clientUri; - this.asKeyword = asKeyword; - this.clientPrefix = clientPrefix; - this.semicolonToken = semicolonToken; - - addChildren( - annotations, - clientKeyword, - clientUri, - asKeyword, - clientPrefix, - semicolonToken); - } - - public STNode modifyWith(Collection diagnostics) { - return new STClientDeclarationNode( - this.annotations, - this.clientKeyword, - this.clientUri, - this.asKeyword, - this.clientPrefix, - this.semicolonToken, - diagnostics); - } - - public STClientDeclarationNode modify( - STNode annotations, - STNode clientKeyword, - STNode clientUri, - STNode asKeyword, - STNode clientPrefix, - STNode semicolonToken) { - if (checkForReferenceEquality( - annotations, - clientKeyword, - clientUri, - asKeyword, - clientPrefix, - semicolonToken)) { - return this; - } - - return new STClientDeclarationNode( - annotations, - clientKeyword, - clientUri, - asKeyword, - clientPrefix, - semicolonToken, - diagnostics); - } - - public Node createFacade(int position, NonTerminalNode parent) { - return new ClientDeclarationNode(this, position, parent); - } - - @Override - public void accept(STNodeVisitor visitor) { - visitor.visit(this); - } - - @Override - public T apply(STNodeTransformer transformer) { - return transformer.transform(this); - } -} diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/ClientDeclarationNode.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/ClientDeclarationNode.java deleted file mode 100644 index dd3c3b7df2e5..000000000000 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/ClientDeclarationNode.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package io.ballerina.compiler.syntax.tree; - -import io.ballerina.compiler.internal.parser.tree.STNode; - -import java.util.Objects; - -/** - * This is a generated syntax tree node. - * - * @since 2201.3.0 - */ -public class ClientDeclarationNode extends StatementNode { - - public ClientDeclarationNode(STNode internalNode, int position, NonTerminalNode parent) { - super(internalNode, position, parent); - } - - public NodeList annotations() { - return new NodeList<>(childInBucket(0)); - } - - public Token clientKeyword() { - return childInBucket(1); - } - - public BasicLiteralNode clientUri() { - return childInBucket(2); - } - - public Token asKeyword() { - return childInBucket(3); - } - - public IdentifierToken clientPrefix() { - return childInBucket(4); - } - - public Token semicolonToken() { - return childInBucket(5); - } - - @Override - public void accept(NodeVisitor visitor) { - visitor.visit(this); - } - - @Override - public T apply(NodeTransformer visitor) { - return visitor.transform(this); - } - - @Override - protected String[] childNames() { - return new String[]{ - "annotations", - "clientKeyword", - "clientUri", - "asKeyword", - "clientPrefix", - "semicolonToken"}; - } - - public ClientDeclarationNode modify( - NodeList annotations, - Token clientKeyword, - BasicLiteralNode clientUri, - Token asKeyword, - IdentifierToken clientPrefix, - Token semicolonToken) { - if (checkForReferenceEquality( - annotations.underlyingListNode(), - clientKeyword, - clientUri, - asKeyword, - clientPrefix, - semicolonToken)) { - return this; - } - - return NodeFactory.createClientDeclarationNode( - annotations, - clientKeyword, - clientUri, - asKeyword, - clientPrefix, - semicolonToken); - } - - public ClientDeclarationNodeModifier modify() { - return new ClientDeclarationNodeModifier(this); - } - - /** - * This is a generated tree node modifier utility. - * - * @since 2.0.0 - */ - public static class ClientDeclarationNodeModifier { - private final ClientDeclarationNode oldNode; - private NodeList annotations; - private Token clientKeyword; - private BasicLiteralNode clientUri; - private Token asKeyword; - private IdentifierToken clientPrefix; - private Token semicolonToken; - - public ClientDeclarationNodeModifier(ClientDeclarationNode oldNode) { - this.oldNode = oldNode; - this.annotations = oldNode.annotations(); - this.clientKeyword = oldNode.clientKeyword(); - this.clientUri = oldNode.clientUri(); - this.asKeyword = oldNode.asKeyword(); - this.clientPrefix = oldNode.clientPrefix(); - this.semicolonToken = oldNode.semicolonToken(); - } - - public ClientDeclarationNodeModifier withAnnotations( - NodeList annotations) { - Objects.requireNonNull(annotations, "annotations must not be null"); - this.annotations = annotations; - return this; - } - - public ClientDeclarationNodeModifier withClientKeyword( - Token clientKeyword) { - Objects.requireNonNull(clientKeyword, "clientKeyword must not be null"); - this.clientKeyword = clientKeyword; - return this; - } - - public ClientDeclarationNodeModifier withClientUri( - BasicLiteralNode clientUri) { - Objects.requireNonNull(clientUri, "clientUri must not be null"); - this.clientUri = clientUri; - return this; - } - - public ClientDeclarationNodeModifier withAsKeyword( - Token asKeyword) { - Objects.requireNonNull(asKeyword, "asKeyword must not be null"); - this.asKeyword = asKeyword; - return this; - } - - public ClientDeclarationNodeModifier withClientPrefix( - IdentifierToken clientPrefix) { - Objects.requireNonNull(clientPrefix, "clientPrefix must not be null"); - this.clientPrefix = clientPrefix; - return this; - } - - public ClientDeclarationNodeModifier withSemicolonToken( - Token semicolonToken) { - Objects.requireNonNull(semicolonToken, "semicolonToken must not be null"); - this.semicolonToken = semicolonToken; - return this; - } - - public ClientDeclarationNode apply() { - return oldNode.modify( - annotations, - clientKeyword, - clientUri, - asKeyword, - clientPrefix, - semicolonToken); - } - } -} diff --git a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/ClientDeclarationStatementTest.java b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/ClientDeclarationStatementTest.java deleted file mode 100644 index c2aa1410b739..000000000000 --- a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/ClientDeclarationStatementTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package io.ballerinalang.compiler.parser.test.syntax.statements; - -import org.testng.annotations.Test; - -/** - * Test parsing client declaration statements. - * - * @since 2201.3.0 - */ -public class ClientDeclarationStatementTest extends AbstractStatementTest { - - // Valid syntax tests - - @Test - public void testClientDeclStmt() { - testFile("client-decl-stmt/client_decl_stmt_source_01.bal", "client-decl-stmt/client_decl_stmt_assert_01.json"); - } - - @Test - public void testClientDeclStmtWithAnnotations() { - testFile("client-decl-stmt/client_decl_stmt_source_02.bal", "client-decl-stmt/client_decl_stmt_assert_02.json"); - } - - // Recovery tests - - @Test - public void testMissingAliasAndSemicolon() { - testFile("client-decl-stmt/client_decl_stmt_source_03.bal", "client-decl-stmt/client_decl_stmt_assert_03.json"); - } - - @Test - public void testMissingAsKeyword() { - testFile("client-decl-stmt/client_decl_stmt_source_04.bal", "client-decl-stmt/client_decl_stmt_assert_04.json"); - } - - @Test - public void testMissingClientAndXmlnsKeyword() { - testFile("client-decl-stmt/client_decl_stmt_source_05.bal", "client-decl-stmt/client_decl_stmt_assert_05.json"); - } - - @Test - public void testMissingUri() { - testFile("client-decl-stmt/client_decl_stmt_source_06.bal", "client-decl-stmt/client_decl_stmt_assert_06.json"); - } - - @Test - public void testIdentifierAsUri() { - testFile("client-decl-stmt/client_decl_stmt_source_07.bal", "client-decl-stmt/client_decl_stmt_assert_07.json"); - } - - @Test - public void testMultipleAliases() { - testFile("client-decl-stmt/client_decl_stmt_source_08.bal", "client-decl-stmt/client_decl_stmt_assert_08.json"); - } - - @Test - public void testOnlyClientKeyword() { - testFile("client-decl-stmt/client_decl_stmt_source_09.bal", "client-decl-stmt/client_decl_stmt_assert_09.json"); - } - - @Test - public void testMissingAlias() { - testFile("client-decl-stmt/client_decl_stmt_source_10.bal", "client-decl-stmt/client_decl_stmt_assert_10.json"); - } - - @Test - public void testMissingSemicolon() { - testFile("client-decl-stmt/client_decl_stmt_source_11.bal", "client-decl-stmt/client_decl_stmt_assert_11.json"); - } - - @Test - public void testRecoveryWithMultipleClientDeclStmts() { - testFile("client-decl-stmt/client_decl_stmt_source_12.bal", "client-decl-stmt/client_decl_stmt_assert_12.json"); - } - - @Test - public void testInvalidQualifiers() { - testFile("client-decl-stmt/client_decl_stmt_source_13.bal", "client-decl-stmt/client_decl_stmt_assert_13.json"); - } -} diff --git a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_01.json b/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_01.json deleted file mode 100644 index f148fb1b4e94..000000000000 --- a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_01.json +++ /dev/null @@ -1,136 +0,0 @@ -{ - "kind": "FUNCTION_DEFINITION", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "fn" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_SIGNATURE", - "children": [ - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "FUNCTION_BODY_BLOCK", - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CLIENT_DECLARATION", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "http://www.example.com/apis/myapi.yaml", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_02.json b/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_02.json deleted file mode 100644 index ba007c329122..000000000000 --- a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_02.json +++ /dev/null @@ -1,334 +0,0 @@ -{ - "kind": "FUNCTION_DEFINITION", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "fn" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_SIGNATURE", - "children": [ - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "FUNCTION_BODY_BLOCK", - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CLIENT_DECLARATION", - "children": [ - { - "kind": "LIST", - "children": [ - { - "kind": "ANNOTATION", - "children": [ - { - "kind": "AT_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "AnnotationOne", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "MAPPING_CONSTRUCTOR", - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "SPECIFIC_FIELD", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "x", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NUMERIC_LITERAL", - "children": [ - { - "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", - "value": "1", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - } - ] - }, - { - "kind": "CLIENT_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "http://www.example.com/apis/myapi.yaml", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CLIENT_DECLARATION", - "children": [ - { - "kind": "LIST", - "children": [ - { - "kind": "ANNOTATION", - "children": [ - { - "kind": "AT_TOKEN", - "leadingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "AnnotationTwo", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - } - ] - }, - { - "kind": "CLIENT_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "http://www.example.com/apis/myapi.yaml", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_03.json b/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_03.json deleted file mode 100644 index 019ec8c18f37..000000000000 --- a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_03.json +++ /dev/null @@ -1,143 +0,0 @@ -{ - "kind": "FUNCTION_DEFINITION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "fn" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_SIGNATURE", - "children": [ - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "FUNCTION_BODY_BLOCK", - "hasDiagnostics": true, - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "CLIENT_DECLARATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "http://www.example.com/apis/myapi.yaml", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_SEMICOLON_TOKEN" - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_04.json b/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_04.json deleted file mode 100644 index e7049e1226c9..000000000000 --- a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_04.json +++ /dev/null @@ -1,139 +0,0 @@ -{ - "kind": "FUNCTION_DEFINITION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "fn" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_SIGNATURE", - "children": [ - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "FUNCTION_BODY_BLOCK", - "hasDiagnostics": true, - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "CLIENT_DECLARATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "http://www.example.com/apis/myapi.yaml", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_AS_KEYWORD" - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_05.json b/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_05.json deleted file mode 100644 index ee9dd3954ce8..000000000000 --- a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_05.json +++ /dev/null @@ -1,162 +0,0 @@ -{ - "kind": "FUNCTION_DEFINITION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "fn" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_SIGNATURE", - "children": [ - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "FUNCTION_BODY_BLOCK", - "hasDiagnostics": true, - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "SINGLETON_TYPE_DESC", - "children": [ - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "http://www.example.com/apis/myapi.yaml", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "hasDiagnostics": true, - "value": "myapi", - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "AS_KEYWORD", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ] - } - ] - } - }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_06.json b/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_06.json deleted file mode 100644 index 2820a51eef31..000000000000 --- a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_06.json +++ /dev/null @@ -1,139 +0,0 @@ -{ - "kind": "FUNCTION_DEFINITION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "fn" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_SIGNATURE", - "children": [ - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "FUNCTION_BODY_BLOCK", - "hasDiagnostics": true, - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "CLIENT_DECLARATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "hasDiagnostics": true, - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_STRING_LITERAL" - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_07.json b/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_07.json deleted file mode 100644 index fc919603fe81..000000000000 --- a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_07.json +++ /dev/null @@ -1,162 +0,0 @@ -{ - "kind": "FUNCTION_DEFINITION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "fn" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_SIGNATURE", - "children": [ - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "FUNCTION_BODY_BLOCK", - "hasDiagnostics": true, - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "CLIENT_DECLARATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "hasDiagnostics": true, - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_STRING_LITERAL" - ], - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ], - "value": "constRef" - } - ] - } - }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi1" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_08.json b/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_08.json deleted file mode 100644 index c168473727a6..000000000000 --- a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_08.json +++ /dev/null @@ -1,166 +0,0 @@ -{ - "kind": "FUNCTION_DEFINITION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "fn" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_SIGNATURE", - "children": [ - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "FUNCTION_BODY_BLOCK", - "hasDiagnostics": true, - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "CLIENT_DECLARATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "http://www.example.com/apis/myapi.yaml", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "hasDiagnostics": true, - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ], - "value": "myapi" - } - ] - } - } - ], - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_09.json b/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_09.json deleted file mode 100644 index 4f8f4214c257..000000000000 --- a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_09.json +++ /dev/null @@ -1,141 +0,0 @@ -{ - "kind": "FUNCTION_DEFINITION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "fn" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_SIGNATURE", - "children": [ - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "FUNCTION_BODY_BLOCK", - "hasDiagnostics": true, - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "CLIENT_DECLARATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "STRING_LITERAL", - "hasDiagnostics": true, - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_STRING_LITERAL" - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_AS_KEYWORD" - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_SEMICOLON_TOKEN" - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_10.json b/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_10.json deleted file mode 100644 index 29b176a41762..000000000000 --- a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_10.json +++ /dev/null @@ -1,144 +0,0 @@ -{ - "kind": "FUNCTION_DEFINITION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "fn" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_SIGNATURE", - "children": [ - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "FUNCTION_BODY_BLOCK", - "hasDiagnostics": true, - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "CLIENT_DECLARATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "http://www.example.com/apis/myapi.yaml", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_11.json b/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_11.json deleted file mode 100644 index 75e588defe24..000000000000 --- a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_11.json +++ /dev/null @@ -1,145 +0,0 @@ -{ - "kind": "FUNCTION_DEFINITION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "fn" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_SIGNATURE", - "children": [ - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "FUNCTION_BODY_BLOCK", - "hasDiagnostics": true, - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "CLIENT_DECLARATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "http://www.example.com/apis/myapi.yaml", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_SEMICOLON_TOKEN" - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_12.json b/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_12.json deleted file mode 100644 index 6e189afa9a0b..000000000000 --- a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_12.json +++ /dev/null @@ -1,280 +0,0 @@ -{ - "kind": "FUNCTION_DEFINITION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "fn" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_SIGNATURE", - "children": [ - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "FUNCTION_BODY_BLOCK", - "hasDiagnostics": true, - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "CLIENT_DECLARATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "http://www.example.com/apis/myapi.yaml", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_SEMICOLON_TOKEN" - ] - } - ] - }, - { - "kind": "CLIENT_DECLARATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "leadingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "http://www.example.com/apis/myapi.yaml", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_AS_KEYWORD" - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_SEMICOLON_TOKEN" - ] - } - ] - }, - { - "kind": "CLIENT_DECLARATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "leadingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "hasDiagnostics": true, - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_STRING_LITERAL" - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi2" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_13.json b/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_13.json deleted file mode 100644 index f32cd3bb00e8..000000000000 --- a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_assert_13.json +++ /dev/null @@ -1,250 +0,0 @@ -{ - "kind": "FUNCTION_DEFINITION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "fn" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_SIGNATURE", - "children": [ - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "FUNCTION_BODY_BLOCK", - "hasDiagnostics": true, - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "CLIENT_DECLARATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "hasDiagnostics": true, - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "hasDiagnostics": true, - "value": "http://www.example.com/apis/myapi2.yaml", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - }, - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "ISOLATED_KEYWORD", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_QUALIFIER" - ] - } - ] - } - }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi2" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CLIENT_DECLARATION", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLIENT_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "hasDiagnostics": true, - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "hasDiagnostics": true, - "value": "http://www.example.com/apis/myapi1.yaml", - "leadingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - }, - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "TRANSACTIONAL_KEYWORD", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_QUALIFIER" - ] - } - ] - } - }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "AS_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "myapi1" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] -} diff --git a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_01.bal b/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_01.bal deleted file mode 100644 index dd680b85357f..000000000000 --- a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_01.bal +++ /dev/null @@ -1,3 +0,0 @@ -function fn() { - client "http://www.example.com/apis/myapi.yaml" as myapi; -} diff --git a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_02.bal b/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_02.bal deleted file mode 100644 index 34790d8ea430..000000000000 --- a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_02.bal +++ /dev/null @@ -1,9 +0,0 @@ -function fn() { - @AnnotationOne { - x: 1 - } - client "http://www.example.com/apis/myapi.yaml" as myapi; - - @AnnotationTwo - client "http://www.example.com/apis/myapi.yaml" as myapi; -} diff --git a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_03.bal b/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_03.bal deleted file mode 100644 index 90d1513f76c7..000000000000 --- a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_03.bal +++ /dev/null @@ -1,3 +0,0 @@ -function fn() { - client "http://www.example.com/apis/myapi.yaml" as -} diff --git a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_04.bal b/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_04.bal deleted file mode 100644 index 40128f3e656c..000000000000 --- a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_04.bal +++ /dev/null @@ -1,3 +0,0 @@ -function fn() { - client "http://www.example.com/apis/myapi.yaml" myapi; -} diff --git a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_05.bal b/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_05.bal deleted file mode 100644 index 0dfe71914bd8..000000000000 --- a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_05.bal +++ /dev/null @@ -1,3 +0,0 @@ -function fn() { - "http://www.example.com/apis/myapi.yaml" as myapi; -} diff --git a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_06.bal b/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_06.bal deleted file mode 100644 index d426233502e1..000000000000 --- a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_06.bal +++ /dev/null @@ -1,3 +0,0 @@ -function fn() { - client as myapi; -} diff --git a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_07.bal b/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_07.bal deleted file mode 100644 index 43d5c7696d5a..000000000000 --- a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_07.bal +++ /dev/null @@ -1,3 +0,0 @@ -function fn() { - client constRef as myapi1; -} diff --git a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_08.bal b/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_08.bal deleted file mode 100644 index e9a15a41ab5d..000000000000 --- a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_08.bal +++ /dev/null @@ -1,3 +0,0 @@ -function fn() { - client "http://www.example.com/apis/myapi.yaml" as myapi myapi; -} diff --git a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_09.bal b/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_09.bal deleted file mode 100644 index 7f327a14926a..000000000000 --- a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_09.bal +++ /dev/null @@ -1,3 +0,0 @@ -function fn() { - client -} diff --git a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_10.bal b/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_10.bal deleted file mode 100644 index f4ebf0d8f863..000000000000 --- a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_10.bal +++ /dev/null @@ -1,3 +0,0 @@ -function fn() { - client "http://www.example.com/apis/myapi.yaml" as ; -} diff --git a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_11.bal b/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_11.bal deleted file mode 100644 index ffa8f36ab468..000000000000 --- a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_11.bal +++ /dev/null @@ -1,3 +0,0 @@ -function fn() { - client "http://www.example.com/apis/myapi.yaml" as myapi -} diff --git a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_12.bal b/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_12.bal deleted file mode 100644 index 943193bde3c4..000000000000 --- a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_12.bal +++ /dev/null @@ -1,7 +0,0 @@ -function fn() { - client "http://www.example.com/apis/myapi.yaml" as myapi - - client "http://www.example.com/apis/myapi.yaml" myapi - - client as myapi2; -} diff --git a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_13.bal b/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_13.bal deleted file mode 100644 index 98d36f1aa9f6..000000000000 --- a/compiler/ballerina-parser/src/test/resources/statements/client-decl-stmt/client_decl_stmt_source_13.bal +++ /dev/null @@ -1,5 +0,0 @@ -function fn() { - isolated client "http://www.example.com/apis/myapi2.yaml" as myapi2; - - transactional client "http://www.example.com/apis/myapi1.yaml" as myapi1; -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config15_client_declaration.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config15_client_declaration.json deleted file mode 100644 index 9aad2fb5e556..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config15_client_declaration.json +++ /dev/null @@ -1,905 +0,0 @@ -{ - "position": { - "line": 2, - "character": 4 - }, - "source": "function_body/source/source15_client_declaration.bal", - "items": [ - { - "label": "ballerina/lang.test", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "test", - "insertText": "test", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.test;\n" - } - ] - }, - { - "label": "ballerina/lang.array", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "array", - "insertText": "array", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.array;\n" - } - ] - }, - { - "label": "ballerina/jballerina.java", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "java", - "insertText": "java", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/jballerina.java;\n" - } - ] - }, - { - "label": "ballerina/lang.value", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "value", - "insertText": "value", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.value;\n" - } - ] - }, - { - "label": "ballerina/module1", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "module1", - "insertText": "module1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/module1;\n" - } - ] - }, - { - "label": "ballerina/lang.runtime", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "runtime", - "insertText": "runtime", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.runtime;\n" - } - ] - }, - { - "label": "xmlns", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "xmlns", - "insertText": "xmlns \"${1}\" as ${2:ns};", - "insertTextFormat": "Snippet" - }, - { - "label": "xmlns", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "xmlns", - "insertText": "xmlns ", - "insertTextFormat": "Snippet" - }, - { - "label": "var", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "var", - "insertText": "var ", - "insertTextFormat": "Snippet" - }, - { - "label": "wait", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "wait", - "insertText": "wait ", - "insertTextFormat": "Snippet" - }, - { - "label": "start", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "start", - "insertText": "start ", - "insertTextFormat": "Snippet" - }, - { - "label": "flush", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "flush", - "insertText": "flush ", - "insertTextFormat": "Snippet" - }, - { - "label": "new", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "new", - "insertText": "new ", - "insertTextFormat": "Snippet" - }, - { - "label": "isolated", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "isolated", - "insertText": "isolated ", - "insertTextFormat": "Snippet" - }, - { - "label": "transactional", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "transactional", - "insertText": "transactional", - "insertTextFormat": "Snippet" - }, - { - "label": "let", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "let", - "insertText": "let", - "insertTextFormat": "Snippet" - }, - { - "label": "typeof", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "typeof", - "insertText": "typeof ", - "insertTextFormat": "Snippet" - }, - { - "label": "trap", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "trap", - "insertText": "trap", - "insertTextFormat": "Snippet" - }, - { - "label": "client", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "client", - "insertText": "client ", - "insertTextFormat": "Snippet" - }, - { - "label": "checkpanic", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "checkpanic", - "insertText": "checkpanic ", - "insertTextFormat": "Snippet" - }, - { - "label": "check", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "check", - "insertText": "check ", - "insertTextFormat": "Snippet" - }, - { - "label": "final", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "final", - "insertText": "final ", - "insertTextFormat": "Snippet" - }, - { - "label": "fail", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "fail", - "insertText": "fail ", - "insertTextFormat": "Snippet" - }, - { - "label": "error constructor", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "error", - "insertText": "error(\"${1}\")", - "insertTextFormat": "Snippet" - }, - { - "label": "object constructor", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "object", - "insertText": "object {${1}}", - "insertTextFormat": "Snippet" - }, - { - "label": "base16", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "base16", - "insertText": "base16 `${1}`", - "insertTextFormat": "Snippet" - }, - { - "label": "base64", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "base64", - "insertText": "base64 `${1}`", - "insertTextFormat": "Snippet" - }, - { - "label": "from", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "from", - "insertText": "from ", - "insertTextFormat": "Snippet" - }, - { - "label": "if", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "if", - "insertText": "if ${1:true} {\n\t${2}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "while", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "while", - "insertText": "while ${1:true} {\n\t${2}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "do", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "do", - "insertText": "do {\n\t${1}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "lock", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "lock", - "insertText": "lock {\n\t${1}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "foreach", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "foreach", - "insertText": "foreach ${1:var} ${2:item} in ${3:itemList} {\n\t${4}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "foreach i", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "foreach", - "insertText": "foreach ${1:int} ${2:i} in ${3:0}...${4:9} {\n\t${5}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "fork", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "fork", - "insertText": "fork {\n\t${1}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "transaction", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "transaction", - "insertText": "transaction {\n\t${1}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "retry", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "retry", - "insertText": "retry {\n\t${1}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "retry transaction", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "retry_transaction", - "insertText": "retry transaction {\n\t${1}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "match", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "match", - "insertText": "match ", - "insertTextFormat": "Snippet" - }, - { - "label": "panic", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "panic", - "insertText": "panic ", - "insertTextFormat": "Snippet" - }, - { - "label": "stream<> streamName = new;", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "stream", - "insertText": "stream<${1}> ${2:streamName} = new;", - "insertTextFormat": "Snippet" - }, - { - "label": "return;", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "return;", - "insertText": "return;", - "insertTextFormat": "Snippet" - }, - { - "label": "StrandData", - "kind": "Struct", - "detail": "Record", - "documentation": { - "left": "Describes Strand execution details for the runtime.\n" - }, - "sortText": "M", - "insertText": "StrandData", - "insertTextFormat": "Snippet" - }, - { - "label": "Thread", - "kind": "TypeParameter", - "detail": "Union", - "sortText": "N", - "insertText": "Thread", - "insertTextFormat": "Snippet" - }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, - { - "label": "record", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "record", - "insertText": "record ", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "function", - "insertText": "function ", - "insertTextFormat": "Snippet" - }, - { - "label": "record {}", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "record", - "insertText": "record {${1}}", - "insertTextFormat": "Snippet" - }, - { - "label": "record {||}", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "record", - "insertText": "record {|${1}|}", - "insertTextFormat": "Snippet" - }, - { - "label": "distinct", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "distinct", - "insertText": "distinct", - "insertTextFormat": "Snippet" - }, - { - "label": "object {}", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "object", - "insertText": "object {${1}}", - "insertTextFormat": "Snippet" - }, - { - "label": "true", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "true", - "insertText": "true", - "insertTextFormat": "Snippet" - }, - { - "label": "false", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "false", - "insertText": "false", - "insertTextFormat": "Snippet" - }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, - { - "label": "map", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "map", - "insertTextFormat": "Snippet" - }, - { - "label": "object", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "object", - "insertTextFormat": "Snippet" - }, - { - "label": "stream", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "stream", - "insertTextFormat": "Snippet" - }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, - { - "label": "table", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "table", - "insertTextFormat": "Snippet" - }, - { - "label": "transaction", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "transaction", - "insertTextFormat": "Snippet" - }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, - { - "label": "worker", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "worker", - "insertText": "worker ${1:name} {\n\t${2}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "test/project2", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "project2", - "insertText": "project2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/project2;\n" - } - ] - }, - { - "label": "test/project1", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "project1", - "insertText": "project1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/project1;\n" - } - ] - }, - { - "label": "test/local_project2", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "local_project2", - "insertText": "local_project2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/local_project2;\n" - } - ] - }, - { - "label": "test/local_project1", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "local_project1", - "insertText": "local_project1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/local_project1;\n" - } - ] - }, - { - "label": "null", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "null", - "insertText": "null", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "testFunction()", - "kind": "Function", - "detail": "()", - "documentation": { - "right": { - "kind": "markdown", - "value": "**Package:** _._ \n \n \n" - } - }, - "sortText": "C", - "filterText": "testFunction", - "insertText": "testFunction()", - "insertTextFormat": "Snippet" - }, - { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] - } - ] -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config16_client_declaration.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config16_client_declaration.json deleted file mode 100644 index 37e88409b751..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config16_client_declaration.json +++ /dev/null @@ -1,905 +0,0 @@ -{ - "position": { - "line": 4, - "character": 4 - }, - "source": "function_body/source/source16_client_declaration.bal", - "items": [ - { - "label": "ballerina/lang.test", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "test", - "insertText": "test", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.test;\n" - } - ] - }, - { - "label": "ballerina/lang.array", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "array", - "insertText": "array", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.array;\n" - } - ] - }, - { - "label": "ballerina/jballerina.java", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "java", - "insertText": "java", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/jballerina.java;\n" - } - ] - }, - { - "label": "ballerina/lang.value", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "value", - "insertText": "value", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.value;\n" - } - ] - }, - { - "label": "ballerina/module1", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "module1", - "insertText": "module1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/module1;\n" - } - ] - }, - { - "label": "ballerina/lang.runtime", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "runtime", - "insertText": "runtime", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.runtime;\n" - } - ] - }, - { - "label": "xmlns", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "xmlns", - "insertText": "xmlns \"${1}\" as ${2:ns};", - "insertTextFormat": "Snippet" - }, - { - "label": "xmlns", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "xmlns", - "insertText": "xmlns ", - "insertTextFormat": "Snippet" - }, - { - "label": "var", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "var", - "insertText": "var ", - "insertTextFormat": "Snippet" - }, - { - "label": "wait", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "wait", - "insertText": "wait ", - "insertTextFormat": "Snippet" - }, - { - "label": "start", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "start", - "insertText": "start ", - "insertTextFormat": "Snippet" - }, - { - "label": "flush", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "flush", - "insertText": "flush ", - "insertTextFormat": "Snippet" - }, - { - "label": "new", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "new", - "insertText": "new ", - "insertTextFormat": "Snippet" - }, - { - "label": "isolated", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "isolated", - "insertText": "isolated ", - "insertTextFormat": "Snippet" - }, - { - "label": "transactional", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "transactional", - "insertText": "transactional", - "insertTextFormat": "Snippet" - }, - { - "label": "let", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "let", - "insertText": "let", - "insertTextFormat": "Snippet" - }, - { - "label": "typeof", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "typeof", - "insertText": "typeof ", - "insertTextFormat": "Snippet" - }, - { - "label": "trap", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "trap", - "insertText": "trap", - "insertTextFormat": "Snippet" - }, - { - "label": "client", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "client", - "insertText": "client ", - "insertTextFormat": "Snippet" - }, - { - "label": "checkpanic", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "checkpanic", - "insertText": "checkpanic ", - "insertTextFormat": "Snippet" - }, - { - "label": "check", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "check", - "insertText": "check ", - "insertTextFormat": "Snippet" - }, - { - "label": "final", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "final", - "insertText": "final ", - "insertTextFormat": "Snippet" - }, - { - "label": "fail", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "fail", - "insertText": "fail ", - "insertTextFormat": "Snippet" - }, - { - "label": "error constructor", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "error", - "insertText": "error(\"${1}\")", - "insertTextFormat": "Snippet" - }, - { - "label": "object constructor", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "object", - "insertText": "object {${1}}", - "insertTextFormat": "Snippet" - }, - { - "label": "base16", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "base16", - "insertText": "base16 `${1}`", - "insertTextFormat": "Snippet" - }, - { - "label": "base64", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "base64", - "insertText": "base64 `${1}`", - "insertTextFormat": "Snippet" - }, - { - "label": "from", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "from", - "insertText": "from ", - "insertTextFormat": "Snippet" - }, - { - "label": "if", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "if", - "insertText": "if ${1:true} {\n\t${2}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "while", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "while", - "insertText": "while ${1:true} {\n\t${2}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "do", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "do", - "insertText": "do {\n\t${1}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "lock", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "lock", - "insertText": "lock {\n\t${1}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "foreach", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "foreach", - "insertText": "foreach ${1:var} ${2:item} in ${3:itemList} {\n\t${4}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "foreach i", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "foreach", - "insertText": "foreach ${1:int} ${2:i} in ${3:0}...${4:9} {\n\t${5}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "fork", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "fork", - "insertText": "fork {\n\t${1}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "transaction", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "transaction", - "insertText": "transaction {\n\t${1}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "retry", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "retry", - "insertText": "retry {\n\t${1}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "retry transaction", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "retry_transaction", - "insertText": "retry transaction {\n\t${1}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "match", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "match", - "insertText": "match ", - "insertTextFormat": "Snippet" - }, - { - "label": "panic", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "panic", - "insertText": "panic ", - "insertTextFormat": "Snippet" - }, - { - "label": "stream<> streamName = new;", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "stream", - "insertText": "stream<${1}> ${2:streamName} = new;", - "insertTextFormat": "Snippet" - }, - { - "label": "return;", - "kind": "Snippet", - "detail": "Statement", - "sortText": "P", - "filterText": "return;", - "insertText": "return;", - "insertTextFormat": "Snippet" - }, - { - "label": "StrandData", - "kind": "Struct", - "detail": "Record", - "documentation": { - "left": "Describes Strand execution details for the runtime.\n" - }, - "sortText": "M", - "insertText": "StrandData", - "insertTextFormat": "Snippet" - }, - { - "label": "Thread", - "kind": "TypeParameter", - "detail": "Union", - "sortText": "N", - "insertText": "Thread", - "insertTextFormat": "Snippet" - }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, - { - "label": "record", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "record", - "insertText": "record ", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "function", - "insertText": "function ", - "insertTextFormat": "Snippet" - }, - { - "label": "record {}", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "record", - "insertText": "record {${1}}", - "insertTextFormat": "Snippet" - }, - { - "label": "record {||}", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "record", - "insertText": "record {|${1}|}", - "insertTextFormat": "Snippet" - }, - { - "label": "distinct", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "distinct", - "insertText": "distinct", - "insertTextFormat": "Snippet" - }, - { - "label": "object {}", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "object", - "insertText": "object {${1}}", - "insertTextFormat": "Snippet" - }, - { - "label": "true", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "true", - "insertText": "true", - "insertTextFormat": "Snippet" - }, - { - "label": "false", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "false", - "insertText": "false", - "insertTextFormat": "Snippet" - }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, - { - "label": "map", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "map", - "insertTextFormat": "Snippet" - }, - { - "label": "object", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "object", - "insertTextFormat": "Snippet" - }, - { - "label": "stream", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "stream", - "insertTextFormat": "Snippet" - }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, - { - "label": "table", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "table", - "insertTextFormat": "Snippet" - }, - { - "label": "transaction", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "transaction", - "insertTextFormat": "Snippet" - }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, - { - "label": "worker", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "worker", - "insertText": "worker ${1:name} {\n\t${2}\n}", - "insertTextFormat": "Snippet" - }, - { - "label": "test/project2", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "project2", - "insertText": "project2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/project2;\n" - } - ] - }, - { - "label": "test/project1", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "project1", - "insertText": "project1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/project1;\n" - } - ] - }, - { - "label": "test/local_project2", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "local_project2", - "insertText": "local_project2", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/local_project2;\n" - } - ] - }, - { - "label": "test/local_project1", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "local_project1", - "insertText": "local_project1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import test/local_project1;\n" - } - ] - }, - { - "label": "null", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "Q", - "filterText": "null", - "insertText": "null", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "testFunction()", - "kind": "Function", - "detail": "()", - "documentation": { - "right": { - "kind": "markdown", - "value": "**Package:** _._ \n \n \n" - } - }, - "sortText": "C", - "filterText": "testFunction", - "insertText": "testFunction()", - "insertTextFormat": "Snippet" - }, - { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] - } - ] -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/source/source15_client_declaration.bal b/language-server/modules/langserver-core/src/test/resources/completion/function_body/source/source15_client_declaration.bal deleted file mode 100644 index f032369d3e2b..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/source/source15_client_declaration.bal +++ /dev/null @@ -1,4 +0,0 @@ -function testFunction() { - client "https://postman-echo.com/get?name=projectapiclientplugin" as testPrefix; - -} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/source/source16_client_declaration.bal b/language-server/modules/langserver-core/src/test/resources/completion/function_body/source/source16_client_declaration.bal deleted file mode 100644 index 6456ad2c508a..000000000000 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/source/source16_client_declaration.bal +++ /dev/null @@ -1,6 +0,0 @@ -client "https://postman-echo1.com/get?name=projectapiclientplugin" as testPrefixMod; - -function testFunction() { - client "https://postman-echo2.com/get?name=projectapiclientplugin" as testPrefix; - -} diff --git a/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/FormattingTreeModifier.java b/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/FormattingTreeModifier.java index ac6c9f89b41d..12f4c65a7567 100644 --- a/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/FormattingTreeModifier.java +++ b/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/FormattingTreeModifier.java @@ -37,7 +37,6 @@ import io.ballerina.compiler.syntax.tree.CaptureBindingPatternNode; import io.ballerina.compiler.syntax.tree.CheckExpressionNode; import io.ballerina.compiler.syntax.tree.ClassDefinitionNode; -import io.ballerina.compiler.syntax.tree.ClientDeclarationNode; import io.ballerina.compiler.syntax.tree.ClientResourceAccessActionNode; import io.ballerina.compiler.syntax.tree.CommitActionNode; import io.ballerina.compiler.syntax.tree.CompoundAssignmentStatementNode; @@ -3623,46 +3622,6 @@ public Token transform(Token token) { return formatToken(token, env.trailingWS, env.trailingNL); } - - @Override - public ModuleClientDeclarationNode transform( - ModuleClientDeclarationNode moduleClientDeclarationNode) { - NodeList annotations = formatNodeList(moduleClientDeclarationNode.annotations(), 1, 0, 1, 0); - Token clientKeyword = formatToken(moduleClientDeclarationNode.clientKeyword(), 1, 0); - BasicLiteralNode clientUri = formatNode(moduleClientDeclarationNode.clientUri(), 1, 0); - Token asKeyword = formatToken(moduleClientDeclarationNode.asKeyword(), 1, 0); - IdentifierToken clientPrefix = formatNode(moduleClientDeclarationNode.clientPrefix(), 0, 0); - Token semicolonToken = formatToken(moduleClientDeclarationNode.semicolonToken(), env.trailingWS, - env.trailingNL); - return moduleClientDeclarationNode.modify() - .withAnnotations(annotations) - .withClientKeyword(clientKeyword) - .withClientUri(clientUri) - .withAsKeyword(asKeyword) - .withClientPrefix(clientPrefix) - .withSemicolonToken(semicolonToken) - .apply(); - } - - @Override - public ClientDeclarationNode transform(ClientDeclarationNode clientDeclarationNode) { - NodeList annotations = formatNodeList(clientDeclarationNode.annotations(), 1, 0, 1, 0); - Token clientKeyword = formatToken(clientDeclarationNode.clientKeyword(), 1, 0); - BasicLiteralNode clientUri = formatNode(clientDeclarationNode.clientUri(), 1, 0); - Token asKeyword = formatToken(clientDeclarationNode.asKeyword(), 1, 0); - IdentifierToken prefix = formatNode(clientDeclarationNode.clientPrefix(), 0, 0); - Token semicolonToken = formatToken(clientDeclarationNode.semicolonToken(), env.trailingWS, env.trailingNL); - - return clientDeclarationNode.modify() - .withAnnotations(annotations) - .withClientKeyword(clientKeyword) - .withClientUri(clientUri) - .withAsKeyword(asKeyword) - .withClientPrefix(prefix) - .withSemicolonToken(semicolonToken) - .apply(); - } - // ------------------------------------- Set of private helper methods ------------------------------------- /** diff --git a/misc/formatter/modules/formatter-core/src/test/java/org/ballerinalang/formatter/core/ParserTestFormatter.java b/misc/formatter/modules/formatter-core/src/test/java/org/ballerinalang/formatter/core/ParserTestFormatter.java index c3b5b0ce89ee..ce1ca7236cf7 100644 --- a/misc/formatter/modules/formatter-core/src/test/java/org/ballerinalang/formatter/core/ParserTestFormatter.java +++ b/misc/formatter/modules/formatter-core/src/test/java/org/ballerinalang/formatter/core/ParserTestFormatter.java @@ -178,10 +178,7 @@ public List skipList() { "func_type_source_09.bal", "func_type_source_13.bal", "func_type_source_14.bal", "func_type_source_15.bal", "func_type_source_16.bal", "import_decl_source_24.bal", "member_access_expr_source_11.bal", "float_literal_source_08.bal", "object_type_def_source_47.bal", - "client_resource_access_action_source_05.bal", "client_resource_access_action_source_06.bal", - "client_decl_stmt_source_08.bal", "client_decl_stmt_source_13.bal", - "client_decl_source_08.bal", "client_decl_source_09.bal", "client_decl_source_13.bal", - "client_decl_source_14.bal", "invalid_usage_of_client_keyword_as_identifier_source.bal", + "client_resource_access_action_source_05.bal", "client_resource_access_action_source_06.bal", "resiliency_source_05.bal", "regexp_constructor_source_26.bal", "regexp_constructor_source_28.bal"); } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/xml/XMLAccessTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/xml/XMLAccessTest.java index 566175b44340..dbc1765eb724 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/xml/XMLAccessTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/xml/XMLAccessTest.java @@ -293,6 +293,8 @@ void testXMLFilterExpressionsNegative() { "incompatible types: expected 'xml', found 'any'", 6, 14); BAssertUtil.validateError(navigationFilterNegative, index++, "incompatible types: expected 'xml', found 'int'", 8, 14); + BAssertUtil.validateError(navigationFilterNegative, index++, + "cannot find xml namespace prefix 'foo'", 13, 16); Assert.assertEquals(navigationFilterNegative.getErrorCount(), index); } } From 4d5c82fb2a24bd77362fa98739355d75b5d196c9 Mon Sep 17 00:00:00 2001 From: praneesha Date: Fri, 25 Nov 2022 15:17:22 +0530 Subject: [PATCH 103/450] Update Slack references to Discord Update Slack references to Discord --- .../ballerina/protobuf/1.0.1/java11/docs/Package.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/ballerina-cli/src/test/resources/test-resources/balacache-template/ballerina/protobuf/1.0.1/java11/docs/Package.md b/cli/ballerina-cli/src/test/resources/test-resources/balacache-template/ballerina/protobuf/1.0.1/java11/docs/Package.md index f3913df59766..e9a0380de011 100644 --- a/cli/ballerina-cli/src/test/resources/test-resources/balacache-template/ballerina/protobuf/1.0.1/java11/docs/Package.md +++ b/cli/ballerina-cli/src/test/resources/test-resources/balacache-template/ballerina/protobuf/1.0.1/java11/docs/Package.md @@ -9,5 +9,5 @@ This package contains a set of pre-defined protobuf types. To report bugs, request new features, start new discussions, view project boards, etc., go to the Ballerina standard library parent repository. ## Useful Links -- Chat live with us via our Slack channel. +- Chat live with us via our Discord server. - Post all technical questions on Stack Overflow with the #ballerina tag. From fea96c6fd72725133ccc8837e9ea89f6d847a9a0 Mon Sep 17 00:00:00 2001 From: praneesha Date: Fri, 25 Nov 2022 15:19:06 +0530 Subject: [PATCH 104/450] Update Slack to Discord in jBallerina tools README file Update Slack to Discord in jBallerina tools README file --- distribution/zip/jballerina-tools/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/distribution/zip/jballerina-tools/README.md b/distribution/zip/jballerina-tools/README.md index 9c8b72c9add8..e44afd4c1cb6 100644 --- a/distribution/zip/jballerina-tools/README.md +++ b/distribution/zip/jballerina-tools/README.md @@ -26,5 +26,5 @@ Ballerina code is distributed under [Apache license 2.0](https://github.com/ball ## Useful links - The ballerina-dev@googlegroups.com mailing list is for discussing code changes to the Ballerina project. -- Chat live with us on our [Slack channel](https://ballerina-platform.slack.com/). -- Technical questions should be posted on Stack Overflow with the [#ballerina](https://stackoverflow.com/questions/tagged/ballerina) tag. \ No newline at end of file +- Chat live with us on our [Discrod server](https://discord.gg/ballerinalang). +- Technical questions should be posted on Stack Overflow with the [#ballerina](https://stackoverflow.com/questions/tagged/ballerina) tag. From 6d79c282828dc164f900dd4c93279eaf5235ac3d Mon Sep 17 00:00:00 2001 From: praneesha Date: Fri, 25 Nov 2022 15:20:15 +0530 Subject: [PATCH 105/450] Update Slack to Discord in jBallerina README file Update Slack to Discord in jBallerina README file --- distribution/zip/jballerina/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/distribution/zip/jballerina/README.md b/distribution/zip/jballerina/README.md index 9c8b72c9add8..1a0c1737a0b5 100644 --- a/distribution/zip/jballerina/README.md +++ b/distribution/zip/jballerina/README.md @@ -26,5 +26,5 @@ Ballerina code is distributed under [Apache license 2.0](https://github.com/ball ## Useful links - The ballerina-dev@googlegroups.com mailing list is for discussing code changes to the Ballerina project. -- Chat live with us on our [Slack channel](https://ballerina-platform.slack.com/). -- Technical questions should be posted on Stack Overflow with the [#ballerina](https://stackoverflow.com/questions/tagged/ballerina) tag. \ No newline at end of file +- Chat live with us on our [Discord server](https://discord.gg/ballerinalang). +- Technical questions should be posted on Stack Overflow with the [#ballerina](https://stackoverflow.com/questions/tagged/ballerina) tag. From 98052aba275101a71972c8c39a06d0cce1cfdbee Mon Sep 17 00:00:00 2001 From: mohan Date: Mon, 28 Nov 2022 10:17:39 +0530 Subject: [PATCH 106/450] Improve DocumentationGenerator logic for enum and const --- .../command/docs/DocumentationGenerator.java | 59 ++++--------------- 1 file changed, 10 insertions(+), 49 deletions(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/command/docs/DocumentationGenerator.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/command/docs/DocumentationGenerator.java index 7f85e170e213..5096b20e39fe 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/command/docs/DocumentationGenerator.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/command/docs/DocumentationGenerator.java @@ -27,6 +27,7 @@ import io.ballerina.compiler.syntax.tree.FunctionSignatureNode; import io.ballerina.compiler.syntax.tree.MetadataNode; import io.ballerina.compiler.syntax.tree.MethodDeclarationNode; +import io.ballerina.compiler.syntax.tree.ModuleMemberDeclarationNode; import io.ballerina.compiler.syntax.tree.ModuleVariableDeclarationNode; import io.ballerina.compiler.syntax.tree.Node; import io.ballerina.compiler.syntax.tree.NodeList; @@ -122,13 +123,13 @@ public static Optional getDocumentationEditForNode(NonTermina return Optional.of(generateClassDocumentation((ClassDefinitionNode) node, syntaxTree)); } case CONST_DECLARATION: { - return Optional.of(generateConstantDocumentation((ConstantDeclarationNode) node, syntaxTree)); + return Optional.of(generateModuleMemberDocumentation((ConstantDeclarationNode) node, syntaxTree)); } case ENUM_DECLARATION: { - return Optional.of(generateEnumDocumentation((EnumDeclarationNode) node, syntaxTree)); + return Optional.of(generateModuleMemberDocumentation((EnumDeclarationNode) node, syntaxTree)); } case MODULE_VAR_DECL: { - return Optional.of(generateModuleVarDocumentation((ModuleVariableDeclarationNode) node, syntaxTree)); + return Optional.of(generateModuleMemberDocumentation((ModuleVariableDeclarationNode) node, syntaxTree)); } case ANNOTATION_DECLARATION: { return Optional.of(generateAnnotationDocumentation((AnnotationDeclarationNode) node, syntaxTree)); @@ -180,57 +181,17 @@ private static DocAttachmentInfo generateServiceDocumentation(ServiceDeclaration } /** - * Generate documentation for constant declaration node. + * Generate documentation for module member declaration nodes. * - * @param constantDeclarationNode constant declaration node + * @param declarationNode declaration node * @param syntaxTree syntaxTree {@link SyntaxTree} * @return generated doc attachment */ - private static DocAttachmentInfo generateConstantDocumentation(ConstantDeclarationNode constantDeclarationNode, - SyntaxTree syntaxTree) { - Optional metadata = constantDeclarationNode.metadata(); - Position docStart = PositionUtil.toRange(constantDeclarationNode.lineRange()).getStart(); - if (metadata.isPresent() && !metadata.get().annotations().isEmpty()) { - docStart = PositionUtil.toRange(metadata.get().annotations().get(0).lineRange()).getStart(); - } - String desc = String.format("Description%n"); - return new DocAttachmentInfo(desc, docStart, getPadding(constantDeclarationNode, syntaxTree)); - } - - /** - * Generate documentation for enum declaration node. - * - * @param enumDeclarationNode enum declaration node - * @param syntaxTree syntaxTree {@link SyntaxTree} - * @return generated doc attachment - */ - private static DocAttachmentInfo generateEnumDocumentation(EnumDeclarationNode enumDeclarationNode, - SyntaxTree syntaxTree) { - Optional metadata = enumDeclarationNode.metadata(); - Position docStart = PositionUtil.toRange(enumDeclarationNode.lineRange()).getStart(); - if (metadata.isPresent() && !metadata.get().annotations().isEmpty()) { - docStart = PositionUtil.toRange(metadata.get().annotations().get(0).lineRange()).getStart(); - } - String desc = String.format("Description%n"); - return new DocAttachmentInfo(desc, docStart, getPadding(enumDeclarationNode, syntaxTree)); - } - - /** - * Generate documentation for service node. - * - * @param varDeclarationNode service declaration node - * @param syntaxTree syntaxTree {@link SyntaxTree} - * @return generated doc attachment - */ - private static DocAttachmentInfo generateModuleVarDocumentation(ModuleVariableDeclarationNode varDeclarationNode, - SyntaxTree syntaxTree) { - Optional metadata = varDeclarationNode.metadata(); - Position docStart = PositionUtil.toRange(varDeclarationNode.lineRange()).getStart(); - if (metadata.isPresent() && !metadata.get().annotations().isEmpty()) { - docStart = PositionUtil.toRange(metadata.get().annotations().get(0).lineRange()).getStart(); - } + private static DocAttachmentInfo generateModuleMemberDocumentation(ModuleMemberDeclarationNode declarationNode, + SyntaxTree syntaxTree) { + Position docStart = PositionUtil.toRange(declarationNode.lineRange()).getStart(); String desc = String.format("Description%n"); - return new DocAttachmentInfo(desc, docStart, getPadding(varDeclarationNode, syntaxTree)); + return new DocAttachmentInfo(desc, docStart, getPadding(declarationNode, syntaxTree)); } /** From af1b78711bcf1e2655b049c7420339679d9bccf2 Mon Sep 17 00:00:00 2001 From: Madusha Date: Tue, 8 Nov 2022 14:41:56 +0530 Subject: [PATCH 107/450] Fix indentation --- .../symbol/BallerinaSymbolService.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolService.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolService.java index 7c49e9f4dfd9..78a9c2f9094a 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolService.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolService.java @@ -196,18 +196,18 @@ public CompletableFuture getTypeFromSymbol(TypeFromSymb try { for (LinePosition position: request.getPositions()) { ResolvedTypeForSymbol resolvedType = new ResolvedTypeForSymbol(position); - Optional semanticModel = - this.workspaceManagerProxy.get(fileUri).semanticModel(filePath.get()); - Optional document = workspaceManagerProxy.get(fileUri).document(filePath.get()); - if (semanticModel.isEmpty() || document.isEmpty()) { - return typeFromSymbolResponse; - } - LinePosition linePosition = LinePosition.from(position.line(), position.offset()); - Optional symbol = semanticModel.get().symbol(document.get(), linePosition); - Type.clearParentSymbols(); - Type type = symbol.map(Type::fromSemanticSymbol).orElse(null); - resolvedType.setType(type); - types.add(resolvedType); + Optional semanticModel = + this.workspaceManagerProxy.get(fileUri).semanticModel(filePath.get()); + Optional document = workspaceManagerProxy.get(fileUri).document(filePath.get()); + if (semanticModel.isEmpty() || document.isEmpty()) { + return typeFromSymbolResponse; + } + LinePosition linePosition = LinePosition.from(position.line(), position.offset()); + Optional symbol = semanticModel.get().symbol(document.get(), linePosition); + Type.clearParentSymbols(); + Type type = symbol.map(Type::fromSemanticSymbol).orElse(null); + resolvedType.setType(type); + types.add(resolvedType); } typeFromSymbolResponse.setTypes(types); return typeFromSymbolResponse; From 5d63133c4ef076130a1ddbd5ea11d45feeef4fc4 Mon Sep 17 00:00:00 2001 From: Madusha Date: Tue, 8 Nov 2022 19:16:25 +0530 Subject: [PATCH 108/450] Add endpoint to fetch types from function signature --- .../symbol/BallerinaSymbolService.java | 78 ++++++++++++++++++ .../ballerina/symbol/SymbolContext.java | 3 +- .../symbol/TypesFromFnSignatureRequest.java | 52 ++++++++++++ .../extensions/LSExtensionTestUtil.java | 24 ++++++ .../symbol/TypesFromFnSignatureTest.java | 72 +++++++++++++++++ .../extensions/symbol/typeFromFnSignature.bal | 81 +++++++++++++++++++ .../connector/models/connector/Type.java | 4 + 7 files changed, 313 insertions(+), 1 deletion(-) create mode 100644 language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/TypesFromFnSignatureRequest.java create mode 100644 language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnSignatureTest.java create mode 100644 language-server/modules/langserver-core/src/test/resources/extensions/symbol/typeFromFnSignature.bal diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolService.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolService.java index 78a9c2f9094a..5b830095ec71 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolService.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolService.java @@ -20,6 +20,7 @@ import io.ballerina.compiler.api.symbols.Documentable; import io.ballerina.compiler.api.symbols.Documentation; import io.ballerina.compiler.api.symbols.FunctionSymbol; +import io.ballerina.compiler.api.symbols.FunctionTypeSymbol; import io.ballerina.compiler.api.symbols.MethodSymbol; import io.ballerina.compiler.api.symbols.ParameterSymbol; import io.ballerina.compiler.api.symbols.Symbol; @@ -33,6 +34,7 @@ import io.ballerina.compiler.syntax.tree.NonTerminalNode; import io.ballerina.compiler.syntax.tree.SyntaxKind; import io.ballerina.projects.Document; +import io.ballerina.tools.diagnostics.Location; import io.ballerina.tools.text.LinePosition; import io.ballerina.tools.text.LineRange; import org.ballerinalang.annotation.JavaSPIService; @@ -220,6 +222,48 @@ public CompletableFuture getTypeFromSymbol(TypeFromSymb }); } + @JsonRequest + public CompletableFuture getTypesFromFnSignature(TypesFromFnSignatureRequest request) { + return CompletableFuture.supplyAsync(() -> { + TypesFromSymbolResponse typeFromSymbolResponse = new TypesFromSymbolResponse(); + String fileUri = request.getDocumentIdentifier().getUri(); + Optional filePath = PathUtil.getPathFromURI(fileUri); + if (filePath.isEmpty()) { + return typeFromSymbolResponse; + } + List types = new ArrayList<>(); + try { + Optional semanticModel = + this.workspaceManagerProxy.get(fileUri).semanticModel(filePath.get()); + Optional document = workspaceManagerProxy.get(fileUri).document(filePath.get()); + if (semanticModel.isEmpty() || document.isEmpty()) { + return typeFromSymbolResponse; + } + LinePosition fnPosition = request.getFnPosition(); + Optional symbol = semanticModel.get().symbol(document.get(), fnPosition); + if (symbol.isPresent()) { + Symbol fnSymbol = symbol.get(); + if (fnSymbol instanceof FunctionSymbol) { + FunctionTypeSymbol fnTypeSymbol = ((FunctionSymbol) fnSymbol).typeDescriptor(); + + Optional returnType = getTypeForReturnTypeDesc(fnTypeSymbol, fnPosition); + returnType.ifPresent(types::add); + + Optional> paramTypes = getTypesForFnParams(fnTypeSymbol); + paramTypes.ifPresent(types::addAll); + } + } + typeFromSymbolResponse.setTypes(types); + return typeFromSymbolResponse; + } catch (Throwable e) { + String msg = "Operation 'ballerinaSymbol/getTypesFromFnSignature' failed!"; + this.clientLogger.logError(SymbolContext.SC_GET_TYPE_FROM_FN_SIGNATURE_API, msg, e, + request.getDocumentIdentifier(), (Position) null); + return typeFromSymbolResponse; + } + }); + } + @JsonRequest public CompletableFuture getSymbol(SymbolInfoRequest request) { return CompletableFuture.supplyAsync(() -> { @@ -416,6 +460,40 @@ private boolean skipFirstParam(Symbol symbolAtCursor, NonTerminalNode nodeAtCurs nodeAtCursor.kind() != SyntaxKind.QUALIFIED_NAME_REFERENCE); } + private Optional getTypeForReturnTypeDesc(FunctionTypeSymbol functionTypeSymbol, + LinePosition typeDescPosition) { + Optional typeSymbol = functionTypeSymbol.returnTypeDescriptor(); + if (typeSymbol.isEmpty()) { + return Optional.empty(); + } + ResolvedTypeForSymbol resolvedType = new ResolvedTypeForSymbol(typeDescPosition); + Type type = Type.fromSemanticSymbol(typeSymbol.get()); + Type.clearParentSymbols(); + resolvedType.setType(type); + return Optional.of(resolvedType); + } + + private Optional> getTypesForFnParams(FunctionTypeSymbol fnTypeSymbol) { + Optional> params = fnTypeSymbol.params(); + if (params.isEmpty()) { + return Optional.empty(); + } + List types = new ArrayList<>(); + for (ParameterSymbol param: params.get()) { + Optional location = param.getLocation(); + if (location.isEmpty()) { + return Optional.empty(); + } + LinePosition paramPosition = location.get().lineRange().startLine(); + ResolvedTypeForSymbol resolvedType = new ResolvedTypeForSymbol(paramPosition); + Type type = Type.fromSemanticSymbol(param); + Type.clearParentSymbols(); + resolvedType.setType(type); + types.add(resolvedType); + } + return Optional.of(types); + } + @Override public Class getRemoteInterface() { return getClass(); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/SymbolContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/SymbolContext.java index a8d65e21725c..f868cd53c36e 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/SymbolContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/SymbolContext.java @@ -26,7 +26,8 @@ public enum SymbolContext implements LSOperation { SC_TYPE_API("ballerinaSymbol/type"), SC_GET_TYPE_FROM_EXPRESSION_API("ballerinaSymbol/getTypeFromExpression"), SC_GET_SYMBOL_API("ballerinaSymbol/getSymbol"), - SC_GET_TYPE_FROM_SYMBOL_API("ballerinaSymbol/getTypeFromSymbol"); + SC_GET_TYPE_FROM_SYMBOL_API("ballerinaSymbol/getTypeFromSymbol"), + SC_GET_TYPE_FROM_FN_SIGNATURE_API("ballerinaSymbol/getTypesFromFnSignature"); private final String name; SymbolContext(String name) { diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/TypesFromFnSignatureRequest.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/TypesFromFnSignatureRequest.java new file mode 100644 index 000000000000..91e347982b01 --- /dev/null +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/TypesFromFnSignatureRequest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://wso2.com) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.ballerinalang.langserver.extensions.ballerina.symbol; + +import io.ballerina.tools.text.LinePosition; +import org.eclipse.lsp4j.TextDocumentIdentifier; + +/** + * Represents a request to get type info given for given positions of symbols. + */ +public class TypesFromFnSignatureRequest { + private TextDocumentIdentifier documentIdentifier; + private LinePosition fnPosition; + private LinePosition returnTypeDescPosition; + + public LinePosition getFnPosition() { + return fnPosition; + } + + public void setFnPosition(LinePosition fnPosition) { + this.fnPosition = fnPosition; + } + + public LinePosition getReturnTypeDescPosition() { + return returnTypeDescPosition; + } + + public void setReturnTypeDescPosition(LinePosition returnTypeDescPosition) { + this.returnTypeDescPosition = returnTypeDescPosition; + } + + public TextDocumentIdentifier getDocumentIdentifier() { + return documentIdentifier; + } + + public void setDocumentIdentifier(TextDocumentIdentifier documentIdentifier) { + this.documentIdentifier = documentIdentifier; + } +} diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/LSExtensionTestUtil.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/LSExtensionTestUtil.java index 4261e1c4ea3a..c9d89a1ec725 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/LSExtensionTestUtil.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/LSExtensionTestUtil.java @@ -33,6 +33,7 @@ import org.ballerinalang.langserver.extensions.ballerina.symbol.SymbolInfoRequest; import org.ballerinalang.langserver.extensions.ballerina.symbol.SymbolInfoResponse; import org.ballerinalang.langserver.extensions.ballerina.symbol.TypeFromExpressionRequest; +import org.ballerinalang.langserver.extensions.ballerina.symbol.TypesFromFnSignatureRequest; import org.ballerinalang.langserver.extensions.ballerina.symbol.TypeFromSymbolRequest; import org.ballerinalang.langserver.extensions.ballerina.symbol.TypesFromExpressionResponse; import org.ballerinalang.langserver.extensions.ballerina.symbol.TypesFromSymbolResponse; @@ -66,6 +67,7 @@ public class LSExtensionTestUtil { private static final String GET_SYMBOL = "ballerinaSymbol/getSymbol"; private static final String GET_TYPE_FROM_SYMBOL = "ballerinaSymbol/getTypeFromSymbol"; private static final String GET_TYPE_FROM_EXPRESSION = "ballerinaSymbol/getTypeFromExpression"; + private static final String GET_TYPE_FROM_FN_SIGNATURE = "ballerinaSymbol/getTypesFromFnSignature"; private static final Gson GSON = new Gson(); private static final JsonParser parser = new JsonParser(); @@ -235,4 +237,26 @@ public static TypesFromExpressionResponse getTypeFromExpression(URI filePath, Li CompletableFuture result = serviceEndpoint.request(GET_TYPE_FROM_EXPRESSION, typeFromExpressionRequest); return (TypesFromExpressionResponse) result.get(); } + + /** + * Get the ballerinaDocument/getTypesFromFnSignature response. + * + * @param filePath Path of the Bal file + * @param fnPosition Ranges of the expressions to get associated types + * @param returnTypeDescPosition Service Endpoint to Language Server + * @param serviceEndpoint Service Endpoint to Language Server + * @return {@link String} Response as String + */ + public static TypesFromSymbolResponse getTypesFromFnSignature(URI filePath, + LinePosition fnPosition, + LinePosition returnTypeDescPosition, + Endpoint serviceEndpoint) + throws ExecutionException, InterruptedException { + TypesFromFnSignatureRequest typesFromFnSignatureRequest = new TypesFromFnSignatureRequest(); + typesFromFnSignatureRequest.setFnPosition(fnPosition); + typesFromFnSignatureRequest.setReturnTypeDescPosition(returnTypeDescPosition); + typesFromFnSignatureRequest.setDocumentIdentifier(TestUtil.getTextDocumentIdentifier(filePath)); + CompletableFuture result = serviceEndpoint.request(GET_TYPE_FROM_FN_SIGNATURE, typesFromFnSignatureRequest); + return (TypesFromSymbolResponse) result.get(); + } } diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnSignatureTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnSignatureTest.java new file mode 100644 index 000000000000..59cf3c901907 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnSignatureTest.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2022, WSO2 Inc. (http://wso2.com) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.ballerinalang.langserver.extensions.symbol; + +import io.ballerina.tools.text.LinePosition; +import org.ballerinalang.diagramutil.connector.models.connector.types.RecordType; +import org.ballerinalang.langserver.extensions.LSExtensionTestUtil; +import org.ballerinalang.langserver.extensions.ballerina.symbol.ResolvedTypeForSymbol; +import org.ballerinalang.langserver.extensions.ballerina.symbol.TypesFromSymbolResponse; +import org.ballerinalang.langserver.util.FileUtils; +import org.ballerinalang.langserver.util.TestUtil; +import org.eclipse.lsp4j.jsonrpc.Endpoint; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.io.IOException; +import java.net.URI; +import java.nio.file.Path; +import java.util.concurrent.ExecutionException; + +/** + * Test type info retrieved via getTypesFromFnSignature endpoint. + */ +public class TypesFromFnSignatureTest { + private Endpoint serviceEndpoint; + + private final Path typeFromFnSignatureBalFile = FileUtils.RES_DIR.resolve("extensions") + .resolve("symbol") + .resolve("typesFromFnSignature.bal"); + + @BeforeClass + public void startLangServer() { + this.serviceEndpoint = TestUtil.initializeLanguageSever(); + } + + @Test(description = "type info retrieved for the return type symbol node") + public void testTypeForReturnTypeNode() throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typeFromFnSignatureBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + LinePosition fnPosition = LinePosition.from(67, 9); + LinePosition returnTypeDescPosition = LinePosition.from(67, 55); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); + + Assert.assertNotNull(typesFromSymbolResponse.getTypes()); + + ResolvedTypeForSymbol type = typesFromSymbolResponse.getTypes().get(0); + Assert.assertEquals(type.getType().name, "Output"); + + RecordType recordType = (RecordType) type.getType(); + Assert.assertEquals(recordType.fields.size(), 2); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } +} diff --git a/language-server/modules/langserver-core/src/test/resources/extensions/symbol/typeFromFnSignature.bal b/language-server/modules/langserver-core/src/test/resources/extensions/symbol/typeFromFnSignature.bal new file mode 100644 index 000000000000..eae99d990677 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/extensions/symbol/typeFromFnSignature.bal @@ -0,0 +1,81 @@ +import ballerina/http; + +type Input record { + MessageProperties MessageProperties; + record { + int Type; + string Id; + boolean Confirmed; + }[] Assets; + record { + string StopId; + string CurrOrPickedTrailer; + any Driver2; + string Driver1; + decimal Latitude; + any Unit; + decimal Longitude; + string TripId; + string Weight; + string BillOfLading; + string ETA; + decimal user_id; + string DroppedTrailer; + string Seal; + record { + anydata[] warnings; + anydata[] errors; + } form_meta; + string Pieces; + } Content; + string FormId; + string CreateDate; +}; + +type Input2 record { + http:Bucket bucket; +}; + +type Output record { + record { + string MessageContentType; + record { + string[] Content; + record { + int OType; + string OId; + boolean OConfirmed; + }[] Assets; + record { + decimal Latitude; + decimal Longitude; + } Coordinates; + string FormId; + string CreateDate; + } MessageContent; + string ParentMessageGuid; + string MessageGuid; + } data; + string 'type; +}; + +type MessageProperties record { + string EventType; + string AuditId; + string MessageId; +}; + +function transform(Input input, Input2 Input2) returns Output[] => { + data: { + MessageContent: { + Assets: from var item in input.Assets + select { + OType: item.Type, + OId: item.Id, + OConfirmed: item.Confirmed + } + }, + MessageGuid: input.MessageProperties.AuditId, + MessageContentType: input.MessageProperties.EventType + } +}; diff --git a/misc/diagram-util/src/main/java/org/ballerinalang/diagramutil/connector/models/connector/Type.java b/misc/diagram-util/src/main/java/org/ballerinalang/diagramutil/connector/models/connector/Type.java index 5fdb436ac8d0..5b3331a18c56 100644 --- a/misc/diagram-util/src/main/java/org/ballerinalang/diagramutil/connector/models/connector/Type.java +++ b/misc/diagram-util/src/main/java/org/ballerinalang/diagramutil/connector/models/connector/Type.java @@ -24,6 +24,7 @@ import io.ballerina.compiler.api.symbols.ErrorTypeSymbol; import io.ballerina.compiler.api.symbols.IntersectionTypeSymbol; import io.ballerina.compiler.api.symbols.ObjectTypeSymbol; +import io.ballerina.compiler.api.symbols.ParameterSymbol; import io.ballerina.compiler.api.symbols.RecordFieldSymbol; import io.ballerina.compiler.api.symbols.RecordTypeSymbol; import io.ballerina.compiler.api.symbols.StreamTypeSymbol; @@ -313,6 +314,9 @@ public static Type fromSemanticSymbol(Symbol symbol) { } else if (symbol instanceof RecordFieldSymbol) { RecordFieldSymbol recordFieldSymbol = (RecordFieldSymbol) symbol; type = fromSemanticSymbol(recordFieldSymbol.typeDescriptor()); + } else if (symbol instanceof ParameterSymbol) { + ParameterSymbol parameterSymbol = (ParameterSymbol) symbol; + type = fromSemanticSymbol(parameterSymbol.typeDescriptor()); } else if (symbol instanceof TypeSymbol) { type = new PrimitiveType(((TypeSymbol) symbol).signature()); } From 311d0edbb076028278754f5a24ec81b3512d1c17 Mon Sep 17 00:00:00 2001 From: Madusha Date: Tue, 8 Nov 2022 22:18:35 +0530 Subject: [PATCH 109/450] Improvements in symbol service tests --- .../symbol/SymbolServiceTestUtil.java | 43 +++++++++++++++ .../symbol/TypeFromExpressionTest.java | 52 +++++++------------ .../extensions/symbol/TypeFromSymbolTest.java | 19 +++---- .../symbol/TypesFromFnSignatureTest.java | 6 ++- ...Signature.bal => typesFromFnSignature.bal} | 2 +- 5 files changed, 74 insertions(+), 48 deletions(-) create mode 100644 language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolServiceTestUtil.java rename language-server/modules/langserver-core/src/test/resources/extensions/symbol/{typeFromFnSignature.bal => typesFromFnSignature.bal} (96%) diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolServiceTestUtil.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolServiceTestUtil.java new file mode 100644 index 000000000000..42e75a043c3e --- /dev/null +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolServiceTestUtil.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022, WSO2 Inc. (http://wso2.com) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.ballerinalang.langserver.extensions.symbol; + +import io.ballerina.tools.text.LinePosition; +import io.ballerina.tools.text.LineRange; + +/** + * Provides util methods for testing symbol service apis. + */ +public class SymbolServiceTestUtil { + + public static boolean isPositionsEquals(LinePosition expectedPosition, LinePosition actualPosition) { + return expectedPosition.line() == actualPosition.line() + && expectedPosition.offset() == actualPosition.offset(); + } + + public static LineRange getExpressionRange(int startLine, int startColumn, int endLine, int endColumn) { + LinePosition start = LinePosition.from(startLine, startColumn); + LinePosition end = LinePosition.from(endLine, endColumn); + return LineRange.from(null, start, end); + } + + public static boolean isRangesEquals(LineRange expectedRange, LineRange actualRange) { + return expectedRange.startLine().line() == actualRange.startLine().line() + && expectedRange.startLine().offset() == actualRange.startLine().offset() + && expectedRange.endLine().line() == actualRange.endLine().line() + && expectedRange.endLine().line() == actualRange.endLine().line(); + } +} diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypeFromExpressionTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypeFromExpressionTest.java index e58cd00cd161..4f1ac2f37b25 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypeFromExpressionTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypeFromExpressionTest.java @@ -15,7 +15,6 @@ */ package org.ballerinalang.langserver.extensions.symbol; -import io.ballerina.tools.text.LinePosition; import io.ballerina.tools.text.LineRange; import org.ballerinalang.diagramutil.connector.models.connector.types.ArrayType; import org.ballerinalang.diagramutil.connector.models.connector.types.PrimitiveType; @@ -56,7 +55,7 @@ public void testTypeForConditionalExprNode() throws IOException, ExecutionExcept URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); - LineRange[] ranges = {getExpressionRange(39, 15, 39, 68)}; + LineRange[] ranges = {SymbolServiceTestUtil.getExpressionRange(39, 15, 39, 68)}; TypesFromExpressionResponse typesFromExpression = LSExtensionTestUtil.getTypeFromExpression( uri, ranges, this.serviceEndpoint); @@ -64,7 +63,7 @@ public void testTypeForConditionalExprNode() throws IOException, ExecutionExcept Assert.assertNotNull(typesFromExpression.getTypes()); ResolvedTypeForExpression type = typesFromExpression.getTypes().get(0); - Assert.assertTrue(isRangesEquals(ranges[0], type.getRequestedRange())); + Assert.assertTrue(SymbolServiceTestUtil.isRangesEquals(ranges[0], type.getRequestedRange())); Assert.assertTrue(type.getType() instanceof RecordType); RecordType recordType = (RecordType) type.getType(); @@ -83,7 +82,7 @@ public void testTypeForFunctionCallExprNode() throws IOException, ExecutionExcep URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); - LineRange[] ranges = {getExpressionRange(40, 39, 40, 53)}; + LineRange[] ranges = {SymbolServiceTestUtil.getExpressionRange(40, 39, 40, 53)}; TypesFromExpressionResponse typesFromExpression = LSExtensionTestUtil.getTypeFromExpression( uri, ranges, this.serviceEndpoint); @@ -91,7 +90,7 @@ public void testTypeForFunctionCallExprNode() throws IOException, ExecutionExcep Assert.assertNotNull(typesFromExpression.getTypes()); ResolvedTypeForExpression type = typesFromExpression.getTypes().get(0); - Assert.assertTrue(isRangesEquals(ranges[0], type.getRequestedRange())); + Assert.assertTrue(SymbolServiceTestUtil.isRangesEquals(ranges[0], type.getRequestedRange())); Assert.assertTrue(type.getType() instanceof ArrayType); ArrayType arrayType = (ArrayType) type.getType(); @@ -113,7 +112,7 @@ public void testPrimitiveTypeForFunctionCallNode() throws IOException, Execution URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); - LineRange[] ranges = {getExpressionRange(42, 24, 42, 57)}; + LineRange[] ranges = {SymbolServiceTestUtil.getExpressionRange(42, 24, 42, 57)}; TypesFromExpressionResponse typesFromExpression = LSExtensionTestUtil.getTypeFromExpression( uri, ranges, this.serviceEndpoint); @@ -121,7 +120,7 @@ public void testPrimitiveTypeForFunctionCallNode() throws IOException, Execution Assert.assertNotNull(typesFromExpression.getTypes()); ResolvedTypeForExpression type = typesFromExpression.getTypes().get(0); - Assert.assertTrue(isRangesEquals(ranges[0], type.getRequestedRange())); + Assert.assertTrue(SymbolServiceTestUtil.isRangesEquals(ranges[0], type.getRequestedRange())); Assert.assertTrue(type.getType() instanceof PrimitiveType); } @@ -131,7 +130,7 @@ public void testTypeForFieldAccessExprNode() throws IOException, ExecutionExcept URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); - LineRange[] ranges = {getExpressionRange(43, 40, 43, 50)}; + LineRange[] ranges = {SymbolServiceTestUtil.getExpressionRange(43, 40, 43, 50)}; TypesFromExpressionResponse typesFromExpression = LSExtensionTestUtil.getTypeFromExpression( uri, ranges, this.serviceEndpoint); @@ -139,7 +138,7 @@ public void testTypeForFieldAccessExprNode() throws IOException, ExecutionExcept Assert.assertNotNull(typesFromExpression.getTypes()); ResolvedTypeForExpression type = typesFromExpression.getTypes().get(0); - Assert.assertTrue(isRangesEquals(ranges[0], type.getRequestedRange())); + Assert.assertTrue(SymbolServiceTestUtil.isRangesEquals(ranges[0], type.getRequestedRange())); Assert.assertTrue(type.getType() instanceof ArrayType); ArrayType arrayType = (ArrayType) type.getType(); @@ -163,11 +162,11 @@ public void testTypeForMultipleExprNodes() throws IOException, ExecutionExceptio URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); - LineRange range1 = getExpressionRange(39, 15, 39, 68); - LineRange range2 = getExpressionRange(40, 39, 40, 53); - LineRange range3 = getExpressionRange(42, 24, 42, 57); - LineRange range4 = getExpressionRange(43, 40, 43, 50); - LineRange range5 = getExpressionRange(47, 32, 47, 44); + LineRange range1 = SymbolServiceTestUtil.getExpressionRange(39, 15, 39, 68); + LineRange range2 = SymbolServiceTestUtil.getExpressionRange(40, 39, 40, 53); + LineRange range3 = SymbolServiceTestUtil.getExpressionRange(42, 24, 42, 57); + LineRange range4 = SymbolServiceTestUtil.getExpressionRange(43, 40, 43, 50); + LineRange range5 = SymbolServiceTestUtil.getExpressionRange(47, 32, 47, 44); LineRange[] ranges = {range1, range2, range3, range4, range5}; TypesFromExpressionResponse typesFromExpression = LSExtensionTestUtil.getTypeFromExpression( @@ -176,23 +175,23 @@ public void testTypeForMultipleExprNodes() throws IOException, ExecutionExceptio Assert.assertNotNull(typesFromExpression.getTypes()); ResolvedTypeForExpression type1 = typesFromExpression.getTypes().get(0); - Assert.assertTrue(isRangesEquals(range1, type1.getRequestedRange())); + Assert.assertTrue(SymbolServiceTestUtil.isRangesEquals(range1, type1.getRequestedRange())); Assert.assertTrue(type1.getType() instanceof RecordType); ResolvedTypeForExpression type2 = typesFromExpression.getTypes().get(1); - Assert.assertTrue(isRangesEquals(range2, type2.getRequestedRange())); + Assert.assertTrue(SymbolServiceTestUtil.isRangesEquals(range2, type2.getRequestedRange())); Assert.assertTrue(type2.getType() instanceof ArrayType); ResolvedTypeForExpression type3 = typesFromExpression.getTypes().get(2); - Assert.assertTrue(isRangesEquals(range3, type3.getRequestedRange())); + Assert.assertTrue(SymbolServiceTestUtil.isRangesEquals(range3, type3.getRequestedRange())); Assert.assertTrue(type3.getType() instanceof PrimitiveType); ResolvedTypeForExpression type4 = typesFromExpression.getTypes().get(3); - Assert.assertTrue(isRangesEquals(range4, type4.getRequestedRange())); + Assert.assertTrue(SymbolServiceTestUtil.isRangesEquals(range4, type4.getRequestedRange())); Assert.assertTrue(type4.getType() instanceof ArrayType); ResolvedTypeForExpression type5 = typesFromExpression.getTypes().get(4); - Assert.assertTrue(isRangesEquals(range5, type5.getRequestedRange())); + Assert.assertTrue(SymbolServiceTestUtil.isRangesEquals(range5, type5.getRequestedRange())); Assert.assertTrue(type5.getType() instanceof PrimitiveType); TestUtil.closeDocument(this.serviceEndpoint, inputFile); @@ -200,7 +199,7 @@ public void testTypeForMultipleExprNodes() throws IOException, ExecutionExceptio @Test(description = "test invalid file path") public void testInvalidFilePath() throws ExecutionException, InterruptedException { - LineRange[] ranges = {getExpressionRange(67, 19, 67, 45)}; + LineRange[] ranges = {SymbolServiceTestUtil.getExpressionRange(67, 19, 67, 45)}; TypesFromExpressionResponse typesFromExpression = LSExtensionTestUtil.getTypeFromExpression( URI.create("file://+"), ranges, this.serviceEndpoint); @@ -221,17 +220,4 @@ public void testEmptyRanges() throws IOException, ExecutionException, Interrupte TestUtil.closeDocument(this.serviceEndpoint, inputFile); } - - public static LineRange getExpressionRange(int startLine, int startColumn, int endLine, int endColumn) { - LinePosition start = LinePosition.from(startLine, startColumn); - LinePosition end = LinePosition.from(endLine, endColumn); - return LineRange.from(null, start, end); - } - - public static boolean isRangesEquals(LineRange expectedRange, LineRange actualRange) { - return expectedRange.startLine().line() == actualRange.startLine().line() - && expectedRange.startLine().offset() == actualRange.startLine().offset() - && expectedRange.endLine().line() == actualRange.endLine().line() - && expectedRange.endLine().line() == actualRange.endLine().line(); - } } diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypeFromSymbolTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypeFromSymbolTest.java index 8b7ce428f4ce..4b568620ec99 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypeFromSymbolTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypeFromSymbolTest.java @@ -63,7 +63,7 @@ public void testTypeForReturnTypeNode() throws IOException, ExecutionException, Assert.assertNotNull(typesFromSymbolResponse.getTypes()); ResolvedTypeForSymbol type = typesFromSymbolResponse.getTypes().get(0); - Assert.assertTrue(isPositionsEquals(position, type.getRequestedPosition())); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(position, type.getRequestedPosition())); Assert.assertEquals(type.getType().name, "Output"); Assert.assertTrue(type.getType() instanceof RecordType); @@ -87,7 +87,7 @@ public void testTypeForRequiredParamTypeNameNode() throws IOException, Execution Assert.assertNotNull(typesFromSymbolResponse.getTypes()); ResolvedTypeForSymbol type = typesFromSymbolResponse.getTypes().get(0); - Assert.assertTrue(isPositionsEquals(position, type.getRequestedPosition())); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(position, type.getRequestedPosition())); Assert.assertTrue(type.getType() instanceof RecordType); RecordType outerRecordType = (RecordType) type.getType(); @@ -122,25 +122,25 @@ public void testTypesForMultipleSymbols() throws IOException, ExecutionException Assert.assertEquals(typesFromSymbolResponse.getTypes().size(), positions.length); ResolvedTypeForSymbol type1 = typesFromSymbolResponse.getTypes().get(0); - Assert.assertTrue(isPositionsEquals(position1, type1.getRequestedPosition())); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(position1, type1.getRequestedPosition())); Assert.assertTrue(type1.getType() instanceof RecordType); Assert.assertEquals(type1.getType().name, "Input"); ResolvedTypeForSymbol type2 = typesFromSymbolResponse.getTypes().get(1); - Assert.assertTrue(isPositionsEquals(position2, type2.getRequestedPosition())); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(position2, type2.getRequestedPosition())); Assert.assertTrue(type2.getType() instanceof RecordType); Assert.assertEquals(type2.getType().name, "Input2"); ResolvedTypeForSymbol type3 = typesFromSymbolResponse.getTypes().get(2); - Assert.assertTrue(isPositionsEquals(position3, type3.getRequestedPosition())); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(position3, type3.getRequestedPosition())); Assert.assertTrue(type3.getType() instanceof RecordType); ResolvedTypeForSymbol type4 = typesFromSymbolResponse.getTypes().get(3); - Assert.assertTrue(isPositionsEquals(position4, type4.getRequestedPosition())); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(position4, type4.getRequestedPosition())); Assert.assertTrue(type4.getType() instanceof ArrayType); ResolvedTypeForSymbol type5 = typesFromSymbolResponse.getTypes().get(4); - Assert.assertTrue(isPositionsEquals(position5, type5.getRequestedPosition())); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(position5, type5.getRequestedPosition())); Assert.assertTrue(type5.getType() instanceof PrimitiveType); TestUtil.closeDocument(this.serviceEndpoint, inputFile); @@ -170,9 +170,4 @@ public void testEmptyPositions() throws IOException, ExecutionException, Interru TestUtil.closeDocument(this.serviceEndpoint, inputFile); } - - public static boolean isPositionsEquals(LinePosition expectedPosition, LinePosition actualPosition) { - return expectedPosition.line() == actualPosition.line() - && expectedPosition.offset() == actualPosition.offset(); - } } diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnSignatureTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnSignatureTest.java index 59cf3c901907..4694d92e68c2 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnSignatureTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnSignatureTest.java @@ -38,7 +38,7 @@ public class TypesFromFnSignatureTest { private Endpoint serviceEndpoint; - private final Path typeFromFnSignatureBalFile = FileUtils.RES_DIR.resolve("extensions") + private final Path typesFromFnSignatureBalFile = FileUtils.RES_DIR.resolve("extensions") .resolve("symbol") .resolve("typesFromFnSignature.bal"); @@ -49,7 +49,7 @@ public void startLangServer() { @Test(description = "type info retrieved for the return type symbol node") public void testTypeForReturnTypeNode() throws IOException, ExecutionException, InterruptedException { - Path inputFile = LSExtensionTestUtil.createTempFile(typeFromFnSignatureBalFile); + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); @@ -63,6 +63,8 @@ public void testTypeForReturnTypeNode() throws IOException, ExecutionException, ResolvedTypeForSymbol type = typesFromSymbolResponse.getTypes().get(0); Assert.assertEquals(type.getType().name, "Output"); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(fnPosition, type.getRequestedPosition())); + Assert.assertTrue(type.getType() instanceof RecordType); RecordType recordType = (RecordType) type.getType(); Assert.assertEquals(recordType.fields.size(), 2); diff --git a/language-server/modules/langserver-core/src/test/resources/extensions/symbol/typeFromFnSignature.bal b/language-server/modules/langserver-core/src/test/resources/extensions/symbol/typesFromFnSignature.bal similarity index 96% rename from language-server/modules/langserver-core/src/test/resources/extensions/symbol/typeFromFnSignature.bal rename to language-server/modules/langserver-core/src/test/resources/extensions/symbol/typesFromFnSignature.bal index eae99d990677..870d4a210f96 100644 --- a/language-server/modules/langserver-core/src/test/resources/extensions/symbol/typeFromFnSignature.bal +++ b/language-server/modules/langserver-core/src/test/resources/extensions/symbol/typesFromFnSignature.bal @@ -65,7 +65,7 @@ type MessageProperties record { string MessageId; }; -function transform(Input input, Input2 Input2) returns Output[] => { +function transform(Input input, Input2 Input2) returns Output => { data: { MessageContent: { Assets: from var item in input.Assets From 02906853b53517cb3342d64002f08504d0ab4003 Mon Sep 17 00:00:00 2001 From: Madusha Date: Wed, 9 Nov 2022 14:00:08 +0530 Subject: [PATCH 110/450] Add unit tests for typesFromFnSignature endpoint --- .../symbol/BallerinaSymbolService.java | 3 +- .../symbol/SymbolServiceTestUtil.java | 10 + .../symbol/TypesFromFnSignatureTest.java | 592 +++++++++++++++++- .../symbol/typesFromFnSignature.bal | 122 ++-- 4 files changed, 645 insertions(+), 82 deletions(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolService.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolService.java index 5b830095ec71..00a2a0dcb392 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolService.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolService.java @@ -246,7 +246,8 @@ public CompletableFuture getTypesFromFnSignature(TypesF if (fnSymbol instanceof FunctionSymbol) { FunctionTypeSymbol fnTypeSymbol = ((FunctionSymbol) fnSymbol).typeDescriptor(); - Optional returnType = getTypeForReturnTypeDesc(fnTypeSymbol, fnPosition); + Optional returnType = + getTypeForReturnTypeDesc(fnTypeSymbol, request.getReturnTypeDescPosition()); returnType.ifPresent(types::add); Optional> paramTypes = getTypesForFnParams(fnTypeSymbol); diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolServiceTestUtil.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolServiceTestUtil.java index 42e75a043c3e..bf9a097fb511 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolServiceTestUtil.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolServiceTestUtil.java @@ -23,6 +23,16 @@ */ public class SymbolServiceTestUtil { + public static final String INTEGER = "int"; + public static final String STRING = "string"; + public static final String FLOAT = "float"; + public static final String RECORD = "record"; + public static final String ARRAY = "array"; + public static final String UNION = "union"; + public static final String ERROR = "error"; + public static final String NULL = "()"; + public static final String NEVER = "never"; + public static boolean isPositionsEquals(LinePosition expectedPosition, LinePosition actualPosition) { return expectedPosition.line() == actualPosition.line() && expectedPosition.offset() == actualPosition.offset(); diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnSignatureTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnSignatureTest.java index 4694d92e68c2..b2e19d6a382c 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnSignatureTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnSignatureTest.java @@ -16,7 +16,10 @@ package org.ballerinalang.langserver.extensions.symbol; import io.ballerina.tools.text.LinePosition; +import org.ballerinalang.diagramutil.connector.models.connector.Type; +import org.ballerinalang.diagramutil.connector.models.connector.types.ArrayType; import org.ballerinalang.diagramutil.connector.models.connector.types.RecordType; +import org.ballerinalang.diagramutil.connector.models.connector.types.UnionType; import org.ballerinalang.langserver.extensions.LSExtensionTestUtil; import org.ballerinalang.langserver.extensions.ballerina.symbol.ResolvedTypeForSymbol; import org.ballerinalang.langserver.extensions.ballerina.symbol.TypesFromSymbolResponse; @@ -47,28 +50,597 @@ public void startLangServer() { this.serviceEndpoint = TestUtil.initializeLanguageSever(); } - @Test(description = "type info retrieved for the return type symbol node") - public void testTypeForReturnTypeNode() throws IOException, ExecutionException, InterruptedException { + @Test(description = "type info retrieved for primitive type param and primitive type return") + public void testTypesForPrimitiveTypeParamAndPrimitiveTypeReturn() + throws IOException, ExecutionException, InterruptedException { Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); - LinePosition fnPosition = LinePosition.from(67, 9); - LinePosition returnTypeDescPosition = LinePosition.from(67, 55); + LinePosition fnPosition = LinePosition.from(33, 9); + LinePosition paramPosition = LinePosition.from(33, 27); + LinePosition returnTypeDescPosition = LinePosition.from(33, 40); TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); Assert.assertNotNull(typesFromSymbolResponse.getTypes()); - ResolvedTypeForSymbol type = typesFromSymbolResponse.getTypes().get(0); - Assert.assertEquals(type.getType().name, "Output"); - Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(fnPosition, type.getRequestedPosition())); - Assert.assertTrue(type.getType() instanceof RecordType); + ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); + Assert.assertEquals(returnType.getType().typeName, SymbolServiceTestUtil.STRING); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals( + returnTypeDescPosition, returnType.getRequestedPosition())); - RecordType recordType = (RecordType) type.getType(); - Assert.assertEquals(recordType.fields.size(), 2); + ResolvedTypeForSymbol paramType = typesFromSymbolResponse.getTypes().get(1); + Assert.assertEquals(paramType.getType().typeName, SymbolServiceTestUtil.STRING); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(paramPosition, paramType.getRequestedPosition())); TestUtil.closeDocument(this.serviceEndpoint, inputFile); } + + @Test(description = "type info retrieved for record type param and record type return") + public void testTypesForRecordTypeParamAndRecordTypeReturn() + throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + LinePosition fnPosition = LinePosition.from(35, 9); + LinePosition paramPosition = LinePosition.from(35, 27); + LinePosition returnTypeDescPosition = LinePosition.from(33, 43); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); + + Assert.assertNotNull(typesFromSymbolResponse.getTypes()); + + ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); + assertStudentType(returnType.getType()); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals( + returnTypeDescPosition, returnType.getRequestedPosition())); + + ResolvedTypeForSymbol paramType = typesFromSymbolResponse.getTypes().get(1); + assertPersonType(paramType.getType()); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(paramPosition, paramType.getRequestedPosition())); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + + @Test(description = "type info retrieved for multiple params and record type return") + public void testTypesForMultipleParamsAndRecordTypeReturn() + throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + LinePosition fnPosition = LinePosition.from(37, 9); + LinePosition param1Position = LinePosition.from(37, 27); + LinePosition param2Position = LinePosition.from(37, 42); + LinePosition param3Position = LinePosition.from(37, 61); + LinePosition returnTypeDescPosition = LinePosition.from(37, 81); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); + + Assert.assertNotNull(typesFromSymbolResponse.getTypes()); + + ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); + assertStudentType(returnType.getType()); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals( + returnTypeDescPosition, returnType.getRequestedPosition())); + + ResolvedTypeForSymbol param1Type = typesFromSymbolResponse.getTypes().get(1); + assertPersonType(param1Type.getType()); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(param1Position, param1Type.getRequestedPosition())); + + ResolvedTypeForSymbol param2Type = typesFromSymbolResponse.getTypes().get(2); + assertCourseType(param2Type.getType()); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(param2Position, param2Type.getRequestedPosition())); + + ResolvedTypeForSymbol param3Type = typesFromSymbolResponse.getTypes().get(3); + assertSubmissionType(param3Type.getType()); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(param3Position, param3Type.getRequestedPosition())); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + + @Test(description = "type info retrieved for multiple params and primitive type return") + public void testTypesForMultipleParamsAndPrimitiveTypeReturn() + throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + LinePosition fnPosition = LinePosition.from(39, 9); + LinePosition param1Position = LinePosition.from(39, 27); + LinePosition param2Position = LinePosition.from(39, 39); + LinePosition returnTypeDescPosition = LinePosition.from(39, 50); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); + + Assert.assertNotNull(typesFromSymbolResponse.getTypes()); + + ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); + Assert.assertEquals(returnType.getType().typeName, SymbolServiceTestUtil.FLOAT); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals( + returnTypeDescPosition, returnType.getRequestedPosition())); + + ResolvedTypeForSymbol param1Type = typesFromSymbolResponse.getTypes().get(1); + assertPersonType(param1Type.getType()); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(param1Position, param1Type.getRequestedPosition())); + + ResolvedTypeForSymbol param2Type = typesFromSymbolResponse.getTypes().get(2); + Assert.assertEquals(param2Type.getType().typeName, SymbolServiceTestUtil.INTEGER); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(param2Position, param2Type.getRequestedPosition())); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + + @Test(description = "type info retrieved for record type(from http module) param and record type(from jwt module) return") + public void testTypesForRecordTypeParamAndRecordTypeReturn2() + throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + LinePosition fnPosition = LinePosition.from(41, 9); + LinePosition paramPosition = LinePosition.from(41, 33); + LinePosition returnTypeDescPosition = LinePosition.from(41, 50); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); + + Assert.assertNotNull(typesFromSymbolResponse.getTypes()); + + ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); + assertCertKeyType(returnType.getType(), "jwt"); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals( + returnTypeDescPosition, returnType.getRequestedPosition())); + + ResolvedTypeForSymbol paramType = typesFromSymbolResponse.getTypes().get(1); + assertCertKeyType(paramType.getType(), "http"); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(paramPosition, paramType.getRequestedPosition())); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + + @Test(description = "type info retrieved for primitive type array param and primitive type array return") + public void testTypesForPrimitiveTypeArrayParamAndPrimitiveTypeArrayReturn() + throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + LinePosition fnPosition = LinePosition.from(43, 9); + LinePosition paramPosition = LinePosition.from(43, 29); + LinePosition returnTypeDescPosition = LinePosition.from(43, 44); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); + + Assert.assertNotNull(typesFromSymbolResponse.getTypes()); + + ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); + Assert.assertEquals(returnType.getType().typeName, SymbolServiceTestUtil.ARRAY); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals( + returnTypeDescPosition, returnType.getRequestedPosition())); + Assert.assertTrue(returnType.getType() instanceof ArrayType); + ArrayType arrayReturnType = (ArrayType) returnType.getType(); + Assert.assertEquals(arrayReturnType.memberType.typeName, SymbolServiceTestUtil.STRING); + + ResolvedTypeForSymbol paramType = typesFromSymbolResponse.getTypes().get(1); + Assert.assertEquals(paramType.getType().typeName, SymbolServiceTestUtil.ARRAY); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(paramPosition, paramType.getRequestedPosition())); + Assert.assertTrue(paramType.getType() instanceof ArrayType); + ArrayType arrayParamType = (ArrayType) paramType.getType(); + Assert.assertEquals(arrayParamType.memberType.typeName, SymbolServiceTestUtil.STRING); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + + @Test(description = "type info retrieved for record type array params and record type array return") + public void testTypesForRecordTypeArrayParamsAndRecordTypeArrayReturn() + throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + LinePosition fnPosition = LinePosition.from(45, 9); + LinePosition param1Position = LinePosition.from(45, 29); + LinePosition param2Position = LinePosition.from(45, 46); + LinePosition returnTypeDescPosition = LinePosition.from(45, 63); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); + + Assert.assertNotNull(typesFromSymbolResponse.getTypes()); + + ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); + Assert.assertEquals(returnType.getType().typeName, SymbolServiceTestUtil.ARRAY); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals( + returnTypeDescPosition, returnType.getRequestedPosition())); + Assert.assertTrue(returnType.getType() instanceof ArrayType); + ArrayType arrayReturnType = (ArrayType) returnType.getType(); + assertStudentType(arrayReturnType.memberType); + + ResolvedTypeForSymbol param1Type = typesFromSymbolResponse.getTypes().get(1); + Assert.assertEquals(param1Type.getType().typeName, SymbolServiceTestUtil.ARRAY); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(param1Position, param1Type.getRequestedPosition())); + Assert.assertTrue(param1Type.getType() instanceof ArrayType); + ArrayType arrayParamType1 = (ArrayType) param1Type.getType(); + assertPersonType(arrayParamType1.memberType); + + ResolvedTypeForSymbol param2Type = typesFromSymbolResponse.getTypes().get(2); + Assert.assertEquals(param2Type.getType().typeName, SymbolServiceTestUtil.ARRAY); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(param2Position, param2Type.getRequestedPosition())); + Assert.assertTrue(param2Type.getType() instanceof ArrayType); + ArrayType arrayParamType2 = (ArrayType) param2Type.getType(); + assertCourseType(arrayParamType2.memberType); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + + @Test(description = "type info retrieved for record type(from imported module) array params and record type(from imported module) array return") + public void testTypesForRecordTypeArrayParamsAndRecordTypeArrayReturn2() + throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + LinePosition fnPosition = LinePosition.from(47, 9); + LinePosition paramPosition = LinePosition.from(47, 35); + LinePosition returnTypeDescPosition = LinePosition.from(47, 49); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); + + Assert.assertNotNull(typesFromSymbolResponse.getTypes()); + + ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); + Assert.assertEquals(returnType.getType().typeName, SymbolServiceTestUtil.ARRAY); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals( + returnTypeDescPosition, returnType.getRequestedPosition())); + Assert.assertTrue(returnType.getType() instanceof ArrayType); + ArrayType arrayReturnType = (ArrayType) returnType.getType(); + assertCertKeyType(arrayReturnType.memberType, "jwt"); + + ResolvedTypeForSymbol paramType = typesFromSymbolResponse.getTypes().get(1); + Assert.assertEquals(paramType.getType().typeName, SymbolServiceTestUtil.ARRAY); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(paramPosition, paramType.getRequestedPosition())); + Assert.assertTrue(paramType.getType() instanceof ArrayType); + ArrayType arrayParamType = (ArrayType) paramType.getType(); + assertCertKeyType(arrayParamType.memberType, "http"); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + + @Test(description = "type info retrieved for optional record type param and optional record type return") + public void testTypesForOptionalRecordTypeParamAndOptionalRecordTypeReturn() + throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + LinePosition fnPosition = LinePosition.from(49, 9); + LinePosition paramPosition = LinePosition.from(49, 28); + LinePosition returnTypeDescPosition = LinePosition.from(49, 44); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); + + Assert.assertNotNull(typesFromSymbolResponse.getTypes()); + + ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); + Assert.assertEquals(returnType.getType().typeName, SymbolServiceTestUtil.UNION); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals( + returnTypeDescPosition, returnType.getRequestedPosition())); + Assert.assertTrue(returnType.getType() instanceof UnionType); + UnionType unionReturnType = (UnionType) returnType.getType(); + Assert.assertEquals(unionReturnType.members.size(), 2); + assertStudentType(unionReturnType.members.get(0)); + Assert.assertEquals(unionReturnType.members.get(1).typeName, SymbolServiceTestUtil.NULL); + + ResolvedTypeForSymbol paramType = typesFromSymbolResponse.getTypes().get(1); + Assert.assertEquals(returnType.getType().typeName, SymbolServiceTestUtil.UNION); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(paramPosition, paramType.getRequestedPosition())); + Assert.assertTrue(paramType.getType() instanceof UnionType); + UnionType unionParamType = (UnionType) paramType.getType(); + Assert.assertEquals(unionParamType.members.size(), 2); + assertPersonType(unionParamType.members.get(0)); + Assert.assertEquals(unionParamType.members.get(1).typeName, SymbolServiceTestUtil.NULL); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + + @Test(description = "type info retrieved for primitive type defaultable param and primitive type return") + public void testTypesForPrimitiveTypeDefaultableParamAndPrimitiveTypeReturn() + throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + LinePosition fnPosition = LinePosition.from(51, 9); + LinePosition paramPosition = LinePosition.from(51, 28); + LinePosition returnTypeDescPosition = LinePosition.from(51, 46); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); + + Assert.assertNotNull(typesFromSymbolResponse.getTypes()); + + ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); + Assert.assertEquals(returnType.getType().typeName, SymbolServiceTestUtil.UNION); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals( + returnTypeDescPosition, returnType.getRequestedPosition())); + Assert.assertTrue(returnType.getType() instanceof UnionType); + UnionType unionReturnType = (UnionType) returnType.getType(); + Assert.assertEquals(unionReturnType.members.size(), 2); + Assert.assertEquals(unionReturnType.members.get(0).typeName, SymbolServiceTestUtil.STRING); + Assert.assertEquals(unionReturnType.members.get(1).typeName, SymbolServiceTestUtil.ERROR); + + ResolvedTypeForSymbol paramType = typesFromSymbolResponse.getTypes().get(1); + Assert.assertEquals(paramType.getType().typeName, SymbolServiceTestUtil.STRING); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(paramPosition, paramType.getRequestedPosition())); + // TODO: Assert defaultable status and the default value + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + + @Test(description = "type info retrieved for inline record type param and inline record type return") + public void testTypesForInlineRecordTypeParamAndInlineRecordTypeReturn() + throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + LinePosition fnPosition = LinePosition.from(53, 9); + LinePosition paramPosition = LinePosition.from(53, 74); + LinePosition returnTypeDescPosition = LinePosition.from(54, 12); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); + + Assert.assertNotNull(typesFromSymbolResponse.getTypes()); + + ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); + Assert.assertEquals(returnType.getType().typeName, SymbolServiceTestUtil.RECORD); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals( + returnTypeDescPosition, returnType.getRequestedPosition())); + Assert.assertNull(returnType.getType().name); + Assert.assertTrue(returnType.getType() instanceof RecordType); + RecordType inlineRecordType1 = (RecordType) returnType.getType(); + Assert.assertEquals(inlineRecordType1.fields.size(), 4); + Assert.assertEquals(inlineRecordType1.fields.get(3).typeName, SymbolServiceTestUtil.INTEGER); + Assert.assertEquals(inlineRecordType1.fields.get(3).name, "zip"); + + ResolvedTypeForSymbol paramType = typesFromSymbolResponse.getTypes().get(1); + Assert.assertEquals(paramType.getType().typeName, SymbolServiceTestUtil.RECORD); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(paramPosition, paramType.getRequestedPosition())); + Assert.assertNull(paramType.getType().name); + Assert.assertTrue(paramType.getType() instanceof RecordType); + RecordType inlineRecordType2 = (RecordType) paramType.getType(); + Assert.assertEquals(inlineRecordType2.fields.size(), 3); + Assert.assertEquals(inlineRecordType2.fields.get(2).typeName, SymbolServiceTestUtil.STRING); + Assert.assertEquals(inlineRecordType2.fields.get(2).name, "city"); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + + @Test(description = "test no params and no return type") + public void testNoParamsAndNoReturnType() + throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + LinePosition fnPosition = LinePosition.from(56, 9); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + uri, fnPosition, null, this.serviceEndpoint); + + Assert.assertNotNull(typesFromSymbolResponse.getTypes()); + + Assert.assertEquals(typesFromSymbolResponse.getTypes().size(), 1); + ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); + Assert.assertEquals(returnType.getType().typeName, SymbolServiceTestUtil.NULL); + Assert.assertNull(returnType.getType().name); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + + @Test(description = "test primitive type param and no return type") + public void testPrimitiveTypeParamAndNoReturnType() + throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + LinePosition fnPosition = LinePosition.from(58, 9); + LinePosition paramPosition = LinePosition.from(58, 28); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + uri, fnPosition, null, this.serviceEndpoint); + + Assert.assertNotNull(typesFromSymbolResponse.getTypes()); + + ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); + Assert.assertEquals(returnType.getType().typeName, SymbolServiceTestUtil.NULL); + Assert.assertNull(returnType.getType().name); + + ResolvedTypeForSymbol paramType = typesFromSymbolResponse.getTypes().get(1); + Assert.assertEquals(paramType.getType().typeName, SymbolServiceTestUtil.STRING); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(paramPosition, paramType.getRequestedPosition())); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + + @Test(description = "test no params and primitive return type") + public void testNoParamsAndPrimitiveReturnType() + throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + LinePosition fnPosition = LinePosition.from(60, 9); + LinePosition returnTypeDescPosition = LinePosition.from(60, 31); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); + + Assert.assertNotNull(typesFromSymbolResponse.getTypes()); + + Assert.assertEquals(typesFromSymbolResponse.getTypes().size(), 1); + ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); + Assert.assertEquals(returnType.getType().typeName, SymbolServiceTestUtil.STRING); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + + @Test(description = "test invalid file path") + public void testInvalidFilePath() throws ExecutionException, InterruptedException { + LinePosition fnPosition = LinePosition.from(60, 9); + LinePosition returnTypeDescPosition = LinePosition.from(60, 31); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + URI.create("file://+"), fnPosition, returnTypeDescPosition, this.serviceEndpoint); + + Assert.assertEquals(typesFromSymbolResponse.getTypes().size(), 0); + } + + private void assertPersonType(Type resolvedType) { + Assert.assertEquals(resolvedType.typeName, SymbolServiceTestUtil.RECORD); + Assert.assertEquals(resolvedType.name, "Person"); + Assert.assertTrue(resolvedType instanceof RecordType); + RecordType personRecordType = (RecordType) resolvedType; + Assert.assertEquals(personRecordType.fields.size(), 4); + + Assert.assertEquals(personRecordType.fields.get(0).name, "id"); + Assert.assertEquals(personRecordType.fields.get(0).typeName, SymbolServiceTestUtil.INTEGER); + + Assert.assertEquals(personRecordType.fields.get(1).name, "firstName"); + Assert.assertEquals(personRecordType.fields.get(1).typeName, SymbolServiceTestUtil.STRING); + + Assert.assertEquals(personRecordType.fields.get(2).name, "lastName"); + Assert.assertEquals(personRecordType.fields.get(2).typeName, SymbolServiceTestUtil.STRING); + + Assert.assertEquals(personRecordType.fields.get(3).name, "age"); + Assert.assertEquals(personRecordType.fields.get(3).typeName, SymbolServiceTestUtil.INTEGER); + Assert.assertTrue(personRecordType.fields.get(3).optional); + } + + private void assertCourseType(Type resolvedType) { + Assert.assertEquals(resolvedType.typeName, SymbolServiceTestUtil.RECORD); + Assert.assertEquals(resolvedType.name, "Course"); + Assert.assertTrue(resolvedType instanceof RecordType); + RecordType courseRecordType = (RecordType) resolvedType; + Assert.assertEquals(courseRecordType.fields.size(), 3); + + Assert.assertEquals(courseRecordType.fields.get(0).name, "id"); + Assert.assertEquals(courseRecordType.fields.get(0).typeName, SymbolServiceTestUtil.STRING); + + Assert.assertEquals(courseRecordType.fields.get(1).name, "name"); + Assert.assertEquals(courseRecordType.fields.get(1).typeName, SymbolServiceTestUtil.STRING); + + Assert.assertEquals(courseRecordType.fields.get(2).name, "credits"); + Assert.assertEquals(courseRecordType.fields.get(2).typeName, SymbolServiceTestUtil.INTEGER); + } + + private void assertSubmissionType(Type resolvedType) { + Assert.assertEquals(resolvedType.typeName, SymbolServiceTestUtil.RECORD); + Assert.assertEquals(resolvedType.name, "Submission"); + Assert.assertTrue(resolvedType instanceof RecordType); + RecordType submissionRecordType = (RecordType) resolvedType; + Assert.assertEquals(submissionRecordType.fields.size(), 3); + + Assert.assertEquals(submissionRecordType.fields.get(0).name, "id"); + Assert.assertEquals(submissionRecordType.fields.get(0).typeName, SymbolServiceTestUtil.INTEGER); + Assert.assertTrue(submissionRecordType.fields.get(0).defaultable); + // TODO: Assert default value + + Assert.assertEquals(submissionRecordType.fields.get(1).name, "date"); + Assert.assertEquals(submissionRecordType.fields.get(1).typeName, SymbolServiceTestUtil.STRING); + + Assert.assertEquals(submissionRecordType.fields.get(2).name, "params"); + Assert.assertEquals(submissionRecordType.fields.get(2).typeInfo.name, "QueryParams"); + Assert.assertEquals(submissionRecordType.fields.get(2).typeInfo.orgName, "ballerina"); + Assert.assertEquals(submissionRecordType.fields.get(2).typeInfo.moduleName, "http"); + Assert.assertTrue(submissionRecordType.fields.get(2) instanceof RecordType); + RecordType queryParamsRecordType = (RecordType) submissionRecordType.fields.get(2); + Assert.assertEquals(queryParamsRecordType.fields.size(), 4); + + Assert.assertEquals(queryParamsRecordType.fields.get(0).name, "headers"); + Assert.assertEquals(queryParamsRecordType.fields.get(0).typeName, SymbolServiceTestUtil.NEVER); + Assert.assertTrue(queryParamsRecordType.fields.get(0).optional); + Assert.assertEquals(queryParamsRecordType.fields.get(1).name, "targetType"); + Assert.assertEquals(queryParamsRecordType.fields.get(1).typeName, SymbolServiceTestUtil.NEVER); + Assert.assertTrue(queryParamsRecordType.fields.get(1).optional); + Assert.assertEquals(queryParamsRecordType.fields.get(2).name, "message"); + Assert.assertEquals(queryParamsRecordType.fields.get(2).typeName, SymbolServiceTestUtil.NEVER); + Assert.assertTrue(queryParamsRecordType.fields.get(2).optional); + Assert.assertEquals(queryParamsRecordType.fields.get(3).name, "mediaType"); + Assert.assertEquals(queryParamsRecordType.fields.get(3).typeName, SymbolServiceTestUtil.NEVER); + Assert.assertTrue(queryParamsRecordType.fields.get(3).optional); + Assert.assertTrue(queryParamsRecordType.hasRestType); + Assert.assertTrue(queryParamsRecordType.restType instanceof UnionType); + UnionType unionType = (UnionType) queryParamsRecordType.restType; + Assert.assertEquals(unionType.members.size(), 6); + } + + private void assertStudentType(Type resolvedType) { + Assert.assertEquals(resolvedType.typeName, SymbolServiceTestUtil.RECORD); + Assert.assertEquals(resolvedType.name, "Student"); + Assert.assertTrue(resolvedType instanceof RecordType); + RecordType studentRecordType = (RecordType) resolvedType; + Assert.assertEquals(studentRecordType.fields.size(), 5); + + Assert.assertEquals(studentRecordType.fields.get(0).typeName, SymbolServiceTestUtil.UNION); + Assert.assertEquals(studentRecordType.fields.get(0).name, "id"); + Assert.assertTrue(studentRecordType.fields.get(0) instanceof UnionType); + UnionType unionType = (UnionType) studentRecordType.fields.get(0); + Assert.assertEquals(unionType.members.size(), 2); + Assert.assertEquals(unionType.members.get(0).typeName, SymbolServiceTestUtil.INTEGER); + Assert.assertEquals(unionType.members.get(1).typeName, SymbolServiceTestUtil.NULL); + + Assert.assertEquals(studentRecordType.fields.get(1).name, "fullName"); + Assert.assertEquals(studentRecordType.fields.get(1).typeName, SymbolServiceTestUtil.STRING); + + Assert.assertEquals(studentRecordType.fields.get(2).name, "age"); + Assert.assertEquals(studentRecordType.fields.get(2).typeName, SymbolServiceTestUtil.STRING); + + Assert.assertEquals(studentRecordType.fields.get(3).name, "courses"); + Assert.assertTrue(studentRecordType.fields.get(3) instanceof ArrayType); + ArrayType coursesArrayType = (ArrayType) studentRecordType.fields.get(3); + Assert.assertTrue(coursesArrayType.memberType instanceof RecordType); + RecordType courseRecordType = (RecordType) coursesArrayType.memberType; + Assert.assertEquals(courseRecordType.fields.size(), 2); + Assert.assertEquals(courseRecordType.fields.get(0).name, "title"); + Assert.assertEquals(courseRecordType.fields.get(0).typeName, SymbolServiceTestUtil.STRING); + Assert.assertEquals(courseRecordType.fields.get(1).name, "credits"); + Assert.assertEquals(courseRecordType.fields.get(1).typeName, SymbolServiceTestUtil.INTEGER); + + Assert.assertEquals(studentRecordType.fields.get(4).name, "totalCredits"); + Assert.assertEquals(studentRecordType.fields.get(4).typeName, SymbolServiceTestUtil.INTEGER); + } + + private void assertCertKeyType(Type resolvedType, String module) { + Assert.assertEquals(resolvedType.typeName, SymbolServiceTestUtil.RECORD); + Assert.assertEquals(resolvedType.name, "CertKey"); + Assert.assertTrue(resolvedType instanceof RecordType); + RecordType certKeyRecordType = (RecordType) resolvedType; + Assert.assertEquals(certKeyRecordType.typeInfo.name, "CertKey"); + Assert.assertEquals(certKeyRecordType.typeInfo.orgName, "ballerina"); + Assert.assertEquals(certKeyRecordType.typeInfo.moduleName, module); + Assert.assertEquals(certKeyRecordType.fields.size(), 3); + + Assert.assertEquals(certKeyRecordType.fields.get(0).name, "certFile"); + Assert.assertEquals(certKeyRecordType.fields.get(0).typeName, SymbolServiceTestUtil.STRING); + + Assert.assertEquals(certKeyRecordType.fields.get(1).name, "keyFile"); + Assert.assertEquals(certKeyRecordType.fields.get(1).typeName, SymbolServiceTestUtil.STRING); + + Assert.assertEquals(certKeyRecordType.fields.get(2).name, "keyPassword"); + Assert.assertEquals(certKeyRecordType.fields.get(2).typeName, SymbolServiceTestUtil.STRING); + Assert.assertTrue(certKeyRecordType.fields.get(2).optional); + } } diff --git a/language-server/modules/langserver-core/src/test/resources/extensions/symbol/typesFromFnSignature.bal b/language-server/modules/langserver-core/src/test/resources/extensions/symbol/typesFromFnSignature.bal index 870d4a210f96..19c4b0c4a5f3 100644 --- a/language-server/modules/langserver-core/src/test/resources/extensions/symbol/typesFromFnSignature.bal +++ b/language-server/modules/langserver-core/src/test/resources/extensions/symbol/typesFromFnSignature.bal @@ -1,81 +1,61 @@ import ballerina/http; +import ballerina/jwt; -type Input record { - MessageProperties MessageProperties; - record { - int Type; - string Id; - boolean Confirmed; - }[] Assets; - record { - string StopId; - string CurrOrPickedTrailer; - any Driver2; - string Driver1; - decimal Latitude; - any Unit; - decimal Longitude; - string TripId; - string Weight; - string BillOfLading; - string ETA; - decimal user_id; - string DroppedTrailer; - string Seal; - record { - anydata[] warnings; - anydata[] errors; - } form_meta; - string Pieces; - } Content; - string FormId; - string CreateDate; +type Person record { + int id; + string firstName; + string lastName; + int age?; }; -type Input2 record { - http:Bucket bucket; +type Course record { + string id; + string name; + int credits; }; -type Output record { - record { - string MessageContentType; - record { - string[] Content; - record { - int OType; - string OId; - boolean OConfirmed; - }[] Assets; - record { - decimal Latitude; - decimal Longitude; - } Coordinates; - string FormId; - string CreateDate; - } MessageContent; - string ParentMessageGuid; - string MessageGuid; - } data; - string 'type; +type Submission record { + int id = 0; + string date; + http:QueryParams params; }; -type MessageProperties record { - string EventType; - string AuditId; - string MessageId; +type Student record { + int? id; + string fullName; + string age; + record { + string title; + int credits; + }[] courses; + int totalCredits; }; -function transform(Input input, Input2 Input2) returns Output => { - data: { - MessageContent: { - Assets: from var item in input.Assets - select { - OType: item.Type, - OId: item.Id, - OConfirmed: item.Confirmed - } - }, - MessageGuid: input.MessageProperties.AuditId, - MessageContentType: input.MessageProperties.EventType - } -}; +function transform1(string str) returns string => ""; + +function transform2(Person person) returns Student => {}; + +function transform3(Person person, Course course, Submission submission) returns Student => {}; + +function transform4(Person person, int i) returns float => 0.0; + +function transform5(http:CertKey certKey) returns jwt:CertKey => {}; + +function transform6(string[] names) returns string[] => []; + +function transform7(Person[] people, Course[] courses) returns Student[] => []; + +function transform8(http:CertKey[] keys) returns jwt:CertKey[] => []; + +function transform9(Person? person) returns Student? => {}; + +function transform10(string str = "") returns string|error => ""; + +function transform11(record {string houseNo; string street; string city;} address) + returns record {string number; string street; string city; int zip;} => {}; + +function transform12() => (); + +function transform13(string str) => (); + +function transform14() returns string => ""; From 94aa73632db27fe5bfbdac070277ab81a46fca34 Mon Sep 17 00:00:00 2001 From: Madusha Date: Wed, 9 Nov 2022 19:57:37 +0530 Subject: [PATCH 111/450] Include defaultable state for parameters --- .../extensions/symbol/TypesFromFnSignatureTest.java | 3 +-- .../diagramutil/connector/models/connector/Type.java | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnSignatureTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnSignatureTest.java index b2e19d6a382c..34876219af99 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnSignatureTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnSignatureTest.java @@ -382,7 +382,7 @@ public void testTypesForPrimitiveTypeDefaultableParamAndPrimitiveTypeReturn() ResolvedTypeForSymbol paramType = typesFromSymbolResponse.getTypes().get(1); Assert.assertEquals(paramType.getType().typeName, SymbolServiceTestUtil.STRING); Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(paramPosition, paramType.getRequestedPosition())); - // TODO: Assert defaultable status and the default value + Assert.assertTrue(paramType.getType().defaultable); TestUtil.closeDocument(this.serviceEndpoint, inputFile); } @@ -556,7 +556,6 @@ private void assertSubmissionType(Type resolvedType) { Assert.assertEquals(submissionRecordType.fields.get(0).name, "id"); Assert.assertEquals(submissionRecordType.fields.get(0).typeName, SymbolServiceTestUtil.INTEGER); Assert.assertTrue(submissionRecordType.fields.get(0).defaultable); - // TODO: Assert default value Assert.assertEquals(submissionRecordType.fields.get(1).name, "date"); Assert.assertEquals(submissionRecordType.fields.get(1).typeName, SymbolServiceTestUtil.STRING); diff --git a/misc/diagram-util/src/main/java/org/ballerinalang/diagramutil/connector/models/connector/Type.java b/misc/diagram-util/src/main/java/org/ballerinalang/diagramutil/connector/models/connector/Type.java index 5b3331a18c56..9f1a3f0e3e45 100644 --- a/misc/diagram-util/src/main/java/org/ballerinalang/diagramutil/connector/models/connector/Type.java +++ b/misc/diagram-util/src/main/java/org/ballerinalang/diagramutil/connector/models/connector/Type.java @@ -24,6 +24,7 @@ import io.ballerina.compiler.api.symbols.ErrorTypeSymbol; import io.ballerina.compiler.api.symbols.IntersectionTypeSymbol; import io.ballerina.compiler.api.symbols.ObjectTypeSymbol; +import io.ballerina.compiler.api.symbols.ParameterKind; import io.ballerina.compiler.api.symbols.ParameterSymbol; import io.ballerina.compiler.api.symbols.RecordFieldSymbol; import io.ballerina.compiler.api.symbols.RecordTypeSymbol; @@ -317,6 +318,9 @@ public static Type fromSemanticSymbol(Symbol symbol) { } else if (symbol instanceof ParameterSymbol) { ParameterSymbol parameterSymbol = (ParameterSymbol) symbol; type = fromSemanticSymbol(parameterSymbol.typeDescriptor()); + if (type != null) { + type.defaultable = parameterSymbol.paramKind() == ParameterKind.DEFAULTABLE; + } } else if (symbol instanceof TypeSymbol) { type = new PrimitiveType(((TypeSymbol) symbol).signature()); } From 305e326b2a5a0756f2cab16097b71f91b59c9747 Mon Sep 17 00:00:00 2001 From: Madusha Date: Thu, 10 Nov 2022 11:16:04 +0530 Subject: [PATCH 112/450] Fix generating type when the same record repeated within the root record --- .../diagramutil/connector/models/connector/Type.java | 1 + 1 file changed, 1 insertion(+) diff --git a/misc/diagram-util/src/main/java/org/ballerinalang/diagramutil/connector/models/connector/Type.java b/misc/diagram-util/src/main/java/org/ballerinalang/diagramutil/connector/models/connector/Type.java index 9f1a3f0e3e45..83022d36298f 100644 --- a/misc/diagram-util/src/main/java/org/ballerinalang/diagramutil/connector/models/connector/Type.java +++ b/misc/diagram-util/src/main/java/org/ballerinalang/diagramutil/connector/models/connector/Type.java @@ -256,6 +256,7 @@ public static Type fromSemanticSymbol(Symbol symbol) { Type restType = recordTypeSymbol.restTypeDescriptor().isPresent() ? fromSemanticSymbol(recordTypeSymbol.restTypeDescriptor().get()) : null; type = new RecordType(fields, restType); + parentSymbols.remove(parentSymbols.size() - 1); } else if (symbol instanceof ArrayTypeSymbol) { ArrayTypeSymbol arrayTypeSymbol = (ArrayTypeSymbol) symbol; type = new ArrayType(fromSemanticSymbol(arrayTypeSymbol.memberTypeDescriptor())); From 94473f363b3975a7298cc2d829be41a50936ca2e Mon Sep 17 00:00:00 2001 From: Madusha Date: Thu, 10 Nov 2022 22:36:00 +0530 Subject: [PATCH 113/450] Add client and server capabilities for the getTypesFromFnDef endpoint --- .../symbol/BallerinaSymbolClientCapabilities.java | 10 ++++++++++ .../symbol/BallerinaSymbolServerCapabilities.java | 10 ++++++++++ .../BallerinaSymbolServiceServerCapabilitySetter.java | 1 + 3 files changed, 21 insertions(+) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolClientCapabilities.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolClientCapabilities.java index a66ab062ab19..97af5c51ba6f 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolClientCapabilities.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolClientCapabilities.java @@ -34,6 +34,8 @@ public class BallerinaSymbolClientCapabilities extends BallerinaClientCapability private boolean getTypeFromSymbol; + private boolean getTypesFromFnSignature; + public boolean isGetSymbol() { return getSymbol; } @@ -74,6 +76,14 @@ public void setGetTypeFromSymbol(boolean getTypeFromSymbol) { this.getTypeFromSymbol = getTypeFromSymbol; } + public boolean isGetTypesFromFnSignature() { + return getTypesFromFnSignature; + } + + public void setGetTypesFromFnSignature(boolean getTypesFromFnSignature) { + this.getTypesFromFnSignature = getTypesFromFnSignature; + } + public BallerinaSymbolClientCapabilities() { super(Constants.CAPABILITY_NAME); } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolServerCapabilities.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolServerCapabilities.java index fb6f8bd29d33..336e6fc7018e 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolServerCapabilities.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolServerCapabilities.java @@ -34,6 +34,8 @@ public class BallerinaSymbolServerCapabilities extends BallerinaServerCapability private boolean getTypeFromSymbol; + private boolean getTypesFromFnSignature; + public boolean isGetSymbol() { return getSymbol; } @@ -74,6 +76,14 @@ public void setGetTypeFromSymbol(boolean getTypeFromSymbol) { this.getTypeFromSymbol = getTypeFromSymbol; } + public boolean isGetTypesFromFnSignature() { + return getTypesFromFnSignature; + } + + public void setGetTypesFromFnSignature(boolean getTypesFromFnSignature) { + this.getTypesFromFnSignature = getTypesFromFnSignature; + } + public BallerinaSymbolServerCapabilities() { super(Constants.CAPABILITY_NAME); } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolServiceServerCapabilitySetter.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolServiceServerCapabilitySetter.java index d8cf8f175a45..732b2d290301 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolServiceServerCapabilitySetter.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolServiceServerCapabilitySetter.java @@ -37,6 +37,7 @@ public Optional build() { capabilities.setGetSymbol(true); capabilities.setGetTypeFromExpression(true); capabilities.setGetTypeFromSymbol(true); + capabilities.setGetTypesFromFnSignature(true); return Optional.of(capabilities); } From de91fc569f98007edf833e78805eb6e6dacf5418 Mon Sep 17 00:00:00 2001 From: Madusha Date: Thu, 10 Nov 2022 23:11:24 +0530 Subject: [PATCH 114/450] Rename LS extension endpoint 'getTypesFromFnSignature' to 'getTypesFromFnDefinition' --- .../BallerinaSymbolClientCapabilities.java | 10 +-- .../BallerinaSymbolServerCapabilities.java | 10 +-- .../symbol/BallerinaSymbolService.java | 6 +- ...naSymbolServiceServerCapabilitySetter.java | 2 +- .../ballerina/symbol/SymbolContext.java | 2 +- ...java => TypesFromFnDefinitionRequest.java} | 2 +- .../extensions/LSExtensionTestUtil.java | 24 +++---- ...st.java => TypesFromFnDefinitionTest.java} | 66 +++++++++---------- ...ignature.bal => typesFromFnDefinition.bal} | 0 9 files changed, 61 insertions(+), 61 deletions(-) rename language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/{TypesFromFnSignatureRequest.java => TypesFromFnDefinitionRequest.java} (97%) rename language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/{TypesFromFnSignatureTest.java => TypesFromFnDefinitionTest.java} (96%) rename language-server/modules/langserver-core/src/test/resources/extensions/symbol/{typesFromFnSignature.bal => typesFromFnDefinition.bal} (100%) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolClientCapabilities.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolClientCapabilities.java index 97af5c51ba6f..1a7f70e8a02b 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolClientCapabilities.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolClientCapabilities.java @@ -34,7 +34,7 @@ public class BallerinaSymbolClientCapabilities extends BallerinaClientCapability private boolean getTypeFromSymbol; - private boolean getTypesFromFnSignature; + private boolean getTypesFromFnDefinition; public boolean isGetSymbol() { return getSymbol; @@ -76,12 +76,12 @@ public void setGetTypeFromSymbol(boolean getTypeFromSymbol) { this.getTypeFromSymbol = getTypeFromSymbol; } - public boolean isGetTypesFromFnSignature() { - return getTypesFromFnSignature; + public boolean isGetTypesFromFnDefinition() { + return getTypesFromFnDefinition; } - public void setGetTypesFromFnSignature(boolean getTypesFromFnSignature) { - this.getTypesFromFnSignature = getTypesFromFnSignature; + public void setGetTypesFromFnDefinition(boolean getTypesFromFnDefinition) { + this.getTypesFromFnDefinition = getTypesFromFnDefinition; } public BallerinaSymbolClientCapabilities() { diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolServerCapabilities.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolServerCapabilities.java index 336e6fc7018e..e438fad60090 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolServerCapabilities.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolServerCapabilities.java @@ -34,7 +34,7 @@ public class BallerinaSymbolServerCapabilities extends BallerinaServerCapability private boolean getTypeFromSymbol; - private boolean getTypesFromFnSignature; + private boolean getTypesFromFnDefinition; public boolean isGetSymbol() { return getSymbol; @@ -76,12 +76,12 @@ public void setGetTypeFromSymbol(boolean getTypeFromSymbol) { this.getTypeFromSymbol = getTypeFromSymbol; } - public boolean isGetTypesFromFnSignature() { - return getTypesFromFnSignature; + public boolean isGetTypesFromFnDefinition() { + return getTypesFromFnDefinition; } - public void setGetTypesFromFnSignature(boolean getTypesFromFnSignature) { - this.getTypesFromFnSignature = getTypesFromFnSignature; + public void setGetTypesFromFnDefinition(boolean getTypesFromFnDefinition) { + this.getTypesFromFnDefinition = getTypesFromFnDefinition; } public BallerinaSymbolServerCapabilities() { diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolService.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolService.java index 00a2a0dcb392..8a17c076c15a 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolService.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolService.java @@ -223,7 +223,7 @@ public CompletableFuture getTypeFromSymbol(TypeFromSymb } @JsonRequest - public CompletableFuture getTypesFromFnSignature(TypesFromFnSignatureRequest request) { + public CompletableFuture getTypesFromFnDefinition(TypesFromFnDefinitionRequest request) { return CompletableFuture.supplyAsync(() -> { TypesFromSymbolResponse typeFromSymbolResponse = new TypesFromSymbolResponse(); String fileUri = request.getDocumentIdentifier().getUri(); @@ -257,8 +257,8 @@ public CompletableFuture getTypesFromFnSignature(TypesF typeFromSymbolResponse.setTypes(types); return typeFromSymbolResponse; } catch (Throwable e) { - String msg = "Operation 'ballerinaSymbol/getTypesFromFnSignature' failed!"; - this.clientLogger.logError(SymbolContext.SC_GET_TYPE_FROM_FN_SIGNATURE_API, msg, e, + String msg = "Operation 'ballerinaSymbol/getTypesFromFnDefinition' failed!"; + this.clientLogger.logError(SymbolContext.SC_GET_TYPE_FROM_FN_DEFINITION_API, msg, e, request.getDocumentIdentifier(), (Position) null); return typeFromSymbolResponse; } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolServiceServerCapabilitySetter.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolServiceServerCapabilitySetter.java index 732b2d290301..29b453d975da 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolServiceServerCapabilitySetter.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolServiceServerCapabilitySetter.java @@ -37,7 +37,7 @@ public Optional build() { capabilities.setGetSymbol(true); capabilities.setGetTypeFromExpression(true); capabilities.setGetTypeFromSymbol(true); - capabilities.setGetTypesFromFnSignature(true); + capabilities.setGetTypesFromFnDefinition(true); return Optional.of(capabilities); } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/SymbolContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/SymbolContext.java index f868cd53c36e..6cd49ffe7ddb 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/SymbolContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/SymbolContext.java @@ -27,7 +27,7 @@ public enum SymbolContext implements LSOperation { SC_GET_TYPE_FROM_EXPRESSION_API("ballerinaSymbol/getTypeFromExpression"), SC_GET_SYMBOL_API("ballerinaSymbol/getSymbol"), SC_GET_TYPE_FROM_SYMBOL_API("ballerinaSymbol/getTypeFromSymbol"), - SC_GET_TYPE_FROM_FN_SIGNATURE_API("ballerinaSymbol/getTypesFromFnSignature"); + SC_GET_TYPE_FROM_FN_DEFINITION_API("ballerinaSymbol/getTypesFromFnDefinition"); private final String name; SymbolContext(String name) { diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/TypesFromFnSignatureRequest.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/TypesFromFnDefinitionRequest.java similarity index 97% rename from language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/TypesFromFnSignatureRequest.java rename to language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/TypesFromFnDefinitionRequest.java index 91e347982b01..3da1197e50c2 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/TypesFromFnSignatureRequest.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/TypesFromFnDefinitionRequest.java @@ -21,7 +21,7 @@ /** * Represents a request to get type info given for given positions of symbols. */ -public class TypesFromFnSignatureRequest { +public class TypesFromFnDefinitionRequest { private TextDocumentIdentifier documentIdentifier; private LinePosition fnPosition; private LinePosition returnTypeDescPosition; diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/LSExtensionTestUtil.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/LSExtensionTestUtil.java index c9d89a1ec725..3e943a61823f 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/LSExtensionTestUtil.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/LSExtensionTestUtil.java @@ -33,7 +33,7 @@ import org.ballerinalang.langserver.extensions.ballerina.symbol.SymbolInfoRequest; import org.ballerinalang.langserver.extensions.ballerina.symbol.SymbolInfoResponse; import org.ballerinalang.langserver.extensions.ballerina.symbol.TypeFromExpressionRequest; -import org.ballerinalang.langserver.extensions.ballerina.symbol.TypesFromFnSignatureRequest; +import org.ballerinalang.langserver.extensions.ballerina.symbol.TypesFromFnDefinitionRequest; import org.ballerinalang.langserver.extensions.ballerina.symbol.TypeFromSymbolRequest; import org.ballerinalang.langserver.extensions.ballerina.symbol.TypesFromExpressionResponse; import org.ballerinalang.langserver.extensions.ballerina.symbol.TypesFromSymbolResponse; @@ -67,7 +67,7 @@ public class LSExtensionTestUtil { private static final String GET_SYMBOL = "ballerinaSymbol/getSymbol"; private static final String GET_TYPE_FROM_SYMBOL = "ballerinaSymbol/getTypeFromSymbol"; private static final String GET_TYPE_FROM_EXPRESSION = "ballerinaSymbol/getTypeFromExpression"; - private static final String GET_TYPE_FROM_FN_SIGNATURE = "ballerinaSymbol/getTypesFromFnSignature"; + private static final String GET_TYPE_FROM_FN_DEFINITION = "ballerinaSymbol/getTypesFromFnDefinition"; private static final Gson GSON = new Gson(); private static final JsonParser parser = new JsonParser(); @@ -239,7 +239,7 @@ public static TypesFromExpressionResponse getTypeFromExpression(URI filePath, Li } /** - * Get the ballerinaDocument/getTypesFromFnSignature response. + * Get the ballerinaDocument/getTypesFromFnDefinition response. * * @param filePath Path of the Bal file * @param fnPosition Ranges of the expressions to get associated types @@ -247,16 +247,16 @@ public static TypesFromExpressionResponse getTypeFromExpression(URI filePath, Li * @param serviceEndpoint Service Endpoint to Language Server * @return {@link String} Response as String */ - public static TypesFromSymbolResponse getTypesFromFnSignature(URI filePath, - LinePosition fnPosition, - LinePosition returnTypeDescPosition, - Endpoint serviceEndpoint) + public static TypesFromSymbolResponse getTypesFromFnDefinition(URI filePath, + LinePosition fnPosition, + LinePosition returnTypeDescPosition, + Endpoint serviceEndpoint) throws ExecutionException, InterruptedException { - TypesFromFnSignatureRequest typesFromFnSignatureRequest = new TypesFromFnSignatureRequest(); - typesFromFnSignatureRequest.setFnPosition(fnPosition); - typesFromFnSignatureRequest.setReturnTypeDescPosition(returnTypeDescPosition); - typesFromFnSignatureRequest.setDocumentIdentifier(TestUtil.getTextDocumentIdentifier(filePath)); - CompletableFuture result = serviceEndpoint.request(GET_TYPE_FROM_FN_SIGNATURE, typesFromFnSignatureRequest); + TypesFromFnDefinitionRequest typesFromFnDefRequest = new TypesFromFnDefinitionRequest(); + typesFromFnDefRequest.setFnPosition(fnPosition); + typesFromFnDefRequest.setReturnTypeDescPosition(returnTypeDescPosition); + typesFromFnDefRequest.setDocumentIdentifier(TestUtil.getTextDocumentIdentifier(filePath)); + CompletableFuture result = serviceEndpoint.request(GET_TYPE_FROM_FN_DEFINITION, typesFromFnDefRequest); return (TypesFromSymbolResponse) result.get(); } } diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnSignatureTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnDefinitionTest.java similarity index 96% rename from language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnSignatureTest.java rename to language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnDefinitionTest.java index 34876219af99..a7829717dae9 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnSignatureTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnDefinitionTest.java @@ -36,14 +36,14 @@ import java.util.concurrent.ExecutionException; /** - * Test type info retrieved via getTypesFromFnSignature endpoint. + * Test type info retrieved via getTypesFromFnDefinition endpoint. */ -public class TypesFromFnSignatureTest { +public class TypesFromFnDefinitionTest { private Endpoint serviceEndpoint; - private final Path typesFromFnSignatureBalFile = FileUtils.RES_DIR.resolve("extensions") + private final Path typesFromFnDefinitionBalFile = FileUtils.RES_DIR.resolve("extensions") .resolve("symbol") - .resolve("typesFromFnSignature.bal"); + .resolve("typesFromFnDefinition.bal"); @BeforeClass public void startLangServer() { @@ -53,7 +53,7 @@ public void startLangServer() { @Test(description = "type info retrieved for primitive type param and primitive type return") public void testTypesForPrimitiveTypeParamAndPrimitiveTypeReturn() throws IOException, ExecutionException, InterruptedException { - Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); @@ -61,7 +61,7 @@ public void testTypesForPrimitiveTypeParamAndPrimitiveTypeReturn() LinePosition paramPosition = LinePosition.from(33, 27); LinePosition returnTypeDescPosition = LinePosition.from(33, 40); - TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); Assert.assertNotNull(typesFromSymbolResponse.getTypes()); @@ -81,7 +81,7 @@ public void testTypesForPrimitiveTypeParamAndPrimitiveTypeReturn() @Test(description = "type info retrieved for record type param and record type return") public void testTypesForRecordTypeParamAndRecordTypeReturn() throws IOException, ExecutionException, InterruptedException { - Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); @@ -89,7 +89,7 @@ public void testTypesForRecordTypeParamAndRecordTypeReturn() LinePosition paramPosition = LinePosition.from(35, 27); LinePosition returnTypeDescPosition = LinePosition.from(33, 43); - TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); Assert.assertNotNull(typesFromSymbolResponse.getTypes()); @@ -109,7 +109,7 @@ public void testTypesForRecordTypeParamAndRecordTypeReturn() @Test(description = "type info retrieved for multiple params and record type return") public void testTypesForMultipleParamsAndRecordTypeReturn() throws IOException, ExecutionException, InterruptedException { - Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); @@ -119,7 +119,7 @@ public void testTypesForMultipleParamsAndRecordTypeReturn() LinePosition param3Position = LinePosition.from(37, 61); LinePosition returnTypeDescPosition = LinePosition.from(37, 81); - TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); Assert.assertNotNull(typesFromSymbolResponse.getTypes()); @@ -147,7 +147,7 @@ public void testTypesForMultipleParamsAndRecordTypeReturn() @Test(description = "type info retrieved for multiple params and primitive type return") public void testTypesForMultipleParamsAndPrimitiveTypeReturn() throws IOException, ExecutionException, InterruptedException { - Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); @@ -156,7 +156,7 @@ public void testTypesForMultipleParamsAndPrimitiveTypeReturn() LinePosition param2Position = LinePosition.from(39, 39); LinePosition returnTypeDescPosition = LinePosition.from(39, 50); - TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); Assert.assertNotNull(typesFromSymbolResponse.getTypes()); @@ -180,7 +180,7 @@ public void testTypesForMultipleParamsAndPrimitiveTypeReturn() @Test(description = "type info retrieved for record type(from http module) param and record type(from jwt module) return") public void testTypesForRecordTypeParamAndRecordTypeReturn2() throws IOException, ExecutionException, InterruptedException { - Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); @@ -188,7 +188,7 @@ public void testTypesForRecordTypeParamAndRecordTypeReturn2() LinePosition paramPosition = LinePosition.from(41, 33); LinePosition returnTypeDescPosition = LinePosition.from(41, 50); - TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); Assert.assertNotNull(typesFromSymbolResponse.getTypes()); @@ -208,7 +208,7 @@ public void testTypesForRecordTypeParamAndRecordTypeReturn2() @Test(description = "type info retrieved for primitive type array param and primitive type array return") public void testTypesForPrimitiveTypeArrayParamAndPrimitiveTypeArrayReturn() throws IOException, ExecutionException, InterruptedException { - Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); @@ -216,7 +216,7 @@ public void testTypesForPrimitiveTypeArrayParamAndPrimitiveTypeArrayReturn() LinePosition paramPosition = LinePosition.from(43, 29); LinePosition returnTypeDescPosition = LinePosition.from(43, 44); - TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); Assert.assertNotNull(typesFromSymbolResponse.getTypes()); @@ -242,7 +242,7 @@ public void testTypesForPrimitiveTypeArrayParamAndPrimitiveTypeArrayReturn() @Test(description = "type info retrieved for record type array params and record type array return") public void testTypesForRecordTypeArrayParamsAndRecordTypeArrayReturn() throws IOException, ExecutionException, InterruptedException { - Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); @@ -251,7 +251,7 @@ public void testTypesForRecordTypeArrayParamsAndRecordTypeArrayReturn() LinePosition param2Position = LinePosition.from(45, 46); LinePosition returnTypeDescPosition = LinePosition.from(45, 63); - TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); Assert.assertNotNull(typesFromSymbolResponse.getTypes()); @@ -284,7 +284,7 @@ public void testTypesForRecordTypeArrayParamsAndRecordTypeArrayReturn() @Test(description = "type info retrieved for record type(from imported module) array params and record type(from imported module) array return") public void testTypesForRecordTypeArrayParamsAndRecordTypeArrayReturn2() throws IOException, ExecutionException, InterruptedException { - Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); @@ -292,7 +292,7 @@ public void testTypesForRecordTypeArrayParamsAndRecordTypeArrayReturn2() LinePosition paramPosition = LinePosition.from(47, 35); LinePosition returnTypeDescPosition = LinePosition.from(47, 49); - TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); Assert.assertNotNull(typesFromSymbolResponse.getTypes()); @@ -318,7 +318,7 @@ public void testTypesForRecordTypeArrayParamsAndRecordTypeArrayReturn2() @Test(description = "type info retrieved for optional record type param and optional record type return") public void testTypesForOptionalRecordTypeParamAndOptionalRecordTypeReturn() throws IOException, ExecutionException, InterruptedException { - Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); @@ -326,7 +326,7 @@ public void testTypesForOptionalRecordTypeParamAndOptionalRecordTypeReturn() LinePosition paramPosition = LinePosition.from(49, 28); LinePosition returnTypeDescPosition = LinePosition.from(49, 44); - TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); Assert.assertNotNull(typesFromSymbolResponse.getTypes()); @@ -356,7 +356,7 @@ public void testTypesForOptionalRecordTypeParamAndOptionalRecordTypeReturn() @Test(description = "type info retrieved for primitive type defaultable param and primitive type return") public void testTypesForPrimitiveTypeDefaultableParamAndPrimitiveTypeReturn() throws IOException, ExecutionException, InterruptedException { - Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); @@ -364,7 +364,7 @@ public void testTypesForPrimitiveTypeDefaultableParamAndPrimitiveTypeReturn() LinePosition paramPosition = LinePosition.from(51, 28); LinePosition returnTypeDescPosition = LinePosition.from(51, 46); - TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); Assert.assertNotNull(typesFromSymbolResponse.getTypes()); @@ -390,7 +390,7 @@ public void testTypesForPrimitiveTypeDefaultableParamAndPrimitiveTypeReturn() @Test(description = "type info retrieved for inline record type param and inline record type return") public void testTypesForInlineRecordTypeParamAndInlineRecordTypeReturn() throws IOException, ExecutionException, InterruptedException { - Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); @@ -398,7 +398,7 @@ public void testTypesForInlineRecordTypeParamAndInlineRecordTypeReturn() LinePosition paramPosition = LinePosition.from(53, 74); LinePosition returnTypeDescPosition = LinePosition.from(54, 12); - TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); Assert.assertNotNull(typesFromSymbolResponse.getTypes()); @@ -430,13 +430,13 @@ public void testTypesForInlineRecordTypeParamAndInlineRecordTypeReturn() @Test(description = "test no params and no return type") public void testNoParamsAndNoReturnType() throws IOException, ExecutionException, InterruptedException { - Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); LinePosition fnPosition = LinePosition.from(56, 9); - TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( uri, fnPosition, null, this.serviceEndpoint); Assert.assertNotNull(typesFromSymbolResponse.getTypes()); @@ -452,14 +452,14 @@ public void testNoParamsAndNoReturnType() @Test(description = "test primitive type param and no return type") public void testPrimitiveTypeParamAndNoReturnType() throws IOException, ExecutionException, InterruptedException { - Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); LinePosition fnPosition = LinePosition.from(58, 9); LinePosition paramPosition = LinePosition.from(58, 28); - TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( uri, fnPosition, null, this.serviceEndpoint); Assert.assertNotNull(typesFromSymbolResponse.getTypes()); @@ -478,14 +478,14 @@ public void testPrimitiveTypeParamAndNoReturnType() @Test(description = "test no params and primitive return type") public void testNoParamsAndPrimitiveReturnType() throws IOException, ExecutionException, InterruptedException { - Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnSignatureBalFile); + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); LinePosition fnPosition = LinePosition.from(60, 9); LinePosition returnTypeDescPosition = LinePosition.from(60, 31); - TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); Assert.assertNotNull(typesFromSymbolResponse.getTypes()); @@ -502,7 +502,7 @@ public void testInvalidFilePath() throws ExecutionException, InterruptedExceptio LinePosition fnPosition = LinePosition.from(60, 9); LinePosition returnTypeDescPosition = LinePosition.from(60, 31); - TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnSignature( + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( URI.create("file://+"), fnPosition, returnTypeDescPosition, this.serviceEndpoint); Assert.assertEquals(typesFromSymbolResponse.getTypes().size(), 0); diff --git a/language-server/modules/langserver-core/src/test/resources/extensions/symbol/typesFromFnSignature.bal b/language-server/modules/langserver-core/src/test/resources/extensions/symbol/typesFromFnDefinition.bal similarity index 100% rename from language-server/modules/langserver-core/src/test/resources/extensions/symbol/typesFromFnSignature.bal rename to language-server/modules/langserver-core/src/test/resources/extensions/symbol/typesFromFnDefinition.bal From ee6880712e7e3adc5d78b39e7e595be716ab2713 Mon Sep 17 00:00:00 2001 From: Madusha Date: Fri, 11 Nov 2022 09:01:28 +0530 Subject: [PATCH 115/450] Minor refactoring --- .../ballerina/symbol/TypesFromFnDefinitionRequest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/TypesFromFnDefinitionRequest.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/TypesFromFnDefinitionRequest.java index 3da1197e50c2..0c53c5040cf8 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/TypesFromFnDefinitionRequest.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/TypesFromFnDefinitionRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, WSO2 Inc. (http://wso2.com) All Rights Reserved. + * Copyright (c) 2022, WSO2 Inc. (http://wso2.com) All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ import org.eclipse.lsp4j.TextDocumentIdentifier; /** - * Represents a request to get type info given for given positions of symbols. + * Represents a request to get type info of params and return type desc of a given function definition. */ public class TypesFromFnDefinitionRequest { private TextDocumentIdentifier documentIdentifier; From 4eb90de2bcd68583e9ceb08d4e9aa8003ab4d915 Mon Sep 17 00:00:00 2001 From: Madusha Date: Fri, 11 Nov 2022 11:49:51 +0530 Subject: [PATCH 116/450] Fix checkstyles --- .../langserver/extensions/LSExtensionTestUtil.java | 2 +- .../extensions/symbol/TypesFromFnDefinitionTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/LSExtensionTestUtil.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/LSExtensionTestUtil.java index 3e943a61823f..1d060f60bdc5 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/LSExtensionTestUtil.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/LSExtensionTestUtil.java @@ -33,9 +33,9 @@ import org.ballerinalang.langserver.extensions.ballerina.symbol.SymbolInfoRequest; import org.ballerinalang.langserver.extensions.ballerina.symbol.SymbolInfoResponse; import org.ballerinalang.langserver.extensions.ballerina.symbol.TypeFromExpressionRequest; -import org.ballerinalang.langserver.extensions.ballerina.symbol.TypesFromFnDefinitionRequest; import org.ballerinalang.langserver.extensions.ballerina.symbol.TypeFromSymbolRequest; import org.ballerinalang.langserver.extensions.ballerina.symbol.TypesFromExpressionResponse; +import org.ballerinalang.langserver.extensions.ballerina.symbol.TypesFromFnDefinitionRequest; import org.ballerinalang.langserver.extensions.ballerina.symbol.TypesFromSymbolResponse; import org.ballerinalang.langserver.util.FileUtils; import org.ballerinalang.langserver.util.TestUtil; diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnDefinitionTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnDefinitionTest.java index a7829717dae9..fd6b259ac433 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnDefinitionTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnDefinitionTest.java @@ -177,7 +177,7 @@ public void testTypesForMultipleParamsAndPrimitiveTypeReturn() TestUtil.closeDocument(this.serviceEndpoint, inputFile); } - @Test(description = "type info retrieved for record type(from http module) param and record type(from jwt module) return") + @Test(description = "type info retrieved for record type param and record type return (types from modules)") public void testTypesForRecordTypeParamAndRecordTypeReturn2() throws IOException, ExecutionException, InterruptedException { Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); @@ -281,7 +281,7 @@ public void testTypesForRecordTypeArrayParamsAndRecordTypeArrayReturn() TestUtil.closeDocument(this.serviceEndpoint, inputFile); } - @Test(description = "type info retrieved for record type(from imported module) array params and record type(from imported module) array return") + @Test(description = "type info retrieved for record array params and record array return (types from modules)") public void testTypesForRecordTypeArrayParamsAndRecordTypeArrayReturn2() throws IOException, ExecutionException, InterruptedException { Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); From 71bdd051149a9e5193f3c5e3c494dd07a19856ec Mon Sep 17 00:00:00 2001 From: Madusha Date: Sat, 12 Nov 2022 13:03:56 +0530 Subject: [PATCH 117/450] Prevent using std libs for unit tests --- .../symbol/SymbolServiceTestUtil.java | 3 +- .../symbol/TypesFromFnDefinitionTest.java | 193 ++++++++++-------- .../symbol/typesFromFnDefinition.bal | 9 +- 3 files changed, 111 insertions(+), 94 deletions(-) diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolServiceTestUtil.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolServiceTestUtil.java index bf9a097fb511..9c613ddbcf0b 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolServiceTestUtil.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolServiceTestUtil.java @@ -31,7 +31,8 @@ public class SymbolServiceTestUtil { public static final String UNION = "union"; public static final String ERROR = "error"; public static final String NULL = "()"; - public static final String NEVER = "never"; + public static final String INTERSECTION = "intersection"; + public static final String READ_ONLY = "readonly"; public static boolean isPositionsEquals(LinePosition expectedPosition, LinePosition actualPosition) { return expectedPosition.line() == actualPosition.line() diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnDefinitionTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnDefinitionTest.java index fd6b259ac433..fcf5e4118f90 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnDefinitionTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnDefinitionTest.java @@ -18,6 +18,7 @@ import io.ballerina.tools.text.LinePosition; import org.ballerinalang.diagramutil.connector.models.connector.Type; import org.ballerinalang.diagramutil.connector.models.connector.types.ArrayType; +import org.ballerinalang.diagramutil.connector.models.connector.types.IntersectionType; import org.ballerinalang.diagramutil.connector.models.connector.types.RecordType; import org.ballerinalang.diagramutil.connector.models.connector.types.UnionType; import org.ballerinalang.langserver.extensions.LSExtensionTestUtil; @@ -57,9 +58,9 @@ public void testTypesForPrimitiveTypeParamAndPrimitiveTypeReturn() URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); - LinePosition fnPosition = LinePosition.from(33, 9); - LinePosition paramPosition = LinePosition.from(33, 27); - LinePosition returnTypeDescPosition = LinePosition.from(33, 40); + LinePosition fnPosition = LinePosition.from(32, 9); + LinePosition paramPosition = LinePosition.from(32, 27); + LinePosition returnTypeDescPosition = LinePosition.from(32, 40); TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); @@ -85,9 +86,9 @@ public void testTypesForRecordTypeParamAndRecordTypeReturn() URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); - LinePosition fnPosition = LinePosition.from(35, 9); - LinePosition paramPosition = LinePosition.from(35, 27); - LinePosition returnTypeDescPosition = LinePosition.from(33, 43); + LinePosition fnPosition = LinePosition.from(34, 9); + LinePosition paramPosition = LinePosition.from(34, 27); + LinePosition returnTypeDescPosition = LinePosition.from(34, 43); TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); @@ -113,11 +114,11 @@ public void testTypesForMultipleParamsAndRecordTypeReturn() URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); - LinePosition fnPosition = LinePosition.from(37, 9); - LinePosition param1Position = LinePosition.from(37, 27); - LinePosition param2Position = LinePosition.from(37, 42); - LinePosition param3Position = LinePosition.from(37, 61); - LinePosition returnTypeDescPosition = LinePosition.from(37, 81); + LinePosition fnPosition = LinePosition.from(36, 9); + LinePosition param1Position = LinePosition.from(36, 27); + LinePosition param2Position = LinePosition.from(36, 42); + LinePosition param3Position = LinePosition.from(36, 61); + LinePosition returnTypeDescPosition = LinePosition.from(36, 81); TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); @@ -151,10 +152,10 @@ public void testTypesForMultipleParamsAndPrimitiveTypeReturn() URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); - LinePosition fnPosition = LinePosition.from(39, 9); - LinePosition param1Position = LinePosition.from(39, 27); - LinePosition param2Position = LinePosition.from(39, 39); - LinePosition returnTypeDescPosition = LinePosition.from(39, 50); + LinePosition fnPosition = LinePosition.from(38, 9); + LinePosition param1Position = LinePosition.from(38, 27); + LinePosition param2Position = LinePosition.from(38, 39); + LinePosition returnTypeDescPosition = LinePosition.from(38, 50); TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); @@ -184,9 +185,9 @@ public void testTypesForRecordTypeParamAndRecordTypeReturn2() URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); - LinePosition fnPosition = LinePosition.from(41, 9); - LinePosition paramPosition = LinePosition.from(41, 33); - LinePosition returnTypeDescPosition = LinePosition.from(41, 50); + LinePosition fnPosition = LinePosition.from(40, 9); + LinePosition paramPosition = LinePosition.from(40, 39); + LinePosition returnTypeDescPosition = LinePosition.from(40, 57); TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); @@ -194,12 +195,12 @@ public void testTypesForRecordTypeParamAndRecordTypeReturn2() Assert.assertNotNull(typesFromSymbolResponse.getTypes()); ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); - assertCertKeyType(returnType.getType(), "jwt"); + assertTypeIdType(returnType.getType()); Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals( returnTypeDescPosition, returnType.getRequestedPosition())); ResolvedTypeForSymbol paramType = typesFromSymbolResponse.getTypes().get(1); - assertCertKeyType(paramType.getType(), "http"); + assertModuleIdType(paramType.getType()); Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(paramPosition, paramType.getRequestedPosition())); TestUtil.closeDocument(this.serviceEndpoint, inputFile); @@ -212,9 +213,9 @@ public void testTypesForPrimitiveTypeArrayParamAndPrimitiveTypeArrayReturn() URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); - LinePosition fnPosition = LinePosition.from(43, 9); - LinePosition paramPosition = LinePosition.from(43, 29); - LinePosition returnTypeDescPosition = LinePosition.from(43, 44); + LinePosition fnPosition = LinePosition.from(42, 9); + LinePosition paramPosition = LinePosition.from(42, 29); + LinePosition returnTypeDescPosition = LinePosition.from(42, 44); TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); @@ -246,10 +247,10 @@ public void testTypesForRecordTypeArrayParamsAndRecordTypeArrayReturn() URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); - LinePosition fnPosition = LinePosition.from(45, 9); - LinePosition param1Position = LinePosition.from(45, 29); - LinePosition param2Position = LinePosition.from(45, 46); - LinePosition returnTypeDescPosition = LinePosition.from(45, 63); + LinePosition fnPosition = LinePosition.from(44, 9); + LinePosition param1Position = LinePosition.from(44, 29); + LinePosition param2Position = LinePosition.from(44, 46); + LinePosition returnTypeDescPosition = LinePosition.from(44, 63); TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); @@ -288,9 +289,9 @@ public void testTypesForRecordTypeArrayParamsAndRecordTypeArrayReturn2() URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); - LinePosition fnPosition = LinePosition.from(47, 9); - LinePosition paramPosition = LinePosition.from(47, 35); - LinePosition returnTypeDescPosition = LinePosition.from(47, 49); + LinePosition fnPosition = LinePosition.from(46, 9); + LinePosition paramPosition = LinePosition.from(46, 41); + LinePosition returnTypeDescPosition = LinePosition.from(46, 60); TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); @@ -303,14 +304,14 @@ public void testTypesForRecordTypeArrayParamsAndRecordTypeArrayReturn2() returnTypeDescPosition, returnType.getRequestedPosition())); Assert.assertTrue(returnType.getType() instanceof ArrayType); ArrayType arrayReturnType = (ArrayType) returnType.getType(); - assertCertKeyType(arrayReturnType.memberType, "jwt"); + assertTypeIdType(arrayReturnType.memberType); ResolvedTypeForSymbol paramType = typesFromSymbolResponse.getTypes().get(1); Assert.assertEquals(paramType.getType().typeName, SymbolServiceTestUtil.ARRAY); Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(paramPosition, paramType.getRequestedPosition())); Assert.assertTrue(paramType.getType() instanceof ArrayType); ArrayType arrayParamType = (ArrayType) paramType.getType(); - assertCertKeyType(arrayParamType.memberType, "http"); + assertModuleIdType(arrayParamType.memberType); TestUtil.closeDocument(this.serviceEndpoint, inputFile); } @@ -322,9 +323,9 @@ public void testTypesForOptionalRecordTypeParamAndOptionalRecordTypeReturn() URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); - LinePosition fnPosition = LinePosition.from(49, 9); - LinePosition paramPosition = LinePosition.from(49, 28); - LinePosition returnTypeDescPosition = LinePosition.from(49, 44); + LinePosition fnPosition = LinePosition.from(48, 9); + LinePosition paramPosition = LinePosition.from(48, 28); + LinePosition returnTypeDescPosition = LinePosition.from(48, 44); TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); @@ -360,9 +361,9 @@ public void testTypesForPrimitiveTypeDefaultableParamAndPrimitiveTypeReturn() URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); - LinePosition fnPosition = LinePosition.from(51, 9); - LinePosition paramPosition = LinePosition.from(51, 28); - LinePosition returnTypeDescPosition = LinePosition.from(51, 46); + LinePosition fnPosition = LinePosition.from(50, 9); + LinePosition paramPosition = LinePosition.from(50, 28); + LinePosition returnTypeDescPosition = LinePosition.from(50, 46); TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); @@ -394,9 +395,9 @@ public void testTypesForInlineRecordTypeParamAndInlineRecordTypeReturn() URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); - LinePosition fnPosition = LinePosition.from(53, 9); - LinePosition paramPosition = LinePosition.from(53, 74); - LinePosition returnTypeDescPosition = LinePosition.from(54, 12); + LinePosition fnPosition = LinePosition.from(52, 9); + LinePosition paramPosition = LinePosition.from(52, 74); + LinePosition returnTypeDescPosition = LinePosition.from(53, 12); TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); @@ -434,7 +435,7 @@ public void testNoParamsAndNoReturnType() URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); - LinePosition fnPosition = LinePosition.from(56, 9); + LinePosition fnPosition = LinePosition.from(55, 9); TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( uri, fnPosition, null, this.serviceEndpoint); @@ -456,8 +457,8 @@ public void testPrimitiveTypeParamAndNoReturnType() URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); - LinePosition fnPosition = LinePosition.from(58, 9); - LinePosition paramPosition = LinePosition.from(58, 28); + LinePosition fnPosition = LinePosition.from(57, 9); + LinePosition paramPosition = LinePosition.from(57, 28); TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( uri, fnPosition, null, this.serviceEndpoint); @@ -482,8 +483,8 @@ public void testNoParamsAndPrimitiveReturnType() URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); - LinePosition fnPosition = LinePosition.from(60, 9); - LinePosition returnTypeDescPosition = LinePosition.from(60, 31); + LinePosition fnPosition = LinePosition.from(59, 9); + LinePosition returnTypeDescPosition = LinePosition.from(59, 31); TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); @@ -499,8 +500,8 @@ public void testNoParamsAndPrimitiveReturnType() @Test(description = "test invalid file path") public void testInvalidFilePath() throws ExecutionException, InterruptedException { - LinePosition fnPosition = LinePosition.from(60, 9); - LinePosition returnTypeDescPosition = LinePosition.from(60, 31); + LinePosition fnPosition = LinePosition.from(59, 9); + LinePosition returnTypeDescPosition = LinePosition.from(59, 31); TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( URI.create("file://+"), fnPosition, returnTypeDescPosition, this.serviceEndpoint); @@ -560,30 +561,7 @@ private void assertSubmissionType(Type resolvedType) { Assert.assertEquals(submissionRecordType.fields.get(1).name, "date"); Assert.assertEquals(submissionRecordType.fields.get(1).typeName, SymbolServiceTestUtil.STRING); - Assert.assertEquals(submissionRecordType.fields.get(2).name, "params"); - Assert.assertEquals(submissionRecordType.fields.get(2).typeInfo.name, "QueryParams"); - Assert.assertEquals(submissionRecordType.fields.get(2).typeInfo.orgName, "ballerina"); - Assert.assertEquals(submissionRecordType.fields.get(2).typeInfo.moduleName, "http"); - Assert.assertTrue(submissionRecordType.fields.get(2) instanceof RecordType); - RecordType queryParamsRecordType = (RecordType) submissionRecordType.fields.get(2); - Assert.assertEquals(queryParamsRecordType.fields.size(), 4); - - Assert.assertEquals(queryParamsRecordType.fields.get(0).name, "headers"); - Assert.assertEquals(queryParamsRecordType.fields.get(0).typeName, SymbolServiceTestUtil.NEVER); - Assert.assertTrue(queryParamsRecordType.fields.get(0).optional); - Assert.assertEquals(queryParamsRecordType.fields.get(1).name, "targetType"); - Assert.assertEquals(queryParamsRecordType.fields.get(1).typeName, SymbolServiceTestUtil.NEVER); - Assert.assertTrue(queryParamsRecordType.fields.get(1).optional); - Assert.assertEquals(queryParamsRecordType.fields.get(2).name, "message"); - Assert.assertEquals(queryParamsRecordType.fields.get(2).typeName, SymbolServiceTestUtil.NEVER); - Assert.assertTrue(queryParamsRecordType.fields.get(2).optional); - Assert.assertEquals(queryParamsRecordType.fields.get(3).name, "mediaType"); - Assert.assertEquals(queryParamsRecordType.fields.get(3).typeName, SymbolServiceTestUtil.NEVER); - Assert.assertTrue(queryParamsRecordType.fields.get(3).optional); - Assert.assertTrue(queryParamsRecordType.hasRestType); - Assert.assertTrue(queryParamsRecordType.restType instanceof UnionType); - UnionType unionType = (UnionType) queryParamsRecordType.restType; - Assert.assertEquals(unionType.members.size(), 6); + assertModuleIdType(submissionRecordType.fields.get(2)); } private void assertStudentType(Type resolvedType) { @@ -622,24 +600,63 @@ private void assertStudentType(Type resolvedType) { Assert.assertEquals(studentRecordType.fields.get(4).typeName, SymbolServiceTestUtil.INTEGER); } - private void assertCertKeyType(Type resolvedType, String module) { - Assert.assertEquals(resolvedType.typeName, SymbolServiceTestUtil.RECORD); - Assert.assertEquals(resolvedType.name, "CertKey"); - Assert.assertTrue(resolvedType instanceof RecordType); - RecordType certKeyRecordType = (RecordType) resolvedType; - Assert.assertEquals(certKeyRecordType.typeInfo.name, "CertKey"); - Assert.assertEquals(certKeyRecordType.typeInfo.orgName, "ballerina"); - Assert.assertEquals(certKeyRecordType.typeInfo.moduleName, module); - Assert.assertEquals(certKeyRecordType.fields.size(), 3); + private void assertModuleIdType(Type resolvedType) { + Assert.assertEquals(resolvedType.typeName, SymbolServiceTestUtil.INTERSECTION); + Assert.assertEquals(resolvedType.typeInfo.name, "ModuleId"); + Assert.assertEquals(resolvedType.typeInfo.orgName, "ballerina"); + Assert.assertEquals(resolvedType.typeInfo.moduleName, "lang.typedesc"); + Assert.assertTrue(resolvedType instanceof IntersectionType); + IntersectionType moduleIdRecordType = (IntersectionType) resolvedType; + Assert.assertEquals(moduleIdRecordType.members.size(), 2); + + Assert.assertEquals(moduleIdRecordType.members.get(0).typeName, SymbolServiceTestUtil.RECORD); + Assert.assertNull(moduleIdRecordType.members.get(0).name); + Assert.assertTrue(moduleIdRecordType.members.get(0) instanceof RecordType); + RecordType recordType = (RecordType) moduleIdRecordType.members.get(0); + + Assert.assertEquals(recordType.fields.size(), 3); + Assert.assertEquals(recordType.fields.get(0).name, "organization"); + Assert.assertEquals(recordType.fields.get(0).typeName, SymbolServiceTestUtil.STRING); + Assert.assertEquals(recordType.fields.get(1).name, "name"); + Assert.assertEquals(recordType.fields.get(1).typeName, SymbolServiceTestUtil.STRING); + Assert.assertEquals(recordType.fields.get(2).name, "platformParts"); + Assert.assertEquals(recordType.fields.get(2).typeName, SymbolServiceTestUtil.ARRAY); + Assert.assertTrue(recordType.fields.get(2) instanceof ArrayType); + ArrayType arrayReturnType = (ArrayType) recordType.fields.get(2); + Assert.assertEquals(arrayReturnType.memberType.typeName, SymbolServiceTestUtil.STRING); - Assert.assertEquals(certKeyRecordType.fields.get(0).name, "certFile"); - Assert.assertEquals(certKeyRecordType.fields.get(0).typeName, SymbolServiceTestUtil.STRING); + Assert.assertEquals(moduleIdRecordType.members.get(1).typeName, SymbolServiceTestUtil.READ_ONLY); + Assert.assertNull(moduleIdRecordType.members.get(1).name); + } - Assert.assertEquals(certKeyRecordType.fields.get(1).name, "keyFile"); - Assert.assertEquals(certKeyRecordType.fields.get(1).typeName, SymbolServiceTestUtil.STRING); + private void assertTypeIdType(Type resolvedType) { + Assert.assertEquals(resolvedType.typeName, SymbolServiceTestUtil.INTERSECTION); + Assert.assertEquals(resolvedType.typeInfo.name, "TypeId"); + Assert.assertEquals(resolvedType.typeInfo.orgName, "ballerina"); + Assert.assertEquals(resolvedType.typeInfo.moduleName, "lang.typedesc"); + Assert.assertTrue(resolvedType instanceof IntersectionType); + IntersectionType typeIdRecordType = (IntersectionType) resolvedType; + Assert.assertEquals(typeIdRecordType.members.size(), 2); + + Assert.assertEquals(typeIdRecordType.members.get(0).typeName, SymbolServiceTestUtil.RECORD); + Assert.assertNull(typeIdRecordType.members.get(0).name); + Assert.assertTrue(typeIdRecordType.members.get(0) instanceof RecordType); + RecordType recordType = (RecordType) typeIdRecordType.members.get(0); + + Assert.assertEquals(recordType.fields.size(), 2); + Assert.assertEquals(recordType.fields.get(0).name, "moduleId"); + Assert.assertEquals(recordType.fields.get(0).typeName, SymbolServiceTestUtil.INTERSECTION); + assertModuleIdType(recordType.fields.get(0)); + Assert.assertEquals(recordType.fields.get(1).name, "localId"); + Assert.assertEquals(recordType.fields.get(1).typeName, SymbolServiceTestUtil.UNION); + + Assert.assertTrue(recordType.fields.get(1) instanceof UnionType); + UnionType unionType = (UnionType) recordType.fields.get(1); + Assert.assertEquals(unionType.members.size(), 2); + Assert.assertEquals(unionType.members.get(0).typeName, SymbolServiceTestUtil.STRING); + Assert.assertEquals(unionType.members.get(1).typeName, SymbolServiceTestUtil.INTEGER); - Assert.assertEquals(certKeyRecordType.fields.get(2).name, "keyPassword"); - Assert.assertEquals(certKeyRecordType.fields.get(2).typeName, SymbolServiceTestUtil.STRING); - Assert.assertTrue(certKeyRecordType.fields.get(2).optional); + Assert.assertEquals(typeIdRecordType.members.get(1).typeName, SymbolServiceTestUtil.READ_ONLY); + Assert.assertNull(typeIdRecordType.members.get(1).name); } } diff --git a/language-server/modules/langserver-core/src/test/resources/extensions/symbol/typesFromFnDefinition.bal b/language-server/modules/langserver-core/src/test/resources/extensions/symbol/typesFromFnDefinition.bal index 19c4b0c4a5f3..a6b0e54f30ce 100644 --- a/language-server/modules/langserver-core/src/test/resources/extensions/symbol/typesFromFnDefinition.bal +++ b/language-server/modules/langserver-core/src/test/resources/extensions/symbol/typesFromFnDefinition.bal @@ -1,5 +1,4 @@ -import ballerina/http; -import ballerina/jwt; +import ballerina/lang.'typedesc; type Person record { int id; @@ -17,7 +16,7 @@ type Course record { type Submission record { int id = 0; string date; - http:QueryParams params; + 'typedesc:ModuleId moduleId; }; type Student record { @@ -39,13 +38,13 @@ function transform3(Person person, Course course, Submission submission) returns function transform4(Person person, int i) returns float => 0.0; -function transform5(http:CertKey certKey) returns jwt:CertKey => {}; +function transform5('typedesc:ModuleId moduleId) returns 'typedesc:TypeId => {}; function transform6(string[] names) returns string[] => []; function transform7(Person[] people, Course[] courses) returns Student[] => []; -function transform8(http:CertKey[] keys) returns jwt:CertKey[] => []; +function transform8('typedesc:ModuleId[] moduleIds) returns 'typedesc:TypeId[] => []; function transform9(Person? person) returns Student? => {}; From 94a19301567934dcfd4d154d7006568a501cdf1f Mon Sep 17 00:00:00 2001 From: Madusha Date: Tue, 15 Nov 2022 23:09:48 +0530 Subject: [PATCH 118/450] Improve symbol service tests --- .../symbol/TypesFromFnDefinitionTest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnDefinitionTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnDefinitionTest.java index fcf5e4118f90..a43d87aceb53 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnDefinitionTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnDefinitionTest.java @@ -509,6 +509,20 @@ public void testInvalidFilePath() throws ExecutionException, InterruptedExceptio Assert.assertEquals(typesFromSymbolResponse.getTypes().size(), 0); } + @Test(description = "test empty positions") + public void testEmptyPositions() throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( + uri, null, null, this.serviceEndpoint); + + Assert.assertEquals(typesFromSymbolResponse.getTypes().size(), 0); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + private void assertPersonType(Type resolvedType) { Assert.assertEquals(resolvedType.typeName, SymbolServiceTestUtil.RECORD); Assert.assertEquals(resolvedType.name, "Person"); From 4aee6d3f0670b7c8de55f0ad40648af164dc2f51 Mon Sep 17 00:00:00 2001 From: Madusha Date: Tue, 15 Nov 2022 23:09:58 +0530 Subject: [PATCH 119/450] Minor refactoring --- .../symbol/BallerinaSymbolService.java | 63 +++++++++---------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolService.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolService.java index 8a17c076c15a..243d1d965c6e 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolService.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolService.java @@ -236,25 +236,24 @@ public CompletableFuture getTypesFromFnDefinition(Types Optional semanticModel = this.workspaceManagerProxy.get(fileUri).semanticModel(filePath.get()); Optional document = workspaceManagerProxy.get(fileUri).document(filePath.get()); - if (semanticModel.isEmpty() || document.isEmpty()) { - return typeFromSymbolResponse; - } - LinePosition fnPosition = request.getFnPosition(); - Optional symbol = semanticModel.get().symbol(document.get(), fnPosition); - if (symbol.isPresent()) { - Symbol fnSymbol = symbol.get(); - if (fnSymbol instanceof FunctionSymbol) { - FunctionTypeSymbol fnTypeSymbol = ((FunctionSymbol) fnSymbol).typeDescriptor(); - - Optional returnType = - getTypeForReturnTypeDesc(fnTypeSymbol, request.getReturnTypeDescPosition()); - returnType.ifPresent(types::add); - - Optional> paramTypes = getTypesForFnParams(fnTypeSymbol); - paramTypes.ifPresent(types::addAll); + if (semanticModel.isPresent() && document.isPresent()) { + LinePosition fnPosition = request.getFnPosition(); + Optional symbol = semanticModel.get().symbol(document.get(), fnPosition); + if (symbol.isPresent()) { + Symbol fnSymbol = symbol.get(); + if (fnSymbol instanceof FunctionSymbol) { + FunctionTypeSymbol fnTypeSymbol = ((FunctionSymbol) fnSymbol).typeDescriptor(); + + Optional returnType = + getTypeForReturnTypeDesc(fnTypeSymbol, request.getReturnTypeDescPosition()); + returnType.ifPresent(types::add); + + List paramTypes = getTypesForFnParams(fnTypeSymbol); + types.addAll(paramTypes); + } } + typeFromSymbolResponse.setTypes(types); } - typeFromSymbolResponse.setTypes(types); return typeFromSymbolResponse; } catch (Throwable e) { String msg = "Operation 'ballerinaSymbol/getTypesFromFnDefinition' failed!"; @@ -474,25 +473,23 @@ private Optional getTypeForReturnTypeDesc(FunctionTypeSym return Optional.of(resolvedType); } - private Optional> getTypesForFnParams(FunctionTypeSymbol fnTypeSymbol) { - Optional> params = fnTypeSymbol.params(); - if (params.isEmpty()) { - return Optional.empty(); - } + private List getTypesForFnParams(FunctionTypeSymbol fnTypeSymbol) { List types = new ArrayList<>(); - for (ParameterSymbol param: params.get()) { - Optional location = param.getLocation(); - if (location.isEmpty()) { - return Optional.empty(); + Optional> params = fnTypeSymbol.params(); + if (params.isPresent()) { + for (ParameterSymbol param: params.get()) { + Optional location = param.getLocation(); + if (location.isPresent()) { + LinePosition paramPosition = location.get().lineRange().startLine(); + ResolvedTypeForSymbol resolvedType = new ResolvedTypeForSymbol(paramPosition); + Type type = Type.fromSemanticSymbol(param); + Type.clearParentSymbols(); + resolvedType.setType(type); + types.add(resolvedType); + } } - LinePosition paramPosition = location.get().lineRange().startLine(); - ResolvedTypeForSymbol resolvedType = new ResolvedTypeForSymbol(paramPosition); - Type type = Type.fromSemanticSymbol(param); - Type.clearParentSymbols(); - resolvedType.setType(type); - types.add(resolvedType); } - return Optional.of(types); + return types; } @Override From bc840c7b0ed138afe05156f9aed00fa2741b7ff5 Mon Sep 17 00:00:00 2001 From: Madusha Date: Wed, 23 Nov 2022 23:06:08 +0530 Subject: [PATCH 120/450] Replace empty checks with orElseThrow in symbol service --- .../symbol/BallerinaSymbolService.java | 103 ++++++++---------- 1 file changed, 47 insertions(+), 56 deletions(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolService.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolService.java index 243d1d965c6e..f0e4bb13a1f1 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolService.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolService.java @@ -148,31 +148,26 @@ public CompletableFuture getTypeFromExpression(Type String fileUri = request.getDocumentIdentifier().getUri(); String[] pathSegments = fileUri.split("/"); String fileName = pathSegments[pathSegments.length - 1]; - Optional filePath = PathUtil.getPathFromURI(fileUri); - if (filePath.isEmpty()) { - return typesResponse; - } List types = new ArrayList<>(); try { + Path filePath = PathUtil.getPathFromURI(fileUri).orElseThrow(); for (LineRange range: request.getExpressionRanges()) { ResolvedTypeForExpression resolvedType = new ResolvedTypeForExpression(range); - - Optional semanticModel = - this.workspaceManagerProxy.get(fileUri).semanticModel(filePath.get()); - if (semanticModel.isEmpty()) { - return typesResponse; - } - LinePosition start = range.startLine(); - LinePosition end = range.endLine(); - LineRange lineRange = LineRange.from(fileName, start, end); - Optional typeSymbol; - if (semanticModel.get().typeOf(lineRange).isPresent()) { - typeSymbol = semanticModel.get().typeOf(lineRange); - Type.clearParentSymbols(); - Type type = typeSymbol.map(Type::fromSemanticSymbol).orElse(null); - resolvedType.setType(type); - types.add(resolvedType); - } + SemanticModel semanticModel = this.workspaceManagerProxy + .get(fileUri) + .semanticModel(filePath) + .orElseThrow(); + LinePosition start = range.startLine(); + LinePosition end = range.endLine(); + LineRange lineRange = LineRange.from(fileName, start, end); + Optional typeSymbol; + if (semanticModel.typeOf(lineRange).isPresent()) { + typeSymbol = semanticModel.typeOf(lineRange); + Type.clearParentSymbols(); + Type type = typeSymbol.map(Type::fromSemanticSymbol).orElse(null); + resolvedType.setType(type); + types.add(resolvedType); + } } typesResponse.setTypes(types); return typesResponse; @@ -190,22 +185,21 @@ public CompletableFuture getTypeFromSymbol(TypeFromSymb return CompletableFuture.supplyAsync(() -> { TypesFromSymbolResponse typeFromSymbolResponse = new TypesFromSymbolResponse(); String fileUri = request.getDocumentIdentifier().getUri(); - Optional filePath = PathUtil.getPathFromURI(fileUri); - if (filePath.isEmpty()) { - return typeFromSymbolResponse; - } List types = new ArrayList<>(); try { + Path filePath = PathUtil.getPathFromURI(fileUri).orElseThrow(); for (LinePosition position: request.getPositions()) { ResolvedTypeForSymbol resolvedType = new ResolvedTypeForSymbol(position); - Optional semanticModel = - this.workspaceManagerProxy.get(fileUri).semanticModel(filePath.get()); - Optional document = workspaceManagerProxy.get(fileUri).document(filePath.get()); - if (semanticModel.isEmpty() || document.isEmpty()) { - return typeFromSymbolResponse; - } + SemanticModel semanticModel = this.workspaceManagerProxy + .get(fileUri) + .semanticModel(filePath) + .orElseThrow(); + Document document = this.workspaceManagerProxy + .get(fileUri) + .document(filePath) + .orElseThrow(); LinePosition linePosition = LinePosition.from(position.line(), position.offset()); - Optional symbol = semanticModel.get().symbol(document.get(), linePosition); + Optional symbol = semanticModel.symbol(document, linePosition); Type.clearParentSymbols(); Type type = symbol.map(Type::fromSemanticSymbol).orElse(null); resolvedType.setType(type); @@ -227,33 +221,30 @@ public CompletableFuture getTypesFromFnDefinition(Types return CompletableFuture.supplyAsync(() -> { TypesFromSymbolResponse typeFromSymbolResponse = new TypesFromSymbolResponse(); String fileUri = request.getDocumentIdentifier().getUri(); - Optional filePath = PathUtil.getPathFromURI(fileUri); - if (filePath.isEmpty()) { - return typeFromSymbolResponse; - } List types = new ArrayList<>(); try { - Optional semanticModel = - this.workspaceManagerProxy.get(fileUri).semanticModel(filePath.get()); - Optional document = workspaceManagerProxy.get(fileUri).document(filePath.get()); - if (semanticModel.isPresent() && document.isPresent()) { - LinePosition fnPosition = request.getFnPosition(); - Optional symbol = semanticModel.get().symbol(document.get(), fnPosition); - if (symbol.isPresent()) { - Symbol fnSymbol = symbol.get(); - if (fnSymbol instanceof FunctionSymbol) { - FunctionTypeSymbol fnTypeSymbol = ((FunctionSymbol) fnSymbol).typeDescriptor(); - - Optional returnType = - getTypeForReturnTypeDesc(fnTypeSymbol, request.getReturnTypeDescPosition()); - returnType.ifPresent(types::add); - - List paramTypes = getTypesForFnParams(fnTypeSymbol); - types.addAll(paramTypes); - } - } - typeFromSymbolResponse.setTypes(types); + Path filePath = PathUtil.getPathFromURI(fileUri).orElseThrow(); + SemanticModel semanticModel = this.workspaceManagerProxy + .get(fileUri) + .semanticModel(filePath) + .orElseThrow(); + Document document = this.workspaceManagerProxy + .get(fileUri) + .document(filePath) + .orElseThrow(); + LinePosition fnPosition = request.getFnPosition(); + Symbol fnSymbol = semanticModel.symbol(document, fnPosition).orElseThrow(); + if (fnSymbol instanceof FunctionSymbol) { + FunctionTypeSymbol fnTypeSymbol = ((FunctionSymbol) fnSymbol).typeDescriptor(); + + Optional returnType = + getTypeForReturnTypeDesc(fnTypeSymbol, request.getReturnTypeDescPosition()); + returnType.ifPresent(types::add); + + List paramTypes = getTypesForFnParams(fnTypeSymbol); + types.addAll(paramTypes); } + typeFromSymbolResponse.setTypes(types); return typeFromSymbolResponse; } catch (Throwable e) { String msg = "Operation 'ballerinaSymbol/getTypesFromFnDefinition' failed!"; From b9225d209ffdd5223d7d765d1a233e8da2d9e954 Mon Sep 17 00:00:00 2001 From: praneesha Date: Mon, 28 Nov 2022 12:53:49 +0530 Subject: [PATCH 121/450] Update 2 more README files --- language-server/README.md | 2 +- misc/json-to-record-converter/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/language-server/README.md b/language-server/README.md index 0974f63d3a04..6af6efe6863d 100644 --- a/language-server/README.md +++ b/language-server/README.md @@ -40,4 +40,4 @@ Ballerina Language Server is currently work in progress and feel free to follow ## Contact Us Managed By [WSO2 Inc.](https://wso2.com/) -Slack channel : [Ballerina Platform](https://ballerina-platform.slack.com/) +Discord server: [Ballerina](https://discord.gg/ballerinalang) diff --git a/misc/json-to-record-converter/README.md b/misc/json-to-record-converter/README.md index 15e2449b1763..1fd52de7f277 100644 --- a/misc/json-to-record-converter/README.md +++ b/misc/json-to-record-converter/README.md @@ -511,4 +511,4 @@ The implementation can handle complex scenarios having many values with differen ## Contact Us Managed By [WSO2 Inc.](https://wso2.com/) -Slack channel : [Ballerina Platform](https://ballerina-platform.slack.com/) +Discord server: [Ballerina](https://discord.gg/ballerinalang) From 37f5a371ecad450cd289977503875c773711c4b3 Mon Sep 17 00:00:00 2001 From: Nadeeshan96 Date: Mon, 28 Nov 2022 13:19:23 +0530 Subject: [PATCH 122/450] Update writing and reading BIRPackage --- .../compiler/BIRPackageSymbolEnter.java | 7 ++++ .../compiler/bir/writer/BIRBinaryWriter.java | 39 +++++++++++++------ .../programfile/ProgramFileConstants.java | 6 +-- .../src/main/resources/kaitai/bir.ksy | 16 +++++--- 4 files changed, 48 insertions(+), 20 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/BIRPackageSymbolEnter.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/BIRPackageSymbolEnter.java index 834793a6d261..5a8fe862c268 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/BIRPackageSymbolEnter.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/BIRPackageSymbolEnter.java @@ -249,6 +249,9 @@ private BPackageSymbol definePackage(DataInputStream dataInStream, int pkgCpInde // Define package level variables. defineSymbols(dataInStream, rethrow(this::definePackageLevelVariables)); + // define imported package variables + defineSymbols(dataInStream, rethrow(this::defineImportedPackageVariables)); + readTypeDefBodies(dataInStream); // Define functions. @@ -895,6 +898,10 @@ private void definePackageLevelVariables(DataInputStream dataInStream) throws IO enclScope.define(varSymbol.name, varSymbol); } + private void defineImportedPackageVariables(DataInputStream dataInStream) throws IOException { + definePackageLevelVariables(dataInStream); + } + private void setParamSymbols(BInvokableSymbol invokableSymbol, DataInputStream dataInStream) throws IOException { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/writer/BIRBinaryWriter.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/writer/BIRBinaryWriter.java index 79c2b85f9a52..a6591be556fa 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/writer/BIRBinaryWriter.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/writer/BIRBinaryWriter.java @@ -46,6 +46,7 @@ import java.io.IOException; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; /** @@ -78,6 +79,8 @@ public byte[] serialize() { writeTypeDefs(birbuf, typeWriter, birPackage.typeDefs); // Write global vars writeGlobalVars(birbuf, typeWriter, birPackage.globalVars); + // Write dummy BIRGlobalVariableDcls for imported global vars + writeImportedGlobalVarIdentifiers(birbuf, typeWriter, birPackage.importedGlobalVarsDummyVarDcls); // Write type def bodies writeTypeDefBodies(birbuf, typeWriter, birPackage.typeDefs); // Write functions @@ -154,21 +157,33 @@ private void writeReferencedTypes(ByteBuf buf, List referencedTypes) { private void writeGlobalVars(ByteBuf buf, BIRTypeWriter typeWriter, List birGlobalVars) { buf.writeInt(birGlobalVars.size()); for (BIRGlobalVariableDcl birGlobalVar : birGlobalVars) { - writePosition(buf, birGlobalVar.pos); - buf.writeByte(birGlobalVar.kind.getValue()); - // Name - buf.writeInt(addStringCPEntry(birGlobalVar.name.value)); - // Flags - buf.writeLong(birGlobalVar.flags); - // Origin - buf.writeByte(birGlobalVar.origin.value()); + writeGlobalVar(buf, typeWriter, birGlobalVar); + } + } + + private void writeGlobalVar(ByteBuf buf, BIRTypeWriter typeWriter, BIRGlobalVariableDcl birGlobalVar) { + writePosition(buf, birGlobalVar.pos); + buf.writeByte(birGlobalVar.kind.getValue()); + // Name + buf.writeInt(addStringCPEntry(birGlobalVar.name.value)); + // Flags + buf.writeLong(birGlobalVar.flags); + // Origin + buf.writeByte(birGlobalVar.origin.value()); + + typeWriter.writeMarkdownDocAttachment(buf, birGlobalVar.markdownDocAttachment); - typeWriter.writeMarkdownDocAttachment(buf, birGlobalVar.markdownDocAttachment); + // Function type as a CP Index + writeType(buf, birGlobalVar.type); - // Function type as a CP Index - writeType(buf, birGlobalVar.type); + writeAnnotAttachments(buf, birGlobalVar.annotAttachments); + } - writeAnnotAttachments(buf, birGlobalVar.annotAttachments); + private void writeImportedGlobalVarIdentifiers(ByteBuf buf, BIRTypeWriter typeWriter, + Set importedGlobalVarsDummyVarDcls) { + buf.writeInt(importedGlobalVarsDummyVarDcls.size()); + for (BIRGlobalVariableDcl birGlobalVar : importedGlobalVarsDummyVarDcls) { + writeGlobalVar(buf, typeWriter, birGlobalVar); } } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/programfile/ProgramFileConstants.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/programfile/ProgramFileConstants.java index 5b23c9e385b0..845894c5c896 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/programfile/ProgramFileConstants.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/programfile/ProgramFileConstants.java @@ -25,9 +25,9 @@ public class ProgramFileConstants { public static final int MAGIC_NUMBER = 0xBA1DA4CE; public static final short VERSION_NUMBER = 50; - public static final int BIR_VERSION_NUMBER = 67; - public static final short MIN_SUPPORTED_VERSION = 67; - public static final short MAX_SUPPORTED_VERSION = 67; + public static final int BIR_VERSION_NUMBER = 68; + public static final short MIN_SUPPORTED_VERSION = 68; + public static final short MAX_SUPPORTED_VERSION = 68; // todo move this to a proper place public static final String[] SUPPORTED_PLATFORMS = {"java11"}; diff --git a/docs/bir-spec/src/main/resources/kaitai/bir.ksy b/docs/bir-spec/src/main/resources/kaitai/bir.ksy index 9d67d8fc1283..8a41c6990e52 100644 --- a/docs/bir-spec/src/main/resources/kaitai/bir.ksy +++ b/docs/bir-spec/src/main/resources/kaitai/bir.ksy @@ -512,12 +512,18 @@ types: type: type_definition repeat: expr repeat-expr: type_definition_count - - id: golbal_var_count + - id: global_var_count type: s4 - - id: golbal_vars - type: golbal_var + - id: global_vars + type: global_var repeat: expr - repeat-expr: golbal_var_count + repeat-expr: global_var_count + - id: imported_global_var_count + type: s4 + - id: imported_global_vars + type: global_var + repeat: expr + repeat-expr: global_var_count - id: type_definition_bodies_count type: s4 - id: type_definition_bodies @@ -542,7 +548,7 @@ types: type: service_declaration repeat: expr repeat-expr: service_decls_size - golbal_var: + global_var: seq: - id: position type: position From b16635050c1eec57cdeede1113e5b10c13b88f0f Mon Sep 17 00:00:00 2001 From: Nadeeshan96 Date: Mon, 28 Nov 2022 15:46:04 +0530 Subject: [PATCH 123/450] Revert "Update writing and reading BIRPackage" This reverts commit 37f5a371 --- .../compiler/BIRPackageSymbolEnter.java | 7 ---- .../compiler/bir/writer/BIRBinaryWriter.java | 39 ++++++------------- .../programfile/ProgramFileConstants.java | 6 +-- .../src/main/resources/kaitai/bir.ksy | 16 +++----- 4 files changed, 20 insertions(+), 48 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/BIRPackageSymbolEnter.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/BIRPackageSymbolEnter.java index 5a8fe862c268..834793a6d261 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/BIRPackageSymbolEnter.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/BIRPackageSymbolEnter.java @@ -249,9 +249,6 @@ private BPackageSymbol definePackage(DataInputStream dataInStream, int pkgCpInde // Define package level variables. defineSymbols(dataInStream, rethrow(this::definePackageLevelVariables)); - // define imported package variables - defineSymbols(dataInStream, rethrow(this::defineImportedPackageVariables)); - readTypeDefBodies(dataInStream); // Define functions. @@ -898,10 +895,6 @@ private void definePackageLevelVariables(DataInputStream dataInStream) throws IO enclScope.define(varSymbol.name, varSymbol); } - private void defineImportedPackageVariables(DataInputStream dataInStream) throws IOException { - definePackageLevelVariables(dataInStream); - } - private void setParamSymbols(BInvokableSymbol invokableSymbol, DataInputStream dataInStream) throws IOException { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/writer/BIRBinaryWriter.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/writer/BIRBinaryWriter.java index a6591be556fa..79c2b85f9a52 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/writer/BIRBinaryWriter.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/writer/BIRBinaryWriter.java @@ -46,7 +46,6 @@ import java.io.IOException; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.stream.Collectors; /** @@ -79,8 +78,6 @@ public byte[] serialize() { writeTypeDefs(birbuf, typeWriter, birPackage.typeDefs); // Write global vars writeGlobalVars(birbuf, typeWriter, birPackage.globalVars); - // Write dummy BIRGlobalVariableDcls for imported global vars - writeImportedGlobalVarIdentifiers(birbuf, typeWriter, birPackage.importedGlobalVarsDummyVarDcls); // Write type def bodies writeTypeDefBodies(birbuf, typeWriter, birPackage.typeDefs); // Write functions @@ -157,33 +154,21 @@ private void writeReferencedTypes(ByteBuf buf, List referencedTypes) { private void writeGlobalVars(ByteBuf buf, BIRTypeWriter typeWriter, List birGlobalVars) { buf.writeInt(birGlobalVars.size()); for (BIRGlobalVariableDcl birGlobalVar : birGlobalVars) { - writeGlobalVar(buf, typeWriter, birGlobalVar); - } - } - - private void writeGlobalVar(ByteBuf buf, BIRTypeWriter typeWriter, BIRGlobalVariableDcl birGlobalVar) { - writePosition(buf, birGlobalVar.pos); - buf.writeByte(birGlobalVar.kind.getValue()); - // Name - buf.writeInt(addStringCPEntry(birGlobalVar.name.value)); - // Flags - buf.writeLong(birGlobalVar.flags); - // Origin - buf.writeByte(birGlobalVar.origin.value()); - - typeWriter.writeMarkdownDocAttachment(buf, birGlobalVar.markdownDocAttachment); + writePosition(buf, birGlobalVar.pos); + buf.writeByte(birGlobalVar.kind.getValue()); + // Name + buf.writeInt(addStringCPEntry(birGlobalVar.name.value)); + // Flags + buf.writeLong(birGlobalVar.flags); + // Origin + buf.writeByte(birGlobalVar.origin.value()); - // Function type as a CP Index - writeType(buf, birGlobalVar.type); + typeWriter.writeMarkdownDocAttachment(buf, birGlobalVar.markdownDocAttachment); - writeAnnotAttachments(buf, birGlobalVar.annotAttachments); - } + // Function type as a CP Index + writeType(buf, birGlobalVar.type); - private void writeImportedGlobalVarIdentifiers(ByteBuf buf, BIRTypeWriter typeWriter, - Set importedGlobalVarsDummyVarDcls) { - buf.writeInt(importedGlobalVarsDummyVarDcls.size()); - for (BIRGlobalVariableDcl birGlobalVar : importedGlobalVarsDummyVarDcls) { - writeGlobalVar(buf, typeWriter, birGlobalVar); + writeAnnotAttachments(buf, birGlobalVar.annotAttachments); } } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/programfile/ProgramFileConstants.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/programfile/ProgramFileConstants.java index 845894c5c896..5b23c9e385b0 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/programfile/ProgramFileConstants.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/programfile/ProgramFileConstants.java @@ -25,9 +25,9 @@ public class ProgramFileConstants { public static final int MAGIC_NUMBER = 0xBA1DA4CE; public static final short VERSION_NUMBER = 50; - public static final int BIR_VERSION_NUMBER = 68; - public static final short MIN_SUPPORTED_VERSION = 68; - public static final short MAX_SUPPORTED_VERSION = 68; + public static final int BIR_VERSION_NUMBER = 67; + public static final short MIN_SUPPORTED_VERSION = 67; + public static final short MAX_SUPPORTED_VERSION = 67; // todo move this to a proper place public static final String[] SUPPORTED_PLATFORMS = {"java11"}; diff --git a/docs/bir-spec/src/main/resources/kaitai/bir.ksy b/docs/bir-spec/src/main/resources/kaitai/bir.ksy index 8a41c6990e52..9d67d8fc1283 100644 --- a/docs/bir-spec/src/main/resources/kaitai/bir.ksy +++ b/docs/bir-spec/src/main/resources/kaitai/bir.ksy @@ -512,18 +512,12 @@ types: type: type_definition repeat: expr repeat-expr: type_definition_count - - id: global_var_count + - id: golbal_var_count type: s4 - - id: global_vars - type: global_var + - id: golbal_vars + type: golbal_var repeat: expr - repeat-expr: global_var_count - - id: imported_global_var_count - type: s4 - - id: imported_global_vars - type: global_var - repeat: expr - repeat-expr: global_var_count + repeat-expr: golbal_var_count - id: type_definition_bodies_count type: s4 - id: type_definition_bodies @@ -548,7 +542,7 @@ types: type: service_declaration repeat: expr repeat-expr: service_decls_size - global_var: + golbal_var: seq: - id: position type: position From de03c18b5711468dd474d0a1f5a2cc7bceeae3b8 Mon Sep 17 00:00:00 2001 From: gabilang Date: Mon, 28 Nov 2022 15:58:23 +0530 Subject: [PATCH 124/450] Remove unnecessary null check --- .../src/main/java/io/ballerina/runtime/internal/cli/Option.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java index 23752d60d7cc..ba5a0d6eb953 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java @@ -92,7 +92,7 @@ private boolean isShortOption(String arg) { } private boolean isNumeric(String stringVal) { - if (stringVal == null || stringVal.length() == 0) { + if (stringVal.length() == 0) { return false; } String upperCaseValue = stringVal.toUpperCase(); From e4147c51cbf67648496141d692af5594698c1763 Mon Sep 17 00:00:00 2001 From: gabilang Date: Mon, 28 Nov 2022 16:19:38 +0530 Subject: [PATCH 125/450] Fix a typo in bir.ksy --- docs/bir-spec/src/main/resources/kaitai/bir.ksy | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/bir-spec/src/main/resources/kaitai/bir.ksy b/docs/bir-spec/src/main/resources/kaitai/bir.ksy index 4fb01e09df52..7db5ed3adf1f 100644 --- a/docs/bir-spec/src/main/resources/kaitai/bir.ksy +++ b/docs/bir-spec/src/main/resources/kaitai/bir.ksy @@ -512,12 +512,12 @@ types: type: type_definition repeat: expr repeat-expr: type_definition_count - - id: golbal_var_count + - id: global_var_count type: s4 - - id: golbal_vars - type: golbal_var + - id: global_vars + type: global_var repeat: expr - repeat-expr: golbal_var_count + repeat-expr: global_var_count - id: type_definition_bodies_count type: s4 - id: type_definition_bodies @@ -542,7 +542,7 @@ types: type: service_declaration repeat: expr repeat-expr: service_decls_size - golbal_var: + global_var: seq: - id: position type: position From 4f9734bf1a431ea25ba2843174d616d35ae62fcc Mon Sep 17 00:00:00 2001 From: Thevakumar-Luheerathan Date: Mon, 28 Nov 2022 16:30:05 +0530 Subject: [PATCH 126/450] Fix warning and remove target jar from native --- .../io/ballerina/cli/cmd/BuildCommand.java | 5 ++--- .../cli/task/CreateExecutableTask.java | 18 ++++++++++-------- .../ballerina/projects/JBallerinaBackend.java | 4 ++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/BuildCommand.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/BuildCommand.java index b8ba8c4bb680..000755e25820 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/BuildCommand.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/BuildCommand.java @@ -246,9 +246,8 @@ public void execute() { return; } - if ((project.buildOptions().nativeImage()) && (project.buildOptions().cloud().equals(""))) { - this.outStream.println("WARNING : Native image generation is an experimental feature, " + - "which supports only a limited set of functionality."); + if (project.buildOptions().nativeImage()) { + this.outStream.println("WARNING: GraalVM Native Image generation in Ballerina is an experimental feature"); } // Validate Settings.toml file diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/CreateExecutableTask.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/CreateExecutableTask.java index 8580300093e3..7f2cd8cc44ee 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/CreateExecutableTask.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/CreateExecutableTask.java @@ -122,16 +122,18 @@ public void execute(Project project) { throw createLauncherException(e.getMessage()); } - Path relativePathToExecutable = currentDir.relativize(executablePath); + if (!project.buildOptions().nativeImage()) { + Path relativePathToExecutable = currentDir.relativize(executablePath); - if (project.buildOptions().getTargetPath() != null) { - this.out.println("\t" + relativePathToExecutable); - } else { - if (relativePathToExecutable.toString().contains("..") || - relativePathToExecutable.toString().contains("." + File.separator)) { - this.out.println("\t" + executablePath); - } else { + if (project.buildOptions().getTargetPath() != null) { this.out.println("\t" + relativePathToExecutable); + } else { + if (relativePathToExecutable.toString().contains("..") || + relativePathToExecutable.toString().contains("." + File.separator)) { + this.out.println("\t" + executablePath); + } else { + this.out.println("\t" + relativePathToExecutable); + } } } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/JBallerinaBackend.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/JBallerinaBackend.java index 9c9a41c74a02..946c503a4297 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/JBallerinaBackend.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/JBallerinaBackend.java @@ -548,7 +548,7 @@ private Path emitGraalExecutable(Path executableFilePath) { String nativeImageCommand = System.getenv("GRAALVM_HOME"); if (nativeImageCommand == null) { - throw new ProjectException("GraalVM installation directory not found. Set GRAALVM_HOME as an " + + throw new ProjectException("graalVM installation directory not found. Set GRAALVM_HOME as an " + "environment variable"); } nativeImageCommand += File.separator + BIN_DIR_NAME + File.separator @@ -556,7 +556,7 @@ private Path emitGraalExecutable(Path executableFilePath) { File commandExecutable = Paths.get(nativeImageCommand).toFile(); if (!commandExecutable.exists()) { - throw new ProjectException("Cannot find '" + commandExecutable.getName() + "' in the GRAALVM_HOME. " + + throw new ProjectException("cannot find '" + commandExecutable.getName() + "' in the GRAALVM_HOME. " + "Install it using: gu install native-image"); } From b83f2b0eb0a95f36e44d0119a803f2faf0b43f31 Mon Sep 17 00:00:00 2001 From: Thevakumar-Luheerathan Date: Tue, 29 Nov 2022 10:53:54 +0530 Subject: [PATCH 127/450] Fix native test case --- .../java/io/ballerina/cli/cmd/TestCommand.java | 2 +- .../cli/task/RunNativeImageTestTask.java | 16 +++++++++++----- .../cli/cmd/TestNativeImageCommandTest.java | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/TestCommand.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/TestCommand.java index 591c6e3e90d9..b864ec9dbe5f 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/TestCommand.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/TestCommand.java @@ -294,7 +294,7 @@ public void execute() { // .addTask(new CopyResourcesTask(), listGroups) // merged with CreateJarTask .addTask(new RunTestsTask(outStream, errStream, rerunTests, groupList, disableGroupList, testList, includes, coverageFormat, moduleMap, listGroups), project.buildOptions().nativeImage()) - .addTask(new RunNativeImageTestTask(outStream, rerunTests, groupList, disableGroupList, + .addTask(new RunNativeImageTestTask(outStream, errStream, rerunTests, groupList, disableGroupList, testList, includes, coverageFormat, moduleMap, listGroups), !project.buildOptions().nativeImage()) .addTask(new DumpBuildTimeTask(outStream), !project.buildOptions().dumpBuildTime()) diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java index 298610719b54..e61fe826a6b5 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java @@ -34,6 +34,7 @@ import io.ballerina.projects.ProjectException; import io.ballerina.projects.ProjectKind; import io.ballerina.projects.internal.model.Target; +import org.apache.commons.compress.utils.IOUtils; import org.ballerinalang.test.runtime.entity.ModuleStatus; import org.ballerinalang.test.runtime.entity.TestReport; import org.ballerinalang.test.runtime.entity.TestSuite; @@ -76,6 +77,8 @@ public class RunNativeImageTestTask implements Task { private static final String OS = System.getProperty("os.name").toLowerCase(Locale.getDefault()); private final PrintStream out; + + private final PrintStream err; private final String includesInCoverage; private String groupList; private String disableGroupList; @@ -89,11 +92,12 @@ public class RunNativeImageTestTask implements Task { TestReport testReport; - public RunNativeImageTestTask(PrintStream out, boolean rerunTests, String groupList, - String disableGroupList, String testList, String includes, String coverageFormat, - Map modules, boolean listGroups) { + public RunNativeImageTestTask(PrintStream out, PrintStream err, boolean rerunTests, String groupList, + String disableGroupList, String testList, String includes, String coverageFormat, + Map modules, boolean listGroups) { this.out = out; this.isRerunTestExecution = rerunTests; + this.err = err; if (disableGroupList != null) { this.disableGroupList = disableGroupList; @@ -330,8 +334,9 @@ private int runTestSuiteWithNativeImage(Package currentPackage, JBallerinaBacken ProcessBuilder builder = new ProcessBuilder(); builder.command(cmdArgs.toArray(new String[0])); - builder.inheritIO(); Process process = builder.start(); + IOUtils.copy(process.getInputStream(), out); + IOUtils.copy(process.getErrorStream(), err); if (process.waitFor() == 0) { cmdArgs = new ArrayList<>(); @@ -351,8 +356,9 @@ private int runTestSuiteWithNativeImage(Package currentPackage, JBallerinaBacken cmdArgs.add(Boolean.toString(listGroups)); // 8 builder.command(cmdArgs.toArray(new String[0])); - builder.inheritIO(); process = builder.start(); + IOUtils.copy(process.getInputStream(), out); + IOUtils.copy(process.getErrorStream(), err); return process.waitFor(); } else { return 1; diff --git a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestNativeImageCommandTest.java b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestNativeImageCommandTest.java index 7275db41313b..d0d20c4b757b 100644 --- a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestNativeImageCommandTest.java +++ b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestNativeImageCommandTest.java @@ -58,6 +58,6 @@ public void testNativeImageTests() throws IOException { new CommandLine(testCommand).parse(); testCommand.execute(); String buildLog = readOutput(true); - Assert.assertTrue(buildLog.contains("1 passed")); + Assert.assertTrue(buildLog.contains("1 passing")); } } From 74fb4dd865082ca1f1e1b56aa5db8fc43445fc98 Mon Sep 17 00:00:00 2001 From: Imesha Sudasingha Date: Thu, 20 Oct 2022 05:03:30 +0530 Subject: [PATCH 128/450] Refactor DocumentServiceContext visible symbols method Only the contexts which are subclasses of PositionedOperationContext are caching the visible symbols for the cursor position. --- .../langserver/commons/HoverContext.java | 7 --- .../AbstractDocumentServiceContext.java | 35 +++++------- .../BallerinaDefinitionContextImpl.java | 29 ++-------- .../contexts/CompletionContextImpl.java | 31 ++-------- .../langserver/contexts/HoverContextImpl.java | 31 ++-------- .../PositionedOperationContextImpl.java | 56 ++++++++++++++++--- .../contexts/ReferencesContextImpl.java | 26 +-------- .../contexts/SignatureContextImpl.java | 25 +-------- 8 files changed, 80 insertions(+), 160 deletions(-) diff --git a/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/HoverContext.java b/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/HoverContext.java index c09e84df8cdc..81e16d87ab5a 100644 --- a/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/HoverContext.java +++ b/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/HoverContext.java @@ -43,13 +43,6 @@ public interface HoverContext extends PositionedOperationContext { */ Token getTokenAtCursor(); - /** - * Get the cursor position. - * - * @return {@link Position} - */ - Position getCursorPosition(); - /** * Set the node at cursor. * diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/AbstractDocumentServiceContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/AbstractDocumentServiceContext.java index 42ddb36a1b42..53a20a2a215d 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/AbstractDocumentServiceContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/AbstractDocumentServiceContext.java @@ -60,9 +60,7 @@ public class AbstractDocumentServiceContext implements DocumentServiceContext { private final String fileUri; private final WorkspaceManager workspaceManager; - - private List visibleSymbols; - + private List currentDocImports; private Map currentDocImportsMap; @@ -132,26 +130,23 @@ public LSOperation operation() { @Override public List visibleSymbols(Position position) { - if (this.visibleSymbols == null) { - Optional semanticModel; - if (this.cancelChecker == null) { - semanticModel = this.workspaceManager.semanticModel(this.filePath); - } else { - semanticModel = this.workspaceManager.semanticModel(this.filePath, this.cancelChecker); - } - Optional srcFile = this.workspaceManager.document(filePath); - - if (semanticModel.isEmpty() || srcFile.isEmpty()) { - return Collections.emptyList(); - } + Optional semanticModel; + if (this.cancelChecker == null) { + semanticModel = this.workspaceManager.semanticModel(this.filePath); + } else { + semanticModel = this.workspaceManager.semanticModel(this.filePath, this.cancelChecker); + } + Optional srcFile = this.workspaceManager.document(filePath); - this.checkCancelled(); - visibleSymbols = semanticModel.get().visibleSymbols(srcFile.get(), - LinePosition.from(position.getLine(), - position.getCharacter()), DiagnosticState.VALID, DiagnosticState.REDECLARED); + if (semanticModel.isEmpty() || srcFile.isEmpty()) { + return Collections.emptyList(); } - return visibleSymbols; + this.checkCancelled(); + + return semanticModel.get().visibleSymbols(srcFile.get(), + LinePosition.from(position.getLine(), + position.getCharacter()), DiagnosticState.VALID, DiagnosticState.REDECLARED); } @Override diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/BallerinaDefinitionContextImpl.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/BallerinaDefinitionContextImpl.java index fc398dd2e12f..11c760b43dd5 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/BallerinaDefinitionContextImpl.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/BallerinaDefinitionContextImpl.java @@ -34,12 +34,10 @@ * * @since 2.0.0 */ -public class BallerinaDefinitionContextImpl - extends AbstractDocumentServiceContext implements BallerinaDefinitionContext { +public class BallerinaDefinitionContextImpl + extends PositionedOperationContextImpl implements BallerinaDefinitionContext { private boolean capturedEnclosingNode = false; private ModuleMemberDeclarationNode enclosingNode = null; - private int cursorPosInTree = -1; - private final Position cursorPosition; BallerinaDefinitionContextImpl(LSOperation operation, String fileUri, @@ -47,8 +45,7 @@ public class BallerinaDefinitionContextImpl Position position, LanguageServerContext serverContext, CancelChecker cancelChecker) { - super(operation, fileUri, wsManager, serverContext, cancelChecker); - this.cursorPosition = position; + super(operation, fileUri, position, wsManager, serverContext, cancelChecker); } @Override @@ -65,25 +62,7 @@ public Optional enclosedModuleMember() { return Optional.ofNullable(this.enclosingNode); } - - @Override - public void setCursorPositionInTree(int offset) { - if (this.cursorPosInTree > -1) { - throw new RuntimeException("Setting the cursor offset more than once is not allowed"); - } - this.cursorPosInTree = offset; - } - - @Override - public int getCursorPositionInTree() { - return this.cursorPosInTree; - } - - @Override - public Position getCursorPosition() { - return this.cursorPosition; - } - + /** * Represents Language server completion context Builder. * diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/CompletionContextImpl.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/CompletionContextImpl.java index c9a5bcb859eb..30883e008d2a 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/CompletionContextImpl.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/CompletionContextImpl.java @@ -31,11 +31,9 @@ * * @since 1.2.0 */ -public class CompletionContextImpl extends AbstractDocumentServiceContext implements CompletionContext { +public class CompletionContextImpl extends PositionedOperationContextImpl implements CompletionContext { private final CompletionCapabilities capabilities; - private final Position cursorPosition; - private int cursorPosInTree = -1; CompletionContextImpl(LSOperation operation, String fileUri, @@ -43,9 +41,7 @@ public class CompletionContextImpl extends AbstractDocumentServiceContext implem CompletionCapabilities capabilities, Position cursorPosition, LanguageServerContext serverContext) { - super(operation, fileUri, wsManager, serverContext); - this.capabilities = capabilities; - this.cursorPosition = cursorPosition; + this(operation, fileUri, wsManager, capabilities, cursorPosition, serverContext, null); } CompletionContextImpl(LSOperation operation, @@ -55,34 +51,15 @@ public class CompletionContextImpl extends AbstractDocumentServiceContext implem Position cursorPosition, LanguageServerContext serverContext, CancelChecker cancelChecker) { - super(operation, fileUri, wsManager, serverContext, cancelChecker); + super(operation, fileUri, cursorPosition, wsManager, serverContext, cancelChecker); this.capabilities = capabilities; - this.cursorPosition = cursorPosition; } @Override public CompletionCapabilities getCapabilities() { return this.capabilities; } - - @Override - public void setCursorPositionInTree(int offset) { - if (this.cursorPosInTree > -1) { - throw new RuntimeException("Setting the cursor offset more than once is not allowed"); - } - this.cursorPosInTree = offset; - } - - @Override - public int getCursorPositionInTree() { - return this.cursorPosInTree; - } - - @Override - public Position getCursorPosition() { - return this.cursorPosition; - } - + /** * Represents Language server completion context Builder. * diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/HoverContextImpl.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/HoverContextImpl.java index 6d1cabbe6b58..d393afbcd045 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/HoverContextImpl.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/HoverContextImpl.java @@ -34,14 +34,10 @@ * * @since 1.2.0 */ -public class HoverContextImpl extends AbstractDocumentServiceContext implements HoverContext { +public class HoverContextImpl extends PositionedOperationContextImpl implements HoverContext { private Token tokenAtCursor; - - private final Position cursorPosition; - - private int cursorPositionInTree = -1; - + private NonTerminalNode nodeAtCursor; HoverContextImpl(LSOperation operation, @@ -50,8 +46,7 @@ public class HoverContextImpl extends AbstractDocumentServiceContext implements Position cursorPosition, LanguageServerContext serverContext, CancelChecker cancelChecker) { - super(operation, fileUri, wsManager, serverContext, cancelChecker); - this.cursorPosition = cursorPosition; + super(operation, fileUri, cursorPosition, wsManager, serverContext, cancelChecker); } @Override @@ -67,25 +62,7 @@ public Token getTokenAtCursor() { return this.tokenAtCursor; } - - @Override - public void setCursorPositionInTree(int offset) { - if (this.cursorPositionInTree > -1) { - throw new RuntimeException("Setting the cursor offset more than once is not allowed"); - } - this.cursorPositionInTree = offset; - } - - @Override - public int getCursorPositionInTree() { - return this.cursorPositionInTree; - } - - @Override - public Position getCursorPosition() { - return this.cursorPosition; - } - + @Override public void setNodeAtCursor(NonTerminalNode node) { if (this.nodeAtCursor != null) { diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/PositionedOperationContextImpl.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/PositionedOperationContextImpl.java index b7c3a45c072f..65808b82fec3 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/PositionedOperationContextImpl.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/PositionedOperationContextImpl.java @@ -15,6 +15,7 @@ */ package org.ballerinalang.langserver.contexts; +import io.ballerina.compiler.api.symbols.Symbol; import org.ballerinalang.langserver.LSContextOperation; import org.ballerinalang.langserver.commons.DocumentServiceContext; import org.ballerinalang.langserver.commons.LSOperation; @@ -24,6 +25,8 @@ import org.eclipse.lsp4j.Position; import org.eclipse.lsp4j.jsonrpc.CancelChecker; +import java.util.List; + /** * Abstract implementation of the {@link PositionedOperationContext}. * @@ -32,20 +35,59 @@ public abstract class PositionedOperationContextImpl extends AbstractDocumentServiceContext implements PositionedOperationContext { - @Deprecated(forRemoval = true) - PositionedOperationContextImpl(LSOperation operation, - String fileUri, - WorkspaceManager wsManager, - LanguageServerContext serverContext) { - super(operation, fileUri, wsManager, serverContext); - } + private final Position cursorPosition; + + private int cursorPositionInTree = -1; + + private List visibleSymbols; PositionedOperationContextImpl(LSOperation operation, String fileUri, + Position cursorPosition, WorkspaceManager wsManager, LanguageServerContext serverContext, CancelChecker cancelChecker) { super(operation, fileUri, wsManager, serverContext, cancelChecker); + this.cursorPosition = cursorPosition; + } + + /** + * {@inheritDoc} + *

+ * Since we know the cursor position here, we can cache the visible symbols for the cursor position. This will be + * good for the performance since the chance of accessing the visible symbols of the cursor position repetitively is high. + * + * @param position Position at which visible symbols are needed + * @return Visible symbols + */ + @Override + public List visibleSymbols(Position position) { + if (this.cursorPosition.equals(position)) { + if (this.visibleSymbols == null) { + this.visibleSymbols = super.visibleSymbols(position); + } + return this.visibleSymbols; + } else { + return super.visibleSymbols(position); + } + } + + @Override + public void setCursorPositionInTree(int offset) { + if (this.cursorPositionInTree > -1) { + throw new RuntimeException("Setting the cursor offset more than once is not allowed"); + } + this.cursorPositionInTree = offset; + } + + @Override + public int getCursorPositionInTree() { + return this.cursorPositionInTree; + } + + @Override + public Position getCursorPosition() { + return this.cursorPosition; } /** diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/ReferencesContextImpl.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/ReferencesContextImpl.java index 782ad0af4d54..6ca824c71fd3 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/ReferencesContextImpl.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/ReferencesContextImpl.java @@ -32,37 +32,15 @@ */ public class ReferencesContextImpl extends PositionedOperationContextImpl implements ReferencesContext { - private final Position cursorPos; - private int cursorPosInTree = -1; - ReferencesContextImpl(LSOperation operation, String fileUri, WorkspaceManager wsManager, Position cursorPos, LanguageServerContext serverContext, CancelChecker cancelChecker) { - super(operation, fileUri, wsManager, serverContext, cancelChecker); - this.cursorPos = cursorPos; - } - - @Override - public Position getCursorPosition() { - return this.cursorPos; + super(operation, fileUri, cursorPos, wsManager, serverContext, cancelChecker); } - - @Override - public void setCursorPositionInTree(int offset) { - if (this.cursorPosInTree > -1) { - throw new RuntimeException("Setting the cursor offset more than once is not allowed"); - } - this.cursorPosInTree = offset; - } - - @Override - public int getCursorPositionInTree() { - return this.cursorPosInTree; - } - + /** * Represents Language server references context Builder. * diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/SignatureContextImpl.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/SignatureContextImpl.java index ffa7a4878c23..3d93735e944c 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/SignatureContextImpl.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/SignatureContextImpl.java @@ -34,11 +34,9 @@ * * @since 1.2.0 */ -public class SignatureContextImpl extends AbstractDocumentServiceContext implements SignatureContext { +public class SignatureContextImpl extends PositionedOperationContextImpl implements SignatureContext { private final SignatureHelpCapabilities capabilities; - private final Position cursorPos; - private int cursorPosInTree = -1; private NonTerminalNode nodeAtCursor; SignatureContextImpl(LSOperation operation, @@ -48,9 +46,8 @@ public class SignatureContextImpl extends AbstractDocumentServiceContext impleme Position cursorPos, LanguageServerContext serverContext, CancelChecker cancelChecker) { - super(operation, fileUri, wsManager, serverContext, cancelChecker); + super(operation, fileUri, cursorPos, wsManager, serverContext, cancelChecker); this.capabilities = capabilities; - this.cursorPos = cursorPos; } @Override @@ -58,24 +55,6 @@ public SignatureHelpCapabilities capabilities() { return this.capabilities; } - @Override - public Position getCursorPosition() { - return this.cursorPos; - } - - @Override - public void setCursorPositionInTree(int offset) { - if (this.cursorPosInTree > -1) { - throw new RuntimeException("Setting the cursor offset more than once is not allowed"); - } - this.cursorPosInTree = offset; - } - - @Override - public int getCursorPositionInTree() { - return this.cursorPosInTree; - } - @Override public Optional getNodeAtCursor() { return Optional.ofNullable(this.nodeAtCursor); From 57c68d9ab5bb4005cc144664a4238772bcb135d7 Mon Sep 17 00:00:00 2001 From: Imesha Sudasingha Date: Thu, 20 Oct 2022 05:04:57 +0530 Subject: [PATCH 129/450] Remove deprecated currentDocImports() method from DocumentServiceContext interface --- .../commons/DocumentServiceContext.java | 10 ---------- .../contexts/AbstractDocumentServiceContext.java | 16 ---------------- .../BallerinaTomlCompletionContext.java | 15 --------------- 3 files changed, 41 deletions(-) diff --git a/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/DocumentServiceContext.java b/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/DocumentServiceContext.java index 2accdee10d86..31578a5ac257 100644 --- a/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/DocumentServiceContext.java +++ b/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/DocumentServiceContext.java @@ -77,16 +77,6 @@ public interface DocumentServiceContext { */ LSOperation operation(); - /** - * Get the imports in the current document. - * This API is deprecated. Instead, use {@link #currentDocImportsMap} - * - * @return {@link List} of import nodes - * @deprecated Use {@link #currentDocImportsMap()} instead - */ - @Deprecated(forRemoval = true) - List currentDocImports(); - /** * Get the imports in the current document. * diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/AbstractDocumentServiceContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/AbstractDocumentServiceContext.java index 53a20a2a215d..37197fffcba4 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/AbstractDocumentServiceContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/AbstractDocumentServiceContext.java @@ -42,8 +42,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.stream.Collectors; - import javax.annotation.Nonnull; /** @@ -154,20 +152,6 @@ public WorkspaceManager workspace() { return this.workspaceManager; } - @Override - public List currentDocImports() { - if (this.currentDocImports == null) { - Optional document = this.workspace().document(this.filePath); - if (document.isEmpty()) { - throw new RuntimeException("Cannot find a valid document"); - } - this.currentDocImports = ((ModulePartNode) document.get().syntaxTree().rootNode()).imports().stream() - .collect(Collectors.toList()); - } - - return this.currentDocImports; - } - @Override public Map currentDocImportsMap() { if (this.currentDocImportsMap == null) { diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/toml/ballerinatoml/completion/BallerinaTomlCompletionContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/toml/ballerinatoml/completion/BallerinaTomlCompletionContext.java index 273d45b51ebe..2a5a92fd215c 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/toml/ballerinatoml/completion/BallerinaTomlCompletionContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/toml/ballerinatoml/completion/BallerinaTomlCompletionContext.java @@ -44,7 +44,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.stream.Collectors; /** * Ballerina toml completion context. @@ -95,20 +94,6 @@ public List visibleSymbols(Position position) { return visibleSymbols; } - @Override - public List currentDocImports() { - if (this.currentDocImports == null) { - Optional document = this.workspace().document(this.filePath()); - if (document.isEmpty()) { - throw new RuntimeException("Cannot find a valid document"); - } - this.currentDocImports = ((ModulePartNode) document.get().syntaxTree().rootNode()).imports().stream() - .collect(Collectors.toList()); - } - - return this.currentDocImports; - } - @Override public Map currentDocImportsMap() { Optional semanticModel = this.workspace().semanticModel(this.filePath()); From b2a6a1d90b0de23413ea296739b88efd9625a272 Mon Sep 17 00:00:00 2001 From: Imesha Sudasingha Date: Tue, 25 Oct 2022 16:37:11 +0530 Subject: [PATCH 130/450] Fix repeating module on imports with multiple module parts --- .../context/ImportDeclarationNodeContext.java | 34 +- ...import_decl_with_partial_module_name1.json | 515 ++++++++++++++++++ ...import_decl_with_partial_module_name2.json | 515 ++++++++++++++++++ .../import_decl_with_partial_module_name1.bal | 1 + .../import_decl_with_partial_module_name2.bal | 1 + 5 files changed, 1062 insertions(+), 4 deletions(-) create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_partial_module_name1.json create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_partial_module_name2.json create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/import_decl/source/import_decl_with_partial_module_name1.bal create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/import_decl/source/import_decl_with_partial_module_name2.bal diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportDeclarationNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportDeclarationNodeContext.java index b1cb028561bb..6f96f87535a6 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportDeclarationNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportDeclarationNodeContext.java @@ -27,10 +27,12 @@ import io.ballerina.projects.PackageName; import io.ballerina.projects.Project; import io.ballerina.projects.ProjectKind; +import io.ballerina.tools.text.LinePosition; import org.ballerinalang.annotation.JavaSPIService; import org.ballerinalang.langserver.LSPackageLoader; import org.ballerinalang.langserver.common.utils.CommonUtil; import org.ballerinalang.langserver.common.utils.ModuleUtil; +import org.ballerinalang.langserver.common.utils.PositionUtil; import org.ballerinalang.langserver.commons.BallerinaCompletionContext; import org.ballerinalang.langserver.commons.LanguageServerContext; import org.ballerinalang.langserver.commons.completion.LSCompletionItem; @@ -38,6 +40,8 @@ import org.ballerinalang.langserver.completions.providers.AbstractCompletionProvider; import org.ballerinalang.langserver.completions.util.Snippet; import org.eclipse.lsp4j.CompletionItem; +import org.eclipse.lsp4j.Range; +import org.eclipse.lsp4j.TextEdit; import org.wso2.ballerinalang.compiler.util.Names; import java.util.ArrayList; @@ -79,6 +83,7 @@ public List getCompletions(BallerinaCompletionContext ctx, Imp (3) import abc.xy (4) import org/mod (5) import org/mod v + (6) import org/mod. Suggests org names and the module names within the same directory */ @@ -103,8 +108,7 @@ public List getCompletions(BallerinaCompletionContext ctx, Imp /* Covers case (4) */ - String orgName = node.orgName().get().orgName().text(); - completionItems.addAll(this.moduleNameContextCompletions(ctx, orgName)); + completionItems.addAll(this.moduleNameContextCompletions(ctx, node)); contextScope = ContextScope.SCOPE2; } else { /* @@ -266,7 +270,27 @@ private List getCurrentProjectModules(BallerinaCompletionConte } private ArrayList moduleNameContextCompletions(BallerinaCompletionContext context, - String orgName) { + ImportDeclarationNode node) { + String orgName = node.orgName().get().orgName().text(); + List< TextEdit> additionalEdits = new ArrayList<>(); + // If the module name contains a dot, we should replace what's before the last dot to make sure a part + // of the module name is not repeated. + if (node.moduleName().size() > 1) { + // There can be 2 cases: + // 1) orgName/mod.xx + // 2) orgName/mod. + IdentifierToken lastModeNamePart = node.moduleName().get(node.moduleName().size() - 1); + LinePosition startPos = node.orgName().get().lineRange().endLine(); + LinePosition endPos = lastModeNamePart.lineRange().endLine(); + if (!lastModeNamePart.isMissing()) { + // Case (2) above + endPos = lastModeNamePart.lineRange().startLine(); + } + Range editRange = new Range(PositionUtil.toPosition(startPos), PositionUtil.toPosition(endPos)); + TextEdit removeModNameEdit = new TextEdit(editRange, ""); + additionalEdits.add(removeModNameEdit); + } + ArrayList completionItems = new ArrayList<>(); List addedPkgNames = new ArrayList<>(); LanguageServerContext serverContext = context.languageServercontext(); @@ -285,7 +309,9 @@ private ArrayList moduleNameContextCompletions(BallerinaComple } addedPkgNames.add(packageName); // Do not add the semi colon at the end of the insert text since the user might type the as keyword - completionItems.add(getImportCompletion(context, packageName, insertText)); + LSCompletionItem completionItem = getImportCompletion(context, packageName, insertText); + completionItem.getCompletionItem().setAdditionalTextEdits(additionalEdits); + completionItems.add(completionItem); } }); diff --git a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_partial_module_name1.json b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_partial_module_name1.json new file mode 100644 index 000000000000..c3373bb56d24 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_partial_module_name1.json @@ -0,0 +1,515 @@ +{ + "position": { + "line": 0, + "character": 22 + }, + "source": "import_decl/source/import_decl_with_partial_module_name1.bal", + "items": [ + { + "label": "module1", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "module1", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.int", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'int;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.boolean", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'boolean;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.decimal", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'decimal;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.runtime", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.runtime;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.future", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'future;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.error", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'error;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.regexp", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.regexp;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.transaction", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'transaction;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.object", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'object;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.function", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'function;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.typedesc", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'typedesc;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.table", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'table;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.string", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'string;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.test", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.test;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.value", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.value;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.xml", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'xml;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "jballerina.java", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "jballerina.java", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.stream", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'stream;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.map", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'map;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.array", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.array;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.float", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'float;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_partial_module_name2.json b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_partial_module_name2.json new file mode 100644 index 000000000000..ebd166e06df8 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_partial_module_name2.json @@ -0,0 +1,515 @@ +{ + "position": { + "line": 0, + "character": 25 + }, + "source": "import_decl/source/import_decl_with_partial_module_name2.bal", + "items": [ + { + "label": "module1", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "module1", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.int", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'int;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.boolean", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'boolean;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.decimal", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'decimal;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.runtime", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.runtime;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.future", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'future;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.error", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'error;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.regexp", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.regexp;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.transaction", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'transaction;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.object", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'object;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.function", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'function;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.typedesc", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'typedesc;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.table", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'table;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.string", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'string;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.test", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.test;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.value", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.value;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.xml", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'xml;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "jballerina.java", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "jballerina.java", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.stream", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'stream;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.map", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'map;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.array", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.array;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.float", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'float;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/source/import_decl_with_partial_module_name1.bal b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/source/import_decl_with_partial_module_name1.bal new file mode 100644 index 000000000000..183764d89a05 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/source/import_decl_with_partial_module_name1.bal @@ -0,0 +1 @@ +import ballerina/lang. \ No newline at end of file diff --git a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/source/import_decl_with_partial_module_name2.bal b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/source/import_decl_with_partial_module_name2.bal new file mode 100644 index 000000000000..2c578b061df6 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/source/import_decl_with_partial_module_name2.bal @@ -0,0 +1 @@ +import ballerina/lang.arr \ No newline at end of file From 0114714d234a7a7a39303fd14822b389fcc4573a Mon Sep 17 00:00:00 2001 From: Imesha Sudasingha Date: Tue, 25 Oct 2022 17:09:25 +0530 Subject: [PATCH 131/450] Fix no module being suggested for non ballerina orgs --- .../context/ImportOrgNameNodeContext.java | 2 +- .../import_decl_with_no_module_name1.json | 38 +++++++++++++++++++ .../import_decl_with_no_module_name1.bal | 1 + 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_no_module_name1.json create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/import_decl/source/import_decl_with_no_module_name1.bal diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportOrgNameNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportOrgNameNodeContext.java index 621ea75ead47..baac84937ed5 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportOrgNameNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportOrgNameNodeContext.java @@ -56,7 +56,7 @@ public List getCompletions(BallerinaCompletionContext ctx, Imp } List moduleList = - new ArrayList<>(LSPackageLoader.getInstance(ctx.languageServercontext()).getDistributionRepoPackages()); + new ArrayList<>(LSPackageLoader.getInstance(ctx.languageServercontext()).getAllVisiblePackages(ctx)); ArrayList completionItems = moduleNameContextCompletions(ctx, orgName, moduleList); this.sort(ctx, node, completionItems); diff --git a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_no_module_name1.json b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_no_module_name1.json new file mode 100644 index 000000000000..d8590062a44f --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_no_module_name1.json @@ -0,0 +1,38 @@ +{ + "position": { + "line": 0, + "character": 12 + }, + "source": "import_decl/source/import_decl_with_no_module_name1.bal", + "description": "Test completions in import declaration node: import orgName/", + "items": [ + { + "label": "project2", + "kind": "Module", + "detail": "Module", + "insertText": "project2", + "insertTextFormat": "Snippet" + }, + { + "label": "project1", + "kind": "Module", + "detail": "Module", + "insertText": "project1", + "insertTextFormat": "Snippet" + }, + { + "label": "local_project2", + "kind": "Module", + "detail": "Module", + "insertText": "local_project2", + "insertTextFormat": "Snippet" + }, + { + "label": "local_project1", + "kind": "Module", + "detail": "Module", + "insertText": "local_project1", + "insertTextFormat": "Snippet" + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/source/import_decl_with_no_module_name1.bal b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/source/import_decl_with_no_module_name1.bal new file mode 100644 index 000000000000..a3107191b7e1 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/source/import_decl_with_no_module_name1.bal @@ -0,0 +1 @@ +import test/ \ No newline at end of file From b931a3fbb8592354539f22075a9dcecef20d703f Mon Sep 17 00:00:00 2001 From: Imesha Sudasingha Date: Thu, 27 Oct 2022 11:58:10 +0530 Subject: [PATCH 132/450] Fix checkstyle errors --- .../org/ballerinalang/langserver/commons/HoverContext.java | 1 - .../providers/context/ImportDeclarationNodeContext.java | 2 +- .../langserver/contexts/AbstractDocumentServiceContext.java | 3 +-- .../langserver/contexts/PositionedOperationContextImpl.java | 3 ++- .../completion/BallerinaTomlCompletionContext.java | 1 - 5 files changed, 4 insertions(+), 6 deletions(-) diff --git a/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/HoverContext.java b/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/HoverContext.java index 81e16d87ab5a..531ba0c88686 100644 --- a/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/HoverContext.java +++ b/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/HoverContext.java @@ -19,7 +19,6 @@ import io.ballerina.compiler.syntax.tree.NonTerminalNode; import io.ballerina.compiler.syntax.tree.Token; -import org.eclipse.lsp4j.Position; /** * Represents the hover operation context. diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportDeclarationNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportDeclarationNodeContext.java index 6f96f87535a6..036dafd35c24 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportDeclarationNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportDeclarationNodeContext.java @@ -272,7 +272,7 @@ private List getCurrentProjectModules(BallerinaCompletionConte private ArrayList moduleNameContextCompletions(BallerinaCompletionContext context, ImportDeclarationNode node) { String orgName = node.orgName().get().orgName().text(); - List< TextEdit> additionalEdits = new ArrayList<>(); + List additionalEdits = new ArrayList<>(); // If the module name contains a dot, we should replace what's before the last dot to make sure a part // of the module name is not repeated. if (node.moduleName().size() > 1) { diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/AbstractDocumentServiceContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/AbstractDocumentServiceContext.java index 37197fffcba4..d5867abdf07b 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/AbstractDocumentServiceContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/AbstractDocumentServiceContext.java @@ -42,6 +42,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; + import javax.annotation.Nonnull; /** @@ -58,8 +59,6 @@ public class AbstractDocumentServiceContext implements DocumentServiceContext { private final String fileUri; private final WorkspaceManager workspaceManager; - - private List currentDocImports; private Map currentDocImportsMap; diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/PositionedOperationContextImpl.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/PositionedOperationContextImpl.java index 65808b82fec3..e55da165018e 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/PositionedOperationContextImpl.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/PositionedOperationContextImpl.java @@ -55,7 +55,8 @@ public abstract class PositionedOperationContextImpl extends AbstractDocumentSer * {@inheritDoc} *

* Since we know the cursor position here, we can cache the visible symbols for the cursor position. This will be - * good for the performance since the chance of accessing the visible symbols of the cursor position repetitively is high. + * good for the performance since the chance of accessing the visible symbols of the cursor position repetitively + * is high. * * @param position Position at which visible symbols are needed * @return Visible symbols diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/toml/ballerinatoml/completion/BallerinaTomlCompletionContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/toml/ballerinatoml/completion/BallerinaTomlCompletionContext.java index 2a5a92fd215c..9d5ea0912936 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/toml/ballerinatoml/completion/BallerinaTomlCompletionContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/toml/ballerinatoml/completion/BallerinaTomlCompletionContext.java @@ -51,7 +51,6 @@ public class BallerinaTomlCompletionContext implements TomlCompletionContext { private List visibleSymbols; - private List currentDocImports; private Map currentDocImportsMap; private final LanguageServerContext languageServerContext; private final CompletionCapabilities capabilities; From 8fcc795bc4d6eadf8276007db73a10ce747cecbe Mon Sep 17 00:00:00 2001 From: Imesha Sudasingha Date: Fri, 25 Nov 2022 09:14:57 +0530 Subject: [PATCH 133/450] Revert removal of currentDocImports() method --- .../langserver/commons/DocumentServiceContext.java | 10 ++++++++++ .../contexts/AbstractDocumentServiceContext.java | 11 +++++++++++ .../completion/BallerinaTomlCompletionContext.java | 12 ++++++++++++ 3 files changed, 33 insertions(+) diff --git a/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/DocumentServiceContext.java b/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/DocumentServiceContext.java index 31578a5ac257..137201062cc4 100644 --- a/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/DocumentServiceContext.java +++ b/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/DocumentServiceContext.java @@ -76,6 +76,16 @@ public interface DocumentServiceContext { * @return {@link LSOperation} */ LSOperation operation(); + + /** + * Get the imports in the current document. + * This API is deprecated. Instead, use {@link #currentDocImportsMap} + * + * @return {@link List} of import nodes + * @deprecated Use {@link #currentDocImportsMap()} instead + */ + @Deprecated(forRemoval = true) + List currentDocImports(); /** * Get the imports in the current document. diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/AbstractDocumentServiceContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/AbstractDocumentServiceContext.java index d5867abdf07b..df2ebade2f90 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/AbstractDocumentServiceContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/AbstractDocumentServiceContext.java @@ -42,6 +42,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.stream.Collectors; import javax.annotation.Nonnull; @@ -151,6 +152,16 @@ public WorkspaceManager workspace() { return this.workspaceManager; } + @Override + public List currentDocImports() { + Optional document = this.workspace().document(this.filePath); + if (document.isEmpty()) { + throw new RuntimeException("Cannot find a valid document"); + } + return ((ModulePartNode) document.get().syntaxTree().rootNode()).imports().stream() + .collect(Collectors.toList()); + } + @Override public Map currentDocImportsMap() { if (this.currentDocImportsMap == null) { diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/toml/ballerinatoml/completion/BallerinaTomlCompletionContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/toml/ballerinatoml/completion/BallerinaTomlCompletionContext.java index 9d5ea0912936..61a98182c73c 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/toml/ballerinatoml/completion/BallerinaTomlCompletionContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/toml/ballerinatoml/completion/BallerinaTomlCompletionContext.java @@ -44,6 +44,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.stream.Collectors; /** * Ballerina toml completion context. @@ -93,6 +94,17 @@ public List visibleSymbols(Position position) { return visibleSymbols; } + @Override + public List currentDocImports() { + Optional document = this.workspace().document(this.filePath()); + if (document.isEmpty()) { + throw new RuntimeException("Cannot find a valid document"); + } + + return ((ModulePartNode) document.get().syntaxTree().rootNode()).imports().stream() + .collect(Collectors.toList()); + } + @Override public Map currentDocImportsMap() { Optional semanticModel = this.workspace().semanticModel(this.filePath()); From f3d6d257cc4791e2f1659a7324a96b00bc623d8d Mon Sep 17 00:00:00 2001 From: Shammi Kolonne Date: Tue, 29 Nov 2022 22:17:24 +0530 Subject: [PATCH 134/450] Handle bad sad error for test command with --native flag when GraalVM not installed --- .../cli/task/RunNativeImageTestTask.java | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java index 298610719b54..b84081aac0b9 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java @@ -241,19 +241,24 @@ private int runTestSuiteWithNativeImage(Package currentPackage, JBallerinaBacken String jacocoAgentJarPath = ""; String nativeImageCommand = System.getenv("GRAALVM_HOME"); - if (nativeImageCommand == null) { - throw new ProjectException("GraalVM installation directory not found. Set GRAALVM_HOME as an " + - "environment variable"); - } - nativeImageCommand += File.separator + BIN_DIR_NAME + File.separator - + (OS.contains("win") ? "native-image.cmd" : "native-image"); + try { + if (nativeImageCommand == null) { + throw new ProjectException("GraalVM installation directory not found. Set GRAALVM_HOME as an " + + "environment variable"); + } + nativeImageCommand += File.separator + BIN_DIR_NAME + File.separator + + (OS.contains("win") ? "native-image.cmd" : "native-image"); - File commandExecutable = Paths.get(nativeImageCommand).toFile(); - if (!commandExecutable.exists()) { - throw new ProjectException("Cannot find '" + commandExecutable.getName() + "' in the GRAALVM_HOME. " + - "Install it using: gu install native-image"); + File commandExecutable = Paths.get(nativeImageCommand).toFile(); + if (!commandExecutable.exists()) { + throw new ProjectException("Cannot find '" + commandExecutable.getName() + "' in the GRAALVM_HOME. " + + "Install it using: gu install native-image"); + } + } catch (ProjectException e) { + throw createLauncherException(e.getMessage()); } + if (coverage) { // Generate the exec in a separate process List execArgs = new ArrayList<>(); From 80ffe1918112aa3e9f9825450696210fa1c1820d Mon Sep 17 00:00:00 2001 From: Shammi Kolonne Date: Tue, 29 Nov 2022 22:24:35 +0530 Subject: [PATCH 135/450] Remove spaces --- .../main/java/io/ballerina/cli/task/RunNativeImageTestTask.java | 1 - 1 file changed, 1 deletion(-) diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java index b84081aac0b9..df245085c315 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java @@ -258,7 +258,6 @@ private int runTestSuiteWithNativeImage(Package currentPackage, JBallerinaBacken throw createLauncherException(e.getMessage()); } - if (coverage) { // Generate the exec in a separate process List execArgs = new ArrayList<>(); From 16e0eaae4439fd406c605fc8eef74d329d30e173 Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Wed, 30 Nov 2022 02:01:51 +0530 Subject: [PATCH 136/450] Implement serviceId retrieval using semantic model --- .../generators/GeneratorUtils.java | 39 +++++++++++ .../nodevisitors/ActionNodeVisitor.java | 65 +++++++++---------- 2 files changed, 69 insertions(+), 35 deletions(-) diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/GeneratorUtils.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/GeneratorUtils.java index 0b470fe21f29..ee3594d64a3d 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/GeneratorUtils.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/GeneratorUtils.java @@ -18,6 +18,10 @@ package io.ballerina.projectdesign.generators; +import io.ballerina.compiler.api.symbols.Annotatable; +import io.ballerina.compiler.api.symbols.AnnotationAttachmentSymbol; +import io.ballerina.compiler.api.symbols.AnnotationSymbol; +import io.ballerina.compiler.api.values.ConstantValue; import io.ballerina.compiler.syntax.tree.AnnotationNode; import io.ballerina.compiler.syntax.tree.ExpressionNode; import io.ballerina.compiler.syntax.tree.MappingFieldNode; @@ -29,6 +33,8 @@ import io.ballerina.projectdesign.model.service.ServiceAnnotation; import io.ballerina.tools.text.LineRange; +import java.util.LinkedHashMap; +import java.util.List; import java.util.UUID; import static io.ballerina.projectdesign.ProjectDesignConstants.DISPLAY_ANNOTATION; @@ -88,4 +94,37 @@ public static ServiceAnnotation getServiceAnnotation(NodeList an return new ServiceAnnotation(id, label, elementLocation); } + + public static ServiceAnnotation getServiceAnnotation(Annotatable annotableSymbol, String filePath) { + + String id = UUID.randomUUID().toString(); + String label = ""; + ElementLocation elementLocation = null; + + List annotSymbols = annotableSymbol.annotations(); + List annotAttachmentSymbols = annotableSymbol.annotAttachments(); + if (annotSymbols.size() == annotAttachmentSymbols.size()) { + for (int i = 0; i < annotSymbols.size(); i++) { + AnnotationSymbol annotSymbol = annotSymbols.get(i); + AnnotationAttachmentSymbol annotAttachmentSymbol = annotAttachmentSymbols.get(i); + String annotName = annotSymbol.getName().orElse(""); + elementLocation = annotSymbol.getLocation().isPresent() ? + getElementLocation(filePath, annotSymbol.getLocation().get().lineRange()) : null; + if (!(annotName.equals(DISPLAY_ANNOTATION) || annotAttachmentSymbol.attachmentValue().isEmpty()) || + !(annotAttachmentSymbol.attachmentValue().get().value() instanceof LinkedHashMap)) { + continue; + } + LinkedHashMap attachmentValue = (LinkedHashMap) annotAttachmentSymbol.attachmentValue().get().value(); + if (attachmentValue.containsKey(ID)) { + id = (String) ((ConstantValue) attachmentValue.get(ID)).value(); + } + if (attachmentValue.containsKey(LABEL)) { + label = (String) ((ConstantValue) attachmentValue.get(LABEL)).value(); + } + break; + } + } + + return new ServiceAnnotation(id, label, elementLocation); + } } diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ActionNodeVisitor.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ActionNodeVisitor.java index c01fd4c8c27c..ec5d808a2735 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ActionNodeVisitor.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ActionNodeVisitor.java @@ -20,6 +20,8 @@ import io.ballerina.compiler.api.ModuleID; import io.ballerina.compiler.api.SemanticModel; +import io.ballerina.compiler.api.symbols.Annotatable; +import io.ballerina.compiler.api.symbols.AnnotationAttachmentSymbol; import io.ballerina.compiler.api.symbols.ModuleSymbol; import io.ballerina.compiler.api.symbols.Symbol; import io.ballerina.compiler.syntax.tree.BasicLiteralNode; @@ -45,6 +47,7 @@ import io.ballerina.projectdesign.generators.GeneratorUtils; import io.ballerina.projectdesign.model.service.Interaction; import io.ballerina.projectdesign.model.service.ResourceId; +import io.ballerina.projectdesign.model.service.ServiceAnnotation; import io.ballerina.projects.DocumentId; import io.ballerina.projects.Package; import io.ballerina.tools.diagnostics.Location; @@ -57,6 +60,7 @@ import static io.ballerina.projectdesign.ProjectDesignConstants.FORWARD_SLASH; import static io.ballerina.projectdesign.ProjectDesignConstants.TYPE_MAP; +import static io.ballerina.projectdesign.generators.GeneratorUtils.getServiceAnnotation; /** * Visitor class for RemoteMethodCallAction nodes. @@ -83,68 +87,59 @@ public List getInteractionList() { @Override public void visit(ClientResourceAccessActionNode clientResourceAccessActionNode) { - - String clientName = String.valueOf(clientResourceAccessActionNode.expression()).trim(); + ExpressionNode clientNode = clientResourceAccessActionNode.expression(); String resourceMethod = String.valueOf(clientResourceAccessActionNode.methodName().get().name().text()); String resourcePath = getResourcePath(clientResourceAccessActionNode.resourceAccessPath()); - StatementNodeVisitor statementVisitor = new StatementNodeVisitor(clientName, semanticModel, filePath); - NonTerminalNode parent = clientResourceAccessActionNode.parent().parent(); + StatementNodeVisitor statementVisitor = + new StatementNodeVisitor(String.valueOf(clientNode).trim(), semanticModel, filePath); - // todo: get the connector type using semantic model - //todo : implement using semantic model. Need to wait till bug fix - while (statementVisitor.getServiceId() == null || statementVisitor.getServiceId().isEmpty()) { //isEmpty - parent = parent.parent(); - if (parent != null) { - parent.accept(statementVisitor); - } else { - break; - } + String serviceId = null; + Optional clientSymbol = semanticModel.symbol(clientNode); + if (clientSymbol.isPresent()) { + Annotatable annotatableSymbol = (Annotatable) clientSymbol.get(); + serviceId = getServiceAnnotation(annotatableSymbol, filePath).getId(); } Interaction interaction = new Interaction( - new ResourceId(statementVisitor.getServiceId(), resourceMethod, resourcePath), + new ResourceId(serviceId, resourceMethod, resourcePath), statementVisitor.getConnectorType(), GeneratorUtils.getElementLocation(filePath, clientResourceAccessActionNode.lineRange())); interactionList.add(interaction); - } @Override public void visit(RemoteMethodCallActionNode remoteMethodCallActionNode) { - - String clientName = String.valueOf(remoteMethodCallActionNode.expression()).trim(); + SimpleNameReferenceNode clientNode = null; if (remoteMethodCallActionNode.expression() instanceof FieldAccessExpressionNode) { NameReferenceNode fieldName = ((FieldAccessExpressionNode) remoteMethodCallActionNode.expression()).fieldName(); if (fieldName instanceof SimpleNameReferenceNode) { - clientName = ((SimpleNameReferenceNode) fieldName).name().text(); + clientNode = (SimpleNameReferenceNode) fieldName; } // todo : Other combinations } else if (remoteMethodCallActionNode.expression() instanceof SimpleNameReferenceNode) { - clientName = ((SimpleNameReferenceNode) remoteMethodCallActionNode.expression()).name().text(); + clientNode = (SimpleNameReferenceNode) remoteMethodCallActionNode.expression(); } // todo : Other combinations - String resourceMethod = remoteMethodCallActionNode.methodName().name().text(); - NonTerminalNode parent = remoteMethodCallActionNode.parent().parent(); - StatementNodeVisitor statementVisitor = new StatementNodeVisitor(clientName, semanticModel, filePath); - //todo : implement using semantic model. Need to wait till bug fix - // semanticModel.symbol(remoteMethodCallActionNode.expression()); -> returns null + if (clientNode != null) { + String resourceMethod = remoteMethodCallActionNode.methodName().name().text(); + StatementNodeVisitor statementVisitor = + new StatementNodeVisitor(clientNode.name().text(), semanticModel, filePath); - while (statementVisitor.getServiceId() == null || statementVisitor.getServiceId().isEmpty()) { - parent = parent.parent(); - if (parent != null) { - parent.accept(statementVisitor); - } else { - break; + String serviceId = null; + Optional clientSymbol = semanticModel.symbol(clientNode); + if (clientSymbol.isPresent()) { + Annotatable annotatableSymbol = (Annotatable) clientSymbol.get(); + serviceId = getServiceAnnotation(annotatableSymbol, filePath).getId(); } - } - Interaction interaction = new Interaction(new ResourceId(statementVisitor.getServiceId(), - resourceMethod, null), statementVisitor.getConnectorType(), - GeneratorUtils.getElementLocation(filePath, remoteMethodCallActionNode.lineRange())); - interactionList.add(interaction); + Interaction interaction = new Interaction(new ResourceId(serviceId, + resourceMethod, null), statementVisitor.getConnectorType(), + GeneratorUtils.getElementLocation(filePath, remoteMethodCallActionNode.lineRange())); + interactionList.add(interaction); + } } @Override From b652deb1d09ece882f2c390bfad2d1f9245666f5 Mon Sep 17 00:00:00 2001 From: Thevakumar-Luheerathan Date: Wed, 30 Nov 2022 11:17:50 +0530 Subject: [PATCH 137/450] Add test case --- .../cli/task/RunNativeImageTestTask.java | 28 ++++----- .../cli/utils/MethodCallReplaceVisitor.java | 12 ++-- .../io/ballerina/cli/utils/NativeUtils.java | 48 +++++++-------- .../utils/OrigMockFunctionReplaceVisitor.java | 4 +- .../cli/cmd/TestNativeImageCommandTest.java | 16 +++++ .../mockFunctionNative/Ballerina.toml | 8 +++ .../mockFunctionNative/main.bal | 4 ++ .../modules/util/tests/lib_test.bal | 58 +++++++++++++++++++ .../modules/util/tests/lib_test2.bal | 18 ++++++ .../mockFunctionNative/modules/util/util.bal | 4 ++ .../modules/util2/tests/tes.bal | 11 ++++ .../modules/util2/util2.bal | 4 ++ .../mockFunctionNative/tests/tes.bal | 47 +++++++++++++++ .../compiler/TestExecutionGenerationTask.java | 47 ++++++++------- .../exceptions/CacheGenException.java | 6 +- 15 files changed, 248 insertions(+), 67 deletions(-) create mode 100644 cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/Ballerina.toml create mode 100644 cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/main.bal create mode 100644 cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util/tests/lib_test.bal create mode 100644 cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util/tests/lib_test2.bal create mode 100644 cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util/util.bal create mode 100644 cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util2/tests/tes.bal create mode 100644 cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util2/util2.bal create mode 100644 cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/tests/tes.bal diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java index 924ba968d4a3..ccc5fe03f8a9 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java @@ -174,10 +174,10 @@ public static byte[] getModifiedClassBytes(String className, List functi for (Method method2 : testClass.getDeclaredMethods()) { if (method2.getName().equals(desugaredMockFunctionName)) { if (!readFromBytes) { - classFile = replaceMethodBody(method1, method2); + classFile = replaceMethodBody(method1); readFromBytes = true; } else { - classFile = replaceMethodBody(classFile, method1, method2); + classFile = replaceMethodBody(classFile, method1); } } } @@ -200,10 +200,10 @@ public static byte[] getModifiedClassBytes(String className, List functi for (Method method2 : mockFunctionClass.getDeclaredMethods()) { if (method2.getName().equals(mockFunctionName)) { if (!readFromBytes) { - classFile = replaceMethodBody(method1, method2); + classFile = replaceMethodBody(method1); readFromBytes = true; } else { - classFile = replaceMethodBody(classFile, method1, method2); + classFile = replaceMethodBody(classFile, method1); } } } @@ -226,7 +226,7 @@ public static byte[] getModifiedTestClassBytes(String className, List fu } boolean readFromBytes; - if(classFile.length == 0) { + if (classFile.length == 0) { readFromBytes = false; } else { readFromBytes = true; @@ -308,7 +308,7 @@ private static byte[] replaceTestClzMethodBody(byte[] classFile, Method toFunc, return cw.toByteArray(); } - private static byte[] replaceMethodBody(Method method, Method mockMethod) { + private static byte[] replaceMethodBody(Method method) { Class clazz = method.getDeclaringClass(); ClassReader cr; try { @@ -320,15 +320,15 @@ private static byte[] replaceMethodBody(Method method, Method mockMethod) { + clazz.getSimpleName()); } ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); - ClassVisitor cv = new OrigMockFunctionReplaceVisitor(Opcodes.ASM7, cw, method, mockMethod); + ClassVisitor cv = new OrigMockFunctionReplaceVisitor(Opcodes.ASM7, cw, method); cr.accept(cv, 0); return cw.toByteArray(); } - private static byte[] replaceMethodBody(byte[] classFile, Method method, Method mockMethod) { + private static byte[] replaceMethodBody(byte[] classFile, Method method) { ClassReader cr = new ClassReader(classFile); ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); - ClassVisitor cv = new OrigMockFunctionReplaceVisitor(Opcodes.ASM7, cw, method, mockMethod); + ClassVisitor cv = new OrigMockFunctionReplaceVisitor(Opcodes.ASM7, cw, method); cr.accept(cv, 0); return cw.toByteArray(); } @@ -723,11 +723,11 @@ private void modifyJarForFunctionMock(TestSuite testSuite, Target target, Module Map mockFunctionMap = testSuite.getMockFunctionNamesMap(); populateClassNameVsFunctionToMockMap(classVsMockFunctionsMap, mockFunctionMap); - Map > mainJarVsClassMapping = new HashMap<>(); + Map> mainJarVsClassMapping = new HashMap<>(); for (Map.Entry> classVsMockFunctionsEntry : classVsMockFunctionsMap.entrySet()) { String className = classVsMockFunctionsEntry.getKey(); String[] classMetaData = className.split("\\."); - mainJarName = classMetaData[0] + HYPHEN + classMetaData[1].replace("$0046",".") + + mainJarName = classMetaData[0] + HYPHEN + classMetaData[1].replace("$0046", ".") + HYPHEN + classMetaData[2]; if (mainJarVsClassMapping.containsKey(mainJarName)) { @@ -735,7 +735,7 @@ private void modifyJarForFunctionMock(TestSuite testSuite, Target target, Module } else { List classList = new ArrayList<>(); classList.add(className); - mainJarVsClassMapping.put(mainJarName,classList); + mainJarVsClassMapping.put(mainJarName, classList); } } @@ -749,7 +749,7 @@ private void modifyJarForFunctionMock(TestSuite testSuite, Target target, Module if (testExecutionDependency.contains(mainJarName) && !testExecutionDependency.contains(TESTABLE)) { mainJarPath = testExecutionDependency; if (originalVsModifiedJarMap.containsKey(mainJarPath)) { - mainJarPath= originalVsModifiedJarMap.get(mainJarPath); + mainJarPath = originalVsModifiedJarMap.get(mainJarPath); } } } @@ -826,7 +826,7 @@ private void modifyJarForFunctionMock(TestSuite testSuite, Target target, Module String testDocumentName = testDocument.name().replace(".bal", "") .replace("/", "."); String testDocumentClassName = TesterinaUtils.getQualifiedClassName(testSuite.getOrgName(), - testSuite.getTestPackageID(), testSuite.getVersion(),testDocumentName); + testSuite.getTestPackageID(), testSuite.getVersion(), testDocumentName); Class testDocumentClass; try { testDocumentClass = classLoader.loadClass(testDocumentClassName); diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/MethodCallReplaceVisitor.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/MethodCallReplaceVisitor.java index 6c70b929a409..653725e2afa3 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/MethodCallReplaceVisitor.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/MethodCallReplaceVisitor.java @@ -9,6 +9,11 @@ import java.lang.reflect.Method; +/** + * Remove existing method call and replace it with a mock call. + * + * @since 2201.4.0 + */ public class MethodCallReplaceVisitor extends ClassVisitor { private final Method toFunc; public final Method fromFunc; @@ -32,7 +37,7 @@ private final class MethodReplaceMethodVisitor extends GeneratorAdapter { public MethodReplaceMethodVisitor( MethodVisitor mv, int access, String name, String desc) { - super(MethodCallReplaceVisitor.this.api ,mv, access, name, desc); + super(MethodCallReplaceVisitor.this.api , mv, access, name, desc); } @Override @@ -49,12 +54,11 @@ public void visitMethodInsn( String toFuncName = MethodCallReplaceVisitor.this.toFunc.getName(); String toFunDesc = Type.getMethodDescriptor(MethodCallReplaceVisitor.this.toFunc); - if(opcode== Opcodes.INVOKESTATIC && owner.equals(fromFuncOwner) + if (opcode == Opcodes.INVOKESTATIC && owner.equals(fromFuncOwner) && name.equals(fromFuncName) && desc.equals(fromFunDesc)) { super.visitMethodInsn(Opcodes.INVOKESTATIC, toFuncOwner, toFuncName, toFunDesc, false); - } - else { + } else { super.visitMethodInsn(opcode, owner, name, desc, itf); } } diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java index 50eb0ecfceea..627f727a0e23 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java @@ -146,33 +146,32 @@ public static void createReflectConfig(Path nativeConfigPath, Package currentPac Path mockedFunctionClassPath = nativeConfigPath.resolve("mocked-func-class-map.json"); File mockedFunctionClassFile = new File(mockedFunctionClassPath.toString()); if (mockedFunctionClassFile.isFile()) { - try (BufferedReader br = Files.newBufferedReader(mockedFunctionClassPath, StandardCharsets.UTF_8)) { - Gson gsonRead = new Gson(); - Map testFileMockedFunctionMapping = gsonRead.fromJson(br, - new TypeToken>() { - }.getType()); - if (!testFileMockedFunctionMapping.isEmpty()) { - ReflectConfigClass originalTestFileRefConfClz; - for (Map.Entry testFileMockedFunctionMappingEntry : - testFileMockedFunctionMapping.entrySet()) { - String moduleName = testFileMockedFunctionMappingEntry.getKey().split("-")[0]; - String testFile = testFileMockedFunctionMappingEntry.getKey().split("-")[1]; - String[] mockedFunctions = testFileMockedFunctionMappingEntry.getValue(); - originalTestFileRefConfClz = new ReflectConfigClass(getQualifiedClassName(org, moduleName, - version, testFile)); - for (int i = 0; i < mockedFunctions.length; i++) { - originalTestFileRefConfClz.addReflectConfigClassMethod( - new ReflectConfigClassMethod(mockedFunctions[i])); - originalTestFileRefConfClz.setUnsafeAllocated(true); - originalTestFileRefConfClz.setAllDeclaredFields(true); - originalTestFileRefConfClz.setQueryAllDeclaredMethods(true); - } - classList.add(originalTestFileRefConfClz); + BufferedReader br = Files.newBufferedReader(mockedFunctionClassPath, StandardCharsets.UTF_8); + Gson gsonRead = new Gson(); + Map testFileMockedFunctionMapping = gsonRead.fromJson(br, + new TypeToken>() { + }.getType()); + if (!testFileMockedFunctionMapping.isEmpty()) { + ReflectConfigClass originalTestFileRefConfClz; + for (Map.Entry testFileMockedFunctionMappingEntry : + testFileMockedFunctionMapping.entrySet()) { + String moduleName = testFileMockedFunctionMappingEntry.getKey().split("-")[0]; + String testFile = testFileMockedFunctionMappingEntry.getKey().split("-")[1]; + String[] mockedFunctions = testFileMockedFunctionMappingEntry.getValue(); + originalTestFileRefConfClz = new ReflectConfigClass(getQualifiedClassName(org, moduleName, + version, testFile)); + for (int i = 0; i < mockedFunctions.length; i++) { + originalTestFileRefConfClz.addReflectConfigClassMethod( + new ReflectConfigClassMethod(mockedFunctions[i])); + originalTestFileRefConfClz.setUnsafeAllocated(true); + originalTestFileRefConfClz.setAllDeclaredFields(true); + originalTestFileRefConfClz.setQueryAllDeclaredMethods(true); } + classList.add(originalTestFileRefConfClz); } } } - ReflectConfigClass originalBalFileRefConfClz = new ReflectConfigClass(""); + ReflectConfigClass originalBalFileRefConfClz; Map> mockFunctionClassMapping = new HashMap<>(); extractMockFunctionClassMapping(testSuiteMap, mockFunctionClassMapping); for (Map.Entry> mockFunctionClassMapEntry : mockFunctionClassMapping.entrySet()) { @@ -230,7 +229,8 @@ public static void createReflectConfig(Path nativeConfigPath, Package currentPac } } - private static void extractMockFunctionClassMapping(Map testSuiteMap, Map> mockFunctionClassMapping) { + private static void extractMockFunctionClassMapping(Map testSuiteMap, + Map> mockFunctionClassMapping) { for (Map.Entry testSuiteEntry : testSuiteMap.entrySet()) { TestSuite suite = testSuiteEntry.getValue(); for (Map.Entry mockFunctionEntry : suite.getMockFunctionNamesMap().entrySet()) { diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/OrigMockFunctionReplaceVisitor.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/OrigMockFunctionReplaceVisitor.java index 174aaa68713b..175ea9d5b45c 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/OrigMockFunctionReplaceVisitor.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/OrigMockFunctionReplaceVisitor.java @@ -46,13 +46,11 @@ public class OrigMockFunctionReplaceVisitor extends ClassVisitor { private final Method origMethod; - private final Method mockFunc; public OrigMockFunctionReplaceVisitor - (int api, ClassWriter cw, Method origMethod, Method mockFunc) { + (int api, ClassWriter cw, Method origMethod) { super(api, cw); this.origMethod = origMethod; - this.mockFunc = mockFunc; } @Override diff --git a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestNativeImageCommandTest.java b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestNativeImageCommandTest.java index 7275db41313b..9b48b6a166b5 100644 --- a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestNativeImageCommandTest.java +++ b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestNativeImageCommandTest.java @@ -60,4 +60,20 @@ public void testNativeImageTests() throws IOException { String buildLog = readOutput(true); Assert.assertTrue(buildLog.contains("1 passed")); } + + @Test(description = "Test function mocking") + public void testNativeFunctionMockTests() throws IOException { + Path projectPath = this.testResources.resolve("mockFunctionNative"); + System.setProperty(ProjectConstants.USER_DIR, projectPath.toString()); + TestCommand testCommand = new TestCommand(projectPath, printStream, printStream, false, true); + // non existing bal file + new CommandLine(testCommand).parse(); + testCommand.execute(); + String buildLog = readOutput(true); + Assert.assertTrue(buildLog.contains("[pass] intAddTest")); + Assert.assertTrue(buildLog.contains("[pass] intAddTest2")); + Assert.assertTrue(buildLog.contains("[pass] intAddTest3")); + Assert.assertTrue(buildLog.contains("[pass] intAddTest4")); + + } } diff --git a/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/Ballerina.toml b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/Ballerina.toml new file mode 100644 index 000000000000..a336d131478f --- /dev/null +++ b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/Ballerina.toml @@ -0,0 +1,8 @@ +[package] +org = "foo" +name = "winery" +version = "0.1.0" + + +[build-options] +observabilityIncluded = true diff --git a/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/main.bal b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/main.bal new file mode 100644 index 000000000000..e38ac20e6334 --- /dev/null +++ b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/main.bal @@ -0,0 +1,4 @@ +function intAdd(int a, int b) returns int { + return (a+b); + +} \ No newline at end of file diff --git a/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util/tests/lib_test.bal b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util/tests/lib_test.bal new file mode 100644 index 000000000000..90b426488a2d --- /dev/null +++ b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util/tests/lib_test.bal @@ -0,0 +1,58 @@ +import ballerina/test; + +import winery.util2 as util3; + +import ballerina/os; + +@test:Mock {functionName: "intAdd1"} +test:MockFunction intAddMockFn = new (); + +@test:Mock { + moduleName: "winery.util2", + functionName: "intDiv" +} +test:MockFunction mockFunc1 = new (); + +@test:Mock { + moduleName: "ballerina/os", + functionName: "getUserHome" +} +test:MockFunction mockFunc2 = new (); + +@test:Config {} +function intAddTest() { + + test:when(mockFunc1).thenReturn(100); + test:assertEquals(util3:intDiv(10, 10), 100); + + test:when(mockFunc2).thenReturn("alpha"); + test:assertEquals(os:getUserHome(), "alpha"); + + test:when(intAddMockFn).thenReturn(210); + test:assertEquals(intAdd1(33, 35), 210); + + test:when(intAddMockFn).withArguments(38, 35).thenReturn(21); + test:assertEquals(intAdd1(38, 35), 21); + + test:when(intAddMockFn).call("intSub"); + test:assertEquals(intAdd1(5, 5), 0); + + test:when(intAddMockFn).withArguments(4, 5).call("intMul"); + test:assertEquals(intAdd1(4, 5), 20); + + test:when(intAddMockFn).callOriginal(); + test:assertEquals(intAdd1(34, 5), 39); + + test:when(intAddMockFn).withArguments(123, 122).callOriginal(); + test:assertEquals(intAdd1(123, 122), 245); + +} + +function intSub(int a, int b) returns int { + return (a - b); +} + +function intMul(int a, int b) returns int { + return (a * b); +} + diff --git a/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util/tests/lib_test2.bal b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util/tests/lib_test2.bal new file mode 100644 index 000000000000..971a3a7c896d --- /dev/null +++ b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util/tests/lib_test2.bal @@ -0,0 +1,18 @@ +import ballerina/test; + +import ballerina/os; + +@test:Config {} +function intAddTest2() { + + // test:when(mockFunc1).thenReturn(100); + // test:assertEquals(util3:intDiv(10, 10), 100); + + // test:when(mockFunc2).thenReturn("alpha"); + // test:assertEquals(os:getUsername(), "alpha"); + + test:when(intAddMockFn).thenReturn(2900); + test:assertEquals(intAdd1(33, 35), 2900); + + test:assertEquals(os:getUserHome(), "alpha"); +} diff --git a/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util/util.bal b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util/util.bal new file mode 100644 index 000000000000..5323f147da57 --- /dev/null +++ b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util/util.bal @@ -0,0 +1,4 @@ +function intAdd1(int a, int b) returns int { + return (a+b); + +} \ No newline at end of file diff --git a/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util2/tests/tes.bal b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util2/tests/tes.bal new file mode 100644 index 000000000000..c8f950be089e --- /dev/null +++ b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util2/tests/tes.bal @@ -0,0 +1,11 @@ +import ballerina/test; + +import ballerina/os; + +@test:Config {} +function intAddTest3() { + test:assertNotEquals(os:getUserHome(), "alpha"); + test:assertNotEquals(os:getUserHome(), "beta"); + +} + diff --git a/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util2/util2.bal b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util2/util2.bal new file mode 100644 index 000000000000..d4ef8219adca --- /dev/null +++ b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util2/util2.bal @@ -0,0 +1,4 @@ +public function intDiv(int a, int b) returns int { + return (a / b); + +} diff --git a/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/tests/tes.bal b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/tests/tes.bal new file mode 100644 index 000000000000..ce8d224f56e8 --- /dev/null +++ b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/tests/tes.bal @@ -0,0 +1,47 @@ +import ballerina/test; + +import ballerina/os; + +@test:Mock {functionName: "intAdd"} +test:MockFunction intAddMockFn = new (); + +@test:Mock { + moduleName: "ballerina/os", + functionName: "getUserHome" +} +test:MockFunction mockFunc2 = new (); + +@test:Config {} +function intAddTest4() { + + test:when(mockFunc2).thenReturn("beta"); + test:assertEquals(os:getUserHome(), "beta"); + + test:when(intAddMockFn).thenReturn(210); + test:assertEquals(intAdd(33, 35), 210); + + test:when(intAddMockFn).withArguments(38, 35).thenReturn(21); + test:assertEquals(intAdd(38, 35), 21); + + test:when(intAddMockFn).call("intSub"); + test:assertEquals(intAdd(5, 5), 0); + + test:when(intAddMockFn).withArguments(4, 5).call("intMul"); + test:assertEquals(intAdd(4, 5), 20); + + test:when(intAddMockFn).callOriginal(); + test:assertEquals(intAdd(34, 5), 39); + + test:when(intAddMockFn).withArguments(123, 122).callOriginal(); + test:assertEquals(intAdd(123, 122), 245); + +} + +function intSub(int a, int b) returns int { + return (a - b); +} + +function intMul(int a, int b) returns int { + return (a * b); +} + diff --git a/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/TestExecutionGenerationTask.java b/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/TestExecutionGenerationTask.java index 23dbd233debd..86ba2b20a293 100644 --- a/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/TestExecutionGenerationTask.java +++ b/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/TestExecutionGenerationTask.java @@ -178,27 +178,29 @@ private static void generateClassMockedFunctionMapping(Package pack, SourceGener String documentName = moduleName + "-" + document.name().replace(".bal", "") .replace("/", "."); List mockedFunctionList = new ArrayList<>(); - Node node = document.syntaxTree().rootNode(); + Node rootNode = document.syntaxTree().rootNode(); TestFunctionVisitor testFunctionVisitor = new TestFunctionVisitor(); - node.accept(testFunctionVisitor); + rootNode.accept(testFunctionVisitor); for (FunctionDefinitionNode func : testFunctionVisitor.getTestStaticFunctions()) { FunctionBodyNode functionBodyNode = func.functionBody(); NodeList statements = ((FunctionBodyBlockNode) functionBodyNode).statements(); for (int i = 0; i < statements.size(); i++) { - StatementNode functionBodyContent = (StatementNode) statements.get(i); - if (functionBodyContent instanceof ExpressionStatementNode) { - ExpressionNode methodCallNode = ((ExpressionStatementNode) functionBodyContent) - .expression(); - if (methodCallNode instanceof MethodCallExpressionNode) { - ExpressionNode expression = ((MethodCallExpressionNode) methodCallNode).expression(); - if (expression instanceof FunctionCallExpressionNode) { - gatherMockedFunctions(mockedFunctionList, (MethodCallExpressionNode) - methodCallNode, (FunctionCallExpressionNode) expression); - } else if (expression instanceof MethodCallExpressionNode) { - expression = ((MethodCallExpressionNode) expression).expression(); - if (expression instanceof FunctionCallExpressionNode) { - gatherMockedFunctions(mockedFunctionList, (MethodCallExpressionNode) - methodCallNode, (FunctionCallExpressionNode) expression); + StatementNode statementNode = (StatementNode) statements.get(i); + if (statementNode instanceof ExpressionStatementNode) { + ExpressionNode expressionStatement = ((ExpressionStatementNode) statementNode).expression(); + if (expressionStatement instanceof MethodCallExpressionNode) { + ExpressionNode methodCallExpression = ((MethodCallExpressionNode) + expressionStatement).expression(); + if (methodCallExpression instanceof FunctionCallExpressionNode) { + gatherMockedFunctions(mockedFunctionList, expressionStatement, + methodCallExpression); + + } else if (methodCallExpression instanceof MethodCallExpressionNode) { + methodCallExpression = ((MethodCallExpressionNode) + methodCallExpression).expression(); + if (methodCallExpression instanceof FunctionCallExpressionNode) { + gatherMockedFunctions(mockedFunctionList, expressionStatement, + methodCallExpression); } } } @@ -214,19 +216,22 @@ private static void generateClassMockedFunctionMapping(Package pack, SourceGener "mocked-func-class-map.json"); } - private static void gatherMockedFunctions(List mockedFunctionList, MethodCallExpressionNode methodCallNode, - FunctionCallExpressionNode expression) { - NameReferenceNode functionName = expression.functionName(); + private static void gatherMockedFunctions(List mockedFunctionList, ExpressionNode expressionStatement, + ExpressionNode methodCallExpression) { + MethodCallExpressionNode methodCallExpressionNode = (MethodCallExpressionNode) expressionStatement; + FunctionCallExpressionNode functionCallExpressionNode = (FunctionCallExpressionNode) methodCallExpression; + NameReferenceNode functionName = functionCallExpressionNode.functionName(); if (functionName instanceof QualifiedNameReferenceNode) { String modulePrefix = ((QualifiedNameReferenceNode) functionName). modulePrefix().text(); String identifier = ((QualifiedNameReferenceNode) functionName). identifier().text(); - String methodName = methodCallNode.methodName() + String methodName = methodCallExpressionNode.methodName() .toString().strip(); + if ("test".equals(modulePrefix) && "call".equals(methodName) && "when".equals(identifier)) { - String mockedFunction = methodCallNode.arguments() + String mockedFunction = methodCallExpressionNode.arguments() .get(0).toString().replaceAll("\"", ""); mockedFunctionList.add(mockedFunction); } diff --git a/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/exceptions/CacheGenException.java b/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/exceptions/CacheGenException.java index 27a90bb0454a..be202e2b11e2 100644 --- a/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/exceptions/CacheGenException.java +++ b/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/exceptions/CacheGenException.java @@ -1,5 +1,9 @@ package org.ballerinalang.testerina.compiler.exceptions; - +/** + * Exception class to throw exception when the test document - mock function map fails to generate. + * + * @since 2201.4.0 + */ public class CacheGenException extends RuntimeException { public CacheGenException(String msg) { super(msg); From 2726f4c5853eccf4891a379a263a2b52640f7a07 Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Wed, 30 Nov 2022 11:22:42 +0530 Subject: [PATCH 138/450] Fix checkstlyle failures --- .../generators/service/nodevisitors/ActionNodeVisitor.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ActionNodeVisitor.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ActionNodeVisitor.java index ec5d808a2735..2e5c2fff7bbd 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ActionNodeVisitor.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ActionNodeVisitor.java @@ -21,7 +21,6 @@ import io.ballerina.compiler.api.ModuleID; import io.ballerina.compiler.api.SemanticModel; import io.ballerina.compiler.api.symbols.Annotatable; -import io.ballerina.compiler.api.symbols.AnnotationAttachmentSymbol; import io.ballerina.compiler.api.symbols.ModuleSymbol; import io.ballerina.compiler.api.symbols.Symbol; import io.ballerina.compiler.syntax.tree.BasicLiteralNode; @@ -47,7 +46,6 @@ import io.ballerina.projectdesign.generators.GeneratorUtils; import io.ballerina.projectdesign.model.service.Interaction; import io.ballerina.projectdesign.model.service.ResourceId; -import io.ballerina.projectdesign.model.service.ServiceAnnotation; import io.ballerina.projects.DocumentId; import io.ballerina.projects.Package; import io.ballerina.tools.diagnostics.Location; From ce0fa2ed9d2ea66434c0b7dc33156431c748f4af Mon Sep 17 00:00:00 2001 From: Sasindu Alahakoon Date: Wed, 30 Nov 2022 11:08:52 +0530 Subject: [PATCH 139/450] Fix test failure in create var type code action --- .../providers/createvar/CreateVariableWithTypeCodeAction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/createvar/CreateVariableWithTypeCodeAction.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/createvar/CreateVariableWithTypeCodeAction.java index 8e1da099e2a3..636ffb1cba15 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/createvar/CreateVariableWithTypeCodeAction.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/createvar/CreateVariableWithTypeCodeAction.java @@ -75,7 +75,7 @@ public class CreateVariableWithTypeCodeAction extends CreateVariableCodeAction { @Override public boolean validate(Diagnostic diagnostic, DiagBasedPositionDetails positionDetails, CodeActionContext context) { - return diagnostic.diagnosticInfo().code().equals("BCE4046") + return diagnostic.diagnosticInfo().code().equals("BCE4038") && context.currentSemanticModel().isPresent() && isInRemoteMethodCallOrResourceAccess(context) && CodeActionNodeValidator.validate(context.nodeAtRange()); From 12c8dd1262ab742d60792cd1eabd5ce909e13d2c Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Wed, 30 Nov 2022 12:44:45 +0530 Subject: [PATCH 140/450] Implement connectorType retrieval method --- .../generators/GeneratorUtils.java | 18 +++++++++++++++++- .../nodevisitors/ActionNodeVisitor.java | 10 +++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/GeneratorUtils.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/GeneratorUtils.java index ee3594d64a3d..0ce0bacb778f 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/GeneratorUtils.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/GeneratorUtils.java @@ -18,13 +18,16 @@ package io.ballerina.projectdesign.generators; +import io.ballerina.compiler.api.SemanticModel; import io.ballerina.compiler.api.symbols.Annotatable; import io.ballerina.compiler.api.symbols.AnnotationAttachmentSymbol; import io.ballerina.compiler.api.symbols.AnnotationSymbol; +import io.ballerina.compiler.api.symbols.TypeSymbol; import io.ballerina.compiler.api.values.ConstantValue; import io.ballerina.compiler.syntax.tree.AnnotationNode; import io.ballerina.compiler.syntax.tree.ExpressionNode; import io.ballerina.compiler.syntax.tree.MappingFieldNode; +import io.ballerina.compiler.syntax.tree.Node; import io.ballerina.compiler.syntax.tree.NodeList; import io.ballerina.compiler.syntax.tree.SeparatedNodeList; import io.ballerina.compiler.syntax.tree.SpecificFieldNode; @@ -35,8 +38,10 @@ import java.util.LinkedHashMap; import java.util.List; +import java.util.Optional; import java.util.UUID; +import static io.ballerina.projectdesign.ProjectDesignConstants.CLIENT; import static io.ballerina.projectdesign.ProjectDesignConstants.DISPLAY_ANNOTATION; import static io.ballerina.projectdesign.ProjectDesignConstants.ID; import static io.ballerina.projectdesign.ProjectDesignConstants.LABEL; @@ -97,7 +102,7 @@ public static ServiceAnnotation getServiceAnnotation(NodeList an public static ServiceAnnotation getServiceAnnotation(Annotatable annotableSymbol, String filePath) { - String id = UUID.randomUUID().toString(); + String id = null; String label = ""; ElementLocation elementLocation = null; @@ -127,4 +132,15 @@ public static ServiceAnnotation getServiceAnnotation(Annotatable annotableSymbol return new ServiceAnnotation(id, label, elementLocation); } + + public static String getClientModuleName(Node clientNode, SemanticModel semanticModel) { + + String clientModuleName = null; + Optional clientTypeSymbol = semanticModel.typeOf(clientNode); + if (clientTypeSymbol.isPresent()) { + clientModuleName = clientTypeSymbol.get().signature().trim().replace(CLIENT, ""); + } + + return clientModuleName; + } } diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ActionNodeVisitor.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ActionNodeVisitor.java index 2e5c2fff7bbd..3f710a42c003 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ActionNodeVisitor.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ActionNodeVisitor.java @@ -58,6 +58,7 @@ import static io.ballerina.projectdesign.ProjectDesignConstants.FORWARD_SLASH; import static io.ballerina.projectdesign.ProjectDesignConstants.TYPE_MAP; +import static io.ballerina.projectdesign.generators.GeneratorUtils.getClientModuleName; import static io.ballerina.projectdesign.generators.GeneratorUtils.getServiceAnnotation; /** @@ -89,9 +90,6 @@ public void visit(ClientResourceAccessActionNode clientResourceAccessActionNode) String resourceMethod = String.valueOf(clientResourceAccessActionNode.methodName().get().name().text()); String resourcePath = getResourcePath(clientResourceAccessActionNode.resourceAccessPath()); - StatementNodeVisitor statementVisitor = - new StatementNodeVisitor(String.valueOf(clientNode).trim(), semanticModel, filePath); - String serviceId = null; Optional clientSymbol = semanticModel.symbol(clientNode); if (clientSymbol.isPresent()) { @@ -101,7 +99,7 @@ public void visit(ClientResourceAccessActionNode clientResourceAccessActionNode) Interaction interaction = new Interaction( new ResourceId(serviceId, resourceMethod, resourcePath), - statementVisitor.getConnectorType(), GeneratorUtils.getElementLocation(filePath, + getClientModuleName(clientNode, semanticModel), GeneratorUtils.getElementLocation(filePath, clientResourceAccessActionNode.lineRange())); interactionList.add(interaction); } @@ -123,8 +121,6 @@ public void visit(RemoteMethodCallActionNode remoteMethodCallActionNode) { if (clientNode != null) { String resourceMethod = remoteMethodCallActionNode.methodName().name().text(); - StatementNodeVisitor statementVisitor = - new StatementNodeVisitor(clientNode.name().text(), semanticModel, filePath); String serviceId = null; Optional clientSymbol = semanticModel.symbol(clientNode); @@ -134,7 +130,7 @@ public void visit(RemoteMethodCallActionNode remoteMethodCallActionNode) { } Interaction interaction = new Interaction(new ResourceId(serviceId, - resourceMethod, null), statementVisitor.getConnectorType(), + resourceMethod, null), getClientModuleName(clientNode, semanticModel), GeneratorUtils.getElementLocation(filePath, remoteMethodCallActionNode.lineRange())); interactionList.add(interaction); } From 463e6f18cfb732401e830e9e7a45a9e78a5e2a51 Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Wed, 30 Nov 2022 13:53:47 +0530 Subject: [PATCH 141/450] Address review comments --- .../projectdesign/generators/GeneratorUtils.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/GeneratorUtils.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/GeneratorUtils.java index 0ce0bacb778f..2df257d19920 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/GeneratorUtils.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/GeneratorUtils.java @@ -115,16 +115,17 @@ public static ServiceAnnotation getServiceAnnotation(Annotatable annotableSymbol String annotName = annotSymbol.getName().orElse(""); elementLocation = annotSymbol.getLocation().isPresent() ? getElementLocation(filePath, annotSymbol.getLocation().get().lineRange()) : null; - if (!(annotName.equals(DISPLAY_ANNOTATION) || annotAttachmentSymbol.attachmentValue().isEmpty()) || - !(annotAttachmentSymbol.attachmentValue().get().value() instanceof LinkedHashMap)) { + if (!annotName.equals(DISPLAY_ANNOTATION) || annotAttachmentSymbol.attachmentValue().isEmpty() || + !(annotAttachmentSymbol.attachmentValue().get().value() instanceof LinkedHashMap) || + !annotAttachmentSymbol.isConstAnnotation()) { continue; } LinkedHashMap attachmentValue = (LinkedHashMap) annotAttachmentSymbol.attachmentValue().get().value(); if (attachmentValue.containsKey(ID)) { - id = (String) ((ConstantValue) attachmentValue.get(ID)).value(); + id = ((ConstantValue) attachmentValue.get(ID)).value().toString(); } if (attachmentValue.containsKey(LABEL)) { - label = (String) ((ConstantValue) attachmentValue.get(LABEL)).value(); + label = ((ConstantValue) attachmentValue.get(LABEL)).value().toString(); } break; } From 8a41a1456f906caeb667099fa5bc50a887f942df Mon Sep 17 00:00:00 2001 From: Nadeeshan96 Date: Wed, 30 Nov 2022 16:01:14 +0530 Subject: [PATCH 142/450] Fix failing documentation tests --- .../deprecated_annotation_project/main.bal | 12 +++++++++--- .../documentation/multi_line_docs_project/main.bal | 10 ++++++++-- .../record_object_fields_project/main.bal | 10 ++++++++-- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/documentation/deprecated_annotation_project/main.bal b/tests/jballerina-unit-test/src/test/resources/test-src/documentation/deprecated_annotation_project/main.bal index a8db593af491..31c888fa523b 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/documentation/deprecated_annotation_project/main.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/documentation/deprecated_annotation_project/main.bal @@ -1,4 +1,4 @@ -import ballerina/io; +import ballerina/jballerina.java; //========== MODULE-LEVEL CONST DECL ======================== @@ -175,7 +175,7 @@ public function createPerson(string fname, string lname, string street, # # + name - name person want to say hello public function sayHello(string name) { - io:println("Hello " + name); + println("Hello " + name); } //========= REQUIRED AND DEFAULTABLE FUNCTION PARAMS ====== @@ -213,5 +213,11 @@ public class Player { public function main() { Person p = createPerson("Jane", "Doe", "Castro Street", "Mountain View", USA); - io:println(p.getFullName()); + println(p.getFullName()); } + +// helper functions + +function println(any|error... values) = @java:Method { + 'class: "org.ballerinalang.test.utils.interop.Utils" +} external; diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/documentation/multi_line_docs_project/main.bal b/tests/jballerina-unit-test/src/test/resources/test-src/documentation/multi_line_docs_project/main.bal index dde5e4d23528..6895f4f00cc4 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/documentation/multi_line_docs_project/main.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/documentation/multi_line_docs_project/main.bal @@ -1,4 +1,4 @@ -import ballerina/io; +import ballerina/jballerina.java; # Returns a formatted string using the specified format string and arguments. Following format specifiers are allowed. # @@ -57,5 +57,11 @@ public function deprecatedMultilineDocsFunction(string format) returns string { } public function main() { - io:println(multilineDocsFunction("world")); + println(multilineDocsFunction("world")); } + +// helper functions + +function println(any|error... values) = @java:Method { + 'class: "org.ballerinalang.test.utils.interop.Utils" +} external; diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/documentation/record_object_fields_project/main.bal b/tests/jballerina-unit-test/src/test/resources/test-src/documentation/record_object_fields_project/main.bal index fbdd580df1aa..691eed706160 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/documentation/record_object_fields_project/main.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/documentation/record_object_fields_project/main.bal @@ -1,4 +1,4 @@ -import ballerina/io; +import ballerina/jballerina.java; public const string LKA = "LKA"; public const string LK = "LK"; @@ -74,5 +74,11 @@ public class Employee { # Prints `Hello World`. public function main() { - io:println("Hello World!"); + println("Hello World!"); } + +// helper functions + +function println(any|error... values) = @java:Method { + 'class: "org.ballerinalang.test.utils.interop.Utils" +} external; From 4c320aea4c48501ed7e877e5256f2c6a91cb4024 Mon Sep 17 00:00:00 2001 From: Thevakumar-Luheerathan Date: Wed, 30 Nov 2022 16:14:21 +0530 Subject: [PATCH 143/450] Fix failing test cases and add comments --- .../io/ballerina/cli/cmd/TestCommand.java | 2 +- .../cli/task/RunNativeImageTestTask.java | 89 ++++++++----------- .../io/ballerina/cli/utils/NativeUtils.java | 14 ++- .../cli/cmd/TestNativeImageCommandTest.java | 2 +- .../mockFunctionNative/Ballerina.toml | 4 +- .../mockFunctionNative/main.bal | 2 +- .../modules/util/tests/lib_test.bal | 4 +- .../modules/util/tests/lib_test2.bal | 6 -- .../mockFunctionNative/modules/util/util.bal | 2 +- 9 files changed, 53 insertions(+), 72 deletions(-) diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/TestCommand.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/TestCommand.java index 591c6e3e90d9..b864ec9dbe5f 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/TestCommand.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/TestCommand.java @@ -294,7 +294,7 @@ public void execute() { // .addTask(new CopyResourcesTask(), listGroups) // merged with CreateJarTask .addTask(new RunTestsTask(outStream, errStream, rerunTests, groupList, disableGroupList, testList, includes, coverageFormat, moduleMap, listGroups), project.buildOptions().nativeImage()) - .addTask(new RunNativeImageTestTask(outStream, rerunTests, groupList, disableGroupList, + .addTask(new RunNativeImageTestTask(outStream, errStream, rerunTests, groupList, disableGroupList, testList, includes, coverageFormat, moduleMap, listGroups), !project.buildOptions().nativeImage()) .addTask(new DumpBuildTimeTask(outStream), !project.buildOptions().dumpBuildTime()) diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java index 66905afd7504..6fea9121d743 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java @@ -52,17 +52,17 @@ import org.wso2.ballerinalang.util.Lists; import java.io.File; -import java.io.FileWriter; import java.io.FileInputStream; import java.io.FileOutputStream; +import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; -import java.nio.charset.Charset; import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; +import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -112,6 +112,7 @@ public class RunNativeImageTestTask implements Task { private static final String OS = System.getProperty("os.name").toLowerCase(Locale.getDefault()); private final PrintStream out; + private final PrintStream err; private final String includesInCoverage; private String groupList; private String disableGroupList; @@ -125,10 +126,11 @@ public class RunNativeImageTestTask implements Task { TestReport testReport; - public RunNativeImageTestTask(PrintStream out, boolean rerunTests, String groupList, - String disableGroupList, String testList, String includes, String coverageFormat, - Map modules, boolean listGroups) { + public RunNativeImageTestTask(PrintStream out, PrintStream errStream, boolean rerunTests, String groupList, + String disableGroupList, String testList, String includes, String coverageFormat, + Map modules, boolean listGroups) { this.out = out; + this.err = errStream; this.isRerunTestExecution = rerunTests; if (disableGroupList != null) { @@ -146,6 +148,7 @@ public RunNativeImageTestTask(PrintStream out, boolean rerunTests, String groupL this.listGroups = listGroups; } + //Get modified class bytes for function mock public static byte[] getModifiedClassBytes(String className, List functionNames, TestSuite suite, ClassLoader classLoader, List modifiedMethods) { Class functionToMockClass; @@ -210,14 +213,13 @@ public static byte[] getModifiedClassBytes(String className, List functi } } } - } else { - continue; } } } return classFile; } + //Get modified test class bytes for function mock public static byte[] getModifiedTestClassBytes(String className, List functionNames, TestSuite suite, ClassLoader classLoader, Class testDocumentClass, byte[] classFile) { @@ -328,6 +330,7 @@ private static byte[] replaceMethodBody(Method method) { return cw.toByteArray(); } + //Move mocked function as $ORIG_function private static byte[] replaceMethodBody(byte[] classFile, Method method) { ClassReader cr = new ClassReader(classFile); ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); @@ -350,6 +353,7 @@ public static List getURLList(List jarFilePaths) { return urlList; } + //Get all mocked functions in a class private static void populateClassNameVsFunctionToMockMap(Map> classVsMockFunctionsMap, Map mockFunctionMap) { for (Map.Entry entry : mockFunctionMap.entrySet()) { @@ -420,13 +424,14 @@ public void execute(Project project) { // Only tests in packages are executed so default packages i.e. single bal files which has the package name // as "." are ignored. This is to be consistent with the "bal test" command which only executes tests // in packages. + + //Track modified functions in a module jar and Have a mpping between modified jar and original jar Map originalVsModifiedJarMap = new HashMap<>(); List modifiedMethods = new ArrayList<>(); for (ModuleDescriptor moduleDescriptor : project.currentPackage().moduleDependencyGraph().toTopologicallySortedList()) { Module module = project.currentPackage().module(moduleDescriptor.name()); ModuleName moduleName = module.moduleName(); - boolean isMockFuncExist; TestSuite suite = testProcessor.testSuite(module).orElse(null); if (suite == null) { @@ -465,6 +470,7 @@ public void execute(Project project) { throw createLauncherException("error while generating the necessary graalvm reflection config ", e); } + //Remove all mock function entries from test suites for (Map.Entry testSuiteEntry : testSuiteMap.entrySet()) { TestSuite testSuite = testSuiteEntry.getValue(); if (!testSuite.getMockFunctionNamesMap().isEmpty()) { @@ -627,8 +633,9 @@ private int runTestSuiteWithNativeImage(Package currentPackage, JBallerinaBacken ProcessBuilder builder = new ProcessBuilder(); builder.command(cmdArgs.toArray(new String[0])); - builder.inheritIO(); Process process = builder.start(); + IOUtils.copy(process.getInputStream(), out); + IOUtils.copy(process.getErrorStream(), err); if (process.waitFor() == 0) { cmdArgs = new ArrayList<>(); @@ -648,8 +655,9 @@ private int runTestSuiteWithNativeImage(Package currentPackage, JBallerinaBacken cmdArgs.add(Boolean.toString(listGroups)); // 8 builder.command(cmdArgs.toArray(new String[0])); - builder.inheritIO(); process = builder.start(); + IOUtils.copy(process.getInputStream(), out); + IOUtils.copy(process.getErrorStream(), err); return process.waitFor(); } else { return 1; @@ -694,6 +702,7 @@ private void modifyJarForFunctionMock(TestSuite testSuite, Target target, Module return; } + //Add testable jar path to classloader URLs List testExecutionDependencies = testSuite.getTestExecutionDependencies(); List classLoaderUrlList = new ArrayList<>(); for (String testExecutionDependency : testExecutionDependencies) { @@ -706,10 +715,12 @@ private void modifyJarForFunctionMock(TestSuite testSuite, Target target, Module ClassLoader classLoader = null; + //Extract the className vs mocking functions list Map> classVsMockFunctionsMap = new HashMap<>(); Map mockFunctionMap = testSuite.getMockFunctionNamesMap(); populateClassNameVsFunctionToMockMap(classVsMockFunctionsMap, mockFunctionMap); + //Extract a mapping between classes and corresponding module jar Map> mainJarVsClassMapping = new HashMap<>(); for (Map.Entry> classVsMockFunctionsEntry : classVsMockFunctionsMap.entrySet()) { String className = classVsMockFunctionsEntry.getKey(); @@ -726,12 +737,13 @@ private void modifyJarForFunctionMock(TestSuite testSuite, Target target, Module } } + //Modify classes within module jar based on above mapping for (Map.Entry> mainJarVsClassEntry : mainJarVsClassMapping.entrySet()) { mainJarName = mainJarVsClassEntry.getKey(); modifiedJarName = mainJarName + HYPHEN + MODIFIED + JAR_EXTENSION; - + //If module jar is modified already, use modified one for (String testExecutionDependency : testExecutionDependencies) { if (testExecutionDependency.contains(mainJarName) && !testExecutionDependency.contains(TESTABLE)) { mainJarPath = testExecutionDependency; @@ -740,12 +752,13 @@ private void modifyJarForFunctionMock(TestSuite testSuite, Target target, Module } } } + //Add module jar path to classloader URLs classLoaderUrlList.add(mainJarPath); classLoader = AccessController.doPrivileged( (PrivilegedAction) () -> new URLClassLoader(getURLList(classLoaderUrlList). toArray(new URL[0]), ClassLoader.getSystemClassLoader())); - + //Modify classes within jar Map modifiedClassDef = new HashMap<>(); for (String className : mainJarVsClassEntry.getValue()) { List functionNamesList = classVsMockFunctionsMap.get(className); @@ -754,61 +767,24 @@ private void modifyJarForFunctionMock(TestSuite testSuite, Target target, Module modifiedClassDef.put(className, classFile); } + //Load all classes within module jar Map unmodifiedFiles = loadUnmodifiedFilesWithinJar(mainJarPath); String modifiedJarPath = (target.path().resolve(CACHE_DIR).resolve(testSuite.getOrgName()).resolve (testSuite.getPackageName()).resolve(testSuite.getVersion()).resolve(JAVA_11_DIR)).toString() + PATH_SEPARATOR + modifiedJarName; + //Dump modified jar dumpJar(modifiedClassDef, unmodifiedFiles, modifiedJarPath); + + //Have a modified jar mapping to modify graal vm classpath if (!originalVsModifiedJarMap.containsKey(mainJarPath)) { originalVsModifiedJarMap.put(mainJarPath, modifiedJarPath); } } -// -// String mainJarName = testSuite.getOrgName() + HYPHEN + moduleName + HYPHEN + -// testSuite.getVersion() + JAR_EXTENSION; -// String testJarName = testSuite.getOrgName() + HYPHEN + moduleName + HYPHEN + -// testSuite.getVersion() + HYPHEN + TESTABLE + JAR_EXTENSION; -// String modifiedJar = testSuite.getOrgName() + HYPHEN + moduleName + HYPHEN + testSuite.getVersion() + HYPHEN + -// MODIFIED + JAR_EXTENSION; -// if (testSuite.getMockFunctionNamesMap().isEmpty()) { -// return; -// } -// functionMockModuleMapping.put(mainJarName, modifiedJar); -// List testExecutionDependencies = testSuite.getTestExecutionDependencies(); -// -// -// List mockFunctionDependencies = new ArrayList<>(); -// for (String testExecutionDependency : testExecutionDependencies) { -// if (testExecutionDependency.endsWith(mainJarName) || testExecutionDependency.endsWith(testJarName)) { -// mockFunctionDependencies.add(testExecutionDependency); -// } -// } -// ClassLoader classLoader = AccessController.doPrivileged( -// (PrivilegedAction) () -> new URLClassLoader(getURLList(mockFunctionDependencies). -// toArray(new URL[0]), ClassLoader.getSystemClassLoader())); -// -// -// Map> classVsMockFunctionsMap = new HashMap<>(); -// Map mockFunctionMap = testSuite.getMockFunctionNamesMap(); -// populateClassNameVsFunctionToMockMap(classVsMockFunctionsMap, mockFunctionMap); -// Map modifiedClassDef = new HashMap<>(); -// for (Map.Entry> entry : classVsMockFunctionsMap.entrySet()) { -// String className = entry.getKey(); -// List functionNamesList = entry.getValue(); -// byte[] classFile = getModifiedClassBytes(className, functionNamesList, testSuite, classLoader); -// modifiedClassDef.put(className, classFile); -// } -// Map unmodifiedFiles = loadUnmodifiedFilesWithinJar(mockFunctionDependencies, mainJarName); -// String modifiedJarPath = (target.path().resolve(CACHE_DIR).resolve(testSuite.getOrgName()).resolve -// (testSuite.getPackageName()).resolve(testSuite.getVersion()).resolve(JAVA_11_DIR)).toString() -// + PATH_SEPARATOR + modifiedJar; -// dumpJar(modifiedClassDef, unmodifiedFiles, modifiedJarPath); - - //Modify testable jar for function mocking Map modifiedTestClassDef = new HashMap<>(); for (DocumentId testDocId : module.testDocumentIds()) { + //Get the class for test document Document testDocument = module.document(testDocId); String testDocumentName = testDocument.name().replace(".bal", "") .replace("/", "."); @@ -821,6 +797,7 @@ private void modifyJarForFunctionMock(TestSuite testSuite, Target target, Module throw createLauncherException("failed to load class: " + testDocumentClassName); } + //Replace the original functions(mocked) in test document with the corresponding $MOCK_ function byte[] classFile = new byte[0]; for (Map.Entry> entry : classVsMockFunctionsMap.entrySet()) { String className = entry.getKey(); @@ -830,14 +807,18 @@ private void modifyJarForFunctionMock(TestSuite testSuite, Target target, Module } modifiedTestClassDef.put(testDocumentClassName, classFile); } + //Get all unmodified classes within testable jar and dump modified version Map unmodifiedTestFiles = loadUnmodifiedFilesWithinJar(testJarPath); String modifiedTestJarPath = testJarPath.replace(JAR_EXTENSION, HYPHEN + MODIFIED + JAR_EXTENSION); dumpJar(modifiedTestClassDef, unmodifiedTestFiles, modifiedTestJarPath); + + //Have a modified jar mapping to modify graal vm classpath if (!originalVsModifiedJarMap.containsKey(testJarPath)) { originalVsModifiedJarMap.put(testJarPath, modifiedTestJarPath); } } + //Replace unmodified classes with corresponding modified classes and dump jar private void dumpJar(Map modifiedClassDefs, Map unmodifiedFiles, String modifiedJarPath) throws IOException { List duplicatePaths = new ArrayList<>(); diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java index 39329172b312..d5f9ba6b5f40 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java @@ -56,6 +56,7 @@ public class NativeUtils { private static final String MODULE_CONFIGURATION_MAPPER = "$configurationMapper"; private static final String MODULE_EXECUTE_GENERATED = "tests.test_execute-generated_"; + //Add dynamically loading classes and methods to reflection config public static void createReflectConfig(Path nativeConfigPath, Package currentPackage, Map testSuiteMap) throws IOException { String org = currentPackage.packageOrg().toString(); @@ -71,6 +72,7 @@ public static void createReflectConfig(Path nativeConfigPath, Package currentPac String name = module.moduleName().toString(); String moduleName = ProjectUtils.getJarFileName(module); + //Add init class ReflectConfigClass testInitRefConfClz = new ReflectConfigClass(getQualifiedClassName(org, name, version, MODULE_INIT_CLASS_NAME)); @@ -94,7 +96,7 @@ public static void createReflectConfig(Path nativeConfigPath, Package currentPac new String[]{"io.ballerina.runtime.internal.scheduling.RuntimeRegistry"} ) ); - + //Add configuration mapper ReflectConfigClass testConfigurationMapperRefConfClz = new ReflectConfigClass( getQualifiedClassName(org, name, version, MODULE_CONFIGURATION_MAPPER)); @@ -124,7 +126,7 @@ public static void createReflectConfig(Path nativeConfigPath, Package currentPac } ) ); - + //Add classes with $MOCK_function methods (mock function case) if (!testSuiteMap.get(moduleName).getMockFunctionNamesMap().isEmpty()) { ReflectConfigClass testNameZeroNameRefConfClz = new ReflectConfigClass(getQualifiedClassName( org, name, version, name.replace(DOT, FILE_NAME_PERIOD_SEPARATOR))); @@ -134,7 +136,7 @@ public static void createReflectConfig(Path nativeConfigPath, Package currentPac classList.add(testNameZeroNameRefConfClz); } - // Add all class values to the array + //Add all class values to the array classList.add(testInitRefConfClz); classList.add(testConfigurationMapperRefConfClz); classList.add(testTestExecuteGeneratedRefConfClz); @@ -142,7 +144,7 @@ public static void createReflectConfig(Path nativeConfigPath, Package currentPac } } - + //Add classes corresponding to test documents Path mockedFunctionClassPath = nativeConfigPath.resolve("mocked-func-class-map.json"); File mockedFunctionClassFile = new File(mockedFunctionClassPath.toString()); if (mockedFunctionClassFile.isFile()) { @@ -171,6 +173,8 @@ public static void createReflectConfig(Path nativeConfigPath, Package currentPac } } } + + //Add classes corresponding to ballerina source files ReflectConfigClass originalBalFileRefConfClz; Map> mockFunctionClassMapping = new HashMap<>(); extractMockFunctionClassMapping(testSuiteMap, mockFunctionClassMapping); @@ -187,6 +191,7 @@ public static void createReflectConfig(Path nativeConfigPath, Package currentPac classList.add(originalBalFileRefConfClz); } + //Add test suite class ReflectConfigClass runtimeEntityTestSuiteRefConfClz = new ReflectConfigClass( "org.ballerinalang.test.runtime.entity" + ".TestSuite"); runtimeEntityTestSuiteRefConfClz.setAllDeclaredFields(true); @@ -203,6 +208,7 @@ public static void createReflectConfig(Path nativeConfigPath, Package currentPac } } + //Create $ORIG_function methods class mapping private static void extractMockFunctionClassMapping(Map testSuiteMap, Map> mockFunctionClassMapping) { for (Map.Entry testSuiteEntry : testSuiteMap.entrySet()) { diff --git a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestNativeImageCommandTest.java b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestNativeImageCommandTest.java index 9b48b6a166b5..7c87dcd3b3f0 100644 --- a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestNativeImageCommandTest.java +++ b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestNativeImageCommandTest.java @@ -58,7 +58,7 @@ public void testNativeImageTests() throws IOException { new CommandLine(testCommand).parse(); testCommand.execute(); String buildLog = readOutput(true); - Assert.assertTrue(buildLog.contains("1 passed")); + Assert.assertTrue(buildLog.contains("1 passing")); } @Test(description = "Test function mocking") diff --git a/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/Ballerina.toml b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/Ballerina.toml index a336d131478f..55d9df724569 100644 --- a/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/Ballerina.toml +++ b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/Ballerina.toml @@ -1,6 +1,6 @@ [package] -org = "foo" -name = "winery" +org = "bar" +name = "winner" version = "0.1.0" diff --git a/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/main.bal b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/main.bal index e38ac20e6334..1641fce4acf2 100644 --- a/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/main.bal +++ b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/main.bal @@ -1,4 +1,4 @@ function intAdd(int a, int b) returns int { return (a+b); -} \ No newline at end of file +} diff --git a/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util/tests/lib_test.bal b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util/tests/lib_test.bal index 90b426488a2d..8bfbf287d68a 100644 --- a/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util/tests/lib_test.bal +++ b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util/tests/lib_test.bal @@ -1,6 +1,6 @@ import ballerina/test; -import winery.util2 as util3; +import winner.util2 as util3; import ballerina/os; @@ -8,7 +8,7 @@ import ballerina/os; test:MockFunction intAddMockFn = new (); @test:Mock { - moduleName: "winery.util2", + moduleName: "winner.util2", functionName: "intDiv" } test:MockFunction mockFunc1 = new (); diff --git a/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util/tests/lib_test2.bal b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util/tests/lib_test2.bal index 971a3a7c896d..dd60f083f4d8 100644 --- a/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util/tests/lib_test2.bal +++ b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util/tests/lib_test2.bal @@ -5,12 +5,6 @@ import ballerina/os; @test:Config {} function intAddTest2() { - // test:when(mockFunc1).thenReturn(100); - // test:assertEquals(util3:intDiv(10, 10), 100); - - // test:when(mockFunc2).thenReturn("alpha"); - // test:assertEquals(os:getUsername(), "alpha"); - test:when(intAddMockFn).thenReturn(2900); test:assertEquals(intAdd1(33, 35), 2900); diff --git a/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util/util.bal b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util/util.bal index 5323f147da57..fa10095c9d1b 100644 --- a/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util/util.bal +++ b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util/util.bal @@ -1,4 +1,4 @@ function intAdd1(int a, int b) returns int { return (a+b); -} \ No newline at end of file +} From 8f53c40c54297c2c1ec2f54db4210c72a5efad41 Mon Sep 17 00:00:00 2001 From: Gayal Dassanayake Date: Wed, 30 Nov 2022 17:37:48 +0530 Subject: [PATCH 144/450] Add empty proj validation to run,test cmds --- .../io/ballerina/cli/cmd/PackCommand.java | 19 ++------ .../java/io/ballerina/cli/cmd/RunCommand.java | 8 ++++ .../io/ballerina/cli/cmd/TestCommand.java | 8 ++++ .../io/ballerina/cli/cmd/RunCommandTest.java | 35 +++++++++----- .../io/ballerina/cli/cmd/TestCommandTest.java | 47 ++++++++++++------- 5 files changed, 74 insertions(+), 43 deletions(-) diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/PackCommand.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/PackCommand.java index b2791b4f24d4..81abb8d4b42f 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/PackCommand.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/PackCommand.java @@ -10,12 +10,11 @@ import io.ballerina.cli.utils.BuildTime; import io.ballerina.cli.utils.FileUtils; import io.ballerina.projects.BuildOptions; -import io.ballerina.projects.Module; -import io.ballerina.projects.ModuleId; import io.ballerina.projects.Project; import io.ballerina.projects.ProjectException; import io.ballerina.projects.directory.BuildProject; import io.ballerina.projects.util.ProjectConstants; +import io.ballerina.projects.util.ProjectUtils; import io.ballerina.toml.semantic.TomlType; import io.ballerina.toml.semantic.ast.TomlTableNode; import org.ballerinalang.toml.exceptions.SettingsTomlException; @@ -42,8 +41,8 @@ public class PackCommand implements BLauncherCmd { private final PrintStream outStream; private final PrintStream errStream; - private boolean exitWhenFinish; - private boolean skipCopyLibsFromDist; + private final boolean exitWhenFinish; + private final boolean skipCopyLibsFromDist; @CommandLine.Option(names = {"--offline"}, description = "Build/Compile offline without downloading " + "dependencies.") @@ -156,7 +155,7 @@ public void execute() { } // If project is empty - if (isProjectEmpty(project) && project.currentPackage().compilerPluginToml().isEmpty()) { + if (ProjectUtils.isProjectEmpty(project) && project.currentPackage().compilerPluginToml().isEmpty()) { CommandUtil.printError(this.errStream, "package is empty. Please add at least one .bal file.", null, false); CommandUtil.exitError(this.exitWhenFinish); @@ -274,16 +273,6 @@ private BuildOptions constructBuildOptions() { return buildOptionsBuilder.build(); } - private boolean isProjectEmpty(Project project) { - for (ModuleId moduleId : project.currentPackage().moduleIds()) { - Module module = project.currentPackage().module(moduleId); - if (!module.documentIds().isEmpty() || !module.testDocumentIds().isEmpty()) { - return false; - } - } - return true; - } - @Override public String getName() { return PACK_COMMAND; diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/RunCommand.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/RunCommand.java index 47764aae9d61..f884e289b336 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/RunCommand.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/RunCommand.java @@ -31,6 +31,7 @@ import io.ballerina.projects.directory.BuildProject; import io.ballerina.projects.directory.SingleFileProject; import io.ballerina.projects.util.ProjectConstants; +import io.ballerina.projects.util.ProjectUtils; import picocli.CommandLine; import java.io.PrintStream; @@ -196,6 +197,13 @@ public void execute() { } } + // If project is empty + if (ProjectUtils.isProjectEmpty(project)) { + CommandUtil.printError(this.errStream, "package is empty. Please add at least one .bal file.", null, false); + CommandUtil.exitError(this.exitWhenFinish); + return; + } + // Check package files are modified after last build boolean isPackageModified = isProjectUpdated(project); diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/TestCommand.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/TestCommand.java index 591c6e3e90d9..e66d815fae3a 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/TestCommand.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/TestCommand.java @@ -34,6 +34,7 @@ import io.ballerina.projects.directory.BuildProject; import io.ballerina.projects.directory.SingleFileProject; import io.ballerina.projects.util.ProjectConstants; +import io.ballerina.projects.util.ProjectUtils; import picocli.CommandLine; import java.io.PrintStream; @@ -244,6 +245,13 @@ public void execute() { } } + // If project is empty + if (ProjectUtils.isProjectEmpty(project)) { + CommandUtil.printError(this.errStream, "package is empty. Please add at least one .bal file.", null, false); + CommandUtil.exitError(this.exitWhenFinish); + return; + } + // Sets the debug port as a system property, which will be used when setting up debug args before running tests. if (this.debugPort != null) { System.setProperty(SYSTEM_PROP_BAL_DEBUG, this.debugPort); diff --git a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/RunCommandTest.java b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/RunCommandTest.java index d575dc50c344..ae3d1532967a 100644 --- a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/RunCommandTest.java +++ b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/RunCommandTest.java @@ -65,7 +65,7 @@ public void testRunValidBalFile() throws IOException { RunCommand runCommand = new RunCommand(validBalFilePath, printStream, false); // name of the file as argument new CommandLine(runCommand).setEndOfOptionsDelimiter("").setUnmatchedOptionsArePositionalParams(true) - .parse(validBalFilePath.toString(), "--", tempFile.toString()); + .parseArgs(validBalFilePath.toString(), "--", tempFile.toString()); Assert.assertFalse(tempFile.toFile().exists()); runCommand.execute(); @@ -84,11 +84,11 @@ public void testRunNonExistingBalFile() throws IOException { Path validBalFilePath = this.testResources.resolve("valid-run-bal-file").resolve("xyz.bal"); RunCommand runCommand = new RunCommand(validBalFilePath, printStream, false); // non existing bal file - new CommandLine(runCommand).parse(validBalFilePath.toString()); + new CommandLine(runCommand).parseArgs(validBalFilePath.toString()); runCommand.execute(); String buildLog = readOutput(true); Assert.assertTrue(buildLog.replaceAll("\r", "") - .contains("The file does not exist: " + validBalFilePath.toString())); + .contains("The file does not exist: " + validBalFilePath)); } @@ -98,7 +98,7 @@ public void testRunBalFileWithSyntaxError() { Path balFilePath = this.testResources.resolve("bal-file-with-syntax-error").resolve("hello_world.bal"); RunCommand runCommand = new RunCommand(balFilePath, printStream, false); // non existing bal file - new CommandLine(runCommand).parse(balFilePath.toString()); + new CommandLine(runCommand).parseArgs(balFilePath.toString()); try { runCommand.execute(); } catch (BLauncherException e) { @@ -112,7 +112,7 @@ public void testRunBalProjectWithSyntaxError() { Path balFilePath = this.testResources.resolve("bal-project-with-syntax-error"); RunCommand runCommand = new RunCommand(balFilePath, printStream, false); // non existing bal file - new CommandLine(runCommand).parse(balFilePath.toString()); + new CommandLine(runCommand).parseArgs(balFilePath.toString()); try { runCommand.execute(); } catch (BLauncherException e) { @@ -129,7 +129,7 @@ public void testRunValidBalProject() throws IOException { RunCommand runCommand = new RunCommand(projectPath, printStream, false); // name of the file as argument new CommandLine(runCommand).setEndOfOptionsDelimiter("").setUnmatchedOptionsArePositionalParams(true) - .parse(projectPath.toString(), "--", tempFile.toString()); + .parseArgs(projectPath.toString(), "--", tempFile.toString()); Assert.assertFalse(tempFile.toFile().exists()); runCommand.execute(); @@ -148,7 +148,7 @@ public void testRunValidBalProjectFromProjectDir() throws IOException { RunCommand runCommand = new RunCommand(projectPath, printStream, false); // name of the file as argument new CommandLine(runCommand).setEndOfOptionsDelimiter("").setUnmatchedOptionsArePositionalParams(true) - .parse("--", tempFile.toString()); + .parseArgs("--", tempFile.toString()); Assert.assertFalse(tempFile.toFile().exists()); runCommand.execute(); @@ -167,7 +167,7 @@ public void testRunCommandWithInvalidArg() { RunCommand runCommand = new RunCommand(projectPath, printStream, false); // name of the file as argument new CommandLine(runCommand).setEndOfOptionsDelimiter("").setUnmatchedOptionsArePositionalParams(true) - .parse(projectPath.toString(), tempFile.toString()); + .parseArgs(projectPath.toString(), tempFile.toString()); try { runCommand.execute(); } catch (BLauncherException e) { @@ -181,7 +181,7 @@ public void testRunProjectContainingImportsWithPlatformLibs() { // set valid source root RunCommand runCommand = new RunCommand(projectPath, printStream, false); // name of the file as argument - new CommandLine(runCommand).parse(projectPath.toString()); + new CommandLine(runCommand).parseArgs(projectPath.toString()); // No assertions required since the command will fail upon expected behavior runCommand.execute(); @@ -203,7 +203,7 @@ public void testRunJarFile() { String args = "--offline"; new CommandLine(runCommand).setEndOfOptionsDelimiter("").setUnmatchedOptionsArePositionalParams(true) - .parse(projectPath.toString(), args, tempFile.toString()); + .parseArgs(projectPath.toString(), args, tempFile.toString()); try { runCommand.execute(); @@ -256,7 +256,7 @@ public void testNoClassDefProject() { System.setProperty("user.dir", String.valueOf(projectPath)); // set valid source root RunCommand runCommand = new RunCommand(projectPath, printStream, false); - new CommandLine(runCommand).parse(); + new CommandLine(runCommand).parseArgs(); runCommand.execute(); } @@ -310,4 +310,17 @@ public void testRunBalProjectWithDumpRawGraphsFlag() throws IOException { ProjectUtils.deleteDirectory(projectPath.resolve("target")); } + + @Test(description = "Run an empty package") + public void testRunEmptyPackage() throws IOException { + Path projectPath = this.testResources.resolve("emptyPackage"); + System.setProperty("user.dir", projectPath.toString()); + + RunCommand runCommand = new RunCommand(projectPath, printStream, false); + new CommandLine(runCommand).parseArgs(); + runCommand.execute(); + + String buildLog = readOutput(true); + Assert.assertEquals(buildLog.replaceAll("\r", ""), getOutput("build-empty-package.txt")); + } } diff --git a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestCommandTest.java b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestCommandTest.java index 6fdd88d8c970..f91bbc58251e 100644 --- a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestCommandTest.java +++ b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestCommandTest.java @@ -91,7 +91,7 @@ public void testTestBalFile() { // set valid source root TestCommand testCommand = new TestCommand(validBalFilePath, false); // name of the file as argument - new CommandLine(testCommand).parse(validBalFilePath.toString()); + new CommandLine(testCommand).parseArgs(validBalFilePath.toString()); testCommand.execute(); } @@ -103,7 +103,7 @@ public void testTestBalFileWithPeriods() { // set valid source root TestCommand testCommand = new TestCommand(validBalFilePath, false); // name of the file as argument - new CommandLine(testCommand).parse(validBalFilePath.toString()); + new CommandLine(testCommand).parseArgs(validBalFilePath.toString()); testCommand.execute(); } @@ -111,12 +111,12 @@ public void testTestBalFileWithPeriods() { public void testNonBalFileTest() throws IOException { Path nonBalFilePath = this.testResources.resolve("non-bal-file").resolve("hello_world.txt"); TestCommand testCommand = new TestCommand(nonBalFilePath, printStream, printStream, false); - new CommandLine(testCommand).parse(nonBalFilePath.toString()); + new CommandLine(testCommand).parseArgs(nonBalFilePath.toString()); testCommand.execute(); String buildLog = readOutput(true); Assert.assertTrue(buildLog.replaceAll("\r", "") - .contains("Invalid Ballerina source file(.bal): " + nonBalFilePath.toString())); + .contains("Invalid Ballerina source file(.bal): " + nonBalFilePath)); } @Test(description = "Test non existing bal file") @@ -125,11 +125,11 @@ public void testNonExistingBalFile() throws IOException { Path validBalFilePath = this.testResources.resolve("valid-non-bal-file").resolve("xyz.bal"); TestCommand testCommand = new TestCommand(validBalFilePath, printStream, printStream, false); // non existing bal file - new CommandLine(testCommand).parse(validBalFilePath.toString()); + new CommandLine(testCommand).parseArgs(validBalFilePath.toString()); testCommand.execute(); String buildLog = readOutput(true); Assert.assertTrue(buildLog.replaceAll("\r", "") - .contains("The file does not exist: " + validBalFilePath.toString())); + .contains("The file does not exist: " + validBalFilePath)); } @@ -139,7 +139,7 @@ public void testBalFileWithSyntaxError() { Path balFilePath = this.testResources.resolve("bal-file-with-syntax-error").resolve("sample_tests.bal"); TestCommand testCommand = new TestCommand(balFilePath, printStream, printStream, false); // non existing bal file - new CommandLine(testCommand).parse(balFilePath.toString()); + new CommandLine(testCommand).parseArgs(balFilePath.toString()); try { testCommand.execute(); } catch (BLauncherException e) { @@ -153,7 +153,7 @@ public void testBuildProjectWithTests() throws IOException { System.setProperty(ProjectConstants.USER_DIR, projectPath.toString()); TestCommand testCommand = new TestCommand(projectPath, printStream, printStream, false); // non existing bal file - new CommandLine(testCommand).parse(); + new CommandLine(testCommand).parseArgs(); testCommand.execute(); String buildLog = readOutput(true); Assert.assertEquals(buildLog.replaceAll("\r", ""), getOutput("test-project.txt")); @@ -165,7 +165,7 @@ public void testBuildMultiModuleProject() { System.setProperty(ProjectConstants.USER_DIR, projectPath.toString()); TestCommand testCommand = new TestCommand(projectPath, printStream, printStream, false); // non existing bal file - new CommandLine(testCommand).parse(); + new CommandLine(testCommand).parseArgs(); testCommand.execute(); } @@ -174,7 +174,7 @@ public void testTestBalProjectFromADifferentDirectory() throws IOException { Path projectPath = this.testResources.resolve("validProjectWithTests"); TestCommand buildCommand = new TestCommand(projectPath, printStream, printStream, false); // non existing bal file - new CommandLine(buildCommand).parse(projectPath.toString()); + new CommandLine(buildCommand).parseArgs(projectPath.toString()); buildCommand.execute(); String buildLog = readOutput(true); Assert.assertEquals(buildLog.replaceAll("\r", ""), getOutput("test-project.txt")); @@ -185,7 +185,7 @@ public void testHeapDumpGenerationForOOM() { Path projectPath = this.testResources.resolve("oom-project"); System.setProperty(ProjectConstants.USER_DIR, projectPath.toString()); TestCommand testCommand = new TestCommand(projectPath, printStream, printStream, false); - new CommandLine(testCommand).parse(); + new CommandLine(testCommand).parseArgs(); try { testCommand.execute(); @@ -202,7 +202,7 @@ public void testTestCommandPreservingBinJarInTargetDir() throws IOException { System.setProperty(ProjectConstants.USER_DIR, projectPath.toString()); // build the project BuildCommand buildCommand = new BuildCommand(projectPath, printStream, printStream, true , false); - new CommandLine(buildCommand).parse(); + new CommandLine(buildCommand).parseArgs(); buildCommand.execute(); Assert.assertTrue(projectPath.resolve("target").resolve("bin").resolve("winery.jar").toFile().exists()); String md5BinJar = DigestUtils.md5Hex( @@ -210,7 +210,7 @@ public void testTestCommandPreservingBinJarInTargetDir() throws IOException { // Run tests TestCommand testCommand = new TestCommand(projectPath, printStream, printStream, false); - new CommandLine(testCommand).parse(); + new CommandLine(testCommand).parseArgs(); testCommand.execute(); Assert.assertTrue(projectPath.resolve("target").resolve("bin").resolve("winery.jar").toFile().exists()); Assert.assertEquals(md5BinJar, DigestUtils.md5Hex( @@ -229,7 +229,7 @@ public void testUnsupportedCoverageFormat() throws IOException { TestCommand testCommand = new TestCommand( projectPath, printStream, printStream, false, false, true, "html"); - new CommandLine(testCommand).parse(); + new CommandLine(testCommand).parseArgs(); testCommand.execute(); String buildLog = readOutput(true); Assert.assertTrue(buildLog.contains("unsupported coverage report format 'html' found. Only 'xml' format is " + @@ -245,7 +245,7 @@ public void testCustomTargetDirWithTestCmd() { TestCommand testCommand = new TestCommand( projectPath, printStream, printStream, false, true, customTargetDir); - new CommandLine(testCommand).parse(); + new CommandLine(testCommand).parseArgs(); testCommand.execute(); Assert.assertFalse(Files.exists(customTargetDir.resolve("bin"))); @@ -272,7 +272,7 @@ public void testBalTestWithStickyFlag() throws IOException { // Run bal test command TestCommand firstTestCommand = new TestCommand(projectPath, printStream, printStream, false); - new CommandLine(firstTestCommand).parse(); + new CommandLine(firstTestCommand).parseArgs(); firstTestCommand.execute(); String buildLog = readOutput(true); Assert.assertEquals(buildLog.replaceAll("\r", ""), getOutput("bal-test-project.txt")); @@ -289,7 +289,7 @@ public void testBalTestWithStickyFlag() throws IOException { // Run bal test command with sticky flag TestCommand secondTestCommand = new TestCommand(projectPath, printStream, printStream, false); - new CommandLine(secondTestCommand).parse("--sticky"); + new CommandLine(secondTestCommand).parseArgs("--sticky"); secondTestCommand.execute(); String secondBuildLog = readOutput(true); Assert.assertEquals(secondBuildLog.replaceAll("\r", ""), getOutput("bal-test-project.txt")); @@ -346,6 +346,19 @@ public void testTestBalProjectWithDumpRawGraphsFlag() throws IOException { ProjectUtils.deleteDirectory(projectPath.resolve("target")); } + @Test(description = "Test an empty package") + public void testTestEmptyPackage() throws IOException { + Path projectPath = this.testResources.resolve("emptyPackage"); + System.setProperty("user.dir", projectPath.toString()); + + TestCommand testCommand = new TestCommand(projectPath, printStream, printStream, false); + new CommandLine(testCommand).parseArgs(); + testCommand.execute(); + + String buildLog = readOutput(true); + Assert.assertEquals(buildLog.replaceAll("\r", ""), getOutput("build-empty-package.txt")); + } + static class Copy extends SimpleFileVisitor { private Path fromPath; private Path toPath; From 854b96a745d50a72a4b87b90de1e3a9c6e2f886f Mon Sep 17 00:00:00 2001 From: praneesha Date: Thu, 1 Dec 2022 11:15:58 +0530 Subject: [PATCH 145/450] Update distribution/zip/jballerina-tools/README.md Co-authored-by: Nadeeshan96 <33286289+Nadeeshan96@users.noreply.github.com> --- distribution/zip/jballerina-tools/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distribution/zip/jballerina-tools/README.md b/distribution/zip/jballerina-tools/README.md index e44afd4c1cb6..1a0c1737a0b5 100644 --- a/distribution/zip/jballerina-tools/README.md +++ b/distribution/zip/jballerina-tools/README.md @@ -26,5 +26,5 @@ Ballerina code is distributed under [Apache license 2.0](https://github.com/ball ## Useful links - The ballerina-dev@googlegroups.com mailing list is for discussing code changes to the Ballerina project. -- Chat live with us on our [Discrod server](https://discord.gg/ballerinalang). +- Chat live with us on our [Discord server](https://discord.gg/ballerinalang). - Technical questions should be posted on Stack Overflow with the [#ballerina](https://stackoverflow.com/questions/tagged/ballerina) tag. From 254c4445105476f1f3110a77feb3f9d2c37096db Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Thu, 1 Dec 2022 14:15:15 +0530 Subject: [PATCH 146/450] Fix array-of-array parsing failure --- .../jsonmapper/JsonToRecordMapper.java | 60 +++++++++---------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java index 817ec55559a9..3ad9cb9143bd 100644 --- a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java +++ b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java @@ -201,20 +201,9 @@ private static void generateRecords(JsonObject jsonObject, String recordName, bo List recordFields = new ArrayList<>(); if (recordToTypeDescNodes.containsKey(recordName)) { for (Map.Entry entry : jsonObject.entrySet()) { - if (entry.getValue().isJsonObject()) { - String elementKey = entry.getKey(); - String type = StringUtils.capitalize(elementKey); - generateRecords(entry.getValue().getAsJsonObject(), type, isClosed, - recordToTypeDescNodes, recordName, jsonNodes, diagnosticMessages); - } else if (entry.getValue().isJsonArray()) { - for (JsonElement element : entry.getValue().getAsJsonArray()) { - if (element.isJsonObject()) { - String elementKey = entry.getKey(); - String type = StringUtils.capitalize(elementKey) + ARRAY_RECORD_SUFFIX; - generateRecords(element.getAsJsonObject(), type, isClosed, - recordToTypeDescNodes, recordName, jsonNodes, diagnosticMessages); - } - } + if (entry.getValue().isJsonObject() || entry.getValue().isJsonArray()) { + generateRecordForObjAndArray(entry.getValue(), entry.getKey(), isClosed, recordToTypeDescNodes, + recordName, jsonNodes, diagnosticMessages, false); } jsonNodes.put(entry.getKey(), entry.getValue()); } @@ -234,20 +223,9 @@ private static void generateRecords(JsonObject jsonObject, String recordName, bo recordFields, previousRecordFieldToNodes, newRecordFieldToNodes); } else { for (Map.Entry entry : jsonObject.entrySet()) { - if (entry.getValue().isJsonObject()) { - String elementKey = entry.getKey(); - String type = StringUtils.capitalize(elementKey); - generateRecords(entry.getValue().getAsJsonObject(), type, isClosed, - recordToTypeDescNodes, null, jsonNodes, diagnosticMessages); - } else if (entry.getValue().isJsonArray()) { - for (JsonElement element : entry.getValue().getAsJsonArray()) { - if (element.isJsonObject()) { - String elementKey = entry.getKey(); - String type = StringUtils.capitalize(elementKey) + ARRAY_RECORD_SUFFIX; - generateRecords(element.getAsJsonObject(), type, isClosed, - recordToTypeDescNodes, null, jsonNodes, diagnosticMessages); - } - } + if (entry.getValue().isJsonObject() || entry.getValue().isJsonArray()) { + generateRecordForObjAndArray(entry.getValue(), entry.getKey(), isClosed, recordToTypeDescNodes, + null, jsonNodes, diagnosticMessages, false); } jsonNodes.put(entry.getKey(), entry.getValue()); Node recordField = getRecordField(entry, false); @@ -274,6 +252,24 @@ private static void generateRecords(JsonObject jsonObject, String recordName, bo } } + private static void generateRecordForObjAndArray(JsonElement jsonElement, String elementKey, boolean isClosed, + Map recordToTypeDescNodes, + String moveBefore, Map jsonNodes, + List diagnosticMessages, + boolean arraySuffixAdded) { + if (jsonElement.isJsonObject()) { + String type = StringUtils.capitalize(elementKey); + generateRecords(jsonElement.getAsJsonObject(), type, isClosed, + recordToTypeDescNodes, moveBefore, jsonNodes, diagnosticMessages); + } else if (jsonElement.isJsonArray()) { + for (JsonElement element : jsonElement.getAsJsonArray()) { + String type = StringUtils.capitalize(elementKey) + (arraySuffixAdded ? "" : ARRAY_RECORD_SUFFIX); + generateRecordForObjAndArray(element, type, isClosed, recordToTypeDescNodes, moveBefore, + jsonNodes, diagnosticMessages, true); + } + } + } + /** * This method updates the record fields already generated, if the fields are optional. * @@ -387,8 +383,8 @@ private static Node getRecordField(Map.Entry entry, boolean fieldTypeName, fieldName, optionalFieldToken, semicolonToken); } else if (entry.getValue().isJsonObject()) { - String elementKey = entry.getKey(); - String type = StringUtils.capitalize(elementKey); + String elementKey = entry.getKey().trim(); + String type = StringUtils.capitalize(escapeIdentifier(elementKey)); typeName = AbstractNodeFactory.createIdentifierToken(type); fieldTypeName = NodeFactory.createBuiltinSimpleNameReferenceNode(typeName.kind(), typeName); recordFieldNode = NodeFactory.createRecordFieldNode(null, null, @@ -478,8 +474,8 @@ private static ArrayTypeDescriptorNode getArrayTypeDescriptorNode(Map.Entry Date: Sat, 15 Oct 2022 11:47:24 +0530 Subject: [PATCH 147/450] Improve sorting in module part context --- .../completions/StaticCompletionItem.java | 1 + .../util/ModulePartNodeContextUtil.java | 84 ++++++++++++++++--- .../util/ServiceTemplateGenerator.java | 2 +- .../langserver/completions/util/Snippet.java | 4 +- 4 files changed, 76 insertions(+), 15 deletions(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/StaticCompletionItem.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/StaticCompletionItem.java index a43bc9506185..b279db738f2d 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/StaticCompletionItem.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/StaticCompletionItem.java @@ -50,6 +50,7 @@ public enum Kind { MODULE, TYPE, KEYWORD, + SERVICE_TEMPLATE, OTHER } } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ModulePartNodeContextUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ModulePartNodeContextUtil.java index c69df2977a03..49d9498da3a9 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ModulePartNodeContextUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ModulePartNodeContextUtil.java @@ -21,17 +21,24 @@ import io.ballerina.compiler.api.symbols.SymbolKind; import io.ballerina.compiler.api.symbols.TypeDescKind; import io.ballerina.compiler.api.symbols.TypeSymbol; +import io.ballerina.compiler.syntax.tree.FunctionDefinitionNode; import io.ballerina.compiler.syntax.tree.Minutiae; +import io.ballerina.compiler.syntax.tree.ModulePartNode; +import io.ballerina.compiler.syntax.tree.NonTerminalNode; import io.ballerina.compiler.syntax.tree.SyntaxKind; +import io.ballerina.compiler.syntax.tree.SyntaxTree; import io.ballerina.compiler.syntax.tree.Token; import org.ballerinalang.langserver.common.utils.CommonUtil; +import org.ballerinalang.langserver.common.utils.PositionUtil; import org.ballerinalang.langserver.common.utils.SymbolUtil; import org.ballerinalang.langserver.commons.BallerinaCompletionContext; import org.ballerinalang.langserver.commons.completion.LSCompletionItem; import org.ballerinalang.langserver.completions.SnippetCompletionItem; +import org.ballerinalang.langserver.completions.StaticCompletionItem; import org.ballerinalang.langserver.completions.util.Snippet; import org.ballerinalang.langserver.completions.util.SnippetBlock; import org.ballerinalang.langserver.completions.util.SortingUtil; +import org.ballerinalang.model.tree.OperatorKind; import org.eclipse.lsp4j.CompletionItem; import java.util.ArrayList; @@ -62,22 +69,63 @@ private ModulePartNodeContextUtil() { public static List getTopLevelItems(BallerinaCompletionContext context) { ArrayList completionItems = new ArrayList<>(); // Here we should add the function keyword as well, although it is added via #getTypeItems - List snippets = Arrays.asList( - Snippet.KW_IMPORT, Snippet.KW_TYPE, Snippet.KW_PUBLIC, Snippet.KW_ISOLATED, + List snippets = new ArrayList<>(Arrays.asList(Snippet.KW_TYPE, Snippet.KW_PUBLIC, Snippet.KW_ISOLATED, Snippet.KW_FINAL, Snippet.KW_CONST, Snippet.KW_LISTENER, Snippet.KW_CLIENT, Snippet.KW_VAR, Snippet.KW_ENUM, Snippet.KW_XMLNS, Snippet.KW_CLASS, Snippet.KW_TRANSACTIONAL, - Snippet.DEF_FUNCTION, Snippet.DEF_EXPRESSION_BODIED_FUNCTION, Snippet.DEF_MAIN_FUNCTION, - Snippet.KW_CONFIGURABLE, Snippet.DEF_ANNOTATION, Snippet.DEF_RECORD, Snippet.STMT_NAMESPACE_DECLARATION, + Snippet.DEF_FUNCTION, Snippet.DEF_EXPRESSION_BODIED_FUNCTION, Snippet.KW_CONFIGURABLE, + Snippet.DEF_ANNOTATION, Snippet.DEF_RECORD, Snippet.STMT_NAMESPACE_DECLARATION, Snippet.DEF_OBJECT_SNIPPET, Snippet.DEF_CLASS, Snippet.DEF_ENUM, Snippet.DEF_CLOSED_RECORD, Snippet.DEF_ERROR_TYPE, Snippet.DEF_TABLE_TYPE_DESC, Snippet.DEF_TABLE_WITH_KEY_TYPE_DESC, Snippet.DEF_STREAM, Snippet.DEF_SERVICE_COMMON, Snippet.DEF_CLIENT_DECLARATION - ); - + )); + //Add import keyword conditionally + if (isInImportStatementsContext(context)) { + snippets.add(Snippet.KW_IMPORT); + } + if (!isMainFunctionAvailable(context)) { + snippets.add(Snippet.DEF_MAIN_FUNCTION); + } snippets.forEach(snippet -> completionItems.add(new SnippetCompletionItem(context, snippet.get()))); return completionItems; } + private static boolean isMainFunctionAvailable(BallerinaCompletionContext context) { + Optional modulePartNode = getModulePartNode(context); + if (modulePartNode.isEmpty()) { + return false; + } + return modulePartNode.get().members().stream().anyMatch(moduleMemberDeclarationNode -> + moduleMemberDeclarationNode.kind() == SyntaxKind.FUNCTION_DEFINITION + && "main".equals(((FunctionDefinitionNode) moduleMemberDeclarationNode).functionName().text())); + } + + private static Optional getModulePartNode(BallerinaCompletionContext context) { + NonTerminalNode node = context.getNodeAtCursor(); + while (node != null && node.kind() != SyntaxKind.MODULE_PART) { + node = node.parent(); + } + if (node == null) { + return Optional.empty(); + } + return Optional.of((ModulePartNode) node); + } + + private static boolean isInImportStatementsContext(BallerinaCompletionContext context) { + Optional syntaxTree = context.currentSyntaxTree(); + Optional modulePartNode = getModulePartNode(context); + if (syntaxTree.isEmpty() || modulePartNode.isEmpty()) { + return false; + } + int cursor = context.getCursorPositionInTree(); + return modulePartNode.get().members().stream().noneMatch( + moduleMemberDeclarationNode -> + moduleMemberDeclarationNode.kind() != SyntaxKind.IMPORT_DECLARATION && + PositionUtil.getPositionOffset( + PositionUtil.toPosition(moduleMemberDeclarationNode.lineRange().endLine()), + syntaxTree.get()) < cursor); + } + /** * Sort the list of completion items. * @@ -87,22 +135,31 @@ public static void sort(List items) { for (LSCompletionItem item : items) { CompletionItem cItem = item.getCompletionItem(); if (isSnippetBlock(item)) { - cItem.setSortText(genSortText(1)); + if(((SnippetCompletionItem) item).id().equals(Snippet.DEF_MAIN_FUNCTION.name())) { + cItem.setSortText(SortingUtil.genSortText(1) + SortingUtil.genSortText(1)); + continue; + } + cItem.setSortText(genSortText(1) + SortingUtil.genSortText(2)); continue; } - if (isKeyword(item)) { + if (isServiceTemplate(item)) { cItem.setSortText(genSortText(2)); continue; } - if (SortingUtil.isModuleCompletionItem(item) && !SortingUtil.isLangLibModuleCompletionItem(item)) { + if (isKeyword(item)) { cItem.setSortText(genSortText(3)); continue; } - if (SortingUtil.isTypeCompletionItem(item)) { + if (SortingUtil.isModuleCompletionItem(item) + && !SortingUtil.isLangLibModuleCompletionItem(item)) { cItem.setSortText(genSortText(4)); continue; } - cItem.setSortText(genSortText(5)); + if (SortingUtil.isTypeCompletionItem(item)) { + cItem.setSortText(genSortText(5)); + continue; + } + cItem.setSortText(genSortText(6)); } } @@ -163,6 +220,11 @@ private static boolean isKeyword(LSCompletionItem completionItem) { && ((SnippetCompletionItem) completionItem).kind() == SnippetBlock.Kind.KEYWORD; } + private static boolean isServiceTemplate(LSCompletionItem completionItem) { + return completionItem.getType() == LSCompletionItem.CompletionItemType.STATIC + && ((StaticCompletionItem) completionItem).kind() == StaticCompletionItem.Kind.SERVICE_TEMPLATE; + } + /** * Get the token value at the cursor. This identified token is not a whitespace or new line token. * diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ServiceTemplateGenerator.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ServiceTemplateGenerator.java index fd3020c39d8a..9a260ea5351b 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ServiceTemplateGenerator.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ServiceTemplateGenerator.java @@ -540,7 +540,7 @@ private LSCompletionItem generateServiceSnippet(ListenerMetaData serviceSnippet, filterText += "_" + serviceSnippet.symbolName; List additionalTextEdits = new ArrayList<>(importsAcceptor.getNewImportTextEdits()); return new StaticCompletionItem(context, ServiceTemplateCompletionItemBuilder.build(snippet, label, detail, - filterText.replace(".", "_"), additionalTextEdits), StaticCompletionItem.Kind.OTHER); + filterText.replace(".", "_"), additionalTextEdits), StaticCompletionItem.Kind.SERVICE_TEMPLATE); } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/Snippet.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/Snippet.java index 4eedf58c9669..0f62c8c514b7 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/Snippet.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/Snippet.java @@ -363,9 +363,7 @@ public enum Snippet { CLAUSE_ON_FAIL(SnippetGenerator.getOnFailClauseSnippet()), - CLAUSE_ON_CONFLICT(SnippetGenerator.getOnConflictClauseSnippet()), - - TYPE_MAP(SnippetGenerator.getMapTypeSnippet()); + CLAUSE_ON_CONFLICT(SnippetGenerator.getOnConflictClauseSnippet()); private final SnippetBlock snippetBlock; From 74d2551c5013a0eeec9421e54e2988c3ca36e940 Mon Sep 17 00:00:00 2001 From: malinthar Date: Thu, 27 Oct 2022 11:26:00 +0530 Subject: [PATCH 148/450] Improve module level completions more --- .../util/ModulePartNodeContextUtil.java | 34 ++++++++++++++----- .../completions/util/ContextTypeResolver.java | 5 ++- .../completions/util/SortingUtil.java | 27 +++++++++++---- 3 files changed, 48 insertions(+), 18 deletions(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ModulePartNodeContextUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ModulePartNodeContextUtil.java index 49d9498da3a9..fe4fb11f26eb 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ModulePartNodeContextUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ModulePartNodeContextUtil.java @@ -38,7 +38,6 @@ import org.ballerinalang.langserver.completions.util.Snippet; import org.ballerinalang.langserver.completions.util.SnippetBlock; import org.ballerinalang.langserver.completions.util.SortingUtil; -import org.ballerinalang.model.tree.OperatorKind; import org.eclipse.lsp4j.CompletionItem; import java.util.ArrayList; @@ -135,27 +134,44 @@ public static void sort(List items) { for (LSCompletionItem item : items) { CompletionItem cItem = item.getCompletionItem(); if (isSnippetBlock(item)) { - if(((SnippetCompletionItem) item).id().equals(Snippet.DEF_MAIN_FUNCTION.name())) { - cItem.setSortText(SortingUtil.genSortText(1) + SortingUtil.genSortText(1)); + SnippetCompletionItem snippetCompletionItem = (SnippetCompletionItem) item; + if (snippetCompletionItem.id().equals(Snippet.DEF_MAIN_FUNCTION.name())) { + cItem.setSortText(genSortText(1) + genSortText(1)); continue; } - cItem.setSortText(genSortText(1) + SortingUtil.genSortText(2)); + if (snippetCompletionItem.id().equals(Snippet.DEF_SERVICE_COMMON.name())) { + cItem.setSortText(genSortText(1) + genSortText(2)); + continue; + } + if (snippetCompletionItem.id().equals(Snippet.DEF_FUNCTION.name())) { + cItem.setSortText(genSortText(1) + genSortText(4)); + continue; + } + if (snippetCompletionItem.id().equals(Snippet.DEF_CLOSED_RECORD.name())) { + cItem.setSortText(genSortText(1) + genSortText(5)); + continue; + } + if (snippetCompletionItem.id().equals(Snippet.DEF_RECORD.name())) { + cItem.setSortText(genSortText(1) + genSortText(6)); + continue; + } + cItem.setSortText(genSortText(2)); continue; } if (isServiceTemplate(item)) { - cItem.setSortText(genSortText(2)); + cItem.setSortText(genSortText(1) + genSortText(4)); continue; } - if (isKeyword(item)) { + if (SortingUtil.isTypeCompletionItem(item)) { cItem.setSortText(genSortText(3)); continue; } - if (SortingUtil.isModuleCompletionItem(item) - && !SortingUtil.isLangLibModuleCompletionItem(item)) { + if (isKeyword(item)) { cItem.setSortText(genSortText(4)); continue; } - if (SortingUtil.isTypeCompletionItem(item)) { + if (SortingUtil.isModuleCompletionItem(item) + && !SortingUtil.isLangLibModuleCompletionItem(item)) { cItem.setSortText(genSortText(5)); continue; } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/ContextTypeResolver.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/ContextTypeResolver.java index f65d438d44c2..1ab2ffb83620 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/ContextTypeResolver.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/ContextTypeResolver.java @@ -546,9 +546,8 @@ public Optional transform(NamedArgumentNode namedArgumentNode) { } for (ParameterSymbol parameterSymbol : parameterSymbols.get()) { - if (parameterSymbol.getName() - .filter(name -> name.equals(namedArgumentNode.argumentName().name().text())) - .isPresent()) { + if (parameterSymbol.getName().map(name -> + name.equals(namedArgumentNode.argumentName().name().text())).orElse(false)) { TypeSymbol typeDescriptor = parameterSymbol.typeDescriptor(); return Optional.of(typeDescriptor); } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/SortingUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/SortingUtil.java index 5daa47345e97..7b0c95d009cc 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/SortingUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/SortingUtil.java @@ -51,6 +51,7 @@ import org.ballerinalang.langserver.completions.SnippetCompletionItem; import org.ballerinalang.langserver.completions.StaticCompletionItem; import org.ballerinalang.langserver.completions.SymbolCompletionItem; +import org.ballerinalang.langserver.completions.TypeCompletionItem; import org.eclipse.lsp4j.CompletionItemKind; import java.util.Arrays; @@ -106,11 +107,25 @@ public static boolean isModuleCompletionItem(LSCompletionItem item) { * @return {@link Boolean} whether type completion or not */ public static boolean isTypeCompletionItem(LSCompletionItem item) { - return (item.getType() == LSCompletionItem.CompletionItemType.SYMBOL - && (((SymbolCompletionItem) item).getSymbol().orElse(null) instanceof TypeSymbol - || ((SymbolCompletionItem) item).getSymbol().orElse(null) instanceof TypeDefinitionSymbol)) - || (item instanceof StaticCompletionItem - && ((StaticCompletionItem) item).kind() == StaticCompletionItem.Kind.TYPE); + if (item.getType() == LSCompletionItem.CompletionItemType.SYMBOL) { + SymbolCompletionItem symbolCompletionItem = (SymbolCompletionItem) item; + Optional symbol = symbolCompletionItem.getSymbol(); + if (symbol.isPresent() && (symbol.get().kind() == SymbolKind.TYPE + || symbol.get().kind() == SymbolKind.TYPE_DEFINITION || + symbol.get().kind() == SymbolKind.CLASS)) { + return true; + } + //Todo:No symbol for string, any completion items. + return false; + } + if (item.getType() == LSCompletionItem.CompletionItemType.STATIC + && (((StaticCompletionItem) item).kind() == StaticCompletionItem.Kind.TYPE)) + return true; + if (item.getType() == LSCompletionItem.CompletionItemType.TYPE + || item instanceof TypeCompletionItem) { + return true; + } + return false; } /** @@ -299,7 +314,7 @@ public static String genSortTextByAssignability(BallerinaCompletionContext conte * Check if the provided completion item is assignable to the provided type. * * @param completionItem Completion item - * @param typeSymbol Type + * @param typeSymbol Type * @return True if assignable */ public static boolean isCompletionItemAssignable(LSCompletionItem completionItem, TypeSymbol typeSymbol) { From 0629b919d59c3e2a62e6e41556e3b96f0d3b6aac Mon Sep 17 00:00:00 2001 From: malinthar Date: Fri, 28 Oct 2022 15:48:25 +0530 Subject: [PATCH 149/450] Refactor module level completion sorting --- .../langserver/common/utils/CommonUtil.java | 1 + .../providers/AbstractCompletionProvider.java | 99 ++++++++++++++++--- .../util/ModulePartNodeContextUtil.java | 28 ++++-- .../completions/util/SortingUtil.java | 6 +- 4 files changed, 109 insertions(+), 25 deletions(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/CommonUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/CommonUtil.java index 899845236dcf..9c1100b47ead 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/CommonUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/CommonUtil.java @@ -112,6 +112,7 @@ public class CommonUtil { public static final String EXPR_SCHEME = "expr"; + //lang.array, regexp, lang.value, lang.runtime, jballerina.java are not pre-declared. public static final List PRE_DECLARED_LANG_LIBS = Arrays.asList("lang.boolean", "lang.decimal", "lang.error", "lang.float", "lang.function", "lang.future", "lang.int", "lang.map", "lang.object", "lang.stream", "lang.string", "lang.table", "lang.transaction", "lang.typedesc", "lang.xml"); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/AbstractCompletionProvider.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/AbstractCompletionProvider.java index 2cd6dd10a32d..f6292f2da6d5 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/AbstractCompletionProvider.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/AbstractCompletionProvider.java @@ -17,6 +17,8 @@ */ package org.ballerinalang.langserver.completions.providers; +import io.ballerina.compiler.api.SemanticModel; +import io.ballerina.compiler.api.Types; import io.ballerina.compiler.api.symbols.ClassSymbol; import io.ballerina.compiler.api.symbols.ClientDeclSymbol; import io.ballerina.compiler.api.symbols.ConstantSymbol; @@ -65,7 +67,6 @@ import org.ballerinalang.langserver.completions.SnippetCompletionItem; import org.ballerinalang.langserver.completions.StaticCompletionItem; import org.ballerinalang.langserver.completions.SymbolCompletionItem; -import org.ballerinalang.langserver.completions.TypeCompletionItem; import org.ballerinalang.langserver.completions.builder.ConstantCompletionItemBuilder; import org.ballerinalang.langserver.completions.builder.FieldCompletionItemBuilder; import org.ballerinalang.langserver.completions.builder.FunctionCompletionItemBuilder; @@ -91,11 +92,11 @@ import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.function.Predicate; import java.util.stream.Collectors; - import javax.annotation.Nonnull; import static io.ballerina.compiler.api.symbols.SymbolKind.CLASS; @@ -272,7 +273,7 @@ private List getTypeItems(BallerinaCompletionContext context) completionItems.addAll(this.getBasicAndOtherTypeCompletions(context)); completionItems.addAll(Arrays.asList( - new TypeCompletionItem(context, null, TypeCompletionItemBuilder.build(null, "service")), + new SnippetCompletionItem(context, Snippet.KW_SERVICE.get()), new SnippetCompletionItem(context, Snippet.KW_RECORD.get()), new SnippetCompletionItem(context, Snippet.KW_FUNCTION.get()), new SnippetCompletionItem(context, Snippet.DEF_RECORD_TYPE_DESC.get()), @@ -580,11 +581,26 @@ protected List getTypeQualifierItems(BallerinaCompletionContex private List getBasicAndOtherTypeCompletions(BallerinaCompletionContext context) { // Types in the predeclared langlibs are handled and extracted via #getPredeclaredLangLibCompletions - List types = Arrays.asList("readonly", "handle", "never", "json", "anydata", "any", "byte"); + Optional semanticModel = context.currentSemanticModel(); + if (semanticModel.isEmpty()) { + return Collections.emptyList(); + } + Types types = semanticModel.get().types(); + + //"readonly", "handle", "never", "json", "anydata", "any", "byte"); + List typeSymbols = new ArrayList<>(); + typeSymbols.add(types.READONLY); + typeSymbols.add(types.HANDLE); + typeSymbols.add(types.NEVER); + typeSymbols.add(types.JSON); + typeSymbols.add(types.ANYDATA); + typeSymbols.add(types.ANY); + typeSymbols.add(types.BYTE); + List completionItems = new ArrayList<>(); - types.forEach(type -> { - CompletionItem cItem = TypeCompletionItemBuilder.build(null, type); - completionItems.add(new SymbolCompletionItem(context, null, cItem)); + typeSymbols.forEach(type -> { + CompletionItem cItem = TypeCompletionItemBuilder.build(type, type.signature()); + completionItems.add(new SymbolCompletionItem(context, type, cItem)); }); return completionItems; @@ -597,6 +613,61 @@ private List getBasicAndOtherTypeCompletions(BallerinaCompleti * @return {@link List} */ protected List getPredeclaredLangLibCompletions(BallerinaCompletionContext context) { + List visibleSymbols = context.visibleSymbols(context.getCursorPosition()); + List completionItems = new ArrayList<>(); + Optional types = context.currentSemanticModel().map(SemanticModel::types); + visibleSymbols.stream() + .filter(symbol -> symbol.getName().isPresent() && symbol.kind() == MODULE) + .map(symbol -> (ModuleSymbol) symbol) + .filter(moduleSymbol -> CommonUtil.PRE_DECLARED_LANG_LIBS.contains(moduleSymbol.id().moduleName())) + .forEach(moduleSymbol -> { + //Some lang libs are essentially types. So,type symbols are specifically created for them. + TypeSymbol typeSymbol = null; + if (types.isPresent()) { + switch (moduleSymbol.id().moduleName()) { + case "lang.boolean": + typeSymbol = types.get().BOOLEAN; + break; + case "lang.int": + typeSymbol = types.get().INT; + break; + case "lang.error": + typeSymbol = types.get().ERROR; + break; + case "lang.decimal": + typeSymbol = types.get().DECIMAL; + break; + case "lang.float": + typeSymbol = types.get().FLOAT; + break; + case "lang.function": + typeSymbol = types.get().FUNCTION; + break; + case "lang.future": + typeSymbol = types.get().FUTURE; + break; + case "lang.typedesc": + typeSymbol = types.get().TYPEDESC; + break; + case "lang.string": + typeSymbol = types.get().STRING; + break; + case "lang.xml": + typeSymbol = types.get().XML; + break; + default: + //ignore + } + } + CompletionItem cItem = TypeCompletionItemBuilder.build( + typeSymbol, moduleSymbol.id().modulePrefix()); + completionItems.add(new SymbolCompletionItem(context, + Objects.requireNonNullElse(typeSymbol, moduleSymbol), cItem)); + }); + return completionItems; + } + + protected List getInBuildTypes(BallerinaCompletionContext context) { List visibleSymbols = context.visibleSymbols(context.getCursorPosition()); List completionItems = new ArrayList<>(); visibleSymbols.stream() @@ -811,16 +882,16 @@ protected void sortByAssignability(BallerinaCompletionContext context, LSComplet } /** - * Get the completion item list for client declaration module prefix reference, when the node is within the + * Get the completion item list for client declaration module prefix reference, when the node is within the * qualified name reference node. - * + * * @param context Ballerina Completion Context * @param qNameRef Qualified Name Reference Node * @param predicate Predicate to filter symbols - * @return Client Declaration Completion Item List + * @return Client Declaration Completion Item List */ - protected List getClientDeclCompletionItemList(BallerinaCompletionContext context, - QualifiedNameReferenceNode qNameRef, + protected List getClientDeclCompletionItemList(BallerinaCompletionContext context, + QualifiedNameReferenceNode qNameRef, Predicate predicate) { Optional clientDeclSymbol = ModuleUtil.searchClientDeclarationForAlias(context, QNameRefCompletionUtil.getAlias(qNameRef)); @@ -831,14 +902,14 @@ protected List getClientDeclCompletionItemList(BallerinaComple List completionItemList = this.getCompletionItemList(clientDeclContent, context); String clientKW = ItemResolverConstants.CLIENT; - for (LSCompletionItem item: completionItemList) { + for (LSCompletionItem item : completionItemList) { CompletionItem cItem = item.getCompletionItem(); if (cItem.getLabel().equals(CommonUtil.escapeReservedKeyword(clientKW))) { cItem.setLabel(clientKW); cItem.setInsertText(clientKW); } } - + return completionItemList; } } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ModulePartNodeContextUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ModulePartNodeContextUtil.java index fe4fb11f26eb..7d652bf3fb5c 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ModulePartNodeContextUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ModulePartNodeContextUtil.java @@ -48,6 +48,7 @@ import java.util.stream.Collectors; import static org.ballerinalang.langserver.completions.util.SortingUtil.genSortText; +import static org.ballerinalang.langserver.completions.util.SortingUtil.isLangLibModuleCompletionItem; /** * Utilities for the module part node context. @@ -144,38 +145,49 @@ public static void sort(List items) { continue; } if (snippetCompletionItem.id().equals(Snippet.DEF_FUNCTION.name())) { - cItem.setSortText(genSortText(1) + genSortText(4)); + cItem.setSortText(genSortText(1) + genSortText(5)); continue; } if (snippetCompletionItem.id().equals(Snippet.DEF_CLOSED_RECORD.name())) { - cItem.setSortText(genSortText(1) + genSortText(5)); + cItem.setSortText(genSortText(1) + genSortText(6)); continue; } if (snippetCompletionItem.id().equals(Snippet.DEF_RECORD.name())) { - cItem.setSortText(genSortText(1) + genSortText(6)); + cItem.setSortText(genSortText(1) + genSortText(7)); continue; } cItem.setSortText(genSortText(2)); continue; } if (isServiceTemplate(item)) { - cItem.setSortText(genSortText(1) + genSortText(4)); + cItem.setSortText(genSortText(1) + genSortText(3)); continue; } if (SortingUtil.isTypeCompletionItem(item)) { - cItem.setSortText(genSortText(3)); + if (isLangLibModuleCompletionItem(item)) { + cItem.setSortText(genSortText(3) + genSortText(2)); + continue; + } + cItem.setSortText(genSortText(3) + genSortText(1)); continue; } if (isKeyword(item)) { + if (((SnippetCompletionItem) item).id().equals(Snippet.KW_SERVICE.name())) { + cItem.setSortText(genSortText(1) + genSortText(4)); + continue; + } cItem.setSortText(genSortText(4)); continue; } - if (SortingUtil.isModuleCompletionItem(item) - && !SortingUtil.isLangLibModuleCompletionItem(item)) { + if (SortingUtil.isLangLibModuleCompletionItem(item)) { cItem.setSortText(genSortText(5)); continue; } - cItem.setSortText(genSortText(6)); + if (SortingUtil.isModuleCompletionItem(item)) { + cItem.setSortText(genSortText(6)); + continue; + } + cItem.setSortText(genSortText(7)); } } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/SortingUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/SortingUtil.java index 7b0c95d009cc..27f16645c4d0 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/SortingUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/SortingUtil.java @@ -115,12 +115,12 @@ public static boolean isTypeCompletionItem(LSCompletionItem item) { symbol.get().kind() == SymbolKind.CLASS)) { return true; } - //Todo:No symbol for string, any completion items. return false; } if (item.getType() == LSCompletionItem.CompletionItemType.STATIC - && (((StaticCompletionItem) item).kind() == StaticCompletionItem.Kind.TYPE)) + && (((StaticCompletionItem) item).kind() == StaticCompletionItem.Kind.TYPE)) { return true; + } if (item.getType() == LSCompletionItem.CompletionItemType.TYPE || item instanceof TypeCompletionItem) { return true; @@ -683,7 +683,7 @@ public static void sortCompletionsAfterConfigurableQualifier(CompletionContext c }); return; } - + List anyDataSubTypeLabels = Arrays.asList("boolean", "int", "float", "decimal", "string", "xml", "map", "table"); completionItems.forEach(lsCompletionItem -> { From 2300c79263afd838dd8919b78db7d93c4a085150 Mon Sep 17 00:00:00 2001 From: malinthar Date: Fri, 28 Oct 2022 16:33:15 +0530 Subject: [PATCH 150/450] Fix failing test cases --- .../completions/util/SortingUtil.java | 5 +- ...med_arg_in_remote_method_call_action1.json | 33 ++ .../config/annotationDeclAnnotation1.json | 160 ++++---- .../config/annotationDeclAnnotation2.json | 160 ++++---- .../config/anonFuncExprAnnotation1.json | 160 ++++---- .../config/anonFuncExprAnnotation2.json | 160 ++++---- .../config/clientDeclAnnotation1.json | 160 ++++---- .../config/clientDeclAnnotation2.json | 160 ++++---- .../config/enumMemberAnnotation1.json | 160 ++++---- .../config/enumMemberAnnotation2.json | 160 ++++---- .../config/externalFunctionAnnotation1.json | 160 ++++---- .../config/externalFunctionAnnotation2.json | 160 ++++---- .../config/functionAnnotation2.json | 160 ++++---- .../config/functionAnnotation7.json | 160 ++++---- .../config/letVarAnnotation1.json | 160 ++++---- .../config/letVarAnnotation2.json | 160 ++++---- .../config/listenerAnnotation1.json | 160 ++++---- .../config/listenerAnnotation2.json | 160 ++++---- .../config/localVarAnnotation1.json | 160 ++++---- .../config/localVarAnnotation2.json | 160 ++++---- .../config/methodDeclAnnotation1.json | 160 ++++---- .../config/methodDeclAnnotation2.json | 160 ++++---- .../config/methodDefnAnnotation1.json | 160 ++++---- .../config/methodDefnAnnotation2.json | 160 ++++---- .../config/moduleClassDefAnnotation1.json | 160 ++++---- .../config/moduleClassDefAnnotation2.json | 160 ++++---- .../config/moduleClientDeclAnnotation1.json | 160 ++++---- .../config/moduleClientDeclAnnotation2.json | 160 ++++---- .../config/moduleConstAnnotation1.json | 160 ++++---- .../config/moduleConstAnnotation2.json | 160 ++++---- .../config/moduleEnumAnnotation1.json | 160 ++++---- .../config/moduleEnumAnnotation2.json | 160 ++++---- .../config/moduleLevelAnnotation2.json | 160 ++++---- .../config/moduleTypeDefAnnotation1.json | 160 ++++---- .../config/moduleTypeDefAnnotation2.json | 160 ++++---- .../config/moduleVarAnnotation1.json | 160 ++++---- .../config/moduleVarAnnotation2.json | 160 ++++---- .../config/objectFieldAnnotation1.json | 160 ++++---- .../config/objectFieldAnnotation2.json | 160 ++++---- .../config/objectFieldDescAnnotation1.json | 160 ++++---- .../config/objectFieldDescAnnotation2.json | 160 ++++---- .../config/paramAnnotation1.json | 160 ++++---- .../config/paramAnnotation10.json | 160 ++++---- .../config/paramAnnotation11.json | 289 +++++++-------- .../config/paramAnnotation2.json | 160 ++++---- .../config/paramAnnotation5.json | 160 ++++---- .../config/paramAnnotation7.json | 160 ++++---- .../config/paramAnnotation9.json | 289 +++++++-------- .../config/recordFieldAnnotation1.json | 160 ++++---- .../config/recordFieldAnnotation2.json | 160 ++++---- .../config/resourceAnnotation1.json | 160 ++++---- .../config/resourceAnnotation2.json | 160 ++++---- .../config/returnTypeDescAnnotation1.json | 160 ++++---- .../config/returnTypeDescAnnotation2.json | 160 ++++---- .../config/serviceAnnotation1.json | 160 ++++---- .../config/serviceAnnotation2.json | 160 ++++---- .../config/startActionAnnotation1.json | 160 ++++---- .../config/startActionAnnotation2.json | 160 ++++---- .../config/typeCastExprAnnotation1.json | 160 ++++---- .../config/typeCastExprAnnotation2.json | 160 ++++---- .../config/workerDeclAnnotation1.json | 160 ++++---- .../config/workerDeclAnnotation2.json | 160 ++++---- .../annotation_decl/config/config1.json | 160 ++++---- .../annotation_decl/config/config2.json | 160 ++++---- .../completion/class_def/config/config1.json | 289 +++++++-------- .../completion/class_def/config/config10.json | 289 +++++++-------- .../completion/class_def/config/config16.json | 289 +++++++-------- .../completion/class_def/config/config17.json | 289 +++++++-------- .../completion/class_def/config/config18.json | 160 ++++---- .../completion/class_def/config/config19.json | 160 ++++---- .../completion/class_def/config/config2.json | 289 +++++++-------- .../completion/class_def/config/config24.json | 289 +++++++-------- .../completion/class_def/config/config26.json | 160 ++++---- .../completion/class_def/config/config29.json | 289 +++++++-------- .../completion/class_def/config/config3.json | 289 +++++++-------- .../completion/class_def/config/config30.json | 289 +++++++-------- .../completion/class_def/config/config4.json | 289 +++++++-------- .../completion/class_def/config/config8.json | 289 +++++++-------- .../client_declaration_client_keyword.json | 289 +++++++-------- .../config/comment_config3.json | 289 +++++++-------- .../config/comment_config4.json | 289 +++++++-------- .../enum_decl_ctx/config/config3.json | 160 ++++---- .../config/anon_func_expr_ctx_config1.json | 289 +++++++-------- .../config/anon_func_expr_ctx_config10.json | 289 +++++++-------- .../config/anon_func_expr_ctx_config2.json | 289 +++++++-------- .../config/anon_func_expr_ctx_config5.json | 289 +++++++-------- .../error_constructor_expr_ctx_config3.json | 160 ++++---- .../error_constructor_expr_ctx_config4.json | 160 ++++---- .../function_call_expression_ctx_config7.json | 289 +++++++-------- .../function_call_expression_ctx_config8.json | 289 +++++++-------- .../config/list_constructor_ctx_config4.json | 2 +- .../config/mapping_expr_ctx_config5.json | 160 ++++---- .../config/mapping_expr_ctx_config6.json | 160 ++++---- .../config/mapping_expr_ctx_config7.json | 160 ++++---- .../config/module_ctx_config1.json | 289 +++++++-------- .../config/module_ctx_config2.json | 289 +++++++-------- .../config/module_ctx_config3.json | 289 +++++++-------- .../config/module_ctx_config4.json | 289 +++++++-------- .../config/module_ctx_config5.json | 291 +++++++-------- .../config/new_expr_ctx_config10.json | 160 ++++---- .../config/new_expr_ctx_config10a.json | 160 ++++---- .../config/new_expr_ctx_config17.json | 160 ++++---- .../config/new_expr_ctx_config18.json | 160 ++++---- .../config/new_expr_ctx_config19.json | 160 ++++---- .../config/new_expr_ctx_config7.json | 160 ++++---- .../config/new_expr_ctx_config8.json | 160 ++++---- .../config/new_expr_ctx_config9.json | 160 ++++---- .../object_constructor_expr_ctx_config13.json | 289 +++++++-------- .../object_constructor_expr_ctx_config15.json | 290 +++++++-------- .../object_constructor_expr_ctx_config2.json | 160 ++++---- .../object_constructor_expr_ctx_config4.json | 289 +++++++-------- .../object_constructor_expr_ctx_config5.json | 289 +++++++-------- .../object_constructor_expr_ctx_config7.json | 289 +++++++-------- .../type_test_expression_ctx_config1.json | 289 +++++++-------- .../type_test_expression_ctx_config2.json | 289 +++++++-------- .../type_test_expression_ctx_config8.json | 289 +++++++-------- .../type_test_expression_ctx_config9.json | 289 +++++++-------- .../config/typecast_expr_ctx_config1.json | 289 +++++++-------- .../config/typecast_expr_ctx_config2.json | 289 +++++++-------- .../config/typecast_expr_ctx_config4.json | 289 +++++++-------- .../config/typecast_expr_ctx_config5.json | 289 +++++++-------- .../config/typeof_expression_ctx_config5.json | 160 ++++---- ...xml_attribute_access_expr_ctx_config1.json | 160 ++++---- ...xml_attribute_access_expr_ctx_config2.json | 160 ++++---- .../config/field_access_ctx_config21.json | 289 +++++++-------- .../config/field_access_ctx_config38.json | 160 ++++---- .../config/field_access_ctx_config39.json | 160 ++++---- .../config/field_access_ctx_config4.json | 160 ++++---- .../config/field_access_ctx_config40.json | 160 ++++---- .../config/field_access_ctx_config41.json | 160 ++++---- .../config/foreach_stmt_ctx_config1.json | 289 +++++++-------- .../config/foreach_stmt_ctx_config2.json | 289 +++++++-------- .../config/foreach_stmt_ctx_config20.json | 160 ++++---- .../config/foreach_stmt_ctx_config24.json | 160 ++++---- .../config/foreach_stmt_ctx_config7.json | 289 +++++++-------- .../config/foreach_stmt_ctx_config8.json | 289 +++++++-------- .../function_body/config/config1.json | 289 +++++++-------- .../function_body/config/config10.json | 289 +++++++-------- .../function_body/config/config12.json | 289 +++++++-------- .../function_body/config/config13.json | 289 +++++++-------- .../function_body/config/config14.json | 289 +++++++-------- .../config/config15_client_declaration.json | 289 +++++++-------- .../config/config16_client_declaration.json | 289 +++++++-------- .../function_body/config/config2.json | 289 +++++++-------- .../function_body/config/config3.json | 289 +++++++-------- .../function_body/config/config4.json | 289 +++++++-------- .../function_body/config/config5.json | 289 +++++++-------- .../function_body/config/config6.json | 289 +++++++-------- .../function_def/config/config10.json | 289 +++++++-------- .../function_def/config/config11.json | 289 +++++++-------- .../function_def/config/config18.json | 160 ++++---- .../function_def/config/config19.json | 160 ++++---- .../function_def/config/config22.json | 289 +++++++-------- .../function_def/config/config3.json | 289 +++++++-------- .../function_def/config/config4.json | 289 +++++++-------- .../function_def/config/config9.json | 289 +++++++-------- .../import_decl/config/config11.json | 289 +++++++-------- .../import_decl/config/config12.json | 289 +++++++-------- .../import_decl/config/config21.json | 289 +++++++-------- .../import_decl/config/config26.json | 289 +++++++-------- .../config/let_expr_ctx_config1.json | 289 +++++++-------- .../config/let_expr_ctx_config12.json | 289 +++++++-------- .../config/let_expr_ctx_config1a.json | 289 +++++++-------- .../listener_decl/config/config1.json | 160 ++++---- .../listener_decl/config/config11.json | 160 ++++---- .../listener_decl/config/config12.json | 289 +++++++-------- .../listener_decl/config/config2.json | 160 ++++---- .../listener_decl/config/config3b.json | 160 ++++---- .../listener_decl/config/config3c.json | 160 ++++---- .../listener_decl/config/config4.json | 160 ++++---- .../listener_decl/config/config5.json | 160 ++++---- .../listener_decl/config/config7.json | 160 ++++---- .../listener_decl/config/config8.json | 160 ++++---- .../listener_decl/config/config9.json | 160 ++++---- ...dule_prefix_reference_in_module_level.json | 4 +- .../module_const_context/config/config1.json | 289 +++++++-------- .../module_const_context/config/config10.json | 160 ++++---- .../module_const_context/config/config2.json | 289 +++++++-------- .../module_const_context/config/config4.json | 289 +++++++-------- .../module_const_context/config/config6.json | 160 ++++---- .../module_const_context/config/config7.json | 160 ++++---- .../module_part_context/config/config10.json | 190 +++++----- .../module_part_context/config/config11.json | 10 +- .../module_part_context/config/config12.json | 6 +- .../module_part_context/config/config13.json | 6 +- .../module_part_context/config/config17.json | 289 +++++++-------- .../module_part_context/config/config4.json | 34 +- .../module_part_context/config/config5.json | 34 +- .../module_part_context/config/config8.json | 345 +++++++++--------- .../module_part_context/config/config9.json | 194 +++++----- .../module_var_context/config/config14.json | 289 +++++++-------- .../module_var_context/config/config15.json | 287 +++++++-------- .../module_var_context/config/config16.json | 289 +++++++-------- .../module_var_context/config/config18.json | 289 +++++++-------- .../module_var_context/config/config7.json | 160 ++++---- .../module_var_context/config/config9.json | 289 +++++++-------- .../config/config1.json | 160 ++++---- .../config/config2.json | 160 ++++---- .../config/config8.json | 160 ++++---- .../config/query_expr_ctx_config18.json | 289 +++++++-------- .../config/query_expr_ctx_config31.json | 281 +++++++------- .../config/query_expr_ctx_config7.json | 289 +++++++-------- .../config/query_expr_ctx_config8.json | 289 +++++++-------- .../query_expr_ctx_from_clause_config1.json | 281 +++++++------- .../query_expr_ctx_from_clause_config2.json | 281 +++++++------- .../query_expr_ctx_from_clause_config3.json | 281 +++++++------- .../query_expr_ctx_from_clause_config4.json | 281 +++++++------- .../query_expr_ctx_from_clause_config5.json | 281 +++++++------- .../query_expr_ctx_from_clause_config6.json | 281 +++++++------- .../query_expr_ctx_join_clause_config1.json | 289 +++++++-------- .../query_expr_ctx_join_clause_config17.json | 289 +++++++-------- .../query_expr_ctx_join_clause_config18.json | 289 +++++++-------- .../query_expr_ctx_join_clause_config2.json | 289 +++++++-------- .../query_expr_ctx_let_clause_config1.json | 289 +++++++-------- .../query_expr_ctx_let_clause_config10.json | 289 +++++++-------- .../query_expr_ctx_let_clause_config2.json | 289 +++++++-------- .../query_expr_ctx_let_clause_config3.json | 289 +++++++-------- .../query_expr_ctx_let_clause_config9.json | 289 +++++++-------- .../record_type_desc/config/config1.json | 289 +++++++-------- .../record_type_desc/config/config10.json | 160 ++++---- .../record_type_desc/config/config2.json | 289 +++++++-------- .../record_type_desc/config/config9.json | 160 ++++---- .../service_body/config/config4.json | 289 +++++++-------- .../service_body/config/config5.json | 289 +++++++-------- .../service_decl/config/config1.json | 160 ++++---- .../service_decl/config/config10.json | 289 +++++++-------- .../service_decl/config/config11.json | 289 +++++++-------- .../service_decl/config/config14.json | 289 +++++++-------- .../service_decl/config/config15.json | 289 +++++++-------- .../service_decl/config/config16.json | 289 +++++++-------- .../service_decl/config/config2.json | 160 ++++---- .../service_decl/config/config3.json | 196 +++++----- .../service_decl/config/config4.json | 160 ++++---- .../service_decl/config/config6c.json | 160 ++++---- .../service_decl/config/config6d.json | 160 ++++---- .../service_decl/config/config6g.json | 160 ++++---- .../continue_break_stmt_ctx_config1.json | 289 +++++++-------- .../continue_break_stmt_ctx_config2.json | 289 +++++++-------- .../config/do_stmt_ctx_config1.json | 289 +++++++-------- .../config/else_stmt_ctx_config1.json | 289 +++++++-------- .../config/else_stmt_ctx_config2.json | 289 +++++++-------- .../config/elseif_stmt_ctx_config1.json | 289 +++++++-------- .../config/elseif_stmt_ctx_config2.json | 289 +++++++-------- .../function_call_stmt_ctx_config1.json | 289 +++++++-------- .../function_call_stmt_ctx_config2.json | 289 +++++++-------- .../config/if_stmt_ctx_config1.json | 289 +++++++-------- .../config/if_stmt_ctx_config2.json | 289 +++++++-------- .../config/if_stmt_ctx_config7.json | 289 +++++++-------- .../config/if_stmt_ctx_config8.json | 289 +++++++-------- .../local_var_decl_stmt_ctx_config1.json | 289 +++++++-------- .../config/lock_stmt_ctx_config1.json | 289 +++++++-------- .../config/lock_stmt_ctx_config3.json | 289 +++++++-------- .../config/match_stmt_ctx_config14.json | 160 ++++---- .../config/match_stmt_ctx_config15.json | 160 ++++---- .../config/match_stmt_ctx_config16.json | 160 ++++---- .../config/match_stmt_ctx_config4.json | 160 ++++---- .../config/match_stmt_ctx_config5.json | 160 ++++---- .../config/onfail_clause_ctx_config1.json | 289 +++++++-------- .../config/onfail_clause_ctx_config1a.json | 289 +++++++-------- .../config/onfail_clause_ctx_config2.json | 289 +++++++-------- .../config/onfail_clause_ctx_config2a.json | 289 +++++++-------- .../config/onfail_clause_ctx_config2c.json | 160 ++++---- .../config/onfail_clause_ctx_config3.json | 289 +++++++-------- .../config/onfail_clause_ctx_config4.json | 289 +++++++-------- .../config/onfail_clause_ctx_config5.json | 289 +++++++-------- .../config/onfail_clause_ctx_config5a.json | 289 +++++++-------- .../config/onfail_clause_ctx_config6.json | 289 +++++++-------- .../config/onfail_clause_ctx_config6a.json | 289 +++++++-------- .../config/panic_stmt_ctx_config1.json | 290 +++++++-------- .../config/return_stmt_ctx_config1.json | 289 +++++++-------- .../config/return_stmt_ctx_config10.json | 289 +++++++-------- .../config/return_stmt_ctx_config11.json | 289 +++++++-------- .../config/return_stmt_ctx_config12.json | 289 +++++++-------- .../config/return_stmt_ctx_config13.json | 289 +++++++-------- .../config/return_stmt_ctx_config14.json | 289 +++++++-------- .../config/return_stmt_ctx_config15.json | 289 +++++++-------- .../config/return_stmt_ctx_config2.json | 289 +++++++-------- .../config/return_stmt_ctx_config3.json | 289 +++++++-------- .../config/return_stmt_ctx_config4.json | 289 +++++++-------- .../config/return_stmt_ctx_config5.json | 289 +++++++-------- .../config/return_stmt_ctx_config6.json | 289 +++++++-------- .../config/return_stmt_ctx_config7.json | 289 +++++++-------- .../config/return_stmt_ctx_config8.json | 289 +++++++-------- .../config/return_stmt_ctx_config9.json | 289 +++++++-------- .../config/start_action_ctx_config1.json | 289 +++++++-------- .../config/start_action_ctx_config2.json | 289 +++++++-------- .../config/start_action_ctx_config3.json | 289 +++++++-------- .../config/start_action_ctx_config4.json | 289 +++++++-------- .../config/transaction_config1.json | 289 +++++++-------- .../config/wait_action_ctx_config1.json | 160 ++++---- .../config/wait_action_ctx_config11.json | 160 ++++---- .../config/wait_action_ctx_config12.json | 160 ++++---- .../config/wait_action_ctx_config14.json | 160 ++++---- .../config/wait_action_ctx_config15.json | 160 ++++---- .../config/wait_action_ctx_config17.json | 160 ++++---- .../config/wait_action_ctx_config18.json | 160 ++++---- .../config/wait_action_ctx_config19.json | 160 ++++---- .../config/wait_action_ctx_config2.json | 160 ++++---- .../config/wait_action_ctx_config3.json | 160 ++++---- .../config/wait_action_ctx_config4.json | 160 ++++---- .../config/wait_action_ctx_config5.json | 160 ++++---- .../config/wait_action_ctx_config6.json | 160 ++++---- .../config/wait_action_ctx_config7.json | 160 ++++---- .../config/wait_action_ctx_config8.json | 160 ++++---- .../config/wait_action_ctx_config9.json | 160 ++++---- .../config/while_stmt_ctx_config1.json | 289 +++++++-------- .../config/while_stmt_ctx_config2.json | 289 +++++++-------- .../worker_declaration_ctx_config1.json | 289 +++++++-------- .../worker_declaration_ctx_config2.json | 289 +++++++-------- .../worker_declaration_ctx_config5.json | 289 +++++++-------- .../config/xmlns_ctx_config3.json | 160 ++++---- .../config/xmlns_ctx_config4.json | 160 ++++---- .../completion/type_def/config/config1.json | 289 +++++++-------- .../completion/type_def/config/config2.json | 289 +++++++-------- .../completion/type_def/config/config7.json | 289 +++++++-------- .../config/array_typedesc1.json | 160 ++++---- .../config/array_typedesc2.json | 160 ++++---- .../config/array_typedesc5.json | 289 +++++++-------- .../config/distinct_typedesc1.json | 160 ++++---- .../config/distinct_typedesc2.json | 160 ++++---- .../config/error_typedesc1.json | 160 ++++---- .../config/error_typedesc2.json | 160 ++++---- .../config/error_typedesc5.json | 160 ++++---- .../config/function_typedesc1.json | 289 +++++++-------- .../config/function_typedesc12.json | 289 +++++++-------- .../config/function_typedesc15.json | 289 +++++++-------- .../config/function_typedesc3.json | 289 +++++++-------- .../config/function_typedesc4.json | 289 +++++++-------- .../config/function_typedesc5.json | 289 +++++++-------- .../config/function_typedesc8.json | 289 +++++++-------- .../config/function_typedesc9.json | 289 +++++++-------- .../config/future_typedesc1.json | 289 +++++++-------- .../config/intersection_type_typedesc1.json | 289 +++++++-------- .../config/intersection_type_typedesc2.json | 289 +++++++-------- .../config/map_typedesc1.json | 289 +++++++-------- .../config/map_typedesc2.json | 289 +++++++-------- .../config/object_typedesc11.json | 289 +++++++-------- .../config/object_typedesc3.json | 289 +++++++-------- .../config/object_typedesc4.json | 289 +++++++-------- .../config/object_typedesc5.json | 289 +++++++-------- .../config/object_typedesc6.json | 289 +++++++-------- .../config/object_typedesc7.json | 289 +++++++-------- .../config/object_typedesc8.json | 289 +++++++-------- .../config/stream_typedesc1.json | 289 +++++++-------- .../config/stream_typedesc4.json | 289 +++++++-------- .../config/table_typedesc1.json | 160 ++++---- .../config/table_typedesc10.json | 289 +++++++-------- .../config/table_typedesc11.json | 160 ++++---- .../config/table_typedesc2.json | 160 ++++---- .../config/tuple_typedesc1.json | 289 +++++++-------- .../config/tuple_typedesc2.json | 289 +++++++-------- .../config/tuple_typedesc5.json | 289 +++++++-------- .../config/union_typedesc1.json | 289 +++++++-------- .../config/union_typedesc2.json | 289 +++++++-------- .../config/var_def_ctx_config18.json | 160 ++++---- .../config/var_def_ctx_config8.json | 160 ++++---- .../config/var_def_ctx_config9.json | 160 ++++---- .../xml_typedesc_context/config/config1.json | 160 ++++---- .../xml_typedesc_context/config/config2.json | 160 ++++---- 359 files changed, 40675 insertions(+), 40458 deletions(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/SortingUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/SortingUtil.java index 27f16645c4d0..c7f6883cd973 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/SortingUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/SortingUtil.java @@ -111,8 +111,9 @@ public static boolean isTypeCompletionItem(LSCompletionItem item) { SymbolCompletionItem symbolCompletionItem = (SymbolCompletionItem) item; Optional symbol = symbolCompletionItem.getSymbol(); if (symbol.isPresent() && (symbol.get().kind() == SymbolKind.TYPE - || symbol.get().kind() == SymbolKind.TYPE_DEFINITION || - symbol.get().kind() == SymbolKind.CLASS)) { + || symbol.get().kind() == SymbolKind.TYPE_DEFINITION + || symbol.get().kind() == SymbolKind.CLASS + || symbol.get().kind() == SymbolKind.CONSTANT)) { return true; } return false; diff --git a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/named_arg_in_remote_method_call_action1.json b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/named_arg_in_remote_method_call_action1.json index b85bdbb38b44..ed202d231cfb 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/named_arg_in_remote_method_call_action1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/named_arg_in_remote_method_call_action1.json @@ -295,6 +295,39 @@ "title": "editor.action.triggerParameterHints", "command": "editor.action.triggerParameterHints" } + }, + { + "label": "ClientError", + "kind": "Event", + "detail": "Error", + "documentation": { + "left": "Defines the possible client error types." + }, + "sortText": "P", + "insertText": "ClientError", + "insertTextFormat": "Snippet" + }, + { + "label": "TargetType2", + "kind": "TypeParameter", + "detail": "Typedesc", + "documentation": { + "left": "The super type of all the types." + }, + "sortText": "R", + "insertText": "TargetType2", + "insertTextFormat": "Snippet" + }, + { + "label": "TargetType", + "kind": "TypeParameter", + "detail": "Typedesc", + "documentation": { + "left": "The types of data values that are expected by the `client` to return after the data binding operation." + }, + "sortText": "R", + "insertText": "TargetType", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/annotationDeclAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/annotationDeclAnnotation1.json index cf33139adacf..2966aad28495 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/annotationDeclAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/annotationDeclAnnotation1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "deprecated", "kind": "Property", @@ -378,14 +306,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -409,6 +329,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/annotationDeclAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/annotationDeclAnnotation2.json index c6a473c1ca8f..beea3355fbe7 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/annotationDeclAnnotation2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/annotationDeclAnnotation2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "deprecated", "kind": "Property", @@ -378,14 +306,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -409,6 +329,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/anonFuncExprAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/anonFuncExprAnnotation1.json index b4428f7e09fd..aa33188e9ee0 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/anonFuncExprAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/anonFuncExprAnnotation1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "deprecated", "kind": "Property", @@ -378,14 +306,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -409,6 +329,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/anonFuncExprAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/anonFuncExprAnnotation2.json index d6e6530e656a..942d6175ed25 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/anonFuncExprAnnotation2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/anonFuncExprAnnotation2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "deprecated", "kind": "Property", @@ -378,14 +306,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -409,6 +329,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/clientDeclAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/clientDeclAnnotation1.json index dbe46ce912c9..a54eb235a2aa 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/clientDeclAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/clientDeclAnnotation1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -342,14 +270,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "commonAnnotation", "kind": "Property", @@ -391,6 +311,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/clientDeclAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/clientDeclAnnotation2.json index 477cf94570de..e3dc461da901 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/clientDeclAnnotation2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/clientDeclAnnotation2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -342,14 +270,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "commonAnnotation", "kind": "Property", @@ -391,6 +311,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/enumMemberAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/enumMemberAnnotation1.json index 838f7c7041e4..007d98df4829 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/enumMemberAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/enumMemberAnnotation1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "sourceConstAnnotation2", "kind": "Property", @@ -378,14 +306,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -409,6 +329,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/enumMemberAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/enumMemberAnnotation2.json index 4c82380ddf63..17cf14adfaf0 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/enumMemberAnnotation2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/enumMemberAnnotation2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "sourceConstAnnotation2", "kind": "Property", @@ -378,14 +306,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -409,6 +329,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/externalFunctionAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/externalFunctionAnnotation1.json index e6402aaca6f4..0736e7dd16c2 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/externalFunctionAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/externalFunctionAnnotation1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "sourceExternalAnnotation2", "kind": "Property", @@ -360,14 +288,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -391,6 +311,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/externalFunctionAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/externalFunctionAnnotation2.json index 0f007c3a2133..c61ecf57df3d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/externalFunctionAnnotation2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/externalFunctionAnnotation2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "sourceExternalAnnotation2", "kind": "Property", @@ -360,14 +288,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -391,6 +311,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/functionAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/functionAnnotation2.json index a69251d9a1fd..0516dc04ec99 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/functionAnnotation2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/functionAnnotation2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "deprecated", "kind": "Property", @@ -378,14 +306,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -409,6 +329,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/functionAnnotation7.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/functionAnnotation7.json index 40f585b65e5d..283451ac1201 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/functionAnnotation7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/functionAnnotation7.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "deprecated", "kind": "Property", @@ -402,14 +330,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -433,6 +353,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/letVarAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/letVarAnnotation1.json index 607ffb987665..f392fb86e6c3 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/letVarAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/letVarAnnotation1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "tainted", "kind": "Property", @@ -378,14 +306,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -409,6 +329,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/letVarAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/letVarAnnotation2.json index 540b6148e224..c10b62e94e36 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/letVarAnnotation2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/letVarAnnotation2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "tainted", "kind": "Property", @@ -378,14 +306,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -409,6 +329,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/listenerAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/listenerAnnotation1.json index 6de954c02667..32f7f597d4eb 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/listenerAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/listenerAnnotation1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "tainted", "kind": "Property", @@ -387,14 +315,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -418,6 +338,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/listenerAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/listenerAnnotation2.json index 362dc1b638bc..a0df7c8cd302 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/listenerAnnotation2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/listenerAnnotation2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "tainted", "kind": "Property", @@ -360,14 +288,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -391,6 +311,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/localVarAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/localVarAnnotation1.json index d471e47161b7..62babb8a34a6 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/localVarAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/localVarAnnotation1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "tainted", "kind": "Property", @@ -378,14 +306,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -409,6 +329,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/localVarAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/localVarAnnotation2.json index 4c5867839512..9180f828f0ef 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/localVarAnnotation2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/localVarAnnotation2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "tainted", "kind": "Property", @@ -378,14 +306,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -409,6 +329,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/methodDeclAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/methodDeclAnnotation1.json index e35efa40ba95..4cbf52c95304 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/methodDeclAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/methodDeclAnnotation1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "deprecated", "kind": "Property", @@ -396,14 +324,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -427,6 +347,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/methodDeclAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/methodDeclAnnotation2.json index a5bdca9bfa8d..a3c84ab95ca3 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/methodDeclAnnotation2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/methodDeclAnnotation2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "deprecated", "kind": "Property", @@ -396,14 +324,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -427,6 +347,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/methodDefnAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/methodDefnAnnotation1.json index 31d2073b2cf4..824ee47922f1 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/methodDefnAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/methodDefnAnnotation1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "objectFunctionAnnotation2", "kind": "Property", @@ -396,14 +324,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -427,6 +347,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/methodDefnAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/methodDefnAnnotation2.json index 80c3ea628a8b..2027a51daef1 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/methodDefnAnnotation2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/methodDefnAnnotation2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "objectFunctionAnnotation2", "kind": "Property", @@ -396,14 +324,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -427,6 +347,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClassDefAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClassDefAnnotation1.json index 67e066a643f4..2126e12341ea 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClassDefAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClassDefAnnotation1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "deprecated", "kind": "Property", @@ -387,14 +315,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -418,6 +338,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClassDefAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClassDefAnnotation2.json index 7cb22eb1d6c6..cc8f6560f31e 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClassDefAnnotation2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClassDefAnnotation2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "deprecated", "kind": "Property", @@ -387,14 +315,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -418,6 +338,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClientDeclAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClientDeclAnnotation1.json index bcb00ea037b2..a4c249d847b0 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClientDeclAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClientDeclAnnotation1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -342,14 +270,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "commonAnnotation", "kind": "Property", @@ -391,6 +311,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClientDeclAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClientDeclAnnotation2.json index 14f13b988a15..595318ea22d4 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClientDeclAnnotation2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleClientDeclAnnotation2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -342,14 +270,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "commonAnnotation", "kind": "Property", @@ -391,6 +311,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleConstAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleConstAnnotation1.json index d043aa0b25ac..b1bd8ef4bd45 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleConstAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleConstAnnotation1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "sourceConstAnnotation2", "kind": "Property", @@ -378,14 +306,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -409,6 +329,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleConstAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleConstAnnotation2.json index 63d20aec93b4..83ff54145dd8 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleConstAnnotation2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleConstAnnotation2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "sourceConstAnnotation2", "kind": "Property", @@ -378,14 +306,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -409,6 +329,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleEnumAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleEnumAnnotation1.json index 3fef25cf4d1d..6ca40c7afe55 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleEnumAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleEnumAnnotation1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "builtinSubtype", "kind": "Property", @@ -423,14 +351,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -454,6 +374,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleEnumAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleEnumAnnotation2.json index dcff23a20b6e..680251e2b906 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleEnumAnnotation2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleEnumAnnotation2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "builtinSubtype", "kind": "Property", @@ -423,14 +351,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -454,6 +374,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleLevelAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleLevelAnnotation2.json index b5f0e4dde164..ab389ed6b0ac 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleLevelAnnotation2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleLevelAnnotation2.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "tainted", "kind": "Property", @@ -465,14 +393,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -496,6 +416,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleTypeDefAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleTypeDefAnnotation1.json index 9a65f91e3e22..276d2957344f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleTypeDefAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleTypeDefAnnotation1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "builtinSubtype", "kind": "Property", @@ -423,14 +351,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -454,6 +374,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleTypeDefAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleTypeDefAnnotation2.json index 73d8232d1f75..d45265f305b2 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleTypeDefAnnotation2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleTypeDefAnnotation2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "builtinSubtype", "kind": "Property", @@ -423,14 +351,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -454,6 +374,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleVarAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleVarAnnotation1.json index 709e0f6715ba..3b6fa88d5eb1 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleVarAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleVarAnnotation1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "tainted", "kind": "Property", @@ -378,14 +306,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -409,6 +329,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleVarAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleVarAnnotation2.json index 7aa327bc3d0c..b31e300a5934 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleVarAnnotation2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/moduleVarAnnotation2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "tainted", "kind": "Property", @@ -378,14 +306,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -409,6 +329,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/objectFieldAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/objectFieldAnnotation1.json index 01fcb4fdba44..561b9e3e32a7 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/objectFieldAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/objectFieldAnnotation1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "deprecated", "kind": "Property", @@ -396,14 +324,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -427,6 +347,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/objectFieldAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/objectFieldAnnotation2.json index bdd6d3f642f7..0bd8a6573a9a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/objectFieldAnnotation2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/objectFieldAnnotation2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "deprecated", "kind": "Property", @@ -396,14 +324,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -427,6 +347,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/objectFieldDescAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/objectFieldDescAnnotation1.json index 79355d893035..74a6dcc344e6 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/objectFieldDescAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/objectFieldDescAnnotation1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "deprecated", "kind": "Property", @@ -396,14 +324,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -427,6 +347,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/objectFieldDescAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/objectFieldDescAnnotation2.json index 39e2f6584a7d..b121b7c66fce 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/objectFieldDescAnnotation2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/objectFieldDescAnnotation2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "deprecated", "kind": "Property", @@ -396,14 +324,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -427,6 +347,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/paramAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/paramAnnotation1.json index c6d0f2d0a8a6..4f76ff97bab3 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/paramAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/paramAnnotation1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "tainted", "kind": "Property", @@ -405,14 +333,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -436,6 +356,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/paramAnnotation10.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/paramAnnotation10.json index d92efa4c8304..ee5c74473e16 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/paramAnnotation10.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/paramAnnotation10.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "isolatedParam", "kind": "Property", @@ -402,14 +330,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -433,6 +353,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/paramAnnotation11.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/paramAnnotation11.json index 7a2f65fae264..720c6a3d3f21 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/paramAnnotation11.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/paramAnnotation11.json @@ -40,70 +40,6 @@ "insertText": "StringType", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -320,54 +256,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -392,14 +280,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -416,22 +296,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -537,14 +401,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -568,6 +424,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/paramAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/paramAnnotation2.json index df61697671d9..e7acd5f8e8bd 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/paramAnnotation2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/paramAnnotation2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "tainted", "kind": "Property", @@ -405,14 +333,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -436,6 +356,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/paramAnnotation5.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/paramAnnotation5.json index 2518a43cd6d2..37a345bc13e5 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/paramAnnotation5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/paramAnnotation5.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "tainted", "kind": "Property", @@ -405,14 +333,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -436,6 +356,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/paramAnnotation7.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/paramAnnotation7.json index 9cfb399166f7..3c3faa242e0a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/paramAnnotation7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/paramAnnotation7.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "tainted", "kind": "Property", @@ -405,14 +333,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -436,6 +356,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/paramAnnotation9.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/paramAnnotation9.json index 75780fece3fc..d0d2cad5de56 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/paramAnnotation9.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/paramAnnotation9.json @@ -40,70 +40,6 @@ "insertText": "StringType", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -320,54 +256,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -392,14 +280,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -416,22 +296,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -537,14 +401,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -568,6 +424,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/recordFieldAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/recordFieldAnnotation1.json index d1211805b0d0..391769a18129 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/recordFieldAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/recordFieldAnnotation1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "recordFieldAnnotation2", "kind": "Property", @@ -387,14 +315,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "deprecated", "kind": "Property", @@ -427,6 +347,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/recordFieldAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/recordFieldAnnotation2.json index f9040068d331..dca6b6aafcc8 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/recordFieldAnnotation2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/recordFieldAnnotation2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "recordFieldAnnotation2", "kind": "Property", @@ -387,14 +315,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "deprecated", "kind": "Property", @@ -427,6 +347,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/resourceAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/resourceAnnotation1.json index fef16e4b9a5c..7d04881e0289 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/resourceAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/resourceAnnotation1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "deprecated", "kind": "Property", @@ -387,14 +315,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -418,6 +338,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/resourceAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/resourceAnnotation2.json index 55821b97a457..ae1c9a564085 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/resourceAnnotation2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/resourceAnnotation2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "deprecated", "kind": "Property", @@ -387,14 +315,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -418,6 +338,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/returnTypeDescAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/returnTypeDescAnnotation1.json index 664b5d5d308a..4e7649f9b2c8 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/returnTypeDescAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/returnTypeDescAnnotation1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "tainted", "kind": "Property", @@ -387,14 +315,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -418,6 +338,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/returnTypeDescAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/returnTypeDescAnnotation2.json index b2607a2f58d3..c48063382340 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/returnTypeDescAnnotation2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/returnTypeDescAnnotation2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "tainted", "kind": "Property", @@ -387,14 +315,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -418,6 +338,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/serviceAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/serviceAnnotation1.json index c36e090f8f94..1f1be50be06c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/serviceAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/serviceAnnotation1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "serviceAnnotation2", "kind": "Property", @@ -369,14 +297,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -400,6 +320,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/serviceAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/serviceAnnotation2.json index 4219df592591..fe313509d000 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/serviceAnnotation2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/serviceAnnotation2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "serviceAnnotation2", "kind": "Property", @@ -369,14 +297,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -400,6 +320,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/startActionAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/startActionAnnotation1.json index 561a26f91cac..0454eeacca7d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/startActionAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/startActionAnnotation1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "sourceWorkerAnnotation2", "kind": "Property", @@ -369,14 +297,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -400,6 +320,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/startActionAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/startActionAnnotation2.json index 91ebc1e2e097..d00350b7ce99 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/startActionAnnotation2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/startActionAnnotation2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "sourceWorkerAnnotation2", "kind": "Property", @@ -369,14 +297,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -400,6 +320,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/typeCastExprAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/typeCastExprAnnotation1.json index c43da1cc1250..79277da254e8 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/typeCastExprAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/typeCastExprAnnotation1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "builtinSubtype", "kind": "Property", @@ -423,14 +351,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -454,6 +374,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/typeCastExprAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/typeCastExprAnnotation2.json index 7433e3783065..64f46b810b22 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/typeCastExprAnnotation2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/typeCastExprAnnotation2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "builtinSubtype", "kind": "Property", @@ -423,14 +351,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -454,6 +374,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/workerDeclAnnotation1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/workerDeclAnnotation1.json index 04a76c2ba4e7..bdef377a8b89 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/workerDeclAnnotation1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/workerDeclAnnotation1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "sourceWorkerAnnotation2", "kind": "Property", @@ -369,14 +297,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -400,6 +320,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/workerDeclAnnotation2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/workerDeclAnnotation2.json index c604673e8ee1..42bf92fb0a31 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/workerDeclAnnotation2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_ctx/config/workerDeclAnnotation2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "sourceWorkerAnnotation2", "kind": "Property", @@ -369,14 +297,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -400,6 +320,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_decl/config/config1.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_decl/config/config1.json index f5becfe5244f..04e6fda46681 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_decl/config/config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_decl/config/config1.json @@ -169,54 +169,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -241,14 +193,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -265,22 +209,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "record {}", "kind": "Snippet", @@ -395,14 +323,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -426,6 +346,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_decl/config/config2.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_decl/config/config2.json index 2416a71dc6a4..0a61545c2882 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_decl/config/config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_decl/config/config2.json @@ -169,54 +169,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -241,14 +193,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -265,22 +209,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "record {}", "kind": "Snippet", @@ -395,14 +323,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -426,6 +346,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config1.json b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config1.json index cb1ce5f988e4..28dd05150777 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config1.json @@ -113,70 +113,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -378,54 +314,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -450,14 +338,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -474,22 +354,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "init function", "kind": "Snippet", @@ -613,14 +477,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -644,6 +500,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config10.json b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config10.json index b9a80f1637a0..7432fe32b535 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config10.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config10.json @@ -32,70 +32,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -297,54 +233,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -369,14 +257,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -393,22 +273,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "isolated", "kind": "Keyword", @@ -541,14 +405,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -572,6 +428,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config16.json b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config16.json index bbbca50086a0..4e2676175853 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config16.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config16.json @@ -113,70 +113,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -378,54 +314,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -450,14 +338,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -474,22 +354,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "init function", "kind": "Snippet", @@ -681,14 +545,6 @@ "insertText": "module1:function1()", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -712,6 +568,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config17.json b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config17.json index 9cccc23efb93..19fff54c8111 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config17.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config17.json @@ -113,70 +113,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -378,54 +314,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -450,14 +338,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -474,22 +354,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "init function", "kind": "Snippet", @@ -613,14 +477,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -644,6 +500,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config18.json b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config18.json index 8f79f269ab21..173121e5a0b4 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config18.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config18.json @@ -166,54 +166,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -238,14 +190,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -262,22 +206,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project1", "kind": "Module", @@ -374,14 +302,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -405,6 +325,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config19.json b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config19.json index 0365d5ac7001..22ec8171d771 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config19.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config19.json @@ -166,54 +166,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -238,14 +190,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -262,22 +206,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project1", "kind": "Module", @@ -374,14 +302,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -405,6 +325,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config2.json b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config2.json index de445314815e..3714dd120872 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config2.json @@ -113,70 +113,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -378,54 +314,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -450,14 +338,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -474,22 +354,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "init function", "kind": "Snippet", @@ -613,14 +477,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -644,6 +500,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config24.json b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config24.json index 645541e7ff1b..3e6150beb56f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config24.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config24.json @@ -266,70 +266,6 @@ "insertText": "Person", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -546,54 +482,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -618,14 +506,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -642,22 +522,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "name", "kind": "Variable", @@ -892,14 +756,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -932,6 +788,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config26.json b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config26.json index 1606db7c7263..188c10e8905a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config26.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config26.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "Person()", "kind": "Function", @@ -349,14 +277,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -380,6 +300,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config29.json b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config29.json index 42a73659f5b1..9d488445d108 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config29.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config29.json @@ -32,70 +32,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -297,54 +233,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -369,14 +257,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -393,22 +273,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project1", "kind": "Module", @@ -514,14 +378,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -545,6 +401,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config3.json b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config3.json index 75f43847453e..6ec65b171b04 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config3.json @@ -95,70 +95,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -360,54 +296,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -432,14 +320,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -456,22 +336,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project1", "kind": "Module", @@ -586,14 +450,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -617,6 +473,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config30.json b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config30.json index 8e614024e3c1..e73ff2aebeae 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config30.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config30.json @@ -32,70 +32,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -297,54 +233,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -369,14 +257,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -393,22 +273,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project1", "kind": "Module", @@ -514,14 +378,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -545,6 +401,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config4.json b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config4.json index 6dfe7adee4a2..14b1a94baf21 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config4.json @@ -113,70 +113,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -378,54 +314,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -450,14 +338,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -474,22 +354,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "init function", "kind": "Snippet", @@ -613,14 +477,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -644,6 +500,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config8.json b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config8.json index fc81dd562282..d8bcce49f9b0 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config8.json @@ -113,70 +113,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -378,54 +314,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -450,14 +338,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -474,22 +354,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "init function", "kind": "Snippet", @@ -613,14 +477,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -644,6 +500,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_client_keyword.json b/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_client_keyword.json index 03651679c056..177443ac2a2a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_client_keyword.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/client_declaration_context/config/client_declaration_client_keyword.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "isolated", "kind": "Keyword", @@ -343,62 +271,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -504,14 +376,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "final", "kind": "Keyword", @@ -566,14 +430,6 @@ "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -909,6 +765,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/comment_context/config/comment_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/comment_context/config/comment_config3.json index 7578a6c8c8bf..d1c3fd45c12d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/comment_context/config/comment_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/comment_context/config/comment_config3.json @@ -267,70 +267,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "getGreeting()", "kind": "Function", @@ -869,14 +733,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -909,6 +765,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "O", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "O", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "O", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "O", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "O", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "O", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "O", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "R", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "O", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "M", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "O", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "O", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "O", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "O", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "O", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "O", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "O", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "O", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/comment_context/config/comment_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/comment_context/config/comment_config4.json index b749594f9f79..ea86af57cefa 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/comment_context/config/comment_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/comment_context/config/comment_config4.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "getGreeting()", "kind": "Function", @@ -869,14 +733,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -909,6 +765,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "O", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "O", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "O", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "O", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "O", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "O", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "O", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "R", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "O", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "M", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "O", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "O", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "O", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "O", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "O", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "O", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "O", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "O", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/enum_decl_ctx/config/config3.json b/language-server/modules/langserver-core/src/test/resources/completion/enum_decl_ctx/config/config3.json index d07a966c3e49..8e1f24bea48d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/enum_decl_ctx/config/config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/enum_decl_ctx/config/config3.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "super", "kind": "Variable", @@ -395,14 +323,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -426,6 +346,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config1.json index 4dfb7bece1a8..b9c5018332d1 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config1.json @@ -24,70 +24,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -265,54 +201,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -337,14 +225,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -361,22 +241,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.value", "kind": "Module", @@ -506,14 +370,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -537,6 +393,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config10.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config10.json index abaabacbeab2..34e62901150c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config10.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config10.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -508,54 +444,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -580,14 +468,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -604,22 +484,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "value4", "kind": "Variable", @@ -913,14 +777,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -953,6 +809,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config2.json index 5a31906d2cf9..991759a749e7 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config2.json @@ -24,70 +24,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -265,54 +201,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -337,14 +225,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -361,22 +241,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.value", "kind": "Module", @@ -506,14 +370,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -537,6 +393,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config5.json index de10bf2a7be7..b14a2a48f550 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config5.json @@ -24,70 +24,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -265,54 +201,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -337,14 +225,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -361,22 +241,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.value", "kind": "Module", @@ -533,14 +397,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -564,6 +420,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config3.json index 78d4267a488e..0e415234551b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config3.json @@ -150,54 +150,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -222,14 +174,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -246,22 +190,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -358,14 +286,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -389,6 +309,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config4.json index 2dfd4face484..e8bf354cc42c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config4.json @@ -158,54 +158,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -230,14 +182,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -254,22 +198,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -366,14 +294,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -397,6 +317,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config7.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config7.json index 14e41ea53440..652cd9f9807b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config7.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -532,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -604,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -628,22 +508,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunctionWithParams1(int a, int b)", "kind": "Function", @@ -908,14 +772,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -948,6 +804,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config8.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config8.json index d81fa8df600a..7ff16fcb172e 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config8.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -532,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -604,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -628,22 +508,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunctionWithParams1(int a, int b)", "kind": "Function", @@ -920,14 +784,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -960,6 +816,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/list_constructor_ctx_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/list_constructor_ctx_config4.json index e561b93693d9..eea83e88a0c1 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/list_constructor_ctx_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/list_constructor_ctx_config4.json @@ -15,7 +15,7 @@ "value": "" } }, - "sortText": "BH", + "sortText": "ALH", "insertText": "ENUM1_FIELD1", "insertTextFormat": "Snippet" }, diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config5.json index 5cddb3567047..6089c7fdca89 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config5.json @@ -186,54 +186,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -258,14 +210,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -282,22 +226,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.value", "kind": "Module", @@ -418,14 +346,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -449,6 +369,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config6.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config6.json index 60f5c881599e..9f982b4b6835 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config6.json @@ -186,54 +186,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -258,14 +210,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -282,22 +226,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.value", "kind": "Module", @@ -418,14 +346,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -449,6 +369,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config7.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config7.json index 52442f1f94be..04c9eba470e0 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config7.json @@ -186,54 +186,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -258,14 +210,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -282,22 +226,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.value", "kind": "Module", @@ -418,14 +346,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -449,6 +369,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config1.json index 467542e4e9dc..2effe44e4ee8 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config1.json @@ -440,70 +440,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -681,54 +617,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -753,14 +641,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -777,22 +657,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "worker", "kind": "Snippet", @@ -946,14 +810,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -986,6 +842,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config2.json index ace80c397677..50560f5a72ae 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config2.json @@ -116,70 +116,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -381,54 +317,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -453,14 +341,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -477,22 +357,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -598,14 +462,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -629,6 +485,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config3.json index 91be2c905844..e9ca854f297f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config3.json @@ -440,70 +440,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -810,54 +746,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -882,14 +770,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -906,22 +786,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test()", "kind": "Function", @@ -946,14 +810,6 @@ "insertText": "worker ${1:name} {\n\t${2}\n}", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -986,6 +842,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config4.json index 2b49f4dec1c6..309d7f42f496 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config4.json @@ -348,70 +348,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -810,62 +746,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -890,14 +770,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -914,22 +786,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test()", "kind": "Function", @@ -986,6 +842,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config5.json index 7ff03aa82e76..c3fac165679c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config5.json @@ -348,70 +348,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -732,62 +668,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -812,14 +692,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -836,22 +708,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test()", "kind": "Function", @@ -910,11 +766,148 @@ ] }, { - "label": "array", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "array", + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", "insertTextFormat": "Snippet" } ] diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config10.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config10.json index 57a6cd61daa4..a64a411da210 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config10.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config10.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "TestObject2()", "kind": "Function", @@ -374,14 +302,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -405,6 +325,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config10a.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config10a.json index 72f35c17d856..73bf0c0f9def 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config10a.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config10a.json @@ -148,54 +148,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -220,14 +172,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -244,22 +188,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "TestObject1(int field1, int field2)", "kind": "Function", @@ -374,14 +302,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -405,6 +325,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config17.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config17.json index 1e0ef56333f4..cb4962819c2a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config17.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config17.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "TestObject1(int field1, int field2)", "kind": "Function", @@ -374,14 +302,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -405,6 +325,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config18.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config18.json index 9123035073bf..8a0fc93801a9 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config18.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config18.json @@ -110,54 +110,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -182,14 +134,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -206,22 +150,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "TestObject1(int field1, int field2)", "kind": "Function", @@ -387,14 +315,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -418,6 +338,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config19.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config19.json index 138282b30e12..a1db423162b1 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config19.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config19.json @@ -110,54 +110,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -182,14 +134,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -206,22 +150,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "TestObject1(int field1, int field2)", "kind": "Function", @@ -400,14 +328,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -431,6 +351,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config7.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config7.json index e2c261c5dbb1..a94394044bd2 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config7.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "TestObject1(int field1, int field2)", "kind": "Function", @@ -374,14 +302,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -405,6 +325,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config8.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config8.json index e7e019fc1da5..e4c23dce77fe 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config8.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "TestObject1(int field1, int field2)", "kind": "Function", @@ -374,14 +302,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -405,6 +325,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config9.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config9.json index f9113c8cc5e0..0ddfc5d33b3f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config9.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config9.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "TestObject2()", "kind": "Function", @@ -374,14 +302,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -405,6 +325,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/object_constructor_expr_ctx_config13.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/object_constructor_expr_ctx_config13.json index 322ff00680ac..0558406751d0 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/object_constructor_expr_ctx_config13.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/object_constructor_expr_ctx_config13.json @@ -24,70 +24,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -265,54 +201,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -337,14 +225,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -361,22 +241,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.value", "kind": "Module", @@ -533,14 +397,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -564,6 +420,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/object_constructor_expr_ctx_config15.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/object_constructor_expr_ctx_config15.json index 363ac911183d..498b84432e16 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/object_constructor_expr_ctx_config15.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/object_constructor_expr_ctx_config15.json @@ -4,7 +4,6 @@ "character": 9 }, "source": "expression_context/source/object_constructor_expr_ctx_source15.bal", - "description": "Checks whether we suggest another init function when we already have a init function", "items": [ { "label": "StrandData", @@ -25,70 +24,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -395,62 +330,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -475,14 +354,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -499,22 +370,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "private", "kind": "Keyword", @@ -592,6 +447,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/object_constructor_expr_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/object_constructor_expr_ctx_config2.json index 8d7097b2fb4f..58e862c80cb3 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/object_constructor_expr_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/object_constructor_expr_ctx_config2.json @@ -110,54 +110,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -182,14 +134,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -206,22 +150,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.value", "kind": "Module", @@ -342,14 +270,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -373,6 +293,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/object_constructor_expr_ctx_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/object_constructor_expr_ctx_config4.json index 5a6e5d2ade0f..6b93364294e9 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/object_constructor_expr_ctx_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/object_constructor_expr_ctx_config4.json @@ -24,70 +24,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -265,54 +201,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -337,14 +225,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -361,22 +241,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "private", "kind": "Keyword", @@ -560,14 +424,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -600,6 +456,151 @@ "filterText": "init_function", "insertText": "function init(${1}) {\n\t${2}\n}", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/object_constructor_expr_ctx_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/object_constructor_expr_ctx_config5.json index a0aa7cfd4b81..8727a540d405 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/object_constructor_expr_ctx_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/object_constructor_expr_ctx_config5.json @@ -24,70 +24,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -265,54 +201,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -337,14 +225,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -361,22 +241,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "private", "kind": "Keyword", @@ -560,14 +424,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -600,6 +456,151 @@ "filterText": "init_function", "insertText": "function init(${1}) {\n\t${2}\n}", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/object_constructor_expr_ctx_config7.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/object_constructor_expr_ctx_config7.json index dc2969668928..d90add7216cf 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/object_constructor_expr_ctx_config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/object_constructor_expr_ctx_config7.json @@ -24,70 +24,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -265,54 +201,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -337,14 +225,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -361,22 +241,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "private", "kind": "Keyword", @@ -560,14 +424,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -600,6 +456,151 @@ "filterText": "init_function", "insertText": "function init(${1}) {\n\t${2}\n}", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/type_test_expression_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/type_test_expression_ctx_config1.json index e39acb4a9961..8305c53dcd82 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/type_test_expression_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/type_test_expression_ctx_config1.json @@ -32,70 +32,6 @@ "insertText": "TestRecord1", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -297,54 +233,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -369,14 +257,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -393,22 +273,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -514,14 +378,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -545,6 +401,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BBN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BBN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "ABN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BBN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BBN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BBN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "ABN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "BZ", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BBN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BBL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BBN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BBN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BBN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "ABN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "ABN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BBN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "ABN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BBN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/type_test_expression_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/type_test_expression_ctx_config2.json index c06c548d8237..ff28ba637511 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/type_test_expression_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/type_test_expression_ctx_config2.json @@ -32,70 +32,6 @@ "insertText": "TestRecord1", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -297,54 +233,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -369,14 +257,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -393,22 +273,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -514,14 +378,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -545,6 +401,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BBN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BBN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "ABN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BBN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BBN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BBN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "ABN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "BZ", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BBN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BBL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BBN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BBN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BBN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "ABN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "ABN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BBN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "ABN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BBN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/type_test_expression_ctx_config8.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/type_test_expression_ctx_config8.json index fb169b3108fa..61ce7651eb46 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/type_test_expression_ctx_config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/type_test_expression_ctx_config8.json @@ -64,70 +64,6 @@ "insertText": "Type1", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -329,54 +265,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -401,14 +289,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -425,22 +305,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "module1:TestMap2", "kind": "TypeParameter", @@ -562,14 +426,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -593,6 +449,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BBN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BBN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "ABN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BBN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BBN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BBN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "ABN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "BZ", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BBN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "ABL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BBN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BBN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BBN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "ABN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BBN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BBN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "ABN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BBN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/type_test_expression_ctx_config9.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/type_test_expression_ctx_config9.json index d48cab1b043a..409959a9d995 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/type_test_expression_ctx_config9.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/type_test_expression_ctx_config9.json @@ -24,70 +24,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -298,54 +234,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -370,14 +258,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -394,22 +274,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "projectls.ls.mod4", "kind": "Module", @@ -603,14 +467,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -634,6 +490,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BBN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BBN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "ABN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BBN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BBN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BBN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "ABN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "BZ", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BBN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BBL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BBN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BBN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BBN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "ABN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BBN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BBN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BBN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BBN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typecast_expr_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typecast_expr_ctx_config1.json index a5ea12d1654d..5e165584abe3 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typecast_expr_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typecast_expr_ctx_config1.json @@ -40,70 +40,6 @@ "insertText": "AnnotationType", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -281,54 +217,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -353,14 +241,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -377,22 +257,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.value", "kind": "Module", @@ -522,14 +386,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -553,6 +409,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typecast_expr_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typecast_expr_ctx_config2.json index abca8922e0e2..6d780358a09f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typecast_expr_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typecast_expr_ctx_config2.json @@ -40,70 +40,6 @@ "insertText": "AnnotationType", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -281,54 +217,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -353,14 +241,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -377,22 +257,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.value", "kind": "Module", @@ -522,14 +386,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -553,6 +409,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typecast_expr_ctx_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typecast_expr_ctx_config4.json index 9da33ade9cc9..268d6169b3c1 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typecast_expr_ctx_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typecast_expr_ctx_config4.json @@ -40,70 +40,6 @@ "insertText": "AnnotationType", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -281,54 +217,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -353,14 +241,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -377,22 +257,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.value", "kind": "Module", @@ -522,14 +386,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -553,6 +409,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typecast_expr_ctx_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typecast_expr_ctx_config5.json index 57df43337ada..fa21aee6d5f9 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typecast_expr_ctx_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typecast_expr_ctx_config5.json @@ -40,70 +40,6 @@ "insertText": "AnnotationType", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -281,54 +217,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -353,14 +241,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -377,22 +257,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.value", "kind": "Module", @@ -522,14 +386,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -553,6 +409,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typeof_expression_ctx_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typeof_expression_ctx_config5.json index c05247370dad..f9305d8d438a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typeof_expression_ctx_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typeof_expression_ctx_config5.json @@ -245,54 +245,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -317,14 +269,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -341,22 +285,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "display", "kind": "Property", @@ -438,14 +366,6 @@ "insertTextFormat": "Snippet", "additionalTextEdits": [] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -469,6 +389,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/xml_attribute_access_expr_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/xml_attribute_access_expr_ctx_config1.json index 2843d1d0ec6b..a8d792f67579 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/xml_attribute_access_expr_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/xml_attribute_access_expr_ctx_config1.json @@ -156,54 +156,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -228,14 +180,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -252,22 +196,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "foreach", "kind": "Snippet", @@ -782,14 +710,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -813,6 +733,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CR", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CP", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CR", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CR", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CR", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CR", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CR", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CR", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CR", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CR", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/xml_attribute_access_expr_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/xml_attribute_access_expr_ctx_config2.json index cdaf69e5d148..99aa3a756a8a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/xml_attribute_access_expr_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/xml_attribute_access_expr_ctx_config2.json @@ -156,54 +156,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -228,14 +180,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -252,22 +196,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "foreach", "kind": "Snippet", @@ -782,14 +710,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -813,6 +733,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CR", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CP", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CR", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CR", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CR", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CR", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CR", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CR", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CR", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CR", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config21.json b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config21.json index b760a50970b5..48dde2ee2934 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config21.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config21.json @@ -283,70 +283,6 @@ "insertText": "TestRec", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -548,54 +484,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -620,14 +508,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -644,22 +524,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "main(TestRec rec)", "kind": "Function", @@ -882,14 +746,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -922,6 +778,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config38.json b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config38.json index c265ea2a287f..837161a9f6f6 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config38.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config38.json @@ -235,54 +235,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -307,14 +259,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -331,22 +275,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "data()", "kind": "Function", @@ -730,14 +658,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -761,6 +681,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CR", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "AP", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CR", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CR", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CR", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CR", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CR", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CR", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CR", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CR", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config39.json b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config39.json index 0083a0a67dc0..fb91f6f2a025 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config39.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config39.json @@ -235,54 +235,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -307,14 +259,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -331,22 +275,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "data()", "kind": "Function", @@ -730,14 +658,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -761,6 +681,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CR", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "AP", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CR", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CR", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CR", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CR", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CR", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CR", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CR", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CR", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config4.json index 60b03a0ec882..3456264045c9 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config4.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "foreach", "kind": "Snippet", @@ -775,14 +703,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -806,6 +726,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CR", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CP", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CR", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CR", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CR", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CR", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CR", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CR", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CR", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CR", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config40.json b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config40.json index 1032a4a0621f..d3f97433265b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config40.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config40.json @@ -235,54 +235,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -307,14 +259,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -331,22 +275,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "data()", "kind": "Function", @@ -730,14 +658,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -761,6 +681,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CR", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "AP", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CR", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CR", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CR", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CR", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CR", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CR", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CR", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CR", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config41.json b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config41.json index 29120d8a0a1b..b6cd94386fcc 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config41.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config41.json @@ -235,54 +235,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -307,14 +259,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -331,22 +275,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "data()", "kind": "Function", @@ -730,14 +658,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -761,6 +681,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CR", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "AP", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CR", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CR", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CR", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CR", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CR", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CR", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CR", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CR", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config1.json index b74ed001255e..4297b4b26f7e 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config1.json @@ -24,70 +24,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -304,54 +240,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -376,14 +264,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -400,22 +280,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "var", "kind": "Keyword", @@ -530,14 +394,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -561,6 +417,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config2.json index 3fa3ba03d8bb..7dd9457c1d92 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config2.json @@ -24,70 +24,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -304,54 +240,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -376,14 +264,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -400,22 +280,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "var", "kind": "Keyword", @@ -530,14 +394,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -561,6 +417,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config20.json b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config20.json index 3050333c9f84..402146ff1ebb 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config20.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config20.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "foreach", "kind": "Snippet", @@ -775,14 +703,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -806,6 +726,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CR", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CP", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CR", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CR", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CR", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CR", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CR", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CR", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CR", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CR", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config24.json b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config24.json index 0b53a19ab621..e9daa4c34d7a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config24.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config24.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "foreach", "kind": "Snippet", @@ -775,14 +703,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -806,6 +726,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CR", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CP", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CR", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CR", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CR", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CR", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CR", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CR", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CR", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CR", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config7.json b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config7.json index 4e6e9ebf2b56..a76596188f41 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config7.json @@ -285,70 +285,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -565,54 +501,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -637,14 +525,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -661,22 +541,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "doSomeTask()", "kind": "Function", @@ -909,14 +773,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -949,6 +805,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config8.json b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config8.json index 65cb29bdb43f..a4b0242bf336 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config8.json @@ -285,70 +285,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -565,54 +501,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -637,14 +525,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -661,22 +541,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "doSomeTask()", "kind": "Function", @@ -909,14 +773,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -949,6 +805,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config1.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config1.json index eb4313916e9b..ec7d4219704c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config1.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -532,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -604,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -628,22 +508,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -854,14 +718,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -894,6 +750,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config10.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config10.json index 7c9edcefa984..9a969ee51115 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config10.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config10.json @@ -176,54 +176,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -248,14 +200,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -272,30 +216,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "isolated", "kind": "Keyword", @@ -396,62 +316,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "xmlns", "kind": "Snippet", @@ -888,14 +752,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -928,6 +784,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config12.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config12.json index 347e560377db..200c15910307 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config12.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config12.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -532,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -604,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -628,22 +508,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "v", "kind": "Variable", @@ -889,14 +753,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -929,6 +785,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "O", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "O", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "O", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "O", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "O", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "O", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "O", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "R", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "O", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "M", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "O", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "O", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "O", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "O", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "O", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "O", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "O", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "O", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config13.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config13.json index ef9bd57470fb..c22f3b464016 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config13.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config13.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -532,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -604,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -628,22 +508,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "v", "kind": "Variable", @@ -889,14 +753,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "module1:TEST_STRING_CONST1", "kind": "Variable", @@ -1043,6 +899,151 @@ "sortText": "O", "insertText": "module1:TargetType", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "O", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "O", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "O", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "O", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "O", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "O", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "O", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "R", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "O", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "M", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "O", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "O", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "O", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "O", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "O", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "O", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "O", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "O", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config14.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config14.json index 191b25006a37..6092235f51d6 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config14.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config14.json @@ -492,70 +492,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -628,54 +564,6 @@ "insertText": "false", "insertTextFormat": "Snippet" }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -700,14 +588,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -724,22 +604,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "foo()", "kind": "Function", @@ -877,14 +741,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -917,6 +773,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config15_client_declaration.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config15_client_declaration.json index 1a86602aedfe..8789b87b8810 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config15_client_declaration.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config15_client_declaration.json @@ -492,70 +492,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -628,54 +564,6 @@ "insertText": "false", "insertTextFormat": "Snippet" }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -700,14 +588,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -724,22 +604,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "worker", "kind": "Snippet", @@ -854,14 +718,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -918,6 +774,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config16_client_declaration.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config16_client_declaration.json index 8ddb65feece9..db72af6c3ce2 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config16_client_declaration.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config16_client_declaration.json @@ -492,70 +492,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -628,54 +564,6 @@ "insertText": "false", "insertTextFormat": "Snippet" }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -700,14 +588,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -724,22 +604,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "worker", "kind": "Snippet", @@ -854,14 +718,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -927,6 +783,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config2.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config2.json index 9231d9349436..6a8d310ba15e 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config2.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -532,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -604,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -628,22 +508,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -854,14 +718,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -894,6 +750,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config3.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config3.json index 0ba844df8f07..aed508772190 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config3.json @@ -258,70 +258,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -523,54 +459,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -595,14 +483,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -619,22 +499,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -845,14 +709,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -885,6 +741,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config4.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config4.json index 25682d346b9e..66940b50dfff 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config4.json @@ -258,70 +258,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -523,54 +459,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -595,14 +483,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -619,22 +499,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "validator2", "kind": "Variable", @@ -856,14 +720,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -896,6 +752,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config5.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config5.json index 8ec45b33f13a..ecb478cdc8a9 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config5.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -508,54 +444,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -580,14 +468,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -604,22 +484,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "validator1", "kind": "Variable", @@ -874,14 +738,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -914,6 +770,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config6.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config6.json index c870ab0a366a..b316b828c0ea 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config6.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -508,54 +444,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -580,14 +468,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -604,22 +484,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "validator2", "kind": "Variable", @@ -874,14 +738,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -914,6 +770,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config10.json b/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config10.json index 21c587becb4a..72c770e0bdd6 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config10.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config10.json @@ -32,70 +32,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -297,54 +233,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -369,14 +257,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -393,22 +273,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -514,14 +378,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -545,6 +401,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config11.json b/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config11.json index 69c97b002f18..b097365df471 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config11.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config11.json @@ -32,70 +32,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -297,54 +233,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -369,14 +257,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -393,22 +273,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -514,14 +378,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -545,6 +401,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config18.json b/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config18.json index f8f11ad940e0..e7ef87db09de 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config18.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config18.json @@ -161,54 +161,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -233,14 +185,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -257,22 +201,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "Address", "kind": "Struct", @@ -396,14 +324,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -427,6 +347,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config19.json b/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config19.json index f2188dcc67fd..5772942fd962 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config19.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config19.json @@ -161,54 +161,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -233,14 +185,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -257,22 +201,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "Address", "kind": "Struct", @@ -396,14 +324,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -427,6 +347,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config22.json b/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config22.json index db1c5631e72a..3f12fca09411 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config22.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config22.json @@ -32,70 +32,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -312,54 +248,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -384,14 +272,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -408,22 +288,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "MyError", "kind": "Event", @@ -537,14 +401,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -568,6 +424,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config3.json b/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config3.json index 055de1601a10..3ece32f4f72c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config3.json @@ -32,70 +32,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -297,54 +233,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -369,14 +257,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -393,22 +273,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "isolated", "kind": "Keyword", @@ -541,14 +405,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -572,6 +428,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config4.json b/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config4.json index 6482c089753a..bfe9342a5ef8 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config4.json @@ -32,70 +32,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -297,54 +233,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -369,14 +257,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -393,22 +273,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "isolated", "kind": "Keyword", @@ -541,14 +405,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "module1:TEST_STRING_CONST1", "kind": "Variable", @@ -686,6 +542,151 @@ "sortText": "BN", "insertText": "module1:TargetType", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config9.json b/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config9.json index eb1a28e2876b..4fb02e4eb56d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config9.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config9.json @@ -32,70 +32,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -297,54 +233,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -369,14 +257,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -393,22 +273,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -514,14 +378,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -545,6 +401,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config11.json b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config11.json index 42da14cb2b78..deb88a1d84cb 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config11.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config11.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -412,54 +348,6 @@ "insertText": "module1", "insertTextFormat": "Snippet" }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -484,14 +372,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -508,22 +388,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "lsproject.hierarchy.module4", "kind": "Module", @@ -956,14 +820,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -996,6 +852,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config12.json b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config12.json index abb200869f7e..81f969dabc04 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config12.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config12.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -412,54 +348,6 @@ "insertText": "module1", "insertTextFormat": "Snippet" }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -484,14 +372,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -508,22 +388,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "lsproject.hierarchy.module4", "kind": "Module", @@ -956,14 +820,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -996,6 +852,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config21.json b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config21.json index becf4b4d7c69..87e413229921 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config21.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config21.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -412,54 +348,6 @@ "insertText": "module1", "insertTextFormat": "Snippet" }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -484,14 +372,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -508,22 +388,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "lsproject.hierarchy.module4", "kind": "Module", @@ -956,14 +820,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -996,6 +852,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config26.json b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config26.json index 41d0eb569790..646a127de601 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config26.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config26.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -403,54 +339,6 @@ "insertText": "false", "insertTextFormat": "Snippet" }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -475,14 +363,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -499,22 +379,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "'service.'transaction.'join", "kind": "Module", @@ -932,14 +796,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -972,6 +828,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config1.json index 37668467cb61..d43ed637a1cc 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config1.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "function", "kind": "Keyword", @@ -316,70 +244,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -530,14 +394,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -561,6 +417,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config12.json b/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config12.json index 8ae6bd6b0e94..529cea964c8b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config12.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config12.json @@ -125,54 +125,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -197,14 +149,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -221,22 +165,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "function", "kind": "Keyword", @@ -292,70 +220,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -530,14 +394,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -561,6 +417,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config1a.json b/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config1a.json index 247d1ae915eb..724441d639fd 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config1a.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config1a.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "function", "kind": "Keyword", @@ -316,70 +244,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -530,14 +394,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -561,6 +417,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config1.json b/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config1.json index a9af0ffd1033..ef8145dc9635 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "Listener", "kind": "Interface", @@ -350,14 +278,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -381,6 +301,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "A", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "A", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "A", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "A", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "A", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "A", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "A", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "A", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "A", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "A", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config11.json b/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config11.json index 4f669b4ff8bf..1fd702444777 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config11.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config11.json @@ -180,54 +180,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -252,14 +204,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -276,22 +220,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "new(int port)", "kind": "Function", @@ -442,14 +370,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -473,6 +393,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "S", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "Q", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "S", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "S", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "S", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "S", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "S", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "S", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "S", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "S", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config12.json b/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config12.json index fde250fc660b..aa4f41ae886f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config12.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config12.json @@ -24,70 +24,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -289,54 +225,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -361,14 +249,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -385,22 +265,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -506,14 +370,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -537,6 +393,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config2.json b/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config2.json index 1448a6b7b1e8..91880220d1ae 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "Listener", "kind": "Interface", @@ -350,14 +278,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -381,6 +301,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "A", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "A", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "A", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "A", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "A", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "A", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "A", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "A", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "A", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "A", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config3b.json b/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config3b.json index 8197ebc1ca10..a80758f71097 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config3b.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config3b.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "Listener", "kind": "Interface", @@ -350,14 +278,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -381,6 +301,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "A", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "A", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "A", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "A", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "A", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "A", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "A", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "A", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "A", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "A", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config3c.json b/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config3c.json index cd1a163d46f9..78d2cf65ea87 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config3c.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config3c.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "Listener", "kind": "Interface", @@ -350,14 +278,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -381,6 +301,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "A", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "A", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "A", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "A", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "A", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "A", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "A", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "A", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "A", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "A", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config4.json b/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config4.json index 7700f4637173..edba259f3d16 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config4.json @@ -142,54 +142,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -214,14 +166,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -238,22 +182,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "new(int port)", "kind": "Function", @@ -404,14 +332,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -435,6 +355,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "S", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "Q", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "S", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "S", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "S", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "S", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "S", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "S", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "S", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "S", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config5.json b/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config5.json index b6e5b19096be..86276f631452 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config5.json @@ -142,54 +142,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -214,14 +166,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -238,22 +182,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "new(int port)", "kind": "Function", @@ -404,14 +332,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -435,6 +355,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "S", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "Q", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "S", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "S", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "S", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "S", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "S", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "S", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "S", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "S", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config7.json b/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config7.json index 5e3b2cbfea1f..0762b70f69b3 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config7.json @@ -142,54 +142,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -214,14 +166,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -238,22 +182,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "new", "kind": "Keyword", @@ -386,14 +314,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -417,6 +337,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "S", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "Q", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "S", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "S", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "S", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "S", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "S", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "S", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "S", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "S", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config8.json b/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config8.json index c55d0e10f529..5171a8b6dcf0 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config8.json @@ -142,54 +142,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -214,14 +166,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -238,22 +182,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "new", "kind": "Keyword", @@ -386,14 +314,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -417,6 +337,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "S", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "Q", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "S", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "S", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "S", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "S", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "S", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "S", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "S", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "S", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config9.json b/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config9.json index 836d86883f87..6d0d391a1fd7 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config9.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/listener_decl/config/config9.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -342,14 +270,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -373,6 +293,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/client_declaration_module_prefix_reference_in_module_level.json b/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/client_declaration_module_prefix_reference_in_module_level.json index 7c2b513a20fd..fa803dcd8ca2 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/client_declaration_module_prefix_reference_in_module_level.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/client_declaration_module_prefix_reference_in_module_level.json @@ -9,7 +9,7 @@ "label": "ClientConfiguration", "kind": "Struct", "detail": "Record", - "sortText": "D", + "sortText": "CA", "insertText": "ClientConfiguration", "insertTextFormat": "Snippet" }, @@ -17,7 +17,7 @@ "label": "client", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "client", "insertTextFormat": "Snippet" } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_const_context/config/config1.json b/language-server/modules/langserver-core/src/test/resources/completion/module_const_context/config/config1.json index 0f535d6056a0..41663864f417 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_const_context/config/config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_const_context/config/config1.json @@ -24,70 +24,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -289,54 +225,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -361,14 +249,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -385,22 +265,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -515,14 +379,6 @@ "insertText": "annotation ", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -546,6 +402,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_const_context/config/config10.json b/language-server/modules/langserver-core/src/test/resources/completion/module_const_context/config/config10.json index 1c6e70c0a21f..5b90f36881d9 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_const_context/config/config10.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_const_context/config/config10.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "true", "kind": "Keyword", @@ -374,14 +302,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -405,6 +325,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_const_context/config/config2.json b/language-server/modules/langserver-core/src/test/resources/completion/module_const_context/config/config2.json index 2de594c853ef..f047542ed3ad 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_const_context/config/config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_const_context/config/config2.json @@ -32,70 +32,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -297,54 +233,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -369,14 +257,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -393,22 +273,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -523,14 +387,6 @@ "insertText": "annotation ", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -554,6 +410,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_const_context/config/config4.json b/language-server/modules/langserver-core/src/test/resources/completion/module_const_context/config/config4.json index f0f004469a9f..ab1c11fc5b4e 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_const_context/config/config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_const_context/config/config4.json @@ -32,70 +32,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -297,54 +233,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -369,14 +257,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -393,22 +273,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -523,14 +387,6 @@ "insertText": "annotation ", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -554,6 +410,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_const_context/config/config6.json b/language-server/modules/langserver-core/src/test/resources/completion/module_const_context/config/config6.json index 3d88279b70f0..23999cfe83d9 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_const_context/config/config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_const_context/config/config6.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "CONST1", "kind": "Variable", @@ -388,14 +316,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -419,6 +339,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_const_context/config/config7.json b/language-server/modules/langserver-core/src/test/resources/completion/module_const_context/config/config7.json index 9fda67d699b0..33f09a7d26ea 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_const_context/config/config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_const_context/config/config7.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "CONST1", "kind": "Variable", @@ -388,14 +316,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -419,6 +339,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config10.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config10.json index 38e102627a26..6867084500fc 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config10.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config10.json @@ -9,7 +9,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -18,7 +18,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -42,7 +42,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -66,7 +66,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -90,7 +90,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -114,7 +114,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,27 +174,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "on", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "on", "insertText": "on ", "insertTextFormat": "Snippet" @@ -259,7 +187,7 @@ "label": "object", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "object", "insertText": "object ", "insertTextFormat": "Snippet" @@ -268,7 +196,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -277,7 +205,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -286,7 +214,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -310,7 +238,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -334,7 +262,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -358,7 +286,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -378,19 +306,11 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -409,6 +329,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config11.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config11.json index 5516335a3de7..bc95aeb3d1b0 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config11.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config11.json @@ -9,7 +9,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -18,7 +18,7 @@ "label": "object", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "object", "insertText": "object ", "insertTextFormat": "Snippet" @@ -27,7 +27,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -36,7 +36,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -45,7 +45,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config12.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config12.json index a9b358129e51..838e82bbe310 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config12.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config12.json @@ -9,7 +9,7 @@ "label": "object", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "object", "insertText": "object ", "insertTextFormat": "Snippet" @@ -18,7 +18,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -27,7 +27,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config13.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config13.json index 815465e8a2ae..89cbba8c1c68 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config13.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config13.json @@ -9,7 +9,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -18,7 +18,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -27,7 +27,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config17.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config17.json index 90bf7d6178c1..c7655eaf1559 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config17.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config17.json @@ -24,70 +24,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -394,62 +330,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -474,14 +354,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -498,22 +370,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -537,6 +393,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "B", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "B", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "B", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "B", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "B", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "B", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "B", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "D", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "B", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "D", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "B", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "B", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "B", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "B", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "B", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "B", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "B", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "B", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config4.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config4.json index 253fb7326f1f..49376c84f7de 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config4.json @@ -9,7 +9,7 @@ "label": "AnnotationType", "kind": "Struct", "detail": "Record", - "sortText": "D", + "sortText": "CA", "insertText": "AnnotationType", "insertTextFormat": "Snippet" }, @@ -20,7 +20,7 @@ "documentation": { "left": "The types of messages that are accepted by HTTP `listener` when sending out the outbound response." }, - "sortText": "D", + "sortText": "CA", "insertText": "ResponseMessage", "insertTextFormat": "Snippet" }, @@ -31,7 +31,7 @@ "documentation": { "left": "The types of messages that are accepted by HTTP `client` when sending out the outbound request." }, - "sortText": "D", + "sortText": "CA", "insertText": "RequestMessage", "insertTextFormat": "Snippet" }, @@ -39,7 +39,7 @@ "label": "TestRecord1", "kind": "Struct", "detail": "Record", - "sortText": "D", + "sortText": "CA", "insertText": "TestRecord1", "insertTextFormat": "Snippet" }, @@ -47,7 +47,7 @@ "label": "TestRecord2", "kind": "Struct", "detail": "Record", - "sortText": "D", + "sortText": "CA", "insertText": "TestRecord2", "insertTextFormat": "Snippet" }, @@ -55,7 +55,7 @@ "label": "TestMap2", "kind": "TypeParameter", "detail": "Map", - "sortText": "D", + "sortText": "CA", "insertText": "TestMap2", "insertTextFormat": "Snippet" }, @@ -63,7 +63,7 @@ "label": "TestMap3", "kind": "TypeParameter", "detail": "Map", - "sortText": "D", + "sortText": "CA", "insertText": "TestMap3", "insertTextFormat": "Snippet" }, @@ -71,7 +71,7 @@ "label": "TestObject1", "kind": "Interface", "detail": "Object", - "sortText": "D", + "sortText": "CA", "insertText": "TestObject1", "insertTextFormat": "Snippet" }, @@ -79,7 +79,7 @@ "label": "ErrorOne", "kind": "Event", "detail": "Error", - "sortText": "D", + "sortText": "CA", "insertText": "ErrorOne", "insertTextFormat": "Snippet" }, @@ -87,7 +87,7 @@ "label": "ErrorTwo", "kind": "Event", "detail": "Error", - "sortText": "D", + "sortText": "CA", "insertText": "ErrorTwo", "insertTextFormat": "Snippet" }, @@ -98,7 +98,7 @@ "documentation": { "left": "The HTTP client provides the capability for initiating contact with a remote HTTP service. The API it\nprovides includes functions for the standard HTTP methods, forwarding a received request and sending requests\nusing custom HTTP verbs." }, - "sortText": "D", + "sortText": "CA", "insertText": "Client", "insertTextFormat": "Snippet" }, @@ -109,7 +109,7 @@ "documentation": { "left": "Represents a response.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "Response", "insertTextFormat": "Snippet" }, @@ -117,7 +117,7 @@ "label": "TestClass1", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass1", "insertTextFormat": "Snippet" }, @@ -125,7 +125,7 @@ "label": "Listener", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "Listener", "insertTextFormat": "Snippet" }, @@ -136,7 +136,7 @@ "documentation": { "left": "Defines the possible client error types." }, - "sortText": "D", + "sortText": "CA", "insertText": "ClientError", "insertTextFormat": "Snippet" }, @@ -147,7 +147,7 @@ "documentation": { "left": "The super type of all the types." }, - "sortText": "D", + "sortText": "CA", "insertText": "TargetType2", "insertTextFormat": "Snippet" }, @@ -158,7 +158,7 @@ "documentation": { "left": "The types of data values that are expected by the `client` to return after the data binding operation." }, - "sortText": "D", + "sortText": "CA", "insertText": "TargetType", "insertTextFormat": "Snippet" } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config5.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config5.json index e65f2b9e6953..a504f9ed1f4f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config5.json @@ -9,7 +9,7 @@ "label": "AnnotationType", "kind": "Struct", "detail": "Record", - "sortText": "D", + "sortText": "CA", "insertText": "AnnotationType", "insertTextFormat": "Snippet" }, @@ -20,7 +20,7 @@ "documentation": { "left": "The types of messages that are accepted by HTTP `listener` when sending out the outbound response." }, - "sortText": "D", + "sortText": "CA", "insertText": "ResponseMessage", "insertTextFormat": "Snippet" }, @@ -31,7 +31,7 @@ "documentation": { "left": "The types of messages that are accepted by HTTP `client` when sending out the outbound request." }, - "sortText": "D", + "sortText": "CA", "insertText": "RequestMessage", "insertTextFormat": "Snippet" }, @@ -39,7 +39,7 @@ "label": "TestRecord1", "kind": "Struct", "detail": "Record", - "sortText": "D", + "sortText": "CA", "insertText": "TestRecord1", "insertTextFormat": "Snippet" }, @@ -47,7 +47,7 @@ "label": "TestRecord2", "kind": "Struct", "detail": "Record", - "sortText": "D", + "sortText": "CA", "insertText": "TestRecord2", "insertTextFormat": "Snippet" }, @@ -55,7 +55,7 @@ "label": "TestMap2", "kind": "TypeParameter", "detail": "Map", - "sortText": "D", + "sortText": "CA", "insertText": "TestMap2", "insertTextFormat": "Snippet" }, @@ -63,7 +63,7 @@ "label": "TestMap3", "kind": "TypeParameter", "detail": "Map", - "sortText": "D", + "sortText": "CA", "insertText": "TestMap3", "insertTextFormat": "Snippet" }, @@ -71,7 +71,7 @@ "label": "TestObject1", "kind": "Interface", "detail": "Object", - "sortText": "D", + "sortText": "CA", "insertText": "TestObject1", "insertTextFormat": "Snippet" }, @@ -79,7 +79,7 @@ "label": "ErrorOne", "kind": "Event", "detail": "Error", - "sortText": "D", + "sortText": "CA", "insertText": "ErrorOne", "insertTextFormat": "Snippet" }, @@ -87,7 +87,7 @@ "label": "ErrorTwo", "kind": "Event", "detail": "Error", - "sortText": "D", + "sortText": "CA", "insertText": "ErrorTwo", "insertTextFormat": "Snippet" }, @@ -98,7 +98,7 @@ "documentation": { "left": "The HTTP client provides the capability for initiating contact with a remote HTTP service. The API it\nprovides includes functions for the standard HTTP methods, forwarding a received request and sending requests\nusing custom HTTP verbs." }, - "sortText": "D", + "sortText": "CA", "insertText": "Client", "insertTextFormat": "Snippet" }, @@ -109,7 +109,7 @@ "documentation": { "left": "Represents a response.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "Response", "insertTextFormat": "Snippet" }, @@ -117,7 +117,7 @@ "label": "TestClass1", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass1", "insertTextFormat": "Snippet" }, @@ -125,7 +125,7 @@ "label": "Listener", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "Listener", "insertTextFormat": "Snippet" }, @@ -136,7 +136,7 @@ "documentation": { "left": "Defines the possible client error types." }, - "sortText": "D", + "sortText": "CA", "insertText": "ClientError", "insertTextFormat": "Snippet" }, @@ -147,7 +147,7 @@ "documentation": { "left": "The super type of all the types." }, - "sortText": "D", + "sortText": "CA", "insertText": "TargetType2", "insertTextFormat": "Snippet" }, @@ -158,7 +158,7 @@ "documentation": { "left": "The types of data values that are expected by the `client` to return after the data binding operation." }, - "sortText": "D", + "sortText": "CA", "insertText": "TargetType", "insertTextFormat": "Snippet" } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config8.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config8.json index 791a744ab438..3a679f4f2d23 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config8.json @@ -9,7 +9,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -18,7 +18,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -27,7 +27,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -36,7 +36,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -48,7 +48,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -56,79 +56,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -137,7 +73,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -146,7 +82,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -155,7 +91,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -164,7 +100,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -173,7 +109,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -182,7 +118,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -191,7 +127,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -200,7 +136,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -209,7 +145,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -233,7 +169,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -257,7 +193,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -281,7 +217,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -305,7 +241,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -325,54 +261,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -397,14 +285,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -421,27 +301,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "object", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "object", "insertText": "object ", "insertTextFormat": "Snippet" @@ -450,7 +314,7 @@ "label": "service", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "service", "insertText": "service", "insertTextFormat": "Snippet" @@ -459,7 +323,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -483,7 +347,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -507,7 +371,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -531,7 +395,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -555,24 +419,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -591,6 +447,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config9.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config9.json index 203ab6512000..c7a3d9c2c823 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config9.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config9.json @@ -9,7 +9,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -18,7 +18,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -42,7 +42,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -66,7 +66,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -90,7 +90,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -114,7 +114,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,27 +174,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "on", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "on", "insertText": "on ", "insertTextFormat": "Snippet" @@ -259,7 +187,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -268,7 +196,7 @@ "label": "object", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "object", "insertText": "object ", "insertTextFormat": "Snippet" @@ -277,7 +205,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -286,7 +214,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -295,7 +223,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -304,7 +232,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -328,7 +256,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -352,7 +280,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -376,7 +304,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -396,19 +324,11 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -427,6 +347,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config14.json b/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config14.json index 12fac3ae59e0..10e7f341d008 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config14.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config14.json @@ -5,46 +5,6 @@ }, "source": "module_var_context/source/source14.bal", "items": [ - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -53,14 +13,6 @@ "insertText": "map", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -69,14 +21,6 @@ "insertText": "table", "insertTextFormat": "Snippet" }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "StrandData", "kind": "Struct", @@ -96,62 +40,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -473,22 +361,6 @@ } ] }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "future", - "insertTextFormat": "Snippet" - }, { "label": "object", "kind": "Unit", @@ -513,22 +385,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -552,6 +408,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "B", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "B", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "B", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "B", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "B", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "B", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "B", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "D", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "B", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "D", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "B", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "B", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "B", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "B", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "B", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "B", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "B", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "B", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config15.json b/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config15.json index fc5f525f14f8..af619023d835 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config15.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config15.json @@ -24,70 +24,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -410,148 +346,213 @@ ] }, { - "label": "boolean", + "label": "map", "kind": "Unit", "detail": "type", "sortText": "A", - "insertText": "boolean", + "insertText": "map", "insertTextFormat": "Snippet" }, { - "label": "decimal", + "label": "object", "kind": "Unit", "detail": "type", - "sortText": "A", - "insertText": "decimal", + "sortText": "C", + "insertText": "object", "insertTextFormat": "Snippet" }, { - "label": "error", + "label": "stream", "kind": "Unit", "detail": "type", "sortText": "C", - "insertText": "error", + "insertText": "stream", "insertTextFormat": "Snippet" }, { - "label": "float", + "label": "table", "kind": "Unit", "detail": "type", "sortText": "A", - "insertText": "float", + "insertText": "table", "insertTextFormat": "Snippet" }, { - "label": "future", + "label": "transaction", "kind": "Unit", "detail": "type", "sortText": "C", - "insertText": "future", + "insertText": "transaction", "insertTextFormat": "Snippet" }, { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "int", + "label": "ballerina/lang.regexp", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "filterText": "regexp", + "insertText": "regexp", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.regexp;\n" + } + ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "B", + "insertText": "readonly", "insertTextFormat": "Snippet" }, { - "label": "map", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "map", + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "B", + "insertText": "handle", "insertTextFormat": "Snippet" }, { - "label": "object", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "object", + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "B", + "insertText": "never", "insertTextFormat": "Snippet" }, { - "label": "stream", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "stream", + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "B", + "insertText": "json", "insertTextFormat": "Snippet" }, { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "string", + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "B", + "insertText": "anydata", "insertTextFormat": "Snippet" }, { - "label": "table", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "table", + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "B", + "insertText": "any", "insertTextFormat": "Snippet" }, { - "label": "transaction", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "transaction", + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "B", + "insertText": "byte", "insertTextFormat": "Snippet" }, { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "typedesc", + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "D", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "B", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "D", + "insertText": "error", "insertTextFormat": "Snippet" }, { "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "A", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "B", "insertText": "xml", "insertTextFormat": "Snippet" }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "B", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "B", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "B", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "B", + "insertText": "float", + "insertTextFormat": "Snippet" + }, { "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "C", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "B", "insertText": "function", "insertTextFormat": "Snippet" }, { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", - "sortText": "C", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "B", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "B", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config16.json b/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config16.json index 19cbd4658834..4ef915507d75 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config16.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config16.json @@ -24,70 +24,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -394,62 +330,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -474,14 +354,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -498,22 +370,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -537,6 +393,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "B", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "B", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "B", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "B", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "B", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "B", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "B", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "D", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "B", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "D", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "B", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "B", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "B", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "B", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "B", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "B", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "B", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "B", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config18.json b/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config18.json index f74597b42774..f0ab6f8adf48 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config18.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config18.json @@ -24,70 +24,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -394,62 +330,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -474,14 +354,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -498,22 +370,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -537,6 +393,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "B", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "B", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "B", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "B", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "B", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "B", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "B", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "D", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "B", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "D", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "B", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "B", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "B", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "B", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "B", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "B", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "B", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "B", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config7.json b/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config7.json index 3f58770b0cf8..d1d6f42fcba4 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config7.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -342,14 +270,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -373,6 +293,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config9.json b/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config9.json index 2d628acfc79d..9e2c97303d2a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config9.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config9.json @@ -96,70 +96,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -343,54 +279,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -415,14 +303,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -439,22 +319,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -571,14 +435,6 @@ "insertText": "module1:Client", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -613,6 +469,151 @@ "sortText": "L", "insertText": "module1:ClientError", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_xml_namespace_decl/config/config1.json b/language-server/modules/langserver-core/src/test/resources/completion/module_xml_namespace_decl/config/config1.json index d6b19b644dfd..3b80057a735a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_xml_namespace_decl/config/config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_xml_namespace_decl/config/config1.json @@ -148,54 +148,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -220,14 +172,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -244,22 +188,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -356,14 +284,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -387,6 +307,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_xml_namespace_decl/config/config2.json b/language-server/modules/langserver-core/src/test/resources/completion/module_xml_namespace_decl/config/config2.json index d3c591e21562..f7205906f36f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_xml_namespace_decl/config/config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_xml_namespace_decl/config/config2.json @@ -148,54 +148,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -220,14 +172,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -244,22 +188,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -356,14 +284,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -387,6 +307,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_xml_namespace_decl/config/config8.json b/language-server/modules/langserver-core/src/test/resources/completion/module_xml_namespace_decl/config/config8.json index cc1710dada59..7217bc743e22 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_xml_namespace_decl/config/config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_xml_namespace_decl/config/config8.json @@ -148,54 +148,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -220,14 +172,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -244,22 +188,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -356,14 +284,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -387,6 +307,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config18.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config18.json index 796348c62c46..c0568fa4a3c7 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config18.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config18.json @@ -32,70 +32,6 @@ "insertText": "Customer", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -312,54 +248,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -384,14 +272,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -408,22 +288,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "var", "kind": "Keyword", @@ -538,14 +402,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -569,6 +425,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config31.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config31.json index 4d9a4fb2b293..8ef7ef12ff46 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config31.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config31.json @@ -32,70 +32,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -418,157 +354,222 @@ ] }, { - "label": "boolean", + "label": "map", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "boolean", + "insertText": "map", "insertTextFormat": "Snippet" }, { - "label": "decimal", + "label": "object", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "decimal", + "insertText": "object", "insertTextFormat": "Snippet" }, { - "label": "error", + "label": "stream", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "error", + "insertText": "stream", "insertTextFormat": "Snippet" }, { - "label": "float", + "label": "table", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "float", + "insertText": "table", "insertTextFormat": "Snippet" }, { - "label": "function", + "label": "transaction", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "function", + "insertText": "transaction", "insertTextFormat": "Snippet" }, { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", + "label": "var", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "var", + "insertText": "var ", "insertTextFormat": "Snippet" }, { - "label": "int", - "kind": "Unit", - "detail": "type", + "label": "ballerina/lang.regexp", + "kind": "Module", + "detail": "Module", "sortText": "R", - "insertText": "int", + "filterText": "regexp", + "insertText": "regexp", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.regexp;\n" + } + ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", "insertTextFormat": "Snippet" }, { - "label": "map", - "kind": "Unit", - "detail": "type", + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", "sortText": "R", - "insertText": "map", + "insertText": "handle", "insertTextFormat": "Snippet" }, { - "label": "object", - "kind": "Unit", - "detail": "type", + "label": "never", + "kind": "TypeParameter", + "detail": "Never", "sortText": "R", - "insertText": "object", + "insertText": "never", "insertTextFormat": "Snippet" }, { - "label": "stream", - "kind": "Unit", - "detail": "type", + "label": "json", + "kind": "TypeParameter", + "detail": "Json", "sortText": "R", - "insertText": "stream", + "insertText": "json", "insertTextFormat": "Snippet" }, { - "label": "string", - "kind": "Unit", - "detail": "type", + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", "sortText": "R", - "insertText": "string", + "insertText": "anydata", "insertTextFormat": "Snippet" }, { - "label": "table", - "kind": "Unit", - "detail": "type", + "label": "any", + "kind": "TypeParameter", + "detail": "Any", "sortText": "R", - "insertText": "table", + "insertText": "any", "insertTextFormat": "Snippet" }, { - "label": "transaction", - "kind": "Unit", - "detail": "type", + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", "sortText": "R", - "insertText": "transaction", + "insertText": "byte", "insertTextFormat": "Snippet" }, { - "label": "typedesc", - "kind": "Unit", - "detail": "type", + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", "sortText": "R", - "insertText": "typedesc", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", "insertTextFormat": "Snippet" }, { "label": "xml", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Xml", "sortText": "R", "insertText": "xml", "insertTextFormat": "Snippet" }, { - "label": "var", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "U", - "filterText": "var", - "insertText": "var ", + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", "insertTextFormat": "Snippet" }, { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", + "label": "future", + "kind": "TypeParameter", + "detail": "Future", "sortText": "R", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config7.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config7.json index b2207a04d051..57d817ae3910 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config7.json @@ -24,70 +24,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -241,54 +177,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -313,14 +201,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -337,22 +217,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "var", "kind": "Keyword", @@ -491,14 +355,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.test", "kind": "Module", @@ -546,6 +402,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config8.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config8.json index b4e3d7dee54a..a92516d593ae 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config8.json @@ -24,70 +24,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -241,54 +177,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -313,14 +201,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -337,22 +217,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "var", "kind": "Keyword", @@ -515,14 +379,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -546,6 +402,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config1.json index 16c492d3906b..4a70d1e04c36 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config1.json @@ -24,70 +24,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -410,157 +346,222 @@ ] }, { - "label": "boolean", + "label": "map", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "boolean", + "insertText": "map", "insertTextFormat": "Snippet" }, { - "label": "decimal", + "label": "object", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "decimal", + "insertText": "object", "insertTextFormat": "Snippet" }, { - "label": "error", + "label": "stream", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "error", + "insertText": "stream", "insertTextFormat": "Snippet" }, { - "label": "float", + "label": "table", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "float", + "insertText": "table", "insertTextFormat": "Snippet" }, { - "label": "function", + "label": "transaction", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "function", + "insertText": "transaction", "insertTextFormat": "Snippet" }, { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", + "label": "var", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "var", + "insertText": "var ", "insertTextFormat": "Snippet" }, { - "label": "int", - "kind": "Unit", - "detail": "type", + "label": "ballerina/lang.regexp", + "kind": "Module", + "detail": "Module", "sortText": "R", - "insertText": "int", + "filterText": "regexp", + "insertText": "regexp", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.regexp;\n" + } + ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", "insertTextFormat": "Snippet" }, { - "label": "map", - "kind": "Unit", - "detail": "type", + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", "sortText": "R", - "insertText": "map", + "insertText": "handle", "insertTextFormat": "Snippet" }, { - "label": "object", - "kind": "Unit", - "detail": "type", + "label": "never", + "kind": "TypeParameter", + "detail": "Never", "sortText": "R", - "insertText": "object", + "insertText": "never", "insertTextFormat": "Snippet" }, { - "label": "stream", - "kind": "Unit", - "detail": "type", + "label": "json", + "kind": "TypeParameter", + "detail": "Json", "sortText": "R", - "insertText": "stream", + "insertText": "json", "insertTextFormat": "Snippet" }, { - "label": "string", - "kind": "Unit", - "detail": "type", + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", "sortText": "R", - "insertText": "string", + "insertText": "anydata", "insertTextFormat": "Snippet" }, { - "label": "table", - "kind": "Unit", - "detail": "type", + "label": "any", + "kind": "TypeParameter", + "detail": "Any", "sortText": "R", - "insertText": "table", + "insertText": "any", "insertTextFormat": "Snippet" }, { - "label": "transaction", - "kind": "Unit", - "detail": "type", + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", "sortText": "R", - "insertText": "transaction", + "insertText": "byte", "insertTextFormat": "Snippet" }, { - "label": "typedesc", - "kind": "Unit", - "detail": "type", + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", "sortText": "R", - "insertText": "typedesc", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", "insertTextFormat": "Snippet" }, { "label": "xml", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Xml", "sortText": "R", "insertText": "xml", "insertTextFormat": "Snippet" }, { - "label": "var", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "U", - "filterText": "var", - "insertText": "var ", + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", "insertTextFormat": "Snippet" }, { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", + "label": "future", + "kind": "TypeParameter", + "detail": "Future", "sortText": "R", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config2.json index ce01ce6b2611..4243e099ce3a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config2.json @@ -24,70 +24,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -410,157 +346,222 @@ ] }, { - "label": "boolean", + "label": "map", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "boolean", + "insertText": "map", "insertTextFormat": "Snippet" }, { - "label": "decimal", + "label": "object", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "decimal", + "insertText": "object", "insertTextFormat": "Snippet" }, { - "label": "error", + "label": "stream", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "error", + "insertText": "stream", "insertTextFormat": "Snippet" }, { - "label": "float", + "label": "table", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "float", + "insertText": "table", "insertTextFormat": "Snippet" }, { - "label": "function", + "label": "transaction", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "function", + "insertText": "transaction", "insertTextFormat": "Snippet" }, { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", + "label": "var", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "var", + "insertText": "var ", "insertTextFormat": "Snippet" }, { - "label": "int", - "kind": "Unit", - "detail": "type", + "label": "ballerina/lang.regexp", + "kind": "Module", + "detail": "Module", "sortText": "R", - "insertText": "int", + "filterText": "regexp", + "insertText": "regexp", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.regexp;\n" + } + ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", "insertTextFormat": "Snippet" }, { - "label": "map", - "kind": "Unit", - "detail": "type", + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", "sortText": "R", - "insertText": "map", + "insertText": "handle", "insertTextFormat": "Snippet" }, { - "label": "object", - "kind": "Unit", - "detail": "type", + "label": "never", + "kind": "TypeParameter", + "detail": "Never", "sortText": "R", - "insertText": "object", + "insertText": "never", "insertTextFormat": "Snippet" }, { - "label": "stream", - "kind": "Unit", - "detail": "type", + "label": "json", + "kind": "TypeParameter", + "detail": "Json", "sortText": "R", - "insertText": "stream", + "insertText": "json", "insertTextFormat": "Snippet" }, { - "label": "string", - "kind": "Unit", - "detail": "type", + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", "sortText": "R", - "insertText": "string", + "insertText": "anydata", "insertTextFormat": "Snippet" }, { - "label": "table", - "kind": "Unit", - "detail": "type", + "label": "any", + "kind": "TypeParameter", + "detail": "Any", "sortText": "R", - "insertText": "table", + "insertText": "any", "insertTextFormat": "Snippet" }, { - "label": "transaction", - "kind": "Unit", - "detail": "type", + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", "sortText": "R", - "insertText": "transaction", + "insertText": "byte", "insertTextFormat": "Snippet" }, { - "label": "typedesc", - "kind": "Unit", - "detail": "type", + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", "sortText": "R", - "insertText": "typedesc", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", "insertTextFormat": "Snippet" }, { "label": "xml", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Xml", "sortText": "R", "insertText": "xml", "insertTextFormat": "Snippet" }, { - "label": "var", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "U", - "filterText": "var", - "insertText": "var ", + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", "insertTextFormat": "Snippet" }, { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", + "label": "future", + "kind": "TypeParameter", + "detail": "Future", "sortText": "R", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config3.json index b8f872c41364..60fda4ef9244 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config3.json @@ -24,70 +24,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -410,157 +346,222 @@ ] }, { - "label": "boolean", + "label": "map", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "boolean", + "insertText": "map", "insertTextFormat": "Snippet" }, { - "label": "decimal", + "label": "object", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "decimal", + "insertText": "object", "insertTextFormat": "Snippet" }, { - "label": "error", + "label": "stream", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "error", + "insertText": "stream", "insertTextFormat": "Snippet" }, { - "label": "float", + "label": "table", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "float", + "insertText": "table", "insertTextFormat": "Snippet" }, { - "label": "function", + "label": "transaction", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "function", + "insertText": "transaction", "insertTextFormat": "Snippet" }, { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", + "label": "var", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "var", + "insertText": "var ", "insertTextFormat": "Snippet" }, { - "label": "int", - "kind": "Unit", - "detail": "type", + "label": "ballerina/lang.regexp", + "kind": "Module", + "detail": "Module", "sortText": "R", - "insertText": "int", + "filterText": "regexp", + "insertText": "regexp", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.regexp;\n" + } + ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", "insertTextFormat": "Snippet" }, { - "label": "map", - "kind": "Unit", - "detail": "type", + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", "sortText": "R", - "insertText": "map", + "insertText": "handle", "insertTextFormat": "Snippet" }, { - "label": "object", - "kind": "Unit", - "detail": "type", + "label": "never", + "kind": "TypeParameter", + "detail": "Never", "sortText": "R", - "insertText": "object", + "insertText": "never", "insertTextFormat": "Snippet" }, { - "label": "stream", - "kind": "Unit", - "detail": "type", + "label": "json", + "kind": "TypeParameter", + "detail": "Json", "sortText": "R", - "insertText": "stream", + "insertText": "json", "insertTextFormat": "Snippet" }, { - "label": "string", - "kind": "Unit", - "detail": "type", + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", "sortText": "R", - "insertText": "string", + "insertText": "anydata", "insertTextFormat": "Snippet" }, { - "label": "table", - "kind": "Unit", - "detail": "type", + "label": "any", + "kind": "TypeParameter", + "detail": "Any", "sortText": "R", - "insertText": "table", + "insertText": "any", "insertTextFormat": "Snippet" }, { - "label": "transaction", - "kind": "Unit", - "detail": "type", + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", "sortText": "R", - "insertText": "transaction", + "insertText": "byte", "insertTextFormat": "Snippet" }, { - "label": "typedesc", - "kind": "Unit", - "detail": "type", + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", "sortText": "R", - "insertText": "typedesc", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", "insertTextFormat": "Snippet" }, { "label": "xml", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Xml", "sortText": "R", "insertText": "xml", "insertTextFormat": "Snippet" }, { - "label": "var", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "U", - "filterText": "var", - "insertText": "var ", + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", "insertTextFormat": "Snippet" }, { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", + "label": "future", + "kind": "TypeParameter", + "detail": "Future", "sortText": "R", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config4.json index 8537aba1e7f2..add1fd17b051 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config4.json @@ -32,70 +32,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -418,157 +354,222 @@ ] }, { - "label": "boolean", + "label": "map", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "boolean", + "insertText": "map", "insertTextFormat": "Snippet" }, { - "label": "decimal", + "label": "object", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "decimal", + "insertText": "object", "insertTextFormat": "Snippet" }, { - "label": "error", + "label": "stream", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "error", + "insertText": "stream", "insertTextFormat": "Snippet" }, { - "label": "float", + "label": "table", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "float", + "insertText": "table", "insertTextFormat": "Snippet" }, { - "label": "function", + "label": "transaction", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "function", + "insertText": "transaction", "insertTextFormat": "Snippet" }, { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", + "label": "var", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "var", + "insertText": "var ", "insertTextFormat": "Snippet" }, { - "label": "int", - "kind": "Unit", - "detail": "type", + "label": "ballerina/lang.regexp", + "kind": "Module", + "detail": "Module", "sortText": "R", - "insertText": "int", + "filterText": "regexp", + "insertText": "regexp", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.regexp;\n" + } + ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", "insertTextFormat": "Snippet" }, { - "label": "map", - "kind": "Unit", - "detail": "type", + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", "sortText": "R", - "insertText": "map", + "insertText": "handle", "insertTextFormat": "Snippet" }, { - "label": "object", - "kind": "Unit", - "detail": "type", + "label": "never", + "kind": "TypeParameter", + "detail": "Never", "sortText": "R", - "insertText": "object", + "insertText": "never", "insertTextFormat": "Snippet" }, { - "label": "stream", - "kind": "Unit", - "detail": "type", + "label": "json", + "kind": "TypeParameter", + "detail": "Json", "sortText": "R", - "insertText": "stream", + "insertText": "json", "insertTextFormat": "Snippet" }, { - "label": "string", - "kind": "Unit", - "detail": "type", + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", "sortText": "R", - "insertText": "string", + "insertText": "anydata", "insertTextFormat": "Snippet" }, { - "label": "table", - "kind": "Unit", - "detail": "type", + "label": "any", + "kind": "TypeParameter", + "detail": "Any", "sortText": "R", - "insertText": "table", + "insertText": "any", "insertTextFormat": "Snippet" }, { - "label": "transaction", - "kind": "Unit", - "detail": "type", + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", "sortText": "R", - "insertText": "transaction", + "insertText": "byte", "insertTextFormat": "Snippet" }, { - "label": "typedesc", - "kind": "Unit", - "detail": "type", + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", "sortText": "R", - "insertText": "typedesc", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", "insertTextFormat": "Snippet" }, { "label": "xml", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Xml", "sortText": "R", "insertText": "xml", "insertTextFormat": "Snippet" }, { - "label": "var", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "U", - "filterText": "var", - "insertText": "var ", + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", "insertTextFormat": "Snippet" }, { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", + "label": "future", + "kind": "TypeParameter", + "detail": "Future", "sortText": "R", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config5.json index 1b906630f911..cd622375a680 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config5.json @@ -32,70 +32,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -418,157 +354,222 @@ ] }, { - "label": "boolean", + "label": "map", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "boolean", + "insertText": "map", "insertTextFormat": "Snippet" }, { - "label": "decimal", + "label": "object", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "decimal", + "insertText": "object", "insertTextFormat": "Snippet" }, { - "label": "error", + "label": "stream", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "error", + "insertText": "stream", "insertTextFormat": "Snippet" }, { - "label": "float", + "label": "table", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "float", + "insertText": "table", "insertTextFormat": "Snippet" }, { - "label": "function", + "label": "transaction", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "function", + "insertText": "transaction", "insertTextFormat": "Snippet" }, { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", + "label": "var", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "var", + "insertText": "var ", "insertTextFormat": "Snippet" }, { - "label": "int", - "kind": "Unit", - "detail": "type", + "label": "ballerina/lang.regexp", + "kind": "Module", + "detail": "Module", "sortText": "R", - "insertText": "int", + "filterText": "regexp", + "insertText": "regexp", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.regexp;\n" + } + ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", "insertTextFormat": "Snippet" }, { - "label": "map", - "kind": "Unit", - "detail": "type", + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", "sortText": "R", - "insertText": "map", + "insertText": "handle", "insertTextFormat": "Snippet" }, { - "label": "object", - "kind": "Unit", - "detail": "type", + "label": "never", + "kind": "TypeParameter", + "detail": "Never", "sortText": "R", - "insertText": "object", + "insertText": "never", "insertTextFormat": "Snippet" }, { - "label": "stream", - "kind": "Unit", - "detail": "type", + "label": "json", + "kind": "TypeParameter", + "detail": "Json", "sortText": "R", - "insertText": "stream", + "insertText": "json", "insertTextFormat": "Snippet" }, { - "label": "string", - "kind": "Unit", - "detail": "type", + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", "sortText": "R", - "insertText": "string", + "insertText": "anydata", "insertTextFormat": "Snippet" }, { - "label": "table", - "kind": "Unit", - "detail": "type", + "label": "any", + "kind": "TypeParameter", + "detail": "Any", "sortText": "R", - "insertText": "table", + "insertText": "any", "insertTextFormat": "Snippet" }, { - "label": "transaction", - "kind": "Unit", - "detail": "type", + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", "sortText": "R", - "insertText": "transaction", + "insertText": "byte", "insertTextFormat": "Snippet" }, { - "label": "typedesc", - "kind": "Unit", - "detail": "type", + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", "sortText": "R", - "insertText": "typedesc", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", "insertTextFormat": "Snippet" }, { "label": "xml", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Xml", "sortText": "R", "insertText": "xml", "insertTextFormat": "Snippet" }, { - "label": "var", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "U", - "filterText": "var", - "insertText": "var ", + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", "insertTextFormat": "Snippet" }, { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", + "label": "future", + "kind": "TypeParameter", + "detail": "Future", "sortText": "R", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config6.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config6.json index 12cb86b33d8d..00089d66016e 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config6.json @@ -32,70 +32,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -418,157 +354,222 @@ ] }, { - "label": "boolean", + "label": "map", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "boolean", + "insertText": "map", "insertTextFormat": "Snippet" }, { - "label": "decimal", + "label": "object", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "decimal", + "insertText": "object", "insertTextFormat": "Snippet" }, { - "label": "error", + "label": "stream", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "error", + "insertText": "stream", "insertTextFormat": "Snippet" }, { - "label": "float", + "label": "table", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "float", + "insertText": "table", "insertTextFormat": "Snippet" }, { - "label": "function", + "label": "transaction", "kind": "Unit", "detail": "type", "sortText": "R", - "insertText": "function", + "insertText": "transaction", "insertTextFormat": "Snippet" }, { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", + "label": "var", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "var", + "insertText": "var ", "insertTextFormat": "Snippet" }, { - "label": "int", - "kind": "Unit", - "detail": "type", + "label": "ballerina/lang.regexp", + "kind": "Module", + "detail": "Module", "sortText": "R", - "insertText": "int", + "filterText": "regexp", + "insertText": "regexp", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.regexp;\n" + } + ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", "insertTextFormat": "Snippet" }, { - "label": "map", - "kind": "Unit", - "detail": "type", + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", "sortText": "R", - "insertText": "map", + "insertText": "handle", "insertTextFormat": "Snippet" }, { - "label": "object", - "kind": "Unit", - "detail": "type", + "label": "never", + "kind": "TypeParameter", + "detail": "Never", "sortText": "R", - "insertText": "object", + "insertText": "never", "insertTextFormat": "Snippet" }, { - "label": "stream", - "kind": "Unit", - "detail": "type", + "label": "json", + "kind": "TypeParameter", + "detail": "Json", "sortText": "R", - "insertText": "stream", + "insertText": "json", "insertTextFormat": "Snippet" }, { - "label": "string", - "kind": "Unit", - "detail": "type", + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", "sortText": "R", - "insertText": "string", + "insertText": "anydata", "insertTextFormat": "Snippet" }, { - "label": "table", - "kind": "Unit", - "detail": "type", + "label": "any", + "kind": "TypeParameter", + "detail": "Any", "sortText": "R", - "insertText": "table", + "insertText": "any", "insertTextFormat": "Snippet" }, { - "label": "transaction", - "kind": "Unit", - "detail": "type", + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", "sortText": "R", - "insertText": "transaction", + "insertText": "byte", "insertTextFormat": "Snippet" }, { - "label": "typedesc", - "kind": "Unit", - "detail": "type", + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", "sortText": "R", - "insertText": "typedesc", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", "insertTextFormat": "Snippet" }, { "label": "xml", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Xml", "sortText": "R", "insertText": "xml", "insertTextFormat": "Snippet" }, { - "label": "var", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "U", - "filterText": "var", - "insertText": "var ", + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", "insertTextFormat": "Snippet" }, { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", + "label": "future", + "kind": "TypeParameter", + "detail": "Future", "sortText": "R", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_join_clause_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_join_clause_config1.json index a8db396446f5..01756505034d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_join_clause_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_join_clause_config1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "function", "kind": "Keyword", @@ -317,70 +245,6 @@ "insertText": "Person", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -531,14 +395,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -562,6 +418,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_join_clause_config17.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_join_clause_config17.json index 2c41c8157e3d..e614b3278e2f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_join_clause_config17.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_join_clause_config17.json @@ -32,70 +32,6 @@ "insertText": "MedalStats", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -312,54 +248,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -384,14 +272,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -408,22 +288,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "var", "kind": "Keyword", @@ -538,14 +402,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -569,6 +425,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_join_clause_config18.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_join_clause_config18.json index 8f1e8bc61a0b..fb4f6eafc52c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_join_clause_config18.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_join_clause_config18.json @@ -32,70 +32,6 @@ "insertText": "MedalStats", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -312,54 +248,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -384,14 +272,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -408,22 +288,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "var", "kind": "Keyword", @@ -538,14 +402,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -569,6 +425,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_join_clause_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_join_clause_config2.json index 4f035b3172a0..15b85174c89e 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_join_clause_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_join_clause_config2.json @@ -40,70 +40,6 @@ "insertText": "Customer", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -305,54 +241,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -377,14 +265,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -401,22 +281,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "var", "kind": "Keyword", @@ -531,14 +395,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -562,6 +418,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config1.json index 1c5bbb934322..95dd548d6f0f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config1.json @@ -40,70 +40,6 @@ "insertText": "Customer", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -305,54 +241,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -377,14 +265,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -401,22 +281,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "var", "kind": "Keyword", @@ -531,14 +395,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -562,6 +418,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config10.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config10.json index b721833e00b1..78311c25be41 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config10.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config10.json @@ -40,70 +40,6 @@ "insertText": "Customer", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -305,54 +241,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -377,14 +265,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -401,22 +281,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "var", "kind": "Keyword", @@ -531,14 +395,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "module1:Client", "kind": "Interface", @@ -584,6 +440,151 @@ "sortText": "BL", "insertText": "module1:ClientError", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config2.json index 9ba8c55d72bb..e689367d18b3 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config2.json @@ -40,70 +40,6 @@ "insertText": "Customer", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -305,54 +241,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -377,14 +265,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -401,22 +281,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "var", "kind": "Keyword", @@ -531,14 +395,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -562,6 +418,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config3.json index 84e262cc4a9d..291c554e00df 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config3.json @@ -40,70 +40,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -305,54 +241,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -377,14 +265,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -401,22 +281,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "var", "kind": "Keyword", @@ -531,14 +395,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -562,6 +418,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config9.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config9.json index 8536823cb1b5..02ccefc6dad4 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config9.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config9.json @@ -40,70 +40,6 @@ "insertText": "Customer", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -305,54 +241,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -377,14 +265,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -401,22 +281,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "var", "kind": "Keyword", @@ -531,14 +395,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -562,6 +418,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config1.json b/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config1.json index 84a1daedceb1..be58feffc8c2 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config1.json @@ -56,70 +56,6 @@ "insertText": "STRING_VAL", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -321,54 +257,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -393,14 +281,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -417,22 +297,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -538,14 +402,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -569,6 +425,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config10.json b/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config10.json index 37bdb1651459..d6c70cc789b7 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config10.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config10.json @@ -169,54 +169,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -241,14 +193,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -265,22 +209,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -377,14 +305,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -408,6 +328,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config2.json b/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config2.json index d27554a79ded..0dc54c5f5d2b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config2.json @@ -56,70 +56,6 @@ "insertText": "STRING_VAL", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -321,54 +257,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -393,14 +281,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -417,22 +297,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -538,14 +402,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "module1:TEST_STRING_CONST1", "kind": "Variable", @@ -683,6 +539,151 @@ "sortText": "BN", "insertText": "module1:TargetType", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config9.json b/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config9.json index 890b4a0271d1..b140adbbf9eb 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config9.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config9.json @@ -169,54 +169,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -241,14 +193,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -265,22 +209,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -377,14 +305,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -408,6 +328,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_body/config/config4.json b/language-server/modules/langserver-core/src/test/resources/completion/service_body/config/config4.json index 4e6cfa16a3b7..80d818d7751c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_body/config/config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_body/config/config4.json @@ -258,70 +258,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -523,54 +459,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -595,14 +483,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -619,22 +499,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "s", "kind": "Variable", @@ -869,14 +733,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -909,6 +765,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_body/config/config5.json b/language-server/modules/langserver-core/src/test/resources/completion/service_body/config/config5.json index 3ac6a671428f..f43f6440cdc5 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_body/config/config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_body/config/config5.json @@ -51,70 +51,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -316,54 +252,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -388,14 +276,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -412,22 +292,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "private", "kind": "Keyword", @@ -605,14 +469,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -636,6 +492,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "B", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "B", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "B", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "B", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "B", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "B", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "B", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "D", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "B", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "B", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "B", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "B", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "B", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "B", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "B", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "B", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "B", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "B", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config1.json b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config1.json index 636d686f0172..356cfa6a4bfc 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config1.json @@ -142,54 +142,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -214,14 +166,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -238,22 +182,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "on", "kind": "Keyword", @@ -404,14 +332,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -435,6 +355,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "A", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "A", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "A", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "A", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "A", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "A", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "A", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "A", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "A", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "A", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config10.json b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config10.json index 385d1f136a4c..1960ddfdb498 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config10.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config10.json @@ -32,70 +32,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -297,54 +233,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -369,14 +257,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -393,22 +273,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "private", "kind": "Keyword", @@ -613,14 +477,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -644,6 +500,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "B", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "B", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "B", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "B", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "B", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "B", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "B", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "D", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "B", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "B", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "B", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "B", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "B", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "B", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "B", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "B", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "B", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "B", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config11.json b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config11.json index 459e339e27c2..8d2687b3842b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config11.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config11.json @@ -32,70 +32,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -297,54 +233,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -369,14 +257,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -393,22 +273,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "private", "kind": "Keyword", @@ -613,14 +477,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -644,6 +500,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "B", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "B", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "B", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "B", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "B", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "B", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "B", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "D", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "B", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "B", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "B", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "B", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "B", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "B", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "B", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "B", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "B", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "B", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config14.json b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config14.json index 6279fb880cb7..56268c76f030 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config14.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config14.json @@ -32,70 +32,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -297,54 +233,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -369,14 +257,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -393,22 +273,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "private", "kind": "Keyword", @@ -681,14 +545,6 @@ "insertText": "module1:function1()", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -712,6 +568,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "B", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "B", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "B", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "B", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "B", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "B", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "B", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "D", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "B", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "B", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "B", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "B", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "B", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "B", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "B", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "B", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "B", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "B", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config15.json b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config15.json index 340e3a833bad..f3d88e4102fb 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config15.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config15.json @@ -32,70 +32,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -297,54 +233,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -369,14 +257,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -393,22 +273,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "private", "kind": "Keyword", @@ -646,14 +510,6 @@ "insertText": "module1:Response", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -677,6 +533,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "B", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "B", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "B", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "B", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "B", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "B", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "B", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "D", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "B", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "B", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "B", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "B", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "B", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "B", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "B", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "B", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "B", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "B", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config16.json b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config16.json index c889d5fd0e87..f00eaadbbed1 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config16.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config16.json @@ -266,70 +266,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -531,54 +467,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -603,14 +491,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -627,22 +507,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "lst", "kind": "Variable", @@ -869,14 +733,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -909,6 +765,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config2.json b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config2.json index 880cbefe96bf..833797ce01fc 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config2.json @@ -142,54 +142,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -214,14 +166,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -238,22 +182,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "on", "kind": "Keyword", @@ -404,14 +332,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -435,6 +355,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "A", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "A", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "A", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "A", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "A", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "A", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "A", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "A", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "A", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "A", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config3.json b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config3.json index f38884c77d9c..c17c4a7e6696 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config3.json @@ -9,7 +9,7 @@ "label": "TestObject", "kind": "Interface", "detail": "Object", - "sortText": "D", + "sortText": "CA", "insertText": "TestObject", "insertTextFormat": "Snippet" }, @@ -17,7 +17,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -26,7 +26,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -50,7 +50,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -74,7 +74,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -98,7 +98,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -122,7 +122,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -142,54 +142,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -214,14 +166,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -238,27 +182,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "on", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "on", "insertText": "on ", "insertTextFormat": "Snippet" @@ -267,7 +195,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -276,7 +204,7 @@ "label": "object", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "object", "insertText": "object ", "insertTextFormat": "Snippet" @@ -285,7 +213,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -294,7 +222,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -303,7 +231,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -312,7 +240,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -336,7 +264,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -360,7 +288,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -384,7 +312,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -404,19 +332,11 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -435,6 +355,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config4.json b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config4.json index 02b317b848bd..0c4a6ac45d1d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config4.json @@ -151,54 +151,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -223,14 +175,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -247,22 +191,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "on", "kind": "Keyword", @@ -368,14 +296,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "D", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -399,6 +319,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "B", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "B", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "B", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "B", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "B", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "B", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "B", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "B", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "B", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "B", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config6c.json b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config6c.json index eaa70be4667d..2878285984c6 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config6c.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config6c.json @@ -142,54 +142,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -214,14 +166,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -238,22 +182,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "new", "kind": "Keyword", @@ -359,14 +287,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -390,6 +310,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "A", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "A", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "A", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "A", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "A", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "A", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "A", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "A", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "A", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "A", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config6d.json b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config6d.json index a965a1c28f37..9f38ff75b791 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config6d.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config6d.json @@ -142,54 +142,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -214,14 +166,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -238,22 +182,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "new", "kind": "Keyword", @@ -359,14 +287,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "A", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -390,6 +310,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "A", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "A", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "A", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "A", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "A", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "A", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "A", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "A", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "A", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "A", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config6g.json b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config6g.json index ecb414f0bdfc..373866bfe905 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config6g.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config6g.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project1", "kind": "Module", @@ -342,14 +270,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -373,6 +293,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/continue_break_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/continue_break_stmt_ctx_config1.json index e496929cae9b..9e097f97c5d8 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/continue_break_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/continue_break_stmt_ctx_config1.json @@ -285,70 +285,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -565,54 +501,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -637,14 +525,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -661,22 +541,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "numberList", "kind": "Variable", @@ -902,14 +766,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -942,6 +798,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/continue_break_stmt_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/continue_break_stmt_ctx_config2.json index 556b0895eade..70932ad4ecbf 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/continue_break_stmt_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/continue_break_stmt_ctx_config2.json @@ -285,70 +285,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -565,54 +501,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -637,14 +525,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -661,22 +541,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "numberList", "kind": "Variable", @@ -910,14 +774,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -950,6 +806,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/do_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/do_stmt_ctx_config1.json index ff1aa3aded07..6cc3f95816c0 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/do_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/do_stmt_ctx_config1.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -508,54 +444,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -580,14 +468,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -604,22 +484,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "value1", "kind": "Variable", @@ -876,14 +740,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -916,6 +772,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/else_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/else_stmt_ctx_config1.json index 2bdd0f149262..3ee1629f5523 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/else_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/else_stmt_ctx_config1.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "doSomeTask()", "kind": "Function", @@ -883,14 +747,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -923,6 +779,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/else_stmt_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/else_stmt_ctx_config2.json index a99ba16dad31..f6af0addb8ae 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/else_stmt_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/else_stmt_ctx_config2.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "doSomeTask()", "kind": "Function", @@ -883,14 +747,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -923,6 +779,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config1.json index 5ee9c0002c26..3dc90aad46bd 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config1.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "doSomeTask()", "kind": "Function", @@ -883,14 +747,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -923,6 +779,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config2.json index 4e93feab02c3..4956425d5048 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config2.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "doSomeTask()", "kind": "Function", @@ -883,14 +747,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -923,6 +779,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/function_call_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/function_call_stmt_ctx_config1.json index 62bc953cbdd2..de9a8aa1c327 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/function_call_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/function_call_stmt_ctx_config1.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "doSomeTask()", "kind": "Function", @@ -884,14 +748,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -924,6 +780,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/function_call_stmt_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/function_call_stmt_ctx_config2.json index 0c9d1deed2ea..8b78bf9f21c0 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/function_call_stmt_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/function_call_stmt_ctx_config2.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "doSomeTask()", "kind": "Function", @@ -884,14 +748,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -924,6 +780,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config1.json index 2c2d832185c6..28a507dae05d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config1.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "doSomeTask()", "kind": "Function", @@ -875,14 +739,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -915,6 +771,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config2.json index 365f41ca73aa..918d080d8bc7 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config2.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "doSomeTask()", "kind": "Function", @@ -875,14 +739,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -915,6 +771,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config7.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config7.json index 0c5d3b93782e..ae0fcba11eef 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config7.json @@ -285,70 +285,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -565,54 +501,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -637,14 +525,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -661,22 +541,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "doSomeTask()", "kind": "Function", @@ -910,14 +774,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -950,6 +806,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config8.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config8.json index ac14d45b53c6..43066823a54e 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config8.json @@ -285,70 +285,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -565,54 +501,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -637,14 +525,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -661,22 +541,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "doSomeTask()", "kind": "Function", @@ -910,14 +774,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -950,6 +806,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/local_var_decl_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/local_var_decl_stmt_ctx_config1.json index e0c41400ef48..b47a77499555 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/local_var_decl_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/local_var_decl_stmt_ctx_config1.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "sendMail()", "kind": "Function", @@ -869,14 +733,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -909,6 +765,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/lock_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/lock_stmt_ctx_config1.json index 182d8492f217..9efd15972f7a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/lock_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/lock_stmt_ctx_config1.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "numberList", "kind": "Variable", @@ -884,14 +748,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -924,6 +780,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/lock_stmt_ctx_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/lock_stmt_ctx_config3.json index 4b00578eb24b..69618e140307 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/lock_stmt_ctx_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/lock_stmt_ctx_config3.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "myInt", "kind": "Variable", @@ -868,14 +732,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -908,6 +764,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config14.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config14.json index 64d57dc2a0cf..9dc8d5edec44 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config14.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config14.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "true", "kind": "Keyword", @@ -397,14 +325,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -428,6 +348,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config15.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config15.json index fd0c2a5c0b8a..634d42a79aa9 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config15.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config15.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "true", "kind": "Keyword", @@ -397,14 +325,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -428,6 +348,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config16.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config16.json index 6b014f30b00a..afb7b7501e4b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config16.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config16.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "true", "kind": "Keyword", @@ -397,14 +325,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -428,6 +348,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config4.json index e197c5cd55d4..133d454427f8 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config4.json @@ -217,54 +217,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -289,14 +241,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -313,22 +257,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -425,14 +353,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -456,6 +376,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config5.json index 03cef9f970cf..4b25f517eae7 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config5.json @@ -217,54 +217,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -289,14 +241,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -313,22 +257,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -425,14 +353,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -456,6 +376,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config1.json index 7a791f6401b6..93d36f5315d8 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config1.json @@ -276,70 +276,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -541,54 +477,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +501,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,22 +517,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -871,14 +735,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -911,6 +767,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config1a.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config1a.json index a55c57ba9ab0..28c8ef48ab1c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config1a.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config1a.json @@ -276,70 +276,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -541,54 +477,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +501,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,22 +517,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -871,14 +735,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -911,6 +767,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config2.json index 111d5d77f148..5b3df3191838 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config2.json @@ -276,70 +276,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -541,54 +477,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +501,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,22 +517,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -871,14 +735,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -911,6 +767,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config2a.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config2a.json index e5fdf1e6744e..a0593c4b5d20 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config2a.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config2a.json @@ -276,70 +276,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -541,54 +477,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +501,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,22 +517,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -871,14 +735,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -911,6 +767,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config2c.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config2c.json index 849facf6da8b..ab164a23b3a9 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config2c.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config2c.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "var", "kind": "Keyword", @@ -351,14 +279,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -382,6 +302,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config3.json index 5058777969b1..b742a41e564a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config3.json @@ -294,70 +294,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -559,54 +495,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -631,14 +519,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -655,22 +535,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "animals", "kind": "Variable", @@ -888,14 +752,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -928,6 +784,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config4.json index 4e2751907182..7559ab687822 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config4.json @@ -276,70 +276,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -541,54 +477,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +501,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,22 +517,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "animals", "kind": "Variable", @@ -871,14 +735,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -911,6 +767,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config5.json index 86c53a4079ac..e8bcc7f0bd29 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config5.json @@ -276,70 +276,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -541,54 +477,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +501,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,22 +517,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "animals", "kind": "Variable", @@ -871,14 +735,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -911,6 +767,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config5a.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config5a.json index bcf71316e56e..c95d0ab4594a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config5a.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config5a.json @@ -276,70 +276,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -541,54 +477,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +501,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,22 +517,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "animals", "kind": "Variable", @@ -871,14 +735,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -911,6 +767,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config6.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config6.json index 96015720253e..5f2e8a01064f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config6.json @@ -276,70 +276,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -541,54 +477,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +501,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,22 +517,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "animals", "kind": "Variable", @@ -875,14 +739,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -915,6 +771,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config6a.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config6a.json index 206a0d77cf87..938822539d9a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config6a.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config6a.json @@ -276,70 +276,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -541,54 +477,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +501,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,22 +517,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "animals", "kind": "Variable", @@ -875,14 +739,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -915,6 +771,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/panic_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/panic_stmt_ctx_config1.json index 87bf77629e38..2c35a83a8f03 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/panic_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/panic_stmt_ctx_config1.json @@ -4,7 +4,6 @@ "character": 9 }, "source": "statement_context/source/panic_stmt_ctx_source1.bal", - "description": "Checks for statement block completions (specifically the panic keyword snippet for panic statement)", "items": [ { "label": "start", @@ -177,54 +176,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -249,14 +200,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -273,22 +216,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "new", "kind": "Keyword", @@ -461,62 +388,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -622,14 +493,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "xmlns", "kind": "Snippet", @@ -801,14 +664,6 @@ "insertText": "return ", "insertTextFormat": "Snippet" }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -921,6 +776,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "O", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "O", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "O", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "O", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "O", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "O", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "O", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "R", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "O", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "M", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "O", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "O", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "O", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "O", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "O", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "O", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "O", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "O", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config1.json index 546675400b16..8a26b89522f5 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config1.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -532,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -604,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -628,22 +508,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -854,14 +718,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -894,6 +750,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "O", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "O", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "O", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "O", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "O", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "O", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "O", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "R", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "O", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "M", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "O", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "O", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "O", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "O", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "O", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "O", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "O", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "O", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config10.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config10.json index ac38832968f6..171f2b92656d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config10.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config10.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -523,54 +459,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -595,14 +483,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -619,22 +499,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.test", "kind": "Module", @@ -869,14 +733,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -909,6 +765,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config11.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config11.json index e6f30bba27b8..d9f5d965486e 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config11.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config11.json @@ -266,70 +266,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -546,54 +482,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -618,14 +506,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -642,22 +522,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "self", "kind": "Variable", @@ -876,14 +740,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -916,6 +772,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config12.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config12.json index dc7024a58528..bcf88d9f00b0 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config12.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config12.json @@ -258,70 +258,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -523,54 +459,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -595,14 +483,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -619,22 +499,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "l1", "kind": "Variable", @@ -879,14 +743,6 @@ "insertText": "module1:Response", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -919,6 +775,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config13.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config13.json index a058765fb4ee..10fedfe08487 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config13.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config13.json @@ -258,70 +258,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -523,54 +459,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -595,14 +483,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -619,22 +499,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "l1", "kind": "Variable", @@ -879,14 +743,6 @@ "insertText": "module1:Response", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -919,6 +775,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config14.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config14.json index be5deb5aede7..0f76a31fb029 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config14.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config14.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -860,14 +724,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -900,6 +756,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config15.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config15.json index 351fe6b1bc46..7e965e1a7431 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config15.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config15.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -523,54 +459,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -595,14 +483,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -619,22 +499,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.test", "kind": "Module", @@ -869,14 +733,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -909,6 +765,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config2.json index 4a38f1374a1b..c51f1a6fecbc 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config2.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -532,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -604,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -628,22 +508,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -887,14 +751,6 @@ "insertText": "module1:Response", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -927,6 +783,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "O", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "O", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "O", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "O", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "O", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "O", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "O", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "R", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "O", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "M", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "O", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "O", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "O", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "O", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "O", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "O", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "O", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "O", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config3.json index 3a6c49ea1074..2286ceb142f6 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config3.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -532,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -604,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -628,22 +508,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -853,14 +717,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -893,6 +749,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "O", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "O", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "O", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "O", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "O", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "O", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "O", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "R", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "O", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "M", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "O", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "O", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "O", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "O", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "O", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "O", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "O", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "O", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config4.json index 4d089575c053..d6145ac063d4 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config4.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -532,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -604,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -628,22 +508,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -845,14 +709,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -885,6 +741,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "O", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "O", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "O", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "O", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "O", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "O", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "O", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "R", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "O", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "M", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "O", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "O", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "O", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "O", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "O", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "O", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "O", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "O", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config5.json index 5399471371ac..17a2ec0cc6c1 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config5.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -532,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -604,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -628,22 +508,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -878,14 +742,6 @@ "insertText": "module1:Response", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -918,6 +774,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "O", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "O", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "O", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "O", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "O", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "O", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "O", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "R", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "O", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "M", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "O", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "O", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "O", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "O", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "O", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "O", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "O", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "O", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config6.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config6.json index ac2c40d347f0..26eaedf0b931 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config6.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -860,14 +724,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -900,6 +756,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config7.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config7.json index 2e419c23f88a..2bf95caafb79 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config7.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -869,14 +733,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -909,6 +765,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "O", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "O", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "O", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "O", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "O", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "O", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "O", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "R", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "O", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "M", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "O", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "O", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "O", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "O", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "O", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "O", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "O", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "O", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config8.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config8.json index fd2513f3abc2..0a0afbf85489 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config8.json @@ -258,70 +258,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -538,54 +474,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -610,14 +498,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -634,22 +514,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "worker", "kind": "Snippet", @@ -853,14 +717,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -893,6 +749,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config9.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config9.json index 810eb005fd72..c1bf8b20f4d4 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config9.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config9.json @@ -258,70 +258,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -538,54 +474,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -610,14 +498,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -634,22 +514,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test", "kind": "Variable", @@ -853,14 +717,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -893,6 +749,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/start_action_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/start_action_ctx_config1.json index 68d5194a2e0d..327b34d160ee 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/start_action_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/start_action_ctx_config1.json @@ -24,70 +24,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -304,54 +240,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -376,14 +264,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -400,22 +280,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -559,14 +423,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -590,6 +446,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "BQ", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/start_action_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/start_action_ctx_config2.json index 57702821706b..5f5f4693c0b8 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/start_action_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/start_action_ctx_config2.json @@ -24,70 +24,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -304,54 +240,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -376,14 +264,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -400,22 +280,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -559,14 +423,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -590,6 +446,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "BQ", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/start_action_ctx_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/start_action_ctx_config3.json index 4da5fe7c6a77..92fee7f1a41a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/start_action_ctx_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/start_action_ctx_config3.json @@ -24,70 +24,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -304,54 +240,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -376,14 +264,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -400,22 +280,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "y", "kind": "Variable", @@ -552,14 +416,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -583,6 +439,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "BQ", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/start_action_ctx_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/start_action_ctx_config4.json index 54362b5ef781..7548a8595e30 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/start_action_ctx_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/start_action_ctx_config4.json @@ -24,70 +24,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -304,54 +240,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -376,14 +264,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -400,22 +280,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -559,14 +423,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -590,6 +446,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "BQ", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/transaction_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/transaction_config1.json index 2fd04f63778e..a8b6ab357887 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/transaction_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/transaction_config1.json @@ -285,70 +285,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -550,54 +486,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -622,14 +510,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -646,22 +526,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "res", "kind": "Variable", @@ -886,14 +750,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -926,6 +782,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config1.json index 9aff9560dd27..34d7167f05a7 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config1.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -542,14 +470,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -573,6 +493,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config11.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config11.json index 71d37942f933..f35a9e7eae02 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config11.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config11.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -573,14 +501,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -604,6 +524,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config12.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config12.json index fa1832e1f732..8dbd38b4d9cf 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config12.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config12.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -573,14 +501,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -604,6 +524,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config14.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config14.json index 93e67e31ba86..99b74673740c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config14.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config14.json @@ -189,54 +189,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -261,14 +213,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -285,22 +229,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -397,14 +325,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -428,6 +348,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "AL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config15.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config15.json index f905d4b1a83f..dde1834722b3 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config15.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config15.json @@ -189,54 +189,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -261,14 +213,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -285,22 +229,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -397,14 +325,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -428,6 +348,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "AL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config17.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config17.json index c8ac8bd03454..833129662967 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config17.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config17.json @@ -189,54 +189,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -261,14 +213,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -285,22 +229,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -397,14 +325,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -428,6 +348,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config18.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config18.json index c6b76118ca78..a6d49e2954bb 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config18.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config18.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -588,14 +516,6 @@ "insertText": "testFutureInt", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -619,6 +539,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config19.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config19.json index 36b1c6d630a5..e8fdb0c8cece 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config19.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config19.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -611,14 +539,6 @@ "insertText": "testFutureString", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -642,6 +562,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config2.json index 1b6e080edadf..a8e7035110b4 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config2.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -542,14 +470,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -573,6 +493,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config3.json index 8c4a2eb69515..5e60927eeeb3 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config3.json @@ -157,54 +157,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -229,14 +181,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -253,22 +197,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -365,14 +293,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -396,6 +316,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config4.json index f4ed9b2c5743..45f55e764208 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config4.json @@ -157,54 +157,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -229,14 +181,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -253,22 +197,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -365,14 +293,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -396,6 +316,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config5.json index 6574a996f5f3..2120db804aa4 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config5.json @@ -165,54 +165,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -237,14 +189,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -261,22 +205,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -373,14 +301,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -404,6 +324,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config6.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config6.json index 18b60f89bec2..8a8a1ba421d7 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config6.json @@ -165,54 +165,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -237,14 +189,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -261,22 +205,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -373,14 +301,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -404,6 +324,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config7.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config7.json index c7ed0e535530..3b2b16725412 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config7.json @@ -165,54 +165,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -237,14 +189,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -261,22 +205,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -373,14 +301,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -404,6 +324,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config8.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config8.json index 32fe42c440f2..96669f31f4ce 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config8.json @@ -165,54 +165,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -237,14 +189,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -261,22 +205,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -580,14 +508,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -611,6 +531,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config9.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config9.json index 76933119c809..6820d248704e 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config9.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/wait_action_ctx_config9.json @@ -165,54 +165,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -237,14 +189,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -261,22 +205,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -580,14 +508,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -611,6 +531,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config1.json index 861fdc212d9f..2bbc33522938 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config1.json @@ -285,70 +285,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -565,54 +501,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -637,14 +525,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -661,22 +541,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "doSomeTask()", "kind": "Function", @@ -893,14 +757,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -933,6 +789,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config2.json index 5ff50125b00b..e03959d072c7 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config2.json @@ -285,70 +285,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -565,54 +501,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -637,14 +525,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -661,22 +541,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "doSomeTask()", "kind": "Function", @@ -893,14 +757,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -933,6 +789,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/worker_declaration_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/worker_declaration_ctx_config1.json index 8ea0c6e4da3e..a3145b8613ad 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/worker_declaration_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/worker_declaration_ctx_config1.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "getMessage()", "kind": "Function", @@ -875,14 +739,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -915,6 +771,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/worker_declaration_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/worker_declaration_ctx_config2.json index df3428331e6c..8c903e6d5ff8 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/worker_declaration_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/worker_declaration_ctx_config2.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "getMessage()", "kind": "Function", @@ -875,14 +739,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", @@ -915,6 +771,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/worker_declaration_ctx_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/worker_declaration_ctx_config5.json index 3e419389f2b0..3aa74264e69d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/worker_declaration_ctx_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/worker_declaration_ctx_config5.json @@ -24,70 +24,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -304,54 +240,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -376,14 +264,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -400,22 +280,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "isolated", "kind": "Keyword", @@ -548,14 +412,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -579,6 +435,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/xmlns_ctx_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/xmlns_ctx_config3.json index c0028758c4f8..8383a8d0a702 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/xmlns_ctx_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/xmlns_ctx_config3.json @@ -148,54 +148,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -220,14 +172,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -244,22 +188,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -356,14 +284,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -387,6 +307,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/xmlns_ctx_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/xmlns_ctx_config4.json index a6e35572ac97..f2e94ed23594 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/xmlns_ctx_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/xmlns_ctx_config4.json @@ -148,54 +148,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -220,14 +172,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -244,22 +188,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -356,14 +284,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -387,6 +307,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/type_def/config/config1.json b/language-server/modules/langserver-core/src/test/resources/completion/type_def/config/config1.json index 20a9e0ca3e7c..ea19b5098299 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/type_def/config/config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/type_def/config/config1.json @@ -56,70 +56,6 @@ "insertText": "TEST_TYPE", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -321,54 +257,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -393,14 +281,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -417,22 +297,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "isolated", "kind": "Keyword", @@ -565,14 +429,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -596,6 +452,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/type_def/config/config2.json b/language-server/modules/langserver-core/src/test/resources/completion/type_def/config/config2.json index 280ea951364a..7d5ebf43a65f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/type_def/config/config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/type_def/config/config2.json @@ -48,70 +48,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -313,54 +249,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -385,14 +273,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -409,22 +289,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "isolated", "kind": "Keyword", @@ -590,14 +454,6 @@ "insertText": "module1:Response", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -621,6 +477,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/type_def/config/config7.json b/language-server/modules/langserver-core/src/test/resources/completion/type_def/config/config7.json index 683b516caf69..20bcea619d49 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/type_def/config/config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/type_def/config/config7.json @@ -32,70 +32,6 @@ "insertText": "Cloneable", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -312,54 +248,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -384,14 +272,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -408,22 +288,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project1", "kind": "Module", @@ -529,14 +393,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -560,6 +416,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/array_typedesc1.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/array_typedesc1.json index 62fe054dd4d3..7b5dbc91fb92 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/array_typedesc1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/array_typedesc1.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "TEST_CONST", "kind": "Variable", @@ -371,14 +299,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -402,6 +322,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/array_typedesc2.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/array_typedesc2.json index 326a2f2b97aa..130226e5575d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/array_typedesc2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/array_typedesc2.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "TEST_CONST", "kind": "Variable", @@ -371,14 +299,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -402,6 +322,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/array_typedesc5.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/array_typedesc5.json index 8be1a5efef70..fbf55f6baf48 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/array_typedesc5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/array_typedesc5.json @@ -283,70 +283,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -548,54 +484,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -620,14 +508,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -644,22 +524,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "main()", "kind": "Function", @@ -884,14 +748,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "module1:TestRecord1", "kind": "Struct", @@ -940,6 +796,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/distinct_typedesc1.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/distinct_typedesc1.json index b44ec7a5d7bd..38498ec68958 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/distinct_typedesc1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/distinct_typedesc1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "object {}", "kind": "Snippet", @@ -399,14 +327,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -430,6 +350,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/distinct_typedesc2.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/distinct_typedesc2.json index 8e550dca56a6..c6013febd0dd 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/distinct_typedesc2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/distinct_typedesc2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "object {}", "kind": "Snippet", @@ -399,14 +327,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -430,6 +350,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/error_typedesc1.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/error_typedesc1.json index 7ac40d41a805..238866c181a1 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/error_typedesc1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/error_typedesc1.json @@ -195,54 +195,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -267,14 +219,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -291,22 +235,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -403,14 +331,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -434,6 +354,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/error_typedesc2.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/error_typedesc2.json index 0f182a2e6606..777e34cb93b4 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/error_typedesc2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/error_typedesc2.json @@ -195,54 +195,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -267,14 +219,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -291,22 +235,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -403,14 +331,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -434,6 +354,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/error_typedesc5.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/error_typedesc5.json index 7db3d1025241..c4c8a83e0a5d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/error_typedesc5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/error_typedesc5.json @@ -195,54 +195,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -267,14 +219,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -291,22 +235,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -403,14 +331,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -434,6 +354,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc1.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc1.json index 70357685e450..91e346f45891 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc1.json @@ -72,70 +72,6 @@ "insertText": "TestMap1", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -337,54 +273,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -409,14 +297,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -433,22 +313,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -554,14 +418,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -585,6 +441,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc12.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc12.json index 6501e0edfa79..e28ba03075b4 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc12.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc12.json @@ -64,70 +64,6 @@ "insertText": "TestMap3", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -329,54 +265,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -401,14 +289,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -425,22 +305,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -546,14 +410,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -577,6 +433,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc15.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc15.json index 2376167d6a7a..5bd1b6b65b2c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc15.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc15.json @@ -64,70 +64,6 @@ "insertText": "TestMap3", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -329,54 +265,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -401,14 +289,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -425,22 +305,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "isolated", "kind": "Keyword", @@ -573,14 +437,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -604,6 +460,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc3.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc3.json index b66c45383a80..4c5056df5184 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc3.json @@ -64,70 +64,6 @@ "insertText": "TestMap1", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -329,54 +265,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -401,14 +289,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -425,22 +305,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -546,14 +410,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "FuncType1", "kind": "TypeParameter", @@ -585,6 +441,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc4.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc4.json index 9ac541471b3a..d59158d9a556 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc4.json @@ -64,70 +64,6 @@ "insertText": "TestMap1", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -329,54 +265,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -401,14 +289,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -425,22 +305,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -546,14 +410,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "FuncType1", "kind": "TypeParameter", @@ -585,6 +441,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc5.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc5.json index 59365b40ae1f..c77b706d89a3 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc5.json @@ -64,70 +64,6 @@ "insertText": "TestMap1", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -329,54 +265,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -401,14 +289,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -425,22 +305,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -546,14 +410,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "FuncType1", "kind": "TypeParameter", @@ -585,6 +441,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc8.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc8.json index d49fed7f6ebe..acc7389ac74f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc8.json @@ -64,70 +64,6 @@ "insertText": "TestMap1", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -329,54 +265,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -401,14 +289,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -425,22 +305,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "isolated", "kind": "Keyword", @@ -573,14 +437,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "FuncType1", "kind": "TypeParameter", @@ -612,6 +468,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc9.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc9.json index 8abc721bbe20..f9145e42b856 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc9.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc9.json @@ -64,70 +64,6 @@ "insertText": "TestMap1", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -329,54 +265,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -401,14 +289,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -425,22 +305,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "isolated", "kind": "Keyword", @@ -573,14 +437,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "FuncType1", "kind": "TypeParameter", @@ -612,6 +468,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/future_typedesc1.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/future_typedesc1.json index 4436d394cd17..299c9d5ca095 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/future_typedesc1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/future_typedesc1.json @@ -64,70 +64,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -329,54 +265,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -401,14 +289,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -425,22 +305,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -546,14 +410,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -577,6 +433,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/intersection_type_typedesc1.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/intersection_type_typedesc1.json index 9c929d84e90d..201538c2d18c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/intersection_type_typedesc1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/intersection_type_typedesc1.json @@ -64,70 +64,6 @@ "insertText": "TestMap1", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -329,54 +265,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -401,14 +289,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -425,22 +305,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -546,14 +410,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -577,6 +433,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/intersection_type_typedesc2.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/intersection_type_typedesc2.json index 3c28392061dd..3f18767913b4 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/intersection_type_typedesc2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/intersection_type_typedesc2.json @@ -64,70 +64,6 @@ "insertText": "TestMap1", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -329,54 +265,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -401,14 +289,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -425,22 +305,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -546,14 +410,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -577,6 +433,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/map_typedesc1.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/map_typedesc1.json index bf74ab8891da..a8d5faee3762 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/map_typedesc1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/map_typedesc1.json @@ -32,70 +32,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -297,54 +233,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -369,14 +257,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -393,22 +273,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -514,14 +378,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -545,6 +401,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/map_typedesc2.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/map_typedesc2.json index b5394538fbda..d9b50fc08d2e 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/map_typedesc2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/map_typedesc2.json @@ -32,70 +32,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -297,54 +233,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -369,14 +257,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -393,22 +273,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -514,14 +378,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -545,6 +401,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/object_typedesc11.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/object_typedesc11.json index d41d0a1d8c4b..18da1058c7a5 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/object_typedesc11.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/object_typedesc11.json @@ -32,70 +32,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -297,54 +233,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -369,14 +257,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -393,22 +273,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "isolated", "kind": "Keyword", @@ -541,14 +405,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -572,6 +428,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/object_typedesc3.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/object_typedesc3.json index 929b0006510e..bf5f1bde57af 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/object_typedesc3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/object_typedesc3.json @@ -86,70 +86,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -351,54 +287,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -423,14 +311,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -447,22 +327,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -568,14 +432,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -599,6 +455,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/object_typedesc4.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/object_typedesc4.json index 009a1c47cf99..a3dc911de26f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/object_typedesc4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/object_typedesc4.json @@ -86,70 +86,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -351,54 +287,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -423,14 +311,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -447,22 +327,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -568,14 +432,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -599,6 +455,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/object_typedesc5.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/object_typedesc5.json index a5ae3a855bf7..37f8007bc8bc 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/object_typedesc5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/object_typedesc5.json @@ -86,70 +86,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -351,54 +287,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -423,14 +311,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -447,22 +327,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -568,14 +432,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -599,6 +455,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/object_typedesc6.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/object_typedesc6.json index 35ae6286eace..9154d2614184 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/object_typedesc6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/object_typedesc6.json @@ -86,70 +86,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -351,54 +287,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -423,14 +311,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -447,22 +327,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -568,14 +432,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -599,6 +455,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/object_typedesc7.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/object_typedesc7.json index 8870f92a12a0..2041fea73e2c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/object_typedesc7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/object_typedesc7.json @@ -86,70 +86,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -351,54 +287,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -423,14 +311,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -447,22 +327,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -568,14 +432,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -599,6 +455,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/object_typedesc8.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/object_typedesc8.json index 51a4ced49b28..cbe848035d70 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/object_typedesc8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/object_typedesc8.json @@ -86,70 +86,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -351,54 +287,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -423,14 +311,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -447,22 +327,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -568,14 +432,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -599,6 +455,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/stream_typedesc1.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/stream_typedesc1.json index de01207d8534..303b085cbdf3 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/stream_typedesc1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/stream_typedesc1.json @@ -64,70 +64,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -329,54 +265,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -401,14 +289,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -425,22 +305,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -546,14 +410,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -577,6 +433,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/stream_typedesc4.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/stream_typedesc4.json index e8f943aec9c6..e460eeca1b1e 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/stream_typedesc4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/stream_typedesc4.json @@ -64,70 +64,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -329,54 +265,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -401,14 +289,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -425,22 +305,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -546,14 +410,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -577,6 +433,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/table_typedesc1.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/table_typedesc1.json index 15351d6ba30e..56ed8dfda7cf 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/table_typedesc1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/table_typedesc1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "StrandData", "kind": "Struct", @@ -380,14 +308,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -411,6 +331,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/table_typedesc10.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/table_typedesc10.json index 7d23e4622f86..0ed7c50aadf3 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/table_typedesc10.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/table_typedesc10.json @@ -88,70 +88,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -353,54 +289,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "AG", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -425,14 +313,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "AG", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -449,22 +329,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -570,14 +434,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -601,6 +457,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BBN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BBN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BBN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BBN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BBN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BBN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BBN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "BZ", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BBN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BBL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BBN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BBN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BBN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "ABN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BBN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BBN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "ABN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BBN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/table_typedesc11.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/table_typedesc11.json index decf8dfbdeb3..c1b13f18d810 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/table_typedesc11.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/table_typedesc11.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "Person", "kind": "TypeParameter", @@ -419,14 +347,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -450,6 +370,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/table_typedesc2.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/table_typedesc2.json index 54898c068c68..80be0fb65cdf 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/table_typedesc2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/table_typedesc2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "StrandData", "kind": "Struct", @@ -380,14 +308,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -411,6 +331,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/tuple_typedesc1.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/tuple_typedesc1.json index c53e883105f2..20055222dd48 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/tuple_typedesc1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/tuple_typedesc1.json @@ -32,70 +32,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -297,54 +233,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -369,14 +257,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -393,22 +273,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -514,14 +378,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -545,6 +401,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/tuple_typedesc2.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/tuple_typedesc2.json index c648312af39f..bd8a11defda8 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/tuple_typedesc2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/tuple_typedesc2.json @@ -32,70 +32,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -297,54 +233,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -369,14 +257,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -393,22 +273,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -514,14 +378,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -545,6 +401,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/tuple_typedesc5.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/tuple_typedesc5.json index 12c14fbf4f69..4c8f372b1e51 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/tuple_typedesc5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/tuple_typedesc5.json @@ -32,70 +32,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -297,54 +233,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -369,14 +257,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -393,22 +273,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -514,14 +378,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -545,6 +401,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/union_typedesc1.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/union_typedesc1.json index c2de07f5bf1e..331a381df678 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/union_typedesc1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/union_typedesc1.json @@ -64,70 +64,6 @@ "insertText": "TestMap3", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -329,54 +265,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -401,14 +289,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -425,22 +305,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -546,14 +410,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -577,6 +433,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/union_typedesc2.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/union_typedesc2.json index 0e194f058db5..eda1e6707590 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/union_typedesc2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/union_typedesc2.json @@ -64,70 +64,6 @@ "insertText": "TestMap3", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -329,54 +265,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -401,14 +289,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -425,22 +305,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -614,14 +478,6 @@ "insertText": "module1:function1()", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -645,6 +501,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Z", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config18.json b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config18.json index 740bf9dfa4d9..70ea20e546ad 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config18.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config18.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "deprecated", "kind": "Property", @@ -429,14 +357,6 @@ "insertTextFormat": "Snippet", "additionalTextEdits": [] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -460,6 +380,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "P", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "N", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "P", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "P", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "P", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "P", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "P", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "P", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "P", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "P", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config8.json b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config8.json index 5bd6f2c80569..b4a2dbaa3d3a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config8.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -342,14 +270,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -373,6 +293,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config9.json b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config9.json index f1ba34322294..1ead73bbbaa6 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config9.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config9.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -342,14 +270,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -373,6 +293,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/xml_typedesc_context/config/config1.json b/language-server/modules/langserver-core/src/test/resources/completion/xml_typedesc_context/config/config1.json index ddf9905bf227..696e1b5f327f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/xml_typedesc_context/config/config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/xml_typedesc_context/config/config1.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -365,14 +293,6 @@ "insertText": "NEW_XML_TYPE", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -396,6 +316,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/xml_typedesc_context/config/config2.json b/language-server/modules/langserver-core/src/test/resources/completion/xml_typedesc_context/config/config2.json index c10e364dfef2..ed20ff63e686 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/xml_typedesc_context/config/config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/xml_typedesc_context/config/config2.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -365,14 +293,6 @@ "insertText": "NEW_XML_TYPE", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "G", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -396,6 +316,86 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } From 64ede6bf8ee6cb066b22d2270d1664adf5b1492a Mon Sep 17 00:00:00 2001 From: malinthar Date: Wed, 23 Nov 2022 10:53:29 +0530 Subject: [PATCH 151/450] Sync with master --- .../providers/AbstractCompletionProvider.java | 1 + .../module_part_context/config/config1.json | 397 ++++++++-------- .../module_part_context/config/config13.json | 2 +- .../module_part_context/config/config14.json | 429 +++++++++--------- .../module_part_context/config/config15.json | 417 ++++++++--------- .../config/config15_client_declaration.json | 406 ++++++++--------- .../module_part_context/config/config16.json | 419 ++++++++--------- .../module_part_context/config/config2.json | 397 ++++++++-------- .../module_part_context/config/config3.json | 397 ++++++++-------- .../module_part_context/config/config6.json | 404 ++++++++--------- ...le_level_after_annotation_decl_config.json | 416 +++++++++-------- .../module_level_after_class_defn_config.json | 416 +++++++++-------- .../module_level_after_const_decl_config.json | 416 +++++++++-------- .../module_level_after_enum_decl_config.json | 416 +++++++++-------- ...dule_level_after_funciton_defn_config.json | 416 +++++++++-------- ...module_level_after_import_decl_config.json | 409 ++++++++--------- ...dule_level_after_listener_decl_config.json | 416 +++++++++-------- ...odule_level_after_service_decl_config.json | 416 +++++++++-------- .../module_level_after_type_defn_config.json | 416 +++++++++-------- .../module_level_after_var_decl_config.json | 416 +++++++++-------- .../module_level_after_xmlns_decl_config.json | 416 +++++++++-------- ...e_level_before_annotation_decl_config.json | 416 +++++++++-------- ...module_level_before_class_defn_config.json | 416 +++++++++-------- ...module_level_before_const_decl_config.json | 416 +++++++++-------- .../module_level_before_enum_decl_config.json | 416 +++++++++-------- ...ule_level_before_function_defn_config.json | 416 +++++++++-------- ...odule_level_before_import_decl_config.json | 409 ++++++++--------- ...ule_level_before_listener_decl_config.json | 409 ++++++++--------- ...dule_level_before_service_decl_config.json | 416 +++++++++-------- .../module_level_before_type_defn_config.json | 416 +++++++++-------- .../module_level_before_var_decl_config.json | 416 +++++++++-------- ...module_level_before_xmlns_decl_config.json | 416 +++++++++-------- 32 files changed, 6094 insertions(+), 6306 deletions(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/AbstractCompletionProvider.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/AbstractCompletionProvider.java index f6292f2da6d5..69b0b19e8c83 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/AbstractCompletionProvider.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/AbstractCompletionProvider.java @@ -97,6 +97,7 @@ import java.util.Set; import java.util.function.Predicate; import java.util.stream.Collectors; + import javax.annotation.Nonnull; import static io.ballerina.compiler.api.symbols.SymbolKind.CLASS; diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config1.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config1.json index 4c11d48979e4..e91e0c8744c8 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config1.json @@ -9,7 +9,7 @@ "label": "import", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "import", "insertText": "import ", "insertTextFormat": "Snippet" @@ -18,7 +18,7 @@ "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +27,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +36,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +45,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +54,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +63,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +72,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +81,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +90,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +99,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +108,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +117,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +126,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +135,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +144,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +153,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +162,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +171,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +180,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +189,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +198,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +207,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +216,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +225,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +234,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +243,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +252,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +264,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +272,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +289,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +298,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +307,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +316,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +325,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +334,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +343,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +352,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +376,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +400,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +424,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +448,7 @@ "label": "ballerina/module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet", @@ -536,7 +472,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -556,54 +492,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -628,14 +516,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -652,27 +532,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -696,7 +560,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -720,7 +584,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -744,7 +608,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -768,7 +632,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -792,7 +656,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -816,24 +680,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -842,7 +698,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -866,10 +722,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config13.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config13.json index 89cbba8c1c68..e95d63a24771 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config13.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config13.json @@ -36,7 +36,7 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config14.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config14.json index 5d5bec3cf955..7f4cf92a9c90 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config14.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config14.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/lsproject/main.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,25 +117,16 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" }, - { - "label": "public main function", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "public_function_main", - "insertText": "public function main() {\n\t${1}\n}", - "insertTextFormat": "Snippet" - }, { "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +135,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +144,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +153,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +162,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +171,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +180,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +189,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +198,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +207,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +216,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +225,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +234,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -261,7 +243,7 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, @@ -272,79 +254,15 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +271,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +280,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +289,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +298,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +307,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +316,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +325,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +334,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -425,7 +343,7 @@ "label": "mod1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "mod1", "insertText": "mod1", "insertTextFormat": "Snippet" @@ -434,7 +352,7 @@ "label": "module2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module2", "insertText": "module2", "insertTextFormat": "Snippet" @@ -443,7 +361,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -467,7 +385,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -491,7 +409,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -515,7 +433,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -539,7 +457,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -559,54 +477,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -631,14 +501,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -655,27 +517,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "lsproject.module3", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module3", "insertText": "module3", "insertTextFormat": "Snippet", @@ -699,7 +545,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -709,7 +555,7 @@ "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -733,7 +579,7 @@ "label": "Service", "kind": "Interface", "detail": "Object", - "sortText": "D", + "sortText": "CA", "insertText": "Service", "insertTextFormat": "Snippet" }, @@ -741,7 +587,7 @@ "label": "Listener", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "Listener", "insertTextFormat": "Snippet" }, @@ -749,7 +595,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -773,7 +619,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -797,7 +643,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -821,7 +667,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -845,7 +691,7 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" @@ -854,7 +700,7 @@ "label": "mod1:Service", "kind": "Interface", "detail": "Object", - "sortText": "D", + "sortText": "CA", "insertText": "mod1:Service", "insertTextFormat": "Snippet" }, @@ -862,7 +708,7 @@ "label": "service on mod1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lsproject_module1_mod1_Listener", "insertText": "service ${1} on new mod1:Listener() {\n\n remote function method1() {\n return;\n }\n\n function method2() returns string|error {\n return ${3:\"\"};\n }\n\n function method3(mod1:MyType|int arg1) returns mod1:MyType {\n return ${4:{a: \"\"\\}};\n }\n\n}\n", "insertTextFormat": "Snippet", @@ -872,7 +718,7 @@ "label": "service on lsproject.module3:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lsproject_module3_Listener", "insertText": "service ${1} on new module3:Listener() {\n\n remote function method1() {\n return;\n }\n\n function method2() returns string|error {\n return ${3:\"\"};\n }\n\n function method3($CompilationError$|int arg1) returns $CompilationError$ {\n ${4}\n }\n\n}\n", "insertTextFormat": "Snippet", @@ -896,25 +742,17 @@ "label": "service on Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_Listener", "insertText": "service ${1} on new Listener() {\n\n remote function method1() {\n return;\n }\n\n function method2() returns string|error {\n return ${3:\"\"};\n }\n\n function method3($CompilationError$|int arg1) returns $CompilationError$ {\n ${4}\n }\n\n}\n", "insertTextFormat": "Snippet", "additionalTextEdits": [] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -923,7 +761,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -947,10 +785,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config15.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config15.json index 3f29f7f6dfda..71bbe77f6834 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config15.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config15.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/source14.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,25 +117,16 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" }, - { - "label": "public main function", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "public_function_main", - "insertText": "public function main() {\n\t${1}\n}", - "insertTextFormat": "Snippet" - }, { "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +135,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +144,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +153,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +162,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +171,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +180,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +189,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +198,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +207,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +216,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +225,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +234,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -261,7 +243,7 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, @@ -269,7 +251,7 @@ "label": "Service", "kind": "Interface", "detail": "Object", - "sortText": "D", + "sortText": "CA", "insertText": "Service", "insertTextFormat": "Snippet" }, @@ -280,7 +262,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -288,79 +270,15 @@ "label": "Listener", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "Listener", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -369,7 +287,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -378,7 +296,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -387,7 +305,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -396,7 +314,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -405,7 +323,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -414,7 +332,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -423,7 +341,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -432,7 +350,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -441,7 +359,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -465,7 +383,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -489,7 +407,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -513,7 +431,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -537,7 +455,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -557,54 +475,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -629,14 +499,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -653,27 +515,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -683,7 +529,7 @@ "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -707,7 +553,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -731,7 +577,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -755,7 +601,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -779,7 +625,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -803,7 +649,7 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" @@ -812,25 +658,17 @@ "label": "service on Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_Listener", "insertText": "service ${1} on new Listener() {\n\n remote function method1() {\n return;\n }\n\n}\n", "insertTextFormat": "Snippet", "additionalTextEdits": [] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -839,7 +677,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -863,10 +701,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config15_client_declaration.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config15_client_declaration.json index e32ecb93e1bf..dd6da31d81a4 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config15_client_declaration.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config15_client_declaration.json @@ -9,7 +9,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -33,7 +33,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -57,7 +57,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -81,7 +81,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -105,7 +105,7 @@ "label": "ballerina/module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet", @@ -129,7 +129,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -153,7 +153,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -162,7 +162,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -171,7 +171,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -180,7 +180,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -189,7 +189,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -198,7 +198,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -207,7 +207,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -216,7 +216,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -225,7 +225,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -237,7 +237,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -245,79 +245,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -326,7 +262,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -335,7 +271,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -344,7 +280,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -353,7 +289,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -362,7 +298,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -371,59 +307,11 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -448,14 +336,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -472,27 +352,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -516,7 +380,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -540,7 +404,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -564,7 +428,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -588,42 +452,25 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" }, - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -632,7 +479,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -641,7 +488,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -650,7 +497,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -659,7 +506,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -668,7 +515,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -677,7 +524,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -686,7 +533,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -695,7 +542,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -704,7 +551,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -713,7 +560,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -722,7 +569,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -731,7 +578,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -740,7 +587,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -749,7 +596,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -758,7 +605,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -767,7 +614,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -776,7 +623,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -785,7 +632,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -794,7 +641,7 @@ "label": "testPrefixMod", "kind": "Module", "detail": "Module", - "sortText": "E", + "sortText": "G", "filterText": "testPrefixMod", "insertText": "testPrefixMod", "insertTextFormat": "Snippet" @@ -803,7 +650,7 @@ "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -827,7 +674,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -851,7 +698,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -875,10 +722,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config16.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config16.json index 4b2f61f72b35..c11d1cb7133f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config16.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config16.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/lsproject/modules/module2/module2.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,25 +117,16 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" }, - { - "label": "public main function", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "public_function_main", - "insertText": "public function main() {\n\t${1}\n}", - "insertTextFormat": "Snippet" - }, { "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +135,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +144,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +153,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +162,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +171,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +180,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +189,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +198,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +207,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +216,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +225,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +234,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -261,7 +243,7 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, @@ -272,79 +254,15 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +271,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +280,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +289,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +298,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +307,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +316,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +325,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +334,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -425,7 +343,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -449,7 +367,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -473,7 +391,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -497,7 +415,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -521,7 +439,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -541,54 +459,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +483,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +499,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "lsproject.module3", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module3", "insertText": "module3", "insertTextFormat": "Snippet", @@ -681,7 +527,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +537,7 @@ "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -715,7 +561,7 @@ "label": "lsproject.module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module11", "insertTextFormat": "Snippet", @@ -739,7 +585,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -763,7 +609,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -787,7 +633,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -811,7 +657,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -835,7 +681,7 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" @@ -844,7 +690,7 @@ "label": "service on lsproject.module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lsproject_module1_Listener", "insertText": "service ${1} on new module11:Listener() {\n\n remote function method1() {\n return;\n }\n\n function method2() returns string|error {\n return ${3:\"\"};\n }\n\n function method3(module11:MyType|int arg1) returns module11:MyType {\n return ${4:{a: \"\"\\}};\n }\n\n}\n", "insertTextFormat": "Snippet", @@ -868,7 +714,7 @@ "label": "service on lsproject.module3:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lsproject_module3_Listener", "insertText": "service ${1} on new module3:Listener() {\n\n remote function method1() {\n return;\n }\n\n function method2() returns string|error {\n return ${3:\"\"};\n }\n\n function method3($CompilationError$|int arg1) returns $CompilationError$ {\n ${4}\n }\n\n}\n", "insertTextFormat": "Snippet", @@ -888,19 +734,11 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -909,7 +747,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -933,10 +771,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config2.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config2.json index 881376cace49..fd371fcaba77 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config2.json @@ -9,7 +9,7 @@ "label": "import", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "import", "insertText": "import ", "insertTextFormat": "Snippet" @@ -18,7 +18,7 @@ "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +27,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +36,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +45,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +54,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +63,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +72,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +81,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +90,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +99,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +108,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +117,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +126,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +135,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +144,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +153,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +162,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +171,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +180,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +189,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +198,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +207,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +216,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +225,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +234,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +243,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +252,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +264,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +272,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +289,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +298,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +307,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +316,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +325,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +334,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +343,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +352,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +376,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +400,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +424,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +448,7 @@ "label": "ballerina/module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet", @@ -536,7 +472,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -556,54 +492,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -628,14 +516,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -652,27 +532,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -696,7 +560,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -720,7 +584,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -744,7 +608,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -768,7 +632,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -792,7 +656,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -816,24 +680,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -842,7 +698,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -866,10 +722,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config3.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config3.json index e27d98debd6d..04aa16320719 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config3.json @@ -9,7 +9,7 @@ "label": "import", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "import", "insertText": "import ", "insertTextFormat": "Snippet" @@ -18,7 +18,7 @@ "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +27,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +36,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +45,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +54,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +63,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +72,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +81,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +90,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +99,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +108,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +117,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +126,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +135,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +144,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +153,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +162,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +171,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +180,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +189,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +198,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +207,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +216,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +225,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +234,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +243,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +252,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +264,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +272,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +289,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +298,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +307,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +316,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +325,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +334,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +343,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +352,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +376,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +400,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +424,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +448,7 @@ "label": "ballerina/module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet", @@ -536,7 +472,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -556,54 +492,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -628,14 +516,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -652,27 +532,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -696,7 +560,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -720,7 +584,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -744,7 +608,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -768,7 +632,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -792,7 +656,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -816,24 +680,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -842,7 +698,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -866,10 +722,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config6.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config6.json index 70764559ac05..fca3985d5433 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config6.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/source6.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -425,7 +352,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -449,7 +376,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -473,7 +400,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -497,7 +424,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -667,7 +522,7 @@ "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -813,7 +660,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -837,10 +684,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_annotation_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_annotation_decl_config.json index 06c2e459e0c6..2f374770a12a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_annotation_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_annotation_decl_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -861,7 +708,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -885,10 +732,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_class_defn_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_class_defn_config.json index 7cac7878a3f7..0b4c8a25018e 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_class_defn_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_class_defn_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -861,7 +708,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -885,10 +732,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_const_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_const_decl_config.json index 7898f4d4ef04..3bb94be78e28 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_const_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_const_decl_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -861,7 +708,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -885,10 +732,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_enum_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_enum_decl_config.json index 75ada66ed2d1..0a20922a549d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_enum_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_enum_decl_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -861,7 +708,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -885,10 +732,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_funciton_defn_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_funciton_defn_config.json index d4e255d21c23..c93cf1880ecc 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_funciton_defn_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_funciton_defn_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -861,7 +708,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -885,10 +732,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_import_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_import_decl_config.json index 7b3cb728709e..f69185a34807 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_import_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_import_decl_config.json @@ -9,7 +9,7 @@ "label": "import", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "import", "insertText": "import ", "insertTextFormat": "Snippet" @@ -18,7 +18,7 @@ "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +27,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +36,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +45,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +54,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +63,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +72,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +81,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +90,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +99,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +108,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +117,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +126,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +135,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +144,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +153,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +162,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +171,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +180,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +189,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +198,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +207,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +216,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +225,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +234,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +243,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +252,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +264,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +272,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +289,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +298,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +307,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +316,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +325,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +334,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +343,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +352,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +376,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +400,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +424,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +448,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +457,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +477,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +501,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +517,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +545,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +555,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +579,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +603,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +627,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +651,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +668,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +676,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +684,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +692,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +700,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +708,7 @@ "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -861,7 +717,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -885,10 +741,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_listener_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_listener_decl_config.json index 241c51582a44..1cb2614a25dc 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_listener_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_listener_decl_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -861,7 +708,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -885,10 +732,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_service_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_service_decl_config.json index e773778cb0ea..fcc023ef4d8f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_service_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_service_decl_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -861,7 +708,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -885,10 +732,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_type_defn_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_type_defn_config.json index 2dbf6410dce0..931a402652c5 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_type_defn_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_type_defn_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -861,7 +708,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -885,10 +732,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_var_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_var_decl_config.json index 6b05532d23f7..16db167387f3 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_var_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_var_decl_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -861,7 +708,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -885,10 +732,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_xmlns_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_xmlns_decl_config.json index 9f251ecc97e1..804c7f424f3e 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_xmlns_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_xmlns_decl_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -861,7 +708,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -885,10 +732,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_annotation_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_annotation_decl_config.json index 17c5c2cfdf2a..1983be273bc3 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_annotation_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_annotation_decl_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -861,7 +708,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -885,10 +732,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_class_defn_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_class_defn_config.json index 42b64f7866af..96fde9eb2684 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_class_defn_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_class_defn_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -861,7 +708,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -885,10 +732,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_const_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_const_decl_config.json index 64ee3e9a2095..13f4ca0a5b84 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_const_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_const_decl_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -861,7 +708,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -885,10 +732,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_enum_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_enum_decl_config.json index 132f188625d8..b71af7f62b64 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_enum_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_enum_decl_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -861,7 +708,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -885,10 +732,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_function_defn_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_function_defn_config.json index 724afad2e7db..5ae7d7a2642e 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_function_defn_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_function_defn_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -861,7 +708,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -885,10 +732,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_import_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_import_decl_config.json index 87de2329bc1d..d24ad3a834f2 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_import_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_import_decl_config.json @@ -9,7 +9,7 @@ "label": "import", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "import", "insertText": "import ", "insertTextFormat": "Snippet" @@ -18,7 +18,7 @@ "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +27,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +36,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +45,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +54,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +63,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +72,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +81,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +90,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +99,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +108,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +117,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +126,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +135,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +144,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +153,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +162,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +171,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +180,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +189,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +198,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +207,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +216,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +225,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +234,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +243,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +252,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +264,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +272,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +289,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +298,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +307,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +316,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +325,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +334,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +343,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +352,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +376,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +400,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +424,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +448,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +457,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +477,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +501,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +517,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +545,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +555,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +579,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +603,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +627,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +651,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +668,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +676,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +684,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +692,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +700,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +708,7 @@ "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -861,7 +717,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -885,10 +741,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_listener_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_listener_decl_config.json index f43bd48011aa..5a83915287e3 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_listener_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_listener_decl_config.json @@ -9,7 +9,7 @@ "label": "import", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "import", "insertText": "import ", "insertTextFormat": "Snippet" @@ -18,7 +18,7 @@ "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +27,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +36,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +45,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +54,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +63,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +72,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +81,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +90,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +99,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +108,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +117,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +126,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +135,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +144,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +153,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +162,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +171,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +180,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +189,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +198,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +207,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +216,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +225,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +234,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +243,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +252,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +264,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +272,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +289,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +298,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +307,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +316,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +325,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +334,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +343,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +352,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +376,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +400,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +424,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +448,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +457,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +477,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +501,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +517,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +545,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +555,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +579,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +603,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +627,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +651,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +668,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +676,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +684,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +692,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +700,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +708,7 @@ "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -861,7 +717,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -885,10 +741,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_service_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_service_decl_config.json index b78629ecbb1b..67cfc4d4986a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_service_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_service_decl_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -861,7 +708,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -885,10 +732,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_type_defn_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_type_defn_config.json index ab92488aa068..26dc09d7b4e3 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_type_defn_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_type_defn_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -861,7 +708,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -885,10 +732,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_var_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_var_decl_config.json index 7daecb806ba8..e22bed4518b2 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_var_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_var_decl_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -861,7 +708,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -885,10 +732,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_xmlns_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_xmlns_decl_config.json index 08b2a499ccbd..023f2d28ed0e 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_xmlns_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_xmlns_decl_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -861,7 +708,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -885,10 +732,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } From 6eadb1a8ba7b5445c7f16a73e8b6b15453f613dd Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Thu, 1 Dec 2022 22:57:45 +0530 Subject: [PATCH 152/450] Fix special char escaping in types issue --- .../jsonmapper/JsonToRecordMapper.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java index 3ad9cb9143bd..9b645c1c1669 100644 --- a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java +++ b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java @@ -151,10 +151,10 @@ public static JsonToRecordResponse convert(String jsonString, String recordName, .map(entry -> { Token typeKeyWord = AbstractNodeFactory.createToken(SyntaxKind.TYPE_KEYWORD); String recordTypeName = entry.getKey() == null ? - (recordName == null || recordName.equals("")) ? NEW_RECORD_NAME : recordName : + (recordName == null || recordName.equals("")) ? + NEW_RECORD_NAME : escapeIdentifier(StringUtils.capitalize(recordName)) : entry.getKey(); - IdentifierToken typeName = AbstractNodeFactory - .createIdentifierToken(escapeIdentifier(recordTypeName)); + IdentifierToken typeName = AbstractNodeFactory.createIdentifierToken(recordTypeName); Token semicolon = AbstractNodeFactory.createToken(SyntaxKind.SEMICOLON_TOKEN); return NodeFactory.createTypeDefinitionNode(null, null, typeKeyWord, typeName, entry.getValue(), semicolon); @@ -258,13 +258,13 @@ private static void generateRecordForObjAndArray(JsonElement jsonElement, String List diagnosticMessages, boolean arraySuffixAdded) { if (jsonElement.isJsonObject()) { - String type = StringUtils.capitalize(elementKey); + String type = escapeIdentifier(StringUtils.capitalize(elementKey)); generateRecords(jsonElement.getAsJsonObject(), type, isClosed, recordToTypeDescNodes, moveBefore, jsonNodes, diagnosticMessages); } else if (jsonElement.isJsonArray()) { for (JsonElement element : jsonElement.getAsJsonArray()) { - String type = StringUtils.capitalize(elementKey) + (arraySuffixAdded ? "" : ARRAY_RECORD_SUFFIX); - generateRecordForObjAndArray(element, type, isClosed, recordToTypeDescNodes, moveBefore, + String arrayElementKey = elementKey + (arraySuffixAdded ? "" : ARRAY_RECORD_SUFFIX); + generateRecordForObjAndArray(element, arrayElementKey, isClosed, recordToTypeDescNodes, moveBefore, jsonNodes, diagnosticMessages, true); } } @@ -339,9 +339,11 @@ private static void updateRecordFields(JsonObject jsonObject, Map entry : differencingRecordFields.entrySet()) { String jsonField = entry.getKey(); - JsonElement jsonElement = jsonNodes.get(jsonField); + Map jsonEscapedFieldToFields = jsonNodes.entrySet().stream() + .collect(Collectors.toMap(jsonEntry -> escapeIdentifier(jsonEntry.getKey()), Map.Entry::getKey)); + JsonElement jsonElement = jsonNodes.get(jsonEscapedFieldToFields.get(jsonField)); Map.Entry jsonEntry = jsonElement != null ? - new AbstractMap.SimpleEntry<>(jsonField, jsonElement) : + new AbstractMap.SimpleEntry<>(jsonEscapedFieldToFields.get(jsonField), jsonElement) : jsonObject.entrySet().stream().filter(elementEntry -> escapeIdentifier(elementEntry.getKey()) .equals(jsonField)).findFirst().orElse(null); if (jsonEntry != null) { @@ -384,7 +386,7 @@ private static Node getRecordField(Map.Entry entry, boolean optionalFieldToken, semicolonToken); } else if (entry.getValue().isJsonObject()) { String elementKey = entry.getKey().trim(); - String type = StringUtils.capitalize(escapeIdentifier(elementKey)); + String type = escapeIdentifier(StringUtils.capitalize(elementKey)); typeName = AbstractNodeFactory.createIdentifierToken(type); fieldTypeName = NodeFactory.createBuiltinSimpleNameReferenceNode(typeName.kind(), typeName); recordFieldNode = NodeFactory.createRecordFieldNode(null, null, From f8cedb66994b007410932ca125d4d0913eba976e Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Thu, 1 Dec 2022 22:59:08 +0530 Subject: [PATCH 153/450] Add testcases to test sprecial char scenarios --- .../jsonmapper/JsonToRecordMapperTests.java | 11 +++++++ .../test/resources/ballerina/sample_11.bal | 14 +++++++++ .../ballerina/sample_3_special_char.bal | 21 +++++++++++++ .../src/test/resources/ballerina/sample_9.bal | 8 +++++ .../ballerina/sample_9_type_desc.bal | 3 +- .../src/test/resources/json/sample_11.json | 30 ++++++++++++++++++- .../src/test/resources/json/sample_9.json | 10 ++++++- 7 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 misc/json-to-record-converter/src/test/resources/ballerina/sample_3_special_char.bal diff --git a/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java b/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java index 64171865ad90..8e99f22fd353 100644 --- a/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java +++ b/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java @@ -65,6 +65,8 @@ public class JsonToRecordMapperTests { .resolve("sample_3_person.bal"); private final Path sample3PersonTypeDescBal = RES_DIR.resolve("ballerina") .resolve("sample_3_person_type_desc.bal"); + private final Path sample3SpecialCharBal = RES_DIR.resolve("ballerina") + .resolve("sample_3_special_char.bal"); private final Path sample4Json = RES_DIR.resolve("json") .resolve("sample_4.json"); @@ -333,6 +335,15 @@ public void testForUserDefinedRecordNameInLIne() throws IOException { Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); } + @Test(description = "Test for JSON with user defined record name with special chars") + public void testForUserDefinedRecordNameWithSpecialChars() throws IOException { + String jsonFileContent = Files.readString(sample3Json); + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "Special Person", false, false, false) + .getCodeBlock().replaceAll("\\s+", ""); + String expectedCodeBlock = Files.readString(sample3SpecialCharBal).replaceAll("\\s+", ""); + Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); + } + @Test(description = "Test Choreo Transformation and Data Mapping Payloads") public void testChoreoTransPayloads() throws IOException { Map samples = new HashMap<>(); diff --git a/misc/json-to-record-converter/src/test/resources/ballerina/sample_11.bal b/misc/json-to-record-converter/src/test/resources/ballerina/sample_11.bal index 3f40aca8c60e..a6e1666a0247 100644 --- a/misc/json-to-record-converter/src/test/resources/ballerina/sample_11.bal +++ b/misc/json-to-record-converter/src/test/resources/ballerina/sample_11.bal @@ -1,7 +1,21 @@ +type Special\ object record { + string name; + int age; +}; + +type Special\\array\-\?Item record { + string date; + int value; + string 'type?; + string[] \2\ favourite\-colors?; +}; + type NewRecord record { string first\ Name; string last\+Name\?; string \007; int ϼ\ \+\-\+; boolean ōŊĖ; + Special\ object special\ object; + (Special\\array\-\?Item[]|Special\\array\-\?Item[][])[] special\\array\-\?; }; diff --git a/misc/json-to-record-converter/src/test/resources/ballerina/sample_3_special_char.bal b/misc/json-to-record-converter/src/test/resources/ballerina/sample_3_special_char.bal new file mode 100644 index 000000000000..ef707f6c3129 --- /dev/null +++ b/misc/json-to-record-converter/src/test/resources/ballerina/sample_3_special_char.bal @@ -0,0 +1,21 @@ +type Address record { + (int|string) streetAddress; + string city; + string state; +}; + +type Friend record { + string firstName; + string lastName; + Address address; +}; + +type Special\ Person record { + string firstName; + string lastName; + string gender; + int age; + Address address; + anydata phoneNumber; + Friend friend; +}; diff --git a/misc/json-to-record-converter/src/test/resources/ballerina/sample_9.bal b/misc/json-to-record-converter/src/test/resources/ballerina/sample_9.bal index efe2aac93101..153935146f98 100644 --- a/misc/json-to-record-converter/src/test/resources/ballerina/sample_9.bal +++ b/misc/json-to-record-converter/src/test/resources/ballerina/sample_9.bal @@ -11,6 +11,13 @@ type Batters record { type ToppingItem record { string id; string 'type; + string color?; +}; + +type BaseItem record { + string id; + string 'type; + string color?; }; type NewRecord record { @@ -20,4 +27,5 @@ type NewRecord record { decimal ppu; Batters batters; (ToppingItem|string|ToppingItem[]|string[])[] topping; + BaseItem[][] base; }; diff --git a/misc/json-to-record-converter/src/test/resources/ballerina/sample_9_type_desc.bal b/misc/json-to-record-converter/src/test/resources/ballerina/sample_9_type_desc.bal index 94f8b58913b3..504bea6e7e11 100644 --- a/misc/json-to-record-converter/src/test/resources/ballerina/sample_9_type_desc.bal +++ b/misc/json-to-record-converter/src/test/resources/ballerina/sample_9_type_desc.bal @@ -4,5 +4,6 @@ type NewRecord record { string name; decimal ppu; record {(decimal|int|record {string id; string 'type; boolean fresh?;}|string)[] batter;} batters; - (record {string id; string 'type;}|string|record {string id;string 'type;}[]|string[])[] topping; + (record {string id; string 'type; string color?;}|string|record {string id; string 'type; string color?;}[]|string[])[] topping; + record {stringid ; string 'type; stringcolor? ;}[][] base; }; diff --git a/misc/json-to-record-converter/src/test/resources/json/sample_11.json b/misc/json-to-record-converter/src/test/resources/json/sample_11.json index 3c99cf459b34..4c771c6602e3 100644 --- a/misc/json-to-record-converter/src/test/resources/json/sample_11.json +++ b/misc/json-to-record-converter/src/test/resources/json/sample_11.json @@ -3,5 +3,33 @@ "last+Name?": "Root", "007": "James Bond", "\\u{03FC} +-+": 123, - "ōŊĖ": false + "ōŊĖ": false, + "special object": { + "name": "Special", + "age": 100 + }, + "special\\array-?": [ + [ + { + "date": "2022-01-01", + "value": 2504, + "type": "None" + } + ], + [ + { + "date": "2022-01-01", + "value": 2504 + } + ], + [ + [ + { + "date": "2022-01-01", + "value": 2504, + "2 favourite-colors": ["Red", "Green"] + } + ] + ] + ] } diff --git a/misc/json-to-record-converter/src/test/resources/json/sample_9.json b/misc/json-to-record-converter/src/test/resources/json/sample_9.json index 13d212a59cb4..40e2d65072ac 100644 --- a/misc/json-to-record-converter/src/test/resources/json/sample_9.json +++ b/misc/json-to-record-converter/src/test/resources/json/sample_9.json @@ -23,10 +23,18 @@ { "id": "5003", "type": "Chocolate" }, { "id": "5004", "type": "Maple" }, [ - { "id": "5001", "type": "None" }, + { "id": "5001", "type": "None", "color": "Red" }, { "id": "5002", "type": "Glazed" } ], ["Chocolate", "Milk"], "Vanilla" + ], + "base": [ + [ + { "id": "1000", "type": "None" } + ], + [ + { "id": "1001", "type": "None", "color": "Blue" } + ] ] } From 048a02b9ebf2dc019ec1bb4d434182a94b7ba12b Mon Sep 17 00:00:00 2001 From: malinthar Date: Thu, 1 Dec 2022 23:52:47 +0530 Subject: [PATCH 154/450] Fix faling tests after rebasing --- .../config/client_remote_action_config1.json | 272 ++++++------ .../config/client_remote_action_config3.json | 272 ++++++------ ...client_resource_access_action_config2.json | 268 ++++++------ ...client_resource_access_action_config3.json | 268 ++++++------ ...med_arg_in_remote_method_call_action1.json | 33 -- .../annotation_decl/config/config21.json | 404 +++++++++-------- .../completion/class_def/config/config22.json | 408 +++++++++--------- .../completion/class_def/config/config25.json | 272 ++++++------ .../completion/class_def/config/config28.json | 272 ++++++------ .../completion/class_def/config/config6.json | 272 ++++++------ .../config/comment_config5.json | 272 ++++++------ .../enum_decl_ctx/config/config5.json | 401 ++++++++--------- .../config/anon_func_expr_ctx_config11.json | 272 ++++++------ .../config/anon_func_expr_ctx_config13.json | 272 ++++++------ .../config/anon_func_expr_ctx_config7.json | 272 ++++++------ .../config/anon_func_expr_ctx_config8.json | 272 ++++++------ .../config/check_expression_ctx_config1.json | 272 ++++++------ .../config/check_expression_ctx_config2.json | 272 ++++++------ .../config/check_expression_ctx_config6.json | 272 ++++++------ .../config/check_expression_ctx_config7.json | 272 ++++++------ .../config/conditional_expr_ctx_config1.json | 272 ++++++------ .../config/conditional_expr_ctx_config10.json | 272 ++++++------ .../config/conditional_expr_ctx_config2.json | 272 ++++++------ .../config/conditional_expr_ctx_config3.json | 272 ++++++------ .../config/conditional_expr_ctx_config4.json | 272 ++++++------ .../config/conditional_expr_ctx_config8.json | 272 ++++++------ .../error_constructor_expr_ctx_config1.json | 272 ++++++------ .../error_constructor_expr_ctx_config10.json | 272 ++++++------ .../error_constructor_expr_ctx_config11.json | 272 ++++++------ .../error_constructor_expr_ctx_config12.json | 272 ++++++------ .../error_constructor_expr_ctx_config2.json | 272 ++++++------ .../error_constructor_expr_ctx_config7.json | 272 ++++++------ .../error_constructor_expr_ctx_config8.json | 272 ++++++------ .../error_constructor_expr_ctx_config9.json | 272 ++++++------ .../config/fail_expr_ctx_config1.json | 272 ++++++------ .../config/fail_expr_ctx_config2.json | 272 ++++++------ .../function_call_expression_ctx_config1.json | 272 ++++++------ ...function_call_expression_ctx_config10.json | 272 ++++++------ ...function_call_expression_ctx_config11.json | 272 ++++++------ ...function_call_expression_ctx_config12.json | 272 ++++++------ ...function_call_expression_ctx_config13.json | 272 ++++++------ ...function_call_expression_ctx_config14.json | 272 ++++++------ ...function_call_expression_ctx_config15.json | 272 ++++++------ ...function_call_expression_ctx_config16.json | 272 ++++++------ ...function_call_expression_ctx_config17.json | 272 ++++++------ ...function_call_expression_ctx_config18.json | 272 ++++++------ ...function_call_expression_ctx_config19.json | 272 ++++++------ .../function_call_expression_ctx_config2.json | 272 ++++++------ ...function_call_expression_ctx_config20.json | 272 ++++++------ ...function_call_expression_ctx_config21.json | 272 ++++++------ ...function_call_expression_ctx_config22.json | 268 ++++++------ .../function_call_expression_ctx_config3.json | 272 ++++++------ .../function_call_expression_ctx_config4.json | 272 ++++++------ .../function_call_expression_ctx_config9.json | 272 ++++++------ .../config/list_constructor_ctx_config1.json | 272 ++++++------ .../config/list_constructor_ctx_config2.json | 272 ++++++------ .../config/list_constructor_ctx_config3.json | 272 ++++++------ .../config/list_constructor_ctx_config5.json | 268 ++++++------ .../mapping_constructor_expr_ctx_config5.json | 254 +++++------ .../config/mapping_expr_ctx_config1.json | 272 ++++++------ .../config/mapping_expr_ctx_config2.json | 272 ++++++------ .../config/mapping_expr_ctx_config55.json | 272 ++++++------ .../config/mapping_expr_ctx_config56.json | 272 ++++++------ .../config/mapping_expr_ctx_config65.json | 272 ++++++------ .../config/mapping_expr_ctx_config75.json | 224 +++++----- .../member_access_expr_ctx_config1.json | 272 ++++++------ .../member_access_expr_ctx_config2.json | 272 ++++++------ .../method_call_expression_ctx_config1.json | 272 ++++++------ .../method_call_expression_ctx_config2.json | 272 ++++++------ .../method_call_expression_ctx_config5.json | 272 ++++++------ .../method_call_expression_ctx_config6.json | 272 ++++++------ .../config/new_expr_ctx_config1.json | 272 ++++++------ .../config/new_expr_ctx_config11.json | 272 ++++++------ .../config/new_expr_ctx_config12.json | 272 ++++++------ .../config/new_expr_ctx_config14.json | 272 ++++++------ .../config/new_expr_ctx_config15.json | 272 ++++++------ .../config/new_expr_ctx_config2.json | 272 ++++++------ .../config/new_expr_ctx_config20.json | 272 ++++++------ .../config/new_expr_ctx_config21.json | 272 ++++++------ .../config/new_expr_ctx_config22.json | 272 ++++++------ .../config/new_expr_ctx_config23.json | 272 ++++++------ .../config/new_expr_ctx_config24.json | 272 ++++++------ .../config/new_expr_ctx_config25.json | 272 ++++++------ .../config/new_expr_ctx_config26.json | 272 ++++++------ .../config/new_expr_ctx_config3.json | 272 ++++++------ .../config/new_expr_ctx_config4.json | 272 ++++++------ .../config/new_expr_ctx_config5.json | 272 ++++++------ .../config/new_expr_ctx_config6.json | 272 ++++++------ .../object_constructor_expr_ctx_config9.json | 272 ++++++------ .../config/trap_expression_ctx_config1.json | 272 ++++++------ .../config/trap_expression_ctx_config2.json | 272 ++++++------ .../type_test_expression_ctx_config5.json | 272 ++++++------ .../config/typecast_expr_ctx_config6.json | 272 ++++++------ .../config/typeof_expression_ctx_config1.json | 272 ++++++------ .../config/typeof_expression_ctx_config2.json | 272 ++++++------ .../config/foreach_stmt_ctx_config5.json | 272 ++++++------ .../config/foreach_stmt_ctx_config6.json | 272 ++++++------ .../function_body/config/config7.json | 272 ++++++------ .../function_body/config/config9.json | 272 ++++++------ .../function_def/config/config14.json | 272 ++++++------ .../function_def/config/config15.json | 272 ++++++------ .../function_def/config/config23.json | 272 ++++++------ .../config/let_expr_ctx_config10.json | 272 ++++++------ .../config/let_expr_ctx_config11.json | 272 ++++++------ .../config/let_expr_ctx_config13.json | 272 ++++++------ .../config/let_expr_ctx_config2.json | 272 ++++++------ .../config/let_expr_ctx_config3.json | 272 ++++++------ .../config/let_expr_ctx_config4.json | 272 ++++++------ .../config/let_expr_ctx_config7.json | 272 ++++++------ .../config/let_expr_ctx_config9.json | 272 ++++++------ ...ule_client_declaration_client_keyword.json | 397 ++++++++--------- .../module_var_context/config/config1.json | 272 ++++++------ .../module_var_context/config/config2.json | 272 ++++++------ .../module_var_context/config/config3.json | 272 ++++++------ .../module_var_context/config/config4.json | 272 ++++++------ .../module_var_context/config/config5.json | 272 ++++++------ .../module_var_context/config/config6.json | 272 ++++++------ .../config/performance_completion.json | 272 ++++++------ .../config/query_expr_ctx_config14.json | 272 ++++++------ .../config/query_expr_ctx_config22.json | 272 ++++++------ .../config/query_expr_ctx_config23.json | 272 ++++++------ .../config/query_expr_ctx_config25.json | 272 ++++++------ .../config/query_expr_ctx_config26.json | 272 ++++++------ .../config/query_expr_ctx_config29.json | 272 ++++++------ .../config/query_expr_ctx_config30.json | 272 ++++++------ .../query_expr_ctx_from_clause_config7.json | 268 ++++++------ .../query_expr_ctx_from_clause_config8.json | 268 ++++++------ .../query_expr_ctx_join_clause_config12.json | 272 ++++++------ .../query_expr_ctx_join_clause_config5.json | 272 ++++++------ .../query_expr_ctx_let_clause_config11.json | 272 ++++++------ .../query_expr_ctx_let_clause_config4.json | 272 ++++++------ .../query_expr_ctx_let_clause_config5.json | 272 ++++++------ .../query_expr_ctx_limit_clause_config1.json | 272 ++++++------ .../query_expr_ctx_limit_clause_config2.json | 272 ++++++------ .../query_expr_ctx_limit_clause_config4.json | 272 ++++++------ ...ry_expr_ctx_onconflict_clause_config2.json | 272 ++++++------ ...query_expr_ctx_orderby_clause_config1.json | 272 ++++++------ ...query_expr_ctx_orderby_clause_config2.json | 272 ++++++------ ...query_expr_ctx_orderby_clause_config7.json | 272 ++++++------ ...query_expr_ctx_orderby_clause_config8.json | 272 ++++++------ ...query_expr_ctx_orderby_clause_config9.json | 272 ++++++------ .../query_expr_ctx_select_clause_config1.json | 272 ++++++------ .../query_expr_ctx_select_clause_config2.json | 272 ++++++------ .../query_expr_ctx_select_clause_config5.json | 272 ++++++------ .../query_expr_ctx_where_clause_config1.json | 272 ++++++------ .../query_expr_ctx_where_clause_config3.json | 272 ++++++------ .../query_expr_ctx_where_clause_config5.json | 272 ++++++------ .../record_type_desc/config/config5.json | 272 ++++++------ .../record_type_desc/config/config6.json | 272 ++++++------ .../record_type_desc/config/config7.json | 272 ++++++------ .../record_type_desc/config/config8.json | 272 ++++++------ .../service_decl/config/config12.json | 272 ++++++------ .../service_decl/config/config17.json | 406 +++++++++-------- .../service_decl/config/config18.json | 406 +++++++++-------- .../service_decl/config/config7.json | 406 +++++++++-------- .../config/assignment_stmt_ctx_config1.json | 272 ++++++------ .../config/assignment_stmt_ctx_config10.json | 272 ++++++------ .../config/assignment_stmt_ctx_config11.json | 272 ++++++------ .../config/assignment_stmt_ctx_config2.json | 272 ++++++------ .../config/assignment_stmt_ctx_config3.json | 272 ++++++------ .../config/assignment_stmt_ctx_config6.json | 272 ++++++------ .../config/assignment_stmt_ctx_config7.json | 272 ++++++------ .../config/assignment_stmt_ctx_config8.json | 272 ++++++------ .../config/assignment_stmt_ctx_config9.json | 272 ++++++------ .../checking_call_stmt_ctx_config1.json | 272 ++++++------ .../checking_call_stmt_ctx_config2.json | 272 ++++++------ .../config/elseif_stmt_ctx_config4.json | 272 ++++++------ .../config/elseif_stmt_ctx_config5.json | 272 ++++++------ .../config/elseif_stmt_ctx_config6.json | 272 ++++++------ .../config/fail_stmt_ctx_config1.json | 272 ++++++------ .../config/fail_stmt_ctx_config2.json | 272 ++++++------ .../config/if_stmt_ctx_config12.json | 254 +++++------ .../config/if_stmt_ctx_config3.json | 272 ++++++------ .../config/if_stmt_ctx_config4.json | 272 ++++++------ .../config/if_stmt_ctx_config5.json | 272 ++++++------ .../config/if_stmt_ctx_config6.json | 272 ++++++------ .../config/lock_stmt_ctx_config2.json | 272 ++++++------ .../config/match_stmt_ctx_config1.json | 272 ++++++------ .../config/match_stmt_ctx_config13.json | 272 ++++++------ .../config/match_stmt_ctx_config2.json | 272 ++++++------ .../config/match_stmt_ctx_config20.json | 272 ++++++------ .../config/match_stmt_ctx_config21.json | 272 ++++++------ .../config/match_stmt_ctx_config22.json | 272 ++++++------ .../config/panic_stmt_ctx_config2.json | 272 ++++++------ .../config/panic_stmt_ctx_config3.json | 272 ++++++------ .../config/transaction_config2.json | 272 ++++++------ .../config/transaction_config3.json | 272 ++++++------ .../config/while_stmt_ctx_config3.json | 272 ++++++------ .../config/while_stmt_ctx_config4.json | 272 ++++++------ .../config/while_stmt_ctx_config5.json | 272 ++++++------ .../config/while_stmt_ctx_config6.json | 272 ++++++------ .../config/while_stmt_ctx_config8.json | 254 +++++------ .../regex_template_expression_config1.json | 188 ++++---- .../regex_template_expression_config2.json | 188 ++++---- .../regex_template_expression_config4.json | 272 ++++++------ .../string_template_expression_config2.json | 272 ++++++------ .../string_template_expression_config3.json | 272 ++++++------ .../string_template_expression_config4.json | 272 ++++++------ .../string_template_expression_config5.json | 272 ++++++------ .../xml_template_expression_config1.json | 272 ++++++------ .../xml_template_expression_config2.json | 272 ++++++------ .../config/function_typedesc15a.json | 272 ++++++------ .../config/function_typedesc15b.json | 272 ++++++------ .../config/project_var_def_ctx_config1.json | 272 ++++++------ .../config/project_var_def_ctx_config2.json | 272 ++++++------ .../config/project_var_def_ctx_config3.json | 272 ++++++------ .../config/var_def_ctx_config1.json | 272 ++++++------ .../config/var_def_ctx_config12.json | 272 ++++++------ .../config/var_def_ctx_config13.json | 272 ++++++------ .../config/var_def_ctx_config14.json | 272 ++++++------ .../config/var_def_ctx_config15.json | 272 ++++++------ .../config/var_def_ctx_config2.json | 272 ++++++------ .../config/var_def_ctx_config20.json | 272 ++++++------ .../config/var_def_ctx_config7.json | 272 ++++++------ .../var_def_ctx_with_escape_char_config1.json | 272 ++++++------ .../var_def_in_obj_constructor_config1.json | 272 ++++++------ .../var_def_with_anon_func_config1.json | 272 ++++++------ .../var_def_with_anon_func_config2.json | 272 ++++++------ .../var_def_with_anon_func_config3.json | 272 ++++++------ .../var_def_with_anon_func_config4.json | 272 ++++++------ 220 files changed, 30080 insertions(+), 30151 deletions(-) diff --git a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_remote_action_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_remote_action_config1.json index 5062cd55adf7..97eea465ca47 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_remote_action_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_remote_action_config1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -459,62 +387,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "start", "kind": "Keyword", @@ -699,14 +571,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -739,6 +603,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_remote_action_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_remote_action_config3.json index 5e214a4a247e..844e803c8628 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_remote_action_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_remote_action_config3.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -490,62 +418,6 @@ "insertText": "resp", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "path = ...", "kind": "Snippet", @@ -714,14 +586,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -754,6 +618,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_resource_access_action_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_resource_access_action_config2.json index b17d8d128efb..c8db895938e6 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_resource_access_action_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_resource_access_action_config2.json @@ -245,62 +245,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -325,14 +269,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -349,22 +285,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -612,93 +532,173 @@ "insertTextFormat": "Snippet" }, { - "label": "readonly", - "kind": "Unit", - "detail": "type", + "label": "ballerina/lang.regexp", + "kind": "Module", + "detail": "Module", "sortText": "R", + "filterText": "regexp", + "insertText": "regexp", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.regexp;\n" + } + ] + }, + { + "label": "re ``", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "P", + "filterText": "re ``", + "insertText": "re `${1}`", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", "insertText": "readonly", "insertTextFormat": "Snippet" }, { "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", "insertText": "handle", "insertTextFormat": "Snippet" }, { "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", "insertText": "never", "insertTextFormat": "Snippet" }, { "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", "insertText": "json", "insertTextFormat": "Snippet" }, { "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", "insertText": "anydata", "insertTextFormat": "Snippet" }, { "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", "insertText": "any", "insertTextFormat": "Snippet" }, { "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", "insertText": "byte", "insertTextFormat": "Snippet" - }, - { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] - }, - { - "label": "re ``", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "re ``", - "insertText": "re `${1}`", - "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_resource_access_action_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_resource_access_action_config3.json index 1e6832f940bb..0b6dc3fcfee2 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_resource_access_action_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_resource_access_action_config3.json @@ -281,62 +281,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -361,14 +305,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -385,22 +321,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -648,93 +568,173 @@ "insertTextFormat": "Snippet" }, { - "label": "readonly", - "kind": "Unit", - "detail": "type", + "label": "ballerina/lang.regexp", + "kind": "Module", + "detail": "Module", "sortText": "R", + "filterText": "regexp", + "insertText": "regexp", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.regexp;\n" + } + ] + }, + { + "label": "re ``", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "P", + "filterText": "re ``", + "insertText": "re `${1}`", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", "insertText": "readonly", "insertTextFormat": "Snippet" }, { "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", "insertText": "handle", "insertTextFormat": "Snippet" }, { "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", "insertText": "never", "insertTextFormat": "Snippet" }, { "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", "insertText": "json", "insertTextFormat": "Snippet" }, { "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", "insertText": "anydata", "insertTextFormat": "Snippet" }, { "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", "insertText": "any", "insertTextFormat": "Snippet" }, { "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", "insertText": "byte", "insertTextFormat": "Snippet" - }, - { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] - }, - { - "label": "re ``", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "P", - "filterText": "re ``", - "insertText": "re `${1}`", - "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/named_arg_in_remote_method_call_action1.json b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/named_arg_in_remote_method_call_action1.json index ed202d231cfb..b85bdbb38b44 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/named_arg_in_remote_method_call_action1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/named_arg_in_remote_method_call_action1.json @@ -295,39 +295,6 @@ "title": "editor.action.triggerParameterHints", "command": "editor.action.triggerParameterHints" } - }, - { - "label": "ClientError", - "kind": "Event", - "detail": "Error", - "documentation": { - "left": "Defines the possible client error types." - }, - "sortText": "P", - "insertText": "ClientError", - "insertTextFormat": "Snippet" - }, - { - "label": "TargetType2", - "kind": "TypeParameter", - "detail": "Typedesc", - "documentation": { - "left": "The super type of all the types." - }, - "sortText": "R", - "insertText": "TargetType2", - "insertTextFormat": "Snippet" - }, - { - "label": "TargetType", - "kind": "TypeParameter", - "detail": "Typedesc", - "documentation": { - "left": "The types of data values that are expected by the `client` to return after the data binding operation." - }, - "sortText": "R", - "insertText": "TargetType", - "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_decl/config/config21.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_decl/config/config21.json index 69ec5bf75f04..32bbaf24c7cb 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_decl/config/config21.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_decl/config/config21.json @@ -9,7 +9,7 @@ "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -18,7 +18,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -27,7 +27,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -36,25 +36,16 @@ "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" }, - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -261,7 +252,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -270,7 +261,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -282,7 +273,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -290,79 +281,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -425,7 +352,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -449,7 +376,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -473,7 +400,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -497,7 +424,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -705,7 +560,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -729,7 +584,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -753,7 +608,7 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" @@ -762,7 +617,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -772,7 +627,7 @@ "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -792,19 +647,11 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -813,7 +660,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -837,10 +684,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config22.json b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config22.json index 3fd39e0373b4..82dddeedde79 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config22.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config22.json @@ -5,20 +5,11 @@ }, "source": "class_def/source/source22.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,7 +263,7 @@ "label": "UniqueGreetingsStore", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "UniqueGreetingsStore", "insertTextFormat": "Snippet" }, @@ -280,7 +271,7 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, @@ -288,79 +279,15 @@ "label": "BALLERINA", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "BALLERINA", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -369,7 +296,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -378,7 +305,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -387,7 +314,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -396,7 +323,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -405,7 +332,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -414,7 +341,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -423,7 +350,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -432,7 +359,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -456,7 +383,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -480,7 +407,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -504,7 +431,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -528,7 +455,7 @@ "label": "ballerina/module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet", @@ -552,7 +479,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -572,54 +499,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -644,14 +523,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -668,27 +539,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -712,7 +567,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -736,7 +591,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -760,7 +615,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -784,7 +639,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -808,7 +663,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -832,24 +687,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -858,7 +705,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -882,10 +729,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config25.json b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config25.json index 4c4a9651398e..85472395ed0d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config25.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config25.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -444,62 +372,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "new(int field1, int field2)", "kind": "Function", @@ -623,14 +495,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -663,6 +527,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config28.json b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config28.json index 7f40c869ba50..6870c2620fb0 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config28.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config28.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -444,62 +372,6 @@ "insertText": "Person", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "new(int field1, int field2)", "kind": "Function", @@ -623,14 +495,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -663,6 +527,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "DN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "DL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "DN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "DN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "DN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "DN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "DN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "DN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "DN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "DN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "DN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "DN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "DN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "DN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "DN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "DN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "DN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config6.json b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config6.json index eed6d4c2c6b9..f819e4164fcc 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config6.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -474,62 +402,6 @@ "insertText": "testFunctionWithReturn2()", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -635,14 +507,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -675,6 +539,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/comment_context/config/comment_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/comment_context/config/comment_config5.json index 8bc344cb8954..07f55f1d3852 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/comment_context/config/comment_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/comment_context/config/comment_config5.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -510,62 +438,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -671,14 +543,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -711,6 +575,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/enum_decl_ctx/config/config5.json b/language-server/modules/langserver-core/src/test/resources/completion/enum_decl_ctx/config/config5.json index c2dc40407d3e..0f7aae7b3c33 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/enum_decl_ctx/config/config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/enum_decl_ctx/config/config5.json @@ -9,7 +9,7 @@ "label": "import", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "import", "insertText": "import ", "insertTextFormat": "Snippet" @@ -18,7 +18,7 @@ "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +27,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +36,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +45,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +54,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +63,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +72,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +81,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +90,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +99,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +108,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +117,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +126,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +135,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +144,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +153,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +162,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +171,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +180,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +189,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +198,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +207,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +216,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +225,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +234,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +243,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +252,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +264,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,7 +272,7 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, @@ -280,7 +280,7 @@ "label": "Colour", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "Colour", "insertTextFormat": "Snippet" }, @@ -288,79 +288,15 @@ "label": "R", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "R", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -369,7 +305,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -378,7 +314,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -387,7 +323,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -396,7 +332,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -405,7 +341,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -414,7 +350,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -423,7 +359,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -432,7 +368,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -441,7 +377,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -465,7 +401,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -489,7 +425,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -513,7 +449,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -537,7 +473,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -557,54 +493,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -629,14 +517,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -653,27 +533,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -683,7 +547,7 @@ "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -707,7 +571,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -731,7 +595,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -755,7 +619,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -779,7 +643,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -803,24 +667,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -829,7 +685,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -853,10 +709,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config11.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config11.json index a8ea3fbd3913..c9375b08fa02 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config11.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config11.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -558,62 +486,6 @@ "insertText": "R1", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -727,14 +599,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -767,6 +631,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config13.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config13.json index bd01a0fdfd2f..25d029f1e8ee 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config13.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config13.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -588,62 +516,6 @@ "insertText": "returnAnonFunc()", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "function (..) {..}", "kind": "Snippet", @@ -749,14 +621,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -789,6 +653,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config7.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config7.json index 479752c8b031..de10012e1083 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config7.json @@ -146,54 +146,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -218,14 +170,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -242,22 +186,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -482,62 +410,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.value", "kind": "Module", @@ -683,14 +555,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -723,6 +587,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config8.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config8.json index 32606b7a35b8..6a5f76623fd5 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config8.json @@ -146,54 +146,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -218,14 +170,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -242,22 +186,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -482,62 +410,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "b", "kind": "Variable", @@ -699,14 +571,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -739,6 +603,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/check_expression_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/check_expression_ctx_config1.json index ffb726f021b3..158ae3acf17d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/check_expression_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/check_expression_ctx_config1.json @@ -146,54 +146,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -218,14 +170,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -242,22 +186,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -502,62 +430,6 @@ "insertText": "testVar", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.value", "kind": "Module", @@ -687,14 +559,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -727,6 +591,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "DN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "DL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "DN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "DN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "DN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "DN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "DN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "DN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "DN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "DN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "DN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "DN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "DN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "DN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "DN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "DN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "DN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/check_expression_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/check_expression_ctx_config2.json index 6e86d32c103b..9f4dc64a29a0 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/check_expression_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/check_expression_ctx_config2.json @@ -146,54 +146,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -218,14 +170,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -242,22 +186,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -494,62 +422,6 @@ "insertText": "Record1", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.value", "kind": "Module", @@ -679,14 +551,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -719,6 +583,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "DN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "DL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "DN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "DN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "DN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "DN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "DN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "DN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "DN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "DN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "DN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "DN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "DN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "DN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "DN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "DN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "DN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/check_expression_ctx_config6.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/check_expression_ctx_config6.json index 053ed5b68796..715bf9b96fba 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/check_expression_ctx_config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/check_expression_ctx_config6.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -601,62 +529,6 @@ "insertText": "ProductClient", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -753,14 +625,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -793,6 +657,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "DN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "DL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "DN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "DN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "DN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "DN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "DN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "DN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "DN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "DN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "DN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "DN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "DN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "DN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "DN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "DN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "DN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/check_expression_ctx_config7.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/check_expression_ctx_config7.json index b4fbaf94a5aa..2a4b92f9747c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/check_expression_ctx_config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/check_expression_ctx_config7.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -593,62 +521,6 @@ "insertText": "ProductClient", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "new(string url)", "kind": "Function", @@ -763,14 +635,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -803,6 +667,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "DN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "DL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "DN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "DN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "DN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "DN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "DN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "DN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "DN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "DN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "DN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "DN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "DN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "DN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "DN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "DN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "DN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/conditional_expr_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/conditional_expr_ctx_config1.json index 0977e893bce5..15095d54adbf 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/conditional_expr_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/conditional_expr_ctx_config1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -467,62 +395,6 @@ "insertText": "n", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -628,14 +500,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -668,6 +532,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/conditional_expr_ctx_config10.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/conditional_expr_ctx_config10.json index a9838221739f..ae6db08cedfb 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/conditional_expr_ctx_config10.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/conditional_expr_ctx_config10.json @@ -110,54 +110,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -182,14 +134,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -206,22 +150,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -428,62 +356,6 @@ "insertText": "n", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -640,14 +512,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -680,6 +544,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/conditional_expr_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/conditional_expr_ctx_config2.json index fa20d8e2cd67..74c4e7944755 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/conditional_expr_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/conditional_expr_ctx_config2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -467,62 +395,6 @@ "insertText": "n", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -628,14 +500,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -668,6 +532,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/conditional_expr_ctx_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/conditional_expr_ctx_config3.json index 1931e55d3bdd..68e575aa5213 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/conditional_expr_ctx_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/conditional_expr_ctx_config3.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -467,62 +395,6 @@ "insertText": "n", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -628,14 +500,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -668,6 +532,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/conditional_expr_ctx_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/conditional_expr_ctx_config4.json index 2f4ee501f8c8..c04da80b86cb 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/conditional_expr_ctx_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/conditional_expr_ctx_config4.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -467,62 +395,6 @@ "insertText": "n", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -628,14 +500,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -668,6 +532,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/conditional_expr_ctx_config8.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/conditional_expr_ctx_config8.json index d839ada74215..bbe7e6462c0c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/conditional_expr_ctx_config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/conditional_expr_ctx_config8.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -476,62 +404,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -628,14 +500,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -668,6 +532,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config1.json index b3c84697c13c..f79213b6b367 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -490,62 +418,6 @@ "insertText": "getStringVal()", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -687,14 +559,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -727,6 +591,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config10.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config10.json index 41c41424e33e..dc2821220fc9 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config10.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config10.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -490,62 +418,6 @@ "insertText": "Error1", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -651,14 +523,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -691,6 +555,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config11.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config11.json index 0e788f64472a..0a26b98d9cbb 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config11.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config11.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -548,62 +476,6 @@ "insertText": "getMessage()", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "stack = ...", "kind": "Snippet", @@ -745,14 +617,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -785,6 +649,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config12.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config12.json index 32fc3572ed05..b1a82501de60 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config12.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config12.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -499,62 +427,6 @@ "insertText": "ErrorData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "cause = ...", "kind": "Snippet", @@ -705,14 +577,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -745,6 +609,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config2.json index 9cbc8c34fcb1..d4601b17bfa1 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -490,62 +418,6 @@ "insertText": "getStringVal()", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -687,14 +559,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -727,6 +591,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config7.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config7.json index cb0b047356e5..40b2352be153 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config7.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -490,62 +418,6 @@ "insertText": "getStringVal()", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -696,14 +568,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -736,6 +600,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config8.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config8.json index 069b9736ec9f..aee0bdfd2236 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config8.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -490,62 +418,6 @@ "insertText": "getStringVal()", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -696,14 +568,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -736,6 +600,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config9.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config9.json index 1b4d4bbdbc31..409466a4668a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config9.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config9.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -490,62 +418,6 @@ "insertText": "Error1", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "stack = ...", "kind": "Snippet", @@ -696,14 +568,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -736,6 +600,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/fail_expr_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/fail_expr_ctx_config1.json index 38b2ca7e2d33..a9f75b3e33e1 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/fail_expr_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/fail_expr_ctx_config1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -475,62 +403,6 @@ "insertText": "obj1", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -636,14 +508,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -676,6 +540,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "C", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "A", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "C", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "C", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "C", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "C", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "C", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "C", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "C", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "C", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "C", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "C", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "C", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "C", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "C", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "C", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "C", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/fail_expr_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/fail_expr_ctx_config2.json index abcb96a35889..bea35995228b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/fail_expr_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/fail_expr_ctx_config2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -475,62 +403,6 @@ "insertText": "obj1", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -636,14 +508,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -676,6 +540,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "C", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "A", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "C", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "C", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "C", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "C", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "C", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "C", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "C", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "C", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "C", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "C", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "C", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "C", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "C", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "C", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "C", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config1.json index 4d6e946bb7a1..9269af7573d0 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config1.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -522,62 +450,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -701,14 +573,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -741,6 +605,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config10.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config10.json index 4c2a096fe4e5..45025e5ad14a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config10.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config10.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -572,62 +500,6 @@ "insertText": "myInt1", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "addFunction", "kind": "Variable", @@ -759,14 +631,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -799,6 +663,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config11.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config11.json index cde8de27174a..2445f5d34a00 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config11.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config11.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -584,62 +512,6 @@ "insertText": "myInt1", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "addFunction", "kind": "Variable", @@ -762,14 +634,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -802,6 +666,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config12.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config12.json index cff2dd50050f..d8d994b2061b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config12.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config12.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -565,62 +493,6 @@ "insertText": "city", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "func", "kind": "Variable", @@ -743,14 +615,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -783,6 +647,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config13.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config13.json index 4ac975e40b61..b5d135a473fa 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config13.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config13.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -518,62 +446,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -679,14 +551,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -719,6 +583,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config14.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config14.json index 0b76a2f2f2d5..41215599423c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config14.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config14.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -518,62 +446,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -679,14 +551,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -719,6 +583,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config15.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config15.json index 10d07addf990..e695305a9323 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config15.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config15.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -521,62 +449,6 @@ "command": "editor.action.triggerParameterHints" } }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "arg2 = ...", "kind": "Snippet", @@ -691,14 +563,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -731,6 +595,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config16.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config16.json index 4427f6e57d44..07c3eb06264c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config16.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config16.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "isolated", "kind": "Keyword", @@ -395,62 +323,6 @@ "command": "editor.action.triggerParameterHints" } }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -646,14 +518,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -686,6 +550,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config17.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config17.json index 52b8e26f0cfc..bf5e757055d7 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config17.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config17.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -521,62 +449,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "arg1 = ...", "kind": "Snippet", @@ -700,14 +572,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -740,6 +604,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config18.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config18.json index 825484ca288f..e8c9f4bf98db 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config18.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config18.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -521,62 +449,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -682,14 +554,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -722,6 +586,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config19.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config19.json index 8c3f979e4baf..099569942932 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config19.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config19.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -521,62 +449,6 @@ "command": "editor.action.triggerParameterHints" } }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "arg2 = ...", "kind": "Snippet", @@ -691,14 +563,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -731,6 +595,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config2.json index 81dbf932588c..3a2ece134658 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config2.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -522,62 +450,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -701,14 +573,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -741,6 +605,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config20.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config20.json index c72998aa2091..70061cb70144 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config20.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config20.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -502,62 +430,6 @@ "insertText": "main()", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -708,14 +580,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -748,6 +612,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config21.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config21.json index aead147daa01..69ffc1962a53 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config21.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config21.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -502,62 +430,6 @@ "insertText": "main()", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -717,14 +589,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -757,6 +621,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CP", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CN", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CP", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CP", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CP", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CP", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CP", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CP", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CP", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CP", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CP", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CP", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CP", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CP", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CP", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CP", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CP", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config22.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config22.json index 0a16e8c401fa..bddf68ad5d90 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config22.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config22.json @@ -281,62 +281,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -361,14 +305,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -385,22 +321,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -632,93 +552,173 @@ "insertTextFormat": "Snippet" }, { - "label": "readonly", - "kind": "Unit", - "detail": "type", + "label": "ballerina/lang.regexp", + "kind": "Module", + "detail": "Module", "sortText": "CR", + "filterText": "regexp", + "insertText": "regexp", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.regexp;\n" + } + ] + }, + { + "label": "re ``", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "CR", + "filterText": "re ``", + "insertText": "re `${1}`", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "AP", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CN", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "AP", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "AP", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CP", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "AP", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "AP", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CP", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "AP", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CP", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CP", "insertText": "readonly", "insertTextFormat": "Snippet" }, { "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "CR", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CP", "insertText": "handle", "insertTextFormat": "Snippet" }, { "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "CR", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "AP", "insertText": "never", "insertTextFormat": "Snippet" }, { "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "CR", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "AP", "insertText": "json", "insertTextFormat": "Snippet" }, { "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "CR", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "AP", "insertText": "anydata", "insertTextFormat": "Snippet" }, { "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "CR", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CP", "insertText": "any", "insertTextFormat": "Snippet" }, { "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "CR", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "AP", "insertText": "byte", "insertTextFormat": "Snippet" - }, - { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", - "sortText": "CR", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] - }, - { - "label": "re ``", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "CR", - "filterText": "re ``", - "insertText": "re `${1}`", - "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config3.json index e2b7d35c57b4..75d4853b1249 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config3.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -522,62 +450,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -692,14 +564,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -732,6 +596,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config4.json index a99737fc7cd7..9c471f30916c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config4.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -522,62 +450,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -692,14 +564,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -732,6 +596,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config9.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config9.json index 8d81a437eb00..94560eaf466f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config9.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config9.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -655,62 +583,6 @@ "command": "editor.action.triggerParameterHints" } }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -852,14 +724,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -892,6 +756,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/list_constructor_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/list_constructor_ctx_config1.json index 3082f6442e3d..2f1933bb14a8 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/list_constructor_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/list_constructor_ctx_config1.json @@ -125,54 +125,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -197,14 +149,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -221,22 +165,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -496,62 +424,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.value", "kind": "Module", @@ -681,14 +553,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -721,6 +585,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/list_constructor_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/list_constructor_ctx_config2.json index af4df25128af..55c0271e8c48 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/list_constructor_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/list_constructor_ctx_config2.json @@ -125,54 +125,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -197,14 +149,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -221,22 +165,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -496,62 +424,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.value", "kind": "Module", @@ -681,14 +553,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -721,6 +585,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/list_constructor_ctx_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/list_constructor_ctx_config3.json index a2ae1a6b9851..d5ca7a30a7d5 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/list_constructor_ctx_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/list_constructor_ctx_config3.json @@ -125,54 +125,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -197,14 +149,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -221,22 +165,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -496,62 +424,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.value", "kind": "Module", @@ -681,14 +553,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -721,6 +585,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/list_constructor_ctx_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/list_constructor_ctx_config5.json index 604fa0d9ce9c..791432856ccd 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/list_constructor_ctx_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/list_constructor_ctx_config5.json @@ -245,54 +245,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -317,14 +269,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -341,22 +285,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -588,101 +516,173 @@ "insertTextFormat": "Snippet" }, { - "label": "readonly", - "kind": "Unit", - "detail": "type", + "label": "ballerina/lang.regexp", + "kind": "Module", + "detail": "Module", "sortText": "ARR", + "filterText": "regexp", + "insertText": "regexp", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.regexp;\n" + } + ] + }, + { + "label": "re ``", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "ATP", + "filterText": "re ``", + "insertText": "re `${1}`", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", "insertText": "readonly", "insertTextFormat": "Snippet" }, { "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", "insertText": "handle", "insertTextFormat": "Snippet" }, { "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", "insertText": "never", "insertTextFormat": "Snippet" }, { "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", "insertText": "json", "insertTextFormat": "Snippet" }, { "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", "insertText": "anydata", "insertTextFormat": "Snippet" }, { "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", "insertText": "any", "insertTextFormat": "Snippet" }, { "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", "insertText": "byte", "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "ARR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", - "sortText": "ARR", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] - }, - { - "label": "re ``", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "ATP", - "filterText": "re ``", - "insertText": "re `${1}`", - "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_constructor_expr_ctx_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_constructor_expr_ctx_config5.json index e1b23c61a0af..7c4cc9ec0f09 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_constructor_expr_ctx_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_constructor_expr_ctx_config5.json @@ -245,62 +245,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -325,14 +269,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -349,22 +285,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -580,94 +500,174 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, + { + "label": "ballerina/lang.regexp", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "regexp", + "insertText": "regexp", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.regexp;\n" + } + ] + }, + { + "label": "re ``", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "T", + "filterText": "re ``", + "insertText": "re `${1}`", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, { "label": "readonly", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Readonly", "sortText": "R", "insertText": "readonly", "insertTextFormat": "Snippet" }, { "label": "handle", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Handle", "sortText": "R", "insertText": "handle", "insertTextFormat": "Snippet" }, { "label": "never", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Never", "sortText": "R", "insertText": "never", "insertTextFormat": "Snippet" }, { "label": "json", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Json", "sortText": "R", "insertText": "json", "insertTextFormat": "Snippet" }, { "label": "anydata", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Anydata", "sortText": "R", "insertText": "anydata", "insertTextFormat": "Snippet" }, { "label": "any", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Any", "sortText": "R", "insertText": "any", "insertTextFormat": "Snippet" }, { "label": "byte", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Byte", "sortText": "R", "insertText": "byte", "insertTextFormat": "Snippet" - }, - { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] - }, - { - "label": "re ``", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "T", - "filterText": "re ``", - "insertText": "re `${1}`", - "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config1.json index 37173d98aed5..5de5c3c6545d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config1.json @@ -110,54 +110,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -182,14 +134,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -206,22 +150,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -488,62 +416,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.value", "kind": "Module", @@ -673,14 +545,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -713,6 +577,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config2.json index 434efc36e0e1..0bd86b9c8e1c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config2.json @@ -110,54 +110,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -182,14 +134,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -206,22 +150,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -488,62 +416,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.value", "kind": "Module", @@ -673,14 +545,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -713,6 +577,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config55.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config55.json index c50ed091ad9f..5615e76ca959 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config55.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config55.json @@ -174,54 +174,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -246,14 +198,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -270,22 +214,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -546,62 +474,6 @@ "insertText": "TestRecord", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "getMapValue()", "kind": "Function", @@ -736,14 +608,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -776,6 +640,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config56.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config56.json index fbca771ae5cc..11007fae0b16 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config56.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config56.json @@ -174,54 +174,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -246,14 +198,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -270,22 +214,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -546,62 +474,6 @@ "insertText": "TestRecord", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "getMapValue()", "kind": "Function", @@ -736,14 +608,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -776,6 +640,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config65.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config65.json index 942f71acecdb..53d8f9fb32a9 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config65.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config65.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -503,62 +431,6 @@ "insertText": "name", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -655,14 +527,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -695,6 +559,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config75.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config75.json index dfd05d26de01..e0329d450c2b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config75.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_ctx_config75.json @@ -305,62 +305,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -385,14 +329,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -409,22 +345,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -663,79 +583,159 @@ "insertText": "test()", "insertTextFormat": "Snippet" }, + { + "label": "school = ...", + "kind": "Snippet", + "detail": "school = {name: \"\", city: \"\"}", + "sortText": "AR", + "filterText": "school", + "insertText": "school = ${1:{name: \"\", city: \"\"\\}}", + "insertTextFormat": "Snippet" + }, + { + "label": "re ``", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "T", + "filterText": "re ``", + "insertText": "re `${1}`", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, { "label": "readonly", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Readonly", "sortText": "R", "insertText": "readonly", "insertTextFormat": "Snippet" }, { "label": "handle", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Handle", "sortText": "R", "insertText": "handle", "insertTextFormat": "Snippet" }, { "label": "never", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Never", "sortText": "R", "insertText": "never", "insertTextFormat": "Snippet" }, { "label": "json", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Json", "sortText": "R", "insertText": "json", "insertTextFormat": "Snippet" }, { "label": "anydata", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Anydata", "sortText": "R", "insertText": "anydata", "insertTextFormat": "Snippet" }, { "label": "any", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Any", "sortText": "R", "insertText": "any", "insertTextFormat": "Snippet" }, { "label": "byte", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Byte", "sortText": "R", "insertText": "byte", "insertTextFormat": "Snippet" - }, - { - "label": "school = ...", - "kind": "Snippet", - "detail": "school = {name: \"\", city: \"\"}", - "sortText": "AR", - "filterText": "school", - "insertText": "school = ${1:{name: \"\", city: \"\"\\}}", - "insertTextFormat": "Snippet" - }, - { - "label": "re ``", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "T", - "filterText": "re ``", - "insertText": "re `${1}`", - "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/member_access_expr_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/member_access_expr_ctx_config1.json index 282579a12b9f..53c0264819dd 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/member_access_expr_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/member_access_expr_ctx_config1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -475,62 +403,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -636,14 +508,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -676,6 +540,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/member_access_expr_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/member_access_expr_ctx_config2.json index e36e1e309d1f..1564f30eda18 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/member_access_expr_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/member_access_expr_ctx_config2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -475,62 +403,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -636,14 +508,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -676,6 +540,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/method_call_expression_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/method_call_expression_ctx_config1.json index 66228f0fff03..ca61b2907921 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/method_call_expression_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/method_call_expression_ctx_config1.json @@ -146,54 +146,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -218,14 +170,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -242,22 +186,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -448,62 +376,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.test", "kind": "Module", @@ -707,14 +579,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -747,6 +611,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CP", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CN", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CP", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CP", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CP", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CP", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CP", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CP", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CP", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CP", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CP", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CP", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CP", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CP", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CP", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CP", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CP", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/method_call_expression_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/method_call_expression_ctx_config2.json index 6eabb47d6270..50e4cbb88cf1 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/method_call_expression_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/method_call_expression_ctx_config2.json @@ -146,54 +146,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -218,14 +170,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -242,22 +186,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -448,62 +376,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.test", "kind": "Module", @@ -750,14 +622,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -790,6 +654,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CP", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CN", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CP", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CP", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CP", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CP", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CP", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CP", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CP", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CP", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CP", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CP", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CP", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CP", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CP", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CP", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CP", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/method_call_expression_ctx_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/method_call_expression_ctx_config5.json index c20e1db2ad22..7a8891b05f6d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/method_call_expression_ctx_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/method_call_expression_ctx_config5.json @@ -146,54 +146,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -218,14 +170,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -242,22 +186,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -448,62 +376,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.test", "kind": "Module", @@ -707,14 +579,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -747,6 +611,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CP", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CN", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CP", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CP", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CP", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CP", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CP", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CP", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CP", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CP", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CP", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CP", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CP", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CP", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CP", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CP", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CP", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/method_call_expression_ctx_config6.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/method_call_expression_ctx_config6.json index 9e3ecc32ea8f..6cf79666af8b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/method_call_expression_ctx_config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/method_call_expression_ctx_config6.json @@ -146,54 +146,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -218,14 +170,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -242,22 +186,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -448,62 +376,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.test", "kind": "Module", @@ -707,14 +579,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -747,6 +611,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CP", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CN", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CP", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CP", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CP", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CP", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CP", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CP", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CP", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CP", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CP", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CP", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CP", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CP", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CP", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CP", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CP", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config1.json index 99eeaea49424..576400d6b001 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config1.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -541,62 +469,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "new(int field1, int field2)", "kind": "Function", @@ -720,14 +592,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -760,6 +624,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config11.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config11.json index e8ad609d9604..d65350f4401d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config11.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config11.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -475,62 +403,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -636,14 +508,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -676,6 +540,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config12.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config12.json index 793991becdb4..32ed9c500fd3 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config12.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config12.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -475,62 +403,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -636,14 +508,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -676,6 +540,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config14.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config14.json index d9a08e773915..bf88ce049139 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config14.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config14.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -475,62 +403,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -636,14 +508,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -676,6 +540,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config15.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config15.json index e4134e7adc89..a1a85385d199 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config15.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config15.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -475,62 +403,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -636,14 +508,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -676,6 +540,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config2.json index ce0013f2ea87..c8c22d15c749 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config2.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -526,62 +454,6 @@ "insertText": "obj2", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "new()", "kind": "Function", @@ -701,14 +573,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -741,6 +605,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config20.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config20.json index 7993dcb3d234..19f63b8c4ae7 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config20.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config20.json @@ -110,54 +110,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -182,14 +134,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -206,22 +150,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "start", "kind": "Keyword", @@ -413,62 +341,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "from clause", "kind": "Snippet", @@ -702,14 +574,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -742,6 +606,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config21.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config21.json index 8e3042e3393c..b4a5ef2ef2d6 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config21.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config21.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -527,62 +455,6 @@ "insertText": "TestStream1", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "new()", "kind": "Function", @@ -702,14 +574,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -742,6 +606,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config22.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config22.json index b43046008cfa..934c0d33adbb 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config22.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config22.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -490,62 +418,6 @@ "insertText": "MyType", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "arg2 = ...", "kind": "Snippet", @@ -669,14 +541,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -709,6 +573,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config23.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config23.json index 932306090b20..4adba7d1a49e 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config23.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config23.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -490,62 +418,6 @@ "insertText": "MyType", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "arg2 = ...", "kind": "Snippet", @@ -669,14 +541,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -709,6 +573,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config24.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config24.json index a067e8130460..afbed46b971c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config24.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config24.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -490,62 +418,6 @@ "insertText": "MyType", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -651,14 +523,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -691,6 +555,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config25.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config25.json index 000e7de3091c..f6d9868aa57f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config25.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config25.json @@ -245,54 +245,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -317,14 +269,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -341,22 +285,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -587,62 +515,6 @@ "insertText": "cls", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "a = ...", "kind": "Snippet", @@ -685,14 +557,6 @@ "insertText": "MyType", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -725,6 +589,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config26.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config26.json index 11e09032fe8d..4e23d37f389c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config26.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config26.json @@ -245,54 +245,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -317,14 +269,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -341,22 +285,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -611,62 +539,6 @@ "insertText": "testNew()", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "a = ...", "kind": "Snippet", @@ -685,14 +557,6 @@ "insertText": "b = ${1:0}", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -725,6 +589,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config3.json index addb5aa4cbfd..a93cdeb7eba6 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config3.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -526,62 +454,6 @@ "insertText": "obj2", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "new()", "kind": "Function", @@ -701,14 +573,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -741,6 +605,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config4.json index 7521fe6f056d..722f878f120f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config4.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -526,62 +454,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "new(int field1, int field2)", "kind": "Function", @@ -705,14 +577,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -745,6 +609,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config5.json index d4e328ea19a8..821d431bd86e 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config5.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -511,62 +439,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "new(int field1, int field2)", "kind": "Function", @@ -690,14 +562,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -730,6 +594,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config6.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config6.json index 1779d00a996d..33a3b16f7e77 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config6.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -511,62 +439,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "new(int field1, int field2)", "kind": "Function", @@ -690,14 +562,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -730,6 +594,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/object_constructor_expr_ctx_config9.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/object_constructor_expr_ctx_config9.json index eadd33b5b543..fe2f3a7801d9 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/object_constructor_expr_ctx_config9.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/object_constructor_expr_ctx_config9.json @@ -110,54 +110,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -182,14 +134,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -206,22 +150,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -457,62 +385,6 @@ "insertText": "testFunctionWithReturn2()", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.value", "kind": "Module", @@ -658,14 +530,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -698,6 +562,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/trap_expression_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/trap_expression_ctx_config1.json index 909ccf644203..db3a17e2bc7a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/trap_expression_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/trap_expression_ctx_config1.json @@ -146,54 +146,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -218,14 +170,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -242,22 +186,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -502,62 +430,6 @@ "insertText": "testVar", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.value", "kind": "Module", @@ -687,14 +559,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -727,6 +591,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/trap_expression_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/trap_expression_ctx_config2.json index 27e5f68ea5b2..9c37153e4c86 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/trap_expression_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/trap_expression_ctx_config2.json @@ -146,54 +146,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -218,14 +170,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -242,22 +186,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -494,62 +422,6 @@ "insertText": "Record1", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.value", "kind": "Module", @@ -679,14 +551,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -719,6 +583,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/type_test_expression_ctx_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/type_test_expression_ctx_config5.json index 1a27a141140d..6ffe93924e1d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/type_test_expression_ctx_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/type_test_expression_ctx_config5.json @@ -142,54 +142,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -214,14 +166,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -238,22 +182,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -467,62 +395,6 @@ "insertText": "testVar", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -628,14 +500,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "BG", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -668,6 +532,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BBN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BBL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BBN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BBN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BBN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BBN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BBN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BBN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BBN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BBN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BBN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BBN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "ABN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BBN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BBN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BBN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BBN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typecast_expr_ctx_config6.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typecast_expr_ctx_config6.json index 42a23c170806..2a0f03444f78 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typecast_expr_ctx_config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typecast_expr_ctx_config6.json @@ -146,54 +146,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -218,14 +170,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -242,22 +186,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -495,62 +423,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.value", "kind": "Module", @@ -680,14 +552,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -720,6 +584,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typeof_expression_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typeof_expression_ctx_config1.json index ac98bc0c9bb3..08fe8ef9cb08 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typeof_expression_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typeof_expression_ctx_config1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -474,62 +402,6 @@ "insertText": "Record1", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -635,14 +507,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -675,6 +539,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typeof_expression_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typeof_expression_ctx_config2.json index 5340d03f8d69..98f7a3c4424b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typeof_expression_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/typeof_expression_ctx_config2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -474,62 +402,6 @@ "insertText": "Record1", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -635,14 +507,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -675,6 +539,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config5.json index f4d624a84bf3..5c7aea5575e0 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config5.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -525,62 +453,6 @@ "insertText": "testFunction()", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -686,14 +558,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -726,6 +590,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config6.json b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config6.json index e364150356e4..b54b25603769 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config6.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -525,62 +453,6 @@ "insertText": "testFunction()", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -686,14 +558,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -726,6 +590,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config7.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config7.json index 6b7c7f3a144b..9e4a648f83bf 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config7.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -538,62 +466,6 @@ "insertText": "Currency", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "'to", "kind": "Variable", @@ -707,14 +579,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -747,6 +611,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config9.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config9.json index fcde4084f426..d4e95fc4d79b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config9.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config9.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -553,62 +481,6 @@ "command": "editor.action.triggerParameterHints" } }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -714,14 +586,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -754,6 +618,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config14.json b/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config14.json index df8732f0c4c3..8824a717b0c2 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config14.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config14.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -545,62 +473,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -706,14 +578,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -746,6 +610,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config15.json b/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config15.json index c8dee54156c1..148b0803ec49 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config15.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config15.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -530,62 +458,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -691,14 +563,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -731,6 +595,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config23.json b/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config23.json index 7536d73aaf7d..c8493da2b350 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config23.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_def/config/config23.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "projectls.mod1", "kind": "Module", @@ -601,62 +529,6 @@ "insertText": "myStr", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -762,14 +634,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -802,6 +666,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config10.json b/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config10.json index 636f48b3decd..c923a5e4086b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config10.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config10.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -479,62 +407,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "a", "kind": "Variable", @@ -663,14 +535,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -703,6 +567,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config11.json b/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config11.json index a514e5027d84..0e134a0a0017 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config11.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config11.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -479,62 +407,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "a", "kind": "Variable", @@ -663,14 +535,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -703,6 +567,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config13.json b/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config13.json index 344b0e3a2637..14f0e05a94d7 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config13.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config13.json @@ -125,54 +125,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -197,14 +149,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -221,22 +165,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "function", "kind": "Keyword", @@ -292,62 +220,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.test", "kind": "Module", @@ -647,14 +519,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -687,6 +551,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config2.json index 9c927a7ae258..58ea999a0bc0 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config2.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -487,62 +415,6 @@ "insertText": "x", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "start", "kind": "Keyword", @@ -675,14 +547,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -715,6 +579,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config3.json index 1aacd806bed9..0d097c17b59e 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config3.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -487,62 +415,6 @@ "insertText": "x", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "start", "kind": "Keyword", @@ -683,14 +555,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -723,6 +587,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config4.json index a086c9a9aa92..ce66dd6b391d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config4.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -487,62 +415,6 @@ "insertText": "x", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "x2", "kind": "Variable", @@ -647,14 +519,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -687,6 +551,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config7.json b/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config7.json index a3eb24bb50dc..246e74d44477 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config7.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -523,62 +451,6 @@ "insertText": "x", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "x2", "kind": "Variable", @@ -683,14 +555,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -723,6 +587,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config9.json b/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config9.json index ca9a4dac5165..f4452da0e1af 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config9.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/let_expression_context/config/let_expr_ctx_config9.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -523,62 +451,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "x1", "kind": "Variable", @@ -691,14 +563,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -731,6 +595,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_client_keyword.json b/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_client_keyword.json index f3835a3bc643..0b93d724f2c7 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_client_keyword.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_client_keyword.json @@ -9,7 +9,7 @@ "label": "import", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "import", "insertText": "import ", "insertTextFormat": "Snippet" @@ -18,7 +18,7 @@ "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +27,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +36,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +45,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +54,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +63,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +72,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +81,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +90,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +99,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +108,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +117,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +126,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +135,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +144,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +153,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +162,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +171,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +180,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +189,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +198,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +207,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +216,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +225,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +234,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +243,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +252,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -261,7 +261,7 @@ "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -270,7 +270,7 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, @@ -281,79 +281,15 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -362,7 +298,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -371,7 +307,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -380,7 +316,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -389,7 +325,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -398,7 +334,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -407,7 +343,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -416,7 +352,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -425,7 +361,7 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" @@ -434,7 +370,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -458,7 +394,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -482,7 +418,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -506,7 +442,7 @@ "label": "ballerina/module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet", @@ -530,7 +466,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -554,7 +490,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -578,7 +514,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -602,7 +538,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -626,7 +562,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -650,7 +586,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -670,62 +606,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -750,14 +630,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -774,27 +646,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -818,7 +674,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -842,7 +698,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -866,10 +722,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config1.json b/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config1.json index 6cf61872b40d..73099342b0db 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config1.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -472,62 +400,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "testClient", "kind": "Variable", @@ -659,14 +531,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -699,6 +563,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config2.json b/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config2.json index 623cd9fcdd86..b776b8dbf283 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config2.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -472,62 +400,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "testClient", "kind": "Variable", @@ -659,14 +531,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -699,6 +563,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config3.json b/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config3.json index fcac7c145f06..f6fd9b67f05c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config3.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -495,62 +423,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -656,14 +528,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -696,6 +560,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config4.json b/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config4.json index 39a4d94e86f9..01d060eefe83 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config4.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -510,62 +438,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -671,14 +543,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -711,6 +575,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config5.json b/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config5.json index f14080be9038..d33e207a446b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config5.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -480,62 +408,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "new(string url)", "kind": "Function", @@ -659,14 +531,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -699,6 +563,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config6.json b/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config6.json index 034fe4aec8e9..3d334d4df874 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_var_context/config/config6.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -495,62 +423,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "new(string url)", "kind": "Function", @@ -674,14 +546,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -714,6 +578,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/performance_completion/config/performance_completion.json b/language-server/modules/langserver-core/src/test/resources/completion/performance_completion/config/performance_completion.json index d5b28dcd7aa1..6e92090777f1 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/performance_completion/config/performance_completion.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/performance_completion/config/performance_completion.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -503,62 +431,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -664,14 +536,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -704,6 +568,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config14.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config14.json index 11d8c0cee504..b59bce389093 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config14.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config14.json @@ -86,54 +86,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -158,14 +110,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -182,22 +126,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -438,62 +366,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.value", "kind": "Module", @@ -647,14 +519,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -687,6 +551,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config22.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config22.json index 47a1e5aa241f..e351193224c0 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config22.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config22.json @@ -152,54 +152,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -224,14 +176,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -248,22 +192,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -508,62 +436,6 @@ "insertText": "ratio", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -660,14 +532,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -700,6 +564,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config23.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config23.json index 9ad9fda3bb29..c3a46720d5f0 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config23.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config23.json @@ -152,54 +152,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -224,14 +176,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -248,22 +192,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -508,62 +436,6 @@ "insertText": "ratio", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -660,14 +532,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -700,6 +564,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config25.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config25.json index 5c14f3f220c1..10e211e2adfd 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config25.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config25.json @@ -152,54 +152,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -224,14 +176,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -248,22 +192,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -492,62 +420,6 @@ "insertText": "listResult", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -644,14 +516,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -684,6 +548,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config26.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config26.json index 1cd31e46ad79..105dcc02ea7c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config26.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config26.json @@ -152,54 +152,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -224,14 +176,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -248,22 +192,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -492,62 +420,6 @@ "insertText": "listResult", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -644,14 +516,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -684,6 +548,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config29.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config29.json index eba4d56471fc..b54d6e05ae7d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config29.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config29.json @@ -158,54 +158,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -230,14 +182,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -254,22 +198,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -545,62 +473,6 @@ "insertText": "tsvStream", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -697,14 +569,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -737,6 +601,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "AL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config30.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config30.json index c0db3edb1f4e..9049c08c507d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config30.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_config30.json @@ -158,54 +158,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -230,14 +182,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -254,22 +198,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -460,62 +388,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -714,14 +586,6 @@ "insertText": "customerStrArray", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -754,6 +618,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config7.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config7.json index b0a228d81a44..40bc7ae68de9 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config7.json @@ -245,62 +245,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -325,14 +269,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -349,22 +285,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -596,93 +516,173 @@ "insertTextFormat": "Snippet" }, { - "label": "readonly", - "kind": "Unit", - "detail": "type", + "label": "ballerina/lang.regexp", + "kind": "Module", + "detail": "Module", "sortText": "CR", + "filterText": "regexp", + "insertText": "regexp", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.regexp;\n" + } + ] + }, + { + "label": "re ``", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "CP", + "filterText": "re ``", + "insertText": "re `${1}`", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CN", "insertText": "readonly", "insertTextFormat": "Snippet" }, { "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "CR", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CN", "insertText": "handle", "insertTextFormat": "Snippet" }, { "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "CR", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CN", "insertText": "never", "insertTextFormat": "Snippet" }, { "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "CR", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CN", "insertText": "json", "insertTextFormat": "Snippet" }, { "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "CR", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CN", "insertText": "anydata", "insertTextFormat": "Snippet" }, { "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "CR", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CN", "insertText": "any", "insertTextFormat": "Snippet" }, { "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "CR", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CN", "insertText": "byte", "insertTextFormat": "Snippet" - }, - { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", - "sortText": "CR", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] - }, - { - "label": "re ``", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "CP", - "filterText": "re ``", - "insertText": "re `${1}`", - "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config8.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config8.json index 2c25374d036b..c51de8c45628 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_from_clause_config8.json @@ -245,62 +245,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -325,14 +269,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -349,22 +285,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -596,93 +516,173 @@ "insertTextFormat": "Snippet" }, { - "label": "readonly", - "kind": "Unit", - "detail": "type", + "label": "ballerina/lang.regexp", + "kind": "Module", + "detail": "Module", "sortText": "CR", + "filterText": "regexp", + "insertText": "regexp", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.regexp;\n" + } + ] + }, + { + "label": "re ``", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "CP", + "filterText": "re ``", + "insertText": "re `${1}`", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CN", "insertText": "readonly", "insertTextFormat": "Snippet" }, { "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "CR", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CN", "insertText": "handle", "insertTextFormat": "Snippet" }, { "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "CR", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CN", "insertText": "never", "insertTextFormat": "Snippet" }, { "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "CR", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CN", "insertText": "json", "insertTextFormat": "Snippet" }, { "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "CR", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CN", "insertText": "anydata", "insertTextFormat": "Snippet" }, { "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "CR", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CN", "insertText": "any", "insertTextFormat": "Snippet" }, { "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "CR", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CN", "insertText": "byte", "insertTextFormat": "Snippet" - }, - { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", - "sortText": "CR", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] - }, - { - "label": "re ``", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "CP", - "filterText": "re ``", - "insertText": "re `${1}`", - "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_join_clause_config12.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_join_clause_config12.json index 2dd917e35aa4..0298f7fb256f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_join_clause_config12.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_join_clause_config12.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -547,62 +475,6 @@ "insertText": "c2", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -708,14 +580,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -748,6 +612,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_join_clause_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_join_clause_config5.json index 000a328e3103..15ffa46abdf7 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_join_clause_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_join_clause_config5.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -547,62 +475,6 @@ "insertText": "c2", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -708,14 +580,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -748,6 +612,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config11.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config11.json index b1e1102e4e49..8fc731b7d103 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config11.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config11.json @@ -110,54 +110,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -182,14 +134,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -206,22 +150,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -523,62 +451,6 @@ "insertText": "c2", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.test", "kind": "Module", @@ -708,14 +580,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -748,6 +612,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config4.json index 36216cf96a28..8ec6d7e972c6 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config4.json @@ -110,54 +110,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -182,14 +134,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -206,22 +150,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -523,62 +451,6 @@ "insertText": "c2", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.test", "kind": "Module", @@ -708,14 +580,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -748,6 +612,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config5.json index c68359615692..057d5587918b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_let_clause_config5.json @@ -110,54 +110,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -182,14 +134,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -206,22 +150,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -523,62 +451,6 @@ "insertText": "c2", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.test", "kind": "Module", @@ -708,14 +580,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -748,6 +612,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_limit_clause_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_limit_clause_config1.json index f237fa928b09..b54cb22ce471 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_limit_clause_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_limit_clause_config1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -539,62 +467,6 @@ "insertText": "c2", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -700,14 +572,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -740,6 +604,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_limit_clause_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_limit_clause_config2.json index 296f38def965..b09da189844c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_limit_clause_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_limit_clause_config2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -539,62 +467,6 @@ "insertText": "c2", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -700,14 +572,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -740,6 +604,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_limit_clause_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_limit_clause_config4.json index 635c1bcc09dd..a37b74f37f4c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_limit_clause_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_limit_clause_config4.json @@ -230,62 +230,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -310,14 +254,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -334,22 +270,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -619,62 +539,6 @@ "insertText": "alimit", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "funcString()", "kind": "Function", @@ -751,6 +615,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_onconflict_clause_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_onconflict_clause_config2.json index cfb4c8acf201..31139ee8ae63 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_onconflict_clause_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_onconflict_clause_config2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -515,62 +443,6 @@ "insertText": "p2", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -676,14 +548,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -716,6 +580,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_orderby_clause_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_orderby_clause_config1.json index 6ac968e0dd26..cd27454fa0a9 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_orderby_clause_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_orderby_clause_config1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -547,62 +475,6 @@ "insertText": "c2", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -708,14 +580,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -748,6 +612,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_orderby_clause_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_orderby_clause_config2.json index 333de9c946f8..252f586d2201 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_orderby_clause_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_orderby_clause_config2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -547,62 +475,6 @@ "insertText": "c2", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -708,14 +580,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -748,6 +612,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_orderby_clause_config7.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_orderby_clause_config7.json index b4e7ad12e423..dee2385aa2be 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_orderby_clause_config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_orderby_clause_config7.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -491,62 +419,6 @@ "insertText": "myMap", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -643,14 +515,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -683,6 +547,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_orderby_clause_config8.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_orderby_clause_config8.json index 8444f22db203..a4833af1d623 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_orderby_clause_config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_orderby_clause_config8.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -483,62 +411,6 @@ "insertText": "myMap", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "p2", "kind": "Variable", @@ -715,14 +587,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -755,6 +619,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_orderby_clause_config9.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_orderby_clause_config9.json index 8a3bb406b71b..81a9da172f6a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_orderby_clause_config9.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_orderby_clause_config9.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -483,62 +411,6 @@ "insertText": "myMap", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "p2", "kind": "Variable", @@ -747,14 +619,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -787,6 +651,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_select_clause_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_select_clause_config1.json index e301f841bfa7..5664a7e15331 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_select_clause_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_select_clause_config1.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -531,62 +459,6 @@ "insertText": "p2", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "on conflict", "kind": "Snippet", @@ -701,14 +573,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -741,6 +605,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_select_clause_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_select_clause_config2.json index 605e9a4d986d..ab4d3ea28cd6 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_select_clause_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_select_clause_config2.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -531,62 +459,6 @@ "insertText": "p2", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "on conflict", "kind": "Snippet", @@ -701,14 +573,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -741,6 +605,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_select_clause_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_select_clause_config5.json index e76373826944..964829080251 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_select_clause_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_select_clause_config5.json @@ -167,54 +167,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -239,14 +191,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -263,22 +207,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -460,62 +388,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "CustomerTable", "kind": "TypeParameter", @@ -714,14 +586,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -754,6 +618,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_where_clause_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_where_clause_config1.json index 95c474a00baa..91b1f308a389 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_where_clause_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_where_clause_config1.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -514,62 +442,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -675,14 +547,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -715,6 +579,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_where_clause_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_where_clause_config3.json index bf7ecc9e7943..b3fde6017107 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_where_clause_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_where_clause_config3.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -514,62 +442,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -683,14 +555,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -723,6 +587,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_where_clause_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_where_clause_config5.json index 77a837c8f74d..d315f9adba75 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_where_clause_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_where_clause_config5.json @@ -158,54 +158,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -230,14 +182,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -254,22 +198,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -595,62 +523,6 @@ "insertText": "recType", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -771,14 +643,6 @@ "insertText": "function (int[] a) returns int {\n return 0;\n}", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "BR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -811,6 +675,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config5.json b/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config5.json index 74cd097f0941..a6de503a2225 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config5.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -577,62 +505,6 @@ "insertText": "STRING_VAL", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "new(string url)", "kind": "Function", @@ -756,14 +628,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -796,6 +660,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config6.json b/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config6.json index 4d06d0ab3498..bf80b01caa1c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config6.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -577,62 +505,6 @@ "insertText": "STRING_VAL", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "new(string url)", "kind": "Function", @@ -756,14 +628,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -796,6 +660,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config7.json b/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config7.json index 332214532fbd..d88fa11a3e2f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config7.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -577,62 +505,6 @@ "insertText": "STRING_VAL", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -738,14 +610,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -778,6 +642,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config8.json b/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config8.json index 7cbedc7d8581..c0beb112b0fb 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/record_type_desc/config/config8.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -577,62 +505,6 @@ "insertText": "STRING_VAL", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -738,14 +610,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -778,6 +642,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config12.json b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config12.json index e33694c0ff65..a178dc67eb71 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config12.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config12.json @@ -110,54 +110,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -182,14 +134,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -206,22 +150,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -443,62 +371,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -628,14 +500,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -668,6 +532,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config17.json b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config17.json index df6918c7c3ec..04268e464277 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config17.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config17.json @@ -5,20 +5,11 @@ }, "source": "service_decl/source/source17.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,7 +263,7 @@ "label": "TestObject", "kind": "Interface", "detail": "Object", - "sortText": "D", + "sortText": "CA", "insertText": "TestObject", "insertTextFormat": "Snippet" }, @@ -280,79 +271,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -361,7 +288,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -370,7 +297,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -379,7 +306,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -388,7 +315,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -397,7 +324,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -406,7 +333,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -415,7 +342,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -424,7 +351,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -433,7 +360,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -457,7 +384,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -481,7 +408,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -505,7 +432,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -529,7 +456,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -549,54 +476,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -621,14 +500,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -645,27 +516,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -675,7 +530,7 @@ "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -699,7 +554,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -723,7 +578,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -747,7 +602,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -771,7 +626,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -795,24 +650,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -821,7 +668,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -845,10 +692,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config18.json b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config18.json index 0a49f7291aa7..4b0177ee55f1 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config18.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config18.json @@ -5,20 +5,11 @@ }, "source": "service_decl/source/source18.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,7 +263,7 @@ "label": "TestObject", "kind": "Interface", "detail": "Object", - "sortText": "D", + "sortText": "CA", "insertText": "TestObject", "insertTextFormat": "Snippet" }, @@ -280,79 +271,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -361,7 +288,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -370,7 +297,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -379,7 +306,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -388,7 +315,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -397,7 +324,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -406,7 +333,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -415,7 +342,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -424,7 +351,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -433,7 +360,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -457,7 +384,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -481,7 +408,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -505,7 +432,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -529,7 +456,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -549,54 +476,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -621,14 +500,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -645,27 +516,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -675,7 +530,7 @@ "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -699,7 +554,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -723,7 +578,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -747,7 +602,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -771,7 +626,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -795,24 +650,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -821,7 +668,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -845,10 +692,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config7.json b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config7.json index 3cd556977a3c..235607dc30ac 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config7.json @@ -5,20 +5,11 @@ }, "source": "service_decl/source/source7.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,7 +263,7 @@ "label": "TestObject", "kind": "Interface", "detail": "Object", - "sortText": "D", + "sortText": "CA", "insertText": "TestObject", "insertTextFormat": "Snippet" }, @@ -280,79 +271,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -361,7 +288,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -370,7 +297,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -379,7 +306,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -388,7 +315,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -397,7 +324,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -406,7 +333,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -415,7 +342,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -424,7 +351,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -433,7 +360,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -457,7 +384,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -481,7 +408,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -505,7 +432,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -529,7 +456,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -549,54 +476,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -621,14 +500,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -645,27 +516,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -675,7 +530,7 @@ "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -699,7 +554,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -723,7 +578,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -747,7 +602,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -771,7 +626,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -795,24 +650,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "client", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "client", "insertText": "client \"${1}\" as ${2:clientName};", "insertTextFormat": "Snippet" @@ -821,7 +668,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -845,10 +692,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config1.json index d5b28dcd7aa1..6e92090777f1 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config1.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -503,62 +431,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -664,14 +536,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -704,6 +568,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config10.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config10.json index 307a7c6fe88d..55eb49afc458 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config10.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config10.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -588,62 +516,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "func", "kind": "Variable", @@ -757,14 +629,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -797,6 +661,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config11.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config11.json index 3e0229800297..826310756957 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config11.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config11.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -596,62 +524,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "func", "kind": "Variable", @@ -765,14 +637,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -805,6 +669,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config2.json index d3d69c78e6e7..da0f916232a0 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config2.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -503,62 +431,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -664,14 +536,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -704,6 +568,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config3.json index b713ccd1eb1a..6def5acefd29 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config3.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -503,62 +431,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "new(int field1, int field2)", "kind": "Function", @@ -682,14 +554,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -722,6 +586,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config6.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config6.json index ef27c3a7ca3d..801181c69a24 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config6.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -571,62 +499,6 @@ "insertText": "getString()", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "new()", "kind": "Function", @@ -746,14 +618,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -786,6 +650,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config7.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config7.json index f955fdc3c82a..3fb7d8edbc56 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config7.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -579,62 +507,6 @@ "insertText": "getString()", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -740,14 +612,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -780,6 +644,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config8.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config8.json index 3d6abc1daf09..fff75ad187e0 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config8.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -510,62 +438,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "new(int field1, int field2)", "kind": "Function", @@ -689,14 +561,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -729,6 +593,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "DN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "DL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "DN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "DN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "DN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "DN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "DN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "DN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "DN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "DN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "DN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "DN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "DN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "DN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "DN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "DN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "DN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config9.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config9.json index 6d13c3a3dcc7..cca98cb069fd 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config9.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/assignment_stmt_ctx_config9.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -512,62 +440,6 @@ "insertText": "ProxyClient", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "new(string url)", "kind": "Function", @@ -691,14 +563,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -731,6 +595,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/checking_call_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/checking_call_stmt_ctx_config1.json index 1dcc615772c1..0456dff15605 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/checking_call_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/checking_call_stmt_ctx_config1.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -517,62 +445,6 @@ "insertText": "testFunction()", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "commit", "kind": "Snippet", @@ -687,14 +559,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -727,6 +591,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "DN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "DL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "DN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "DN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "DN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "DN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "DN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "DN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "DN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "DN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "DN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "DN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "DN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "DN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "DN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "DN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "DN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/checking_call_stmt_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/checking_call_stmt_ctx_config2.json index 50b199dd4dee..644b1c5d6dad 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/checking_call_stmt_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/checking_call_stmt_ctx_config2.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -517,62 +445,6 @@ "insertText": "testFunction()", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "commit", "kind": "Snippet", @@ -687,14 +559,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -727,6 +591,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "DN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "DL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "DN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "DN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "DN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "DN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "DN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "DN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "DN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "DN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "DN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "DN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "DN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "DN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "DN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "DN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "DN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config4.json index 515da3d0025c..1bda5fea6f48 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config4.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -489,62 +417,6 @@ "insertText": "testFunction()", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -650,14 +522,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -690,6 +554,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config5.json index 385959f1bc74..c0b8df599cf6 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config5.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -489,62 +417,6 @@ "insertText": "testFunction()", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -650,14 +522,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -690,6 +554,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config6.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config6.json index b7f93f7bd73f..04c98ccc9e08 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config6.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -489,62 +417,6 @@ "insertText": "testFunction()", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -650,14 +522,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -690,6 +554,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/fail_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/fail_stmt_ctx_config1.json index a375391e9e7d..dba6e1fdc0f0 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/fail_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/fail_stmt_ctx_config1.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -491,62 +419,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "getIntOrError()", "kind": "Function", @@ -673,14 +545,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -713,6 +577,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "C", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "A", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "C", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "C", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "C", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "C", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "C", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "C", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "C", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "C", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "C", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "C", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "C", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "C", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "C", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "C", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "C", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/fail_stmt_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/fail_stmt_ctx_config2.json index 78eea79d626b..4b984e6cb092 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/fail_stmt_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/fail_stmt_ctx_config2.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -523,62 +451,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -675,14 +547,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "C", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -715,6 +579,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "C", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "A", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "C", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "C", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "C", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "C", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "C", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "C", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "C", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "C", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "C", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "C", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "C", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "C", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "C", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "C", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "C", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config12.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config12.json index 4b1e020cf2cb..a61c47e081ff 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config12.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config12.json @@ -245,62 +245,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -325,14 +269,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -349,22 +285,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -610,94 +530,174 @@ "insertText": "testFunction()", "insertTextFormat": "Snippet" }, + { + "label": "ballerina/lang.regexp", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "regexp", + "insertText": "regexp", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.regexp;\n" + } + ] + }, + { + "label": "re ``", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "T", + "filterText": "re ``", + "insertText": "re `${1}`", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, { "label": "readonly", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Readonly", "sortText": "R", "insertText": "readonly", "insertTextFormat": "Snippet" }, { "label": "handle", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Handle", "sortText": "R", "insertText": "handle", "insertTextFormat": "Snippet" }, { "label": "never", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Never", "sortText": "R", "insertText": "never", "insertTextFormat": "Snippet" }, { "label": "json", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Json", "sortText": "R", "insertText": "json", "insertTextFormat": "Snippet" }, { "label": "anydata", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Anydata", "sortText": "R", "insertText": "anydata", "insertTextFormat": "Snippet" }, { "label": "any", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Any", "sortText": "R", "insertText": "any", "insertTextFormat": "Snippet" }, { "label": "byte", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Byte", "sortText": "R", "insertText": "byte", "insertTextFormat": "Snippet" - }, - { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] - }, - { - "label": "re ``", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "T", - "filterText": "re ``", - "insertText": "re `${1}`", - "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config3.json index c85ab9473089..cc21fda3b27d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config3.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -481,62 +409,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -642,14 +514,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -682,6 +546,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config4.json index 139050ecf9aa..1495f0372bb0 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config4.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -481,62 +409,6 @@ "insertText": "testFunction()", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -642,14 +514,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -682,6 +546,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config5.json index 99206a0f0a5a..cc23c4281140 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config5.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -481,62 +409,6 @@ "insertText": "testFunction()", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -642,14 +514,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -682,6 +546,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config6.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config6.json index f0108ee296f4..0553fa7477ab 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config6.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -481,62 +409,6 @@ "insertText": "testFunction()", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -642,14 +514,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -682,6 +546,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/lock_stmt_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/lock_stmt_ctx_config2.json index d3a25c122916..8eff5a8ec762 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/lock_stmt_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/lock_stmt_ctx_config2.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -526,62 +454,6 @@ "insertText": "testFunction()", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -687,14 +559,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -727,6 +591,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config1.json index 87c06998881c..b042e7eca594 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config1.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -546,62 +474,6 @@ "insertText": "var5", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -707,14 +579,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -747,6 +611,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config13.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config13.json index 3935f48eabd2..61f52fafd0c9 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config13.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config13.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -513,62 +441,6 @@ "insertText": "main()", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -665,14 +537,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -705,6 +569,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config2.json index 7676bd2282a8..49e542922de0 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config2.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -531,62 +459,6 @@ "insertText": "var5", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -692,14 +564,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -732,6 +596,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config20.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config20.json index 9de98cf1a2e4..e8efaeaf3036 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config20.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config20.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -445,62 +373,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "E2", "kind": "EnumMember", @@ -668,14 +540,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -708,6 +572,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config21.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config21.json index 3bf9e4b0f938..a30571bcd264 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config21.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config21.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -445,62 +373,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "E2", "kind": "EnumMember", @@ -668,14 +540,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -708,6 +572,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config22.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config22.json index b930144b6047..bc61b8167bf8 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config22.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/match_stmt_ctx_config22.json @@ -134,54 +134,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -206,14 +158,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -230,22 +174,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -445,62 +373,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "E2", "kind": "EnumMember", @@ -668,14 +540,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -708,6 +572,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/panic_stmt_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/panic_stmt_ctx_config2.json index 511e4e186e55..564aaf193a90 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/panic_stmt_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/panic_stmt_ctx_config2.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "new", "kind": "Keyword", @@ -433,62 +361,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -594,14 +466,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "n", "kind": "Variable", @@ -687,6 +551,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "AL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/panic_stmt_ctx_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/panic_stmt_ctx_config3.json index 46c8daee023d..b88c2d9c4837 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/panic_stmt_ctx_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/panic_stmt_ctx_config3.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "new", "kind": "Keyword", @@ -433,62 +361,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -594,14 +466,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "n", "kind": "Variable", @@ -711,6 +575,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "AL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/transaction_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/transaction_config2.json index 3954a5b203ae..d387d5e095c1 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/transaction_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/transaction_config2.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -510,62 +438,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "commit", "kind": "Snippet", @@ -680,14 +552,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -720,6 +584,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "DN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "DL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "DN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "DN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "DN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "DN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "DN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "DN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "DN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "DN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "DN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "DN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "DN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "DN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "DN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "DN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "DN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/transaction_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/transaction_config3.json index 161046dfc057..cc4d50df6d48 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/transaction_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/transaction_config3.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -510,62 +438,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "commit", "kind": "Snippet", @@ -680,14 +552,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -720,6 +584,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "DN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "DL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "DN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "DN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "DN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "DN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "DN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "DN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "DN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "DN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "DN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "DN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "DN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "DN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "DN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "DN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "DN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config3.json index a91d1a1baf71..785ab079130a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config3.json @@ -187,54 +187,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -259,14 +211,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -283,22 +227,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "true", "kind": "Keyword", @@ -498,62 +426,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -650,14 +522,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -690,6 +554,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config4.json index 8ab1e68bf2b3..2322c325b905 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config4.json @@ -187,54 +187,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -259,14 +211,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -283,22 +227,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "true", "kind": "Keyword", @@ -498,62 +426,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -650,14 +522,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -690,6 +554,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config5.json index de3f7e3e637f..b70152085c64 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config5.json @@ -187,54 +187,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -259,14 +211,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -283,22 +227,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "true", "kind": "Keyword", @@ -498,62 +426,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -650,14 +522,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -690,6 +554,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config6.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config6.json index 2582eb85eef9..8de580e805a9 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config6.json @@ -187,54 +187,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -259,14 +211,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -283,22 +227,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "true", "kind": "Keyword", @@ -498,62 +426,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -650,14 +522,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -690,6 +554,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config8.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config8.json index c90e8f7526b9..fc9a2cb68746 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config8.json @@ -245,62 +245,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -325,14 +269,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -349,22 +285,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -610,94 +530,174 @@ "insertText": "testFunction()", "insertTextFormat": "Snippet" }, + { + "label": "ballerina/lang.regexp", + "kind": "Module", + "detail": "Module", + "sortText": "R", + "filterText": "regexp", + "insertText": "regexp", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.regexp;\n" + } + ] + }, + { + "label": "re ``", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "T", + "filterText": "re ``", + "insertText": "re `${1}`", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, { "label": "readonly", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Readonly", "sortText": "R", "insertText": "readonly", "insertTextFormat": "Snippet" }, { "label": "handle", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Handle", "sortText": "R", "insertText": "handle", "insertTextFormat": "Snippet" }, { "label": "never", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Never", "sortText": "R", "insertText": "never", "insertTextFormat": "Snippet" }, { "label": "json", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Json", "sortText": "R", "insertText": "json", "insertTextFormat": "Snippet" }, { "label": "anydata", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Anydata", "sortText": "R", "insertText": "anydata", "insertTextFormat": "Snippet" }, { "label": "any", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Any", "sortText": "R", "insertText": "any", "insertTextFormat": "Snippet" }, { "label": "byte", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Byte", "sortText": "R", "insertText": "byte", "insertTextFormat": "Snippet" - }, - { - "label": "ballerina/lang.regexp", - "kind": "Module", - "detail": "Module", - "sortText": "R", - "filterText": "regexp", - "insertText": "regexp", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/lang.regexp;\n" - } - ] - }, - { - "label": "re ``", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "T", - "filterText": "re ``", - "insertText": "re `${1}`", - "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/regex_template_expression_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/regex_template_expression_config1.json index e303aa3374ea..92fca24b4ca7 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/regex_template_expression_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/regex_template_expression_config1.json @@ -305,22 +305,6 @@ } ] }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, { "label": "object", "kind": "Unit", @@ -337,14 +321,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -369,62 +345,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -656,58 +576,138 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, { "label": "readonly", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Readonly", "sortText": "R", "insertText": "readonly", "insertTextFormat": "Snippet" }, { "label": "handle", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Handle", "sortText": "R", "insertText": "handle", "insertTextFormat": "Snippet" }, { "label": "never", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Never", "sortText": "R", "insertText": "never", "insertTextFormat": "Snippet" }, { "label": "json", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Json", "sortText": "R", "insertText": "json", "insertTextFormat": "Snippet" }, { "label": "anydata", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Anydata", "sortText": "R", "insertText": "anydata", "insertTextFormat": "Snippet" }, { "label": "any", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Any", "sortText": "R", "insertText": "any", "insertTextFormat": "Snippet" }, { "label": "byte", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Byte", "sortText": "R", "insertText": "byte", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/regex_template_expression_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/regex_template_expression_config2.json index badd14048f32..a8fe2d371d50 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/regex_template_expression_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/regex_template_expression_config2.json @@ -305,22 +305,6 @@ } ] }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, { "label": "object", "kind": "Unit", @@ -337,14 +321,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -369,62 +345,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -656,58 +576,138 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, { "label": "readonly", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Readonly", "sortText": "R", "insertText": "readonly", "insertTextFormat": "Snippet" }, { "label": "handle", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Handle", "sortText": "R", "insertText": "handle", "insertTextFormat": "Snippet" }, { "label": "never", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Never", "sortText": "R", "insertText": "never", "insertTextFormat": "Snippet" }, { "label": "json", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Json", "sortText": "R", "insertText": "json", "insertTextFormat": "Snippet" }, { "label": "anydata", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Anydata", "sortText": "R", "insertText": "anydata", "insertTextFormat": "Snippet" }, { "label": "any", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Any", "sortText": "R", "insertText": "any", "insertTextFormat": "Snippet" }, { "label": "byte", - "kind": "Unit", - "detail": "type", + "kind": "TypeParameter", + "detail": "Byte", "sortText": "R", "insertText": "byte", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/regex_template_expression_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/regex_template_expression_config4.json index cc8e0ea1d6e2..0df8049fca9c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/regex_template_expression_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/regex_template_expression_config4.json @@ -269,22 +269,6 @@ } ] }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, { "label": "object", "kind": "Unit", @@ -301,14 +285,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -333,62 +309,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -620,62 +540,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "()", "kind": "Snippet", @@ -715,6 +579,142 @@ "sortText": "ACB", "insertText": "intVal", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "ACN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "ACL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "ACN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "ACN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "ACN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "ACN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "ACN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "ACN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "ACN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "ACN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "ACN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "ACN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "ACN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "ACN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "ACN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "ACN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "ACN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/string_template_expression_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/string_template_expression_config2.json index d6fefa3f9423..7e498028c184 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/string_template_expression_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/string_template_expression_config2.json @@ -238,54 +238,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -310,14 +262,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "transaction", "kind": "Unit", @@ -326,22 +270,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "main()", "kind": "Function", @@ -498,62 +426,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -659,14 +531,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -699,6 +563,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "AAN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "ACL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "ACN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "AAN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "ACN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "AAN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "AAN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "ACN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "AAN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "ACN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "ACN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "ACN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "ACN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "ACN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "ACN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "ACN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "ACN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/string_template_expression_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/string_template_expression_config3.json index e41182112095..bcd8471a5058 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/string_template_expression_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/string_template_expression_config3.json @@ -238,54 +238,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -310,14 +262,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "transaction", "kind": "Unit", @@ -326,22 +270,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "main()", "kind": "Function", @@ -498,62 +426,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -659,14 +531,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -699,6 +563,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "AAN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "ACL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "ACN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "AAN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "ACN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "AAN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "AAN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "ACN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "AAN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "ACN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "ACN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "ACN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "ACN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "ACN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "ACN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "ACN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "ACN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/string_template_expression_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/string_template_expression_config4.json index b2fb01b62c28..eb8b1da1e732 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/string_template_expression_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/string_template_expression_config4.json @@ -223,54 +223,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -295,14 +247,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "transaction", "kind": "Unit", @@ -311,22 +255,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "main()", "kind": "Function", @@ -537,62 +465,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -698,14 +570,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -738,6 +602,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "AAN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "ACL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "ACN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "AAN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "ACN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "AAN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "AAN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "ACN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "AAN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "ACN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "ACN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "ACN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "ACN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "ACN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "ACN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "ACN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "ACN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/string_template_expression_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/string_template_expression_config5.json index d7bee925680a..f2b910afc23a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/string_template_expression_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/string_template_expression_config5.json @@ -223,54 +223,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -295,14 +247,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "transaction", "kind": "Unit", @@ -311,22 +255,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "main()", "kind": "Function", @@ -537,62 +465,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -698,14 +570,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -738,6 +602,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "AAN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "ACL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "ACN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "AAN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "ACN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "AAN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "AAN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "ACN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "AAN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "ACN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "ACN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "ACN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "ACN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "ACN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "ACN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "ACN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "ACN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/xml_template_expression_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/xml_template_expression_config1.json index b3ccecae9d84..b3633c30ade7 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/xml_template_expression_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/xml_template_expression_config1.json @@ -223,54 +223,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -295,14 +247,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "transaction", "kind": "Unit", @@ -311,22 +255,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "main()", "kind": "Function", @@ -567,62 +495,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -728,14 +600,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -768,6 +632,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "ABN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "ACL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "AAN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "ABN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "ACN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "ABN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "ABN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "ACN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "ACN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "ACN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "ACN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "ACN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "ACN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "ACN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "ACN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "ACN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "ACN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/xml_template_expression_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/xml_template_expression_config2.json index dd3514175fee..b1779815681a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/xml_template_expression_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/template_expression/config/xml_template_expression_config2.json @@ -223,54 +223,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -295,14 +247,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "transaction", "kind": "Unit", @@ -311,22 +255,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "main()", "kind": "Function", @@ -567,62 +495,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -728,14 +600,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -768,6 +632,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "ABN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "ACL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "AAN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "ABN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "ACN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "ABN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "ABN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "ACN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "ACN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "ACN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "ACN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "ACN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "ACN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "ACN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "ACN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "ACN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "ACN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc15a.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc15a.json index 4a85f88a082c..e25f3e8cd9fc 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc15a.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc15a.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -548,62 +476,6 @@ "insertText": "TestMap2", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -709,14 +581,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -749,6 +613,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc15b.json b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc15b.json index 3b70d351e288..7f9f205f99c4 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc15b.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/typedesc_context/config/function_typedesc15b.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -548,62 +476,6 @@ "insertText": "TestMap2", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -709,14 +581,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -749,6 +613,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/project_var_def_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/project_var_def_ctx_config1.json index 4b6eac378188..874728fe922b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/project_var_def_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/project_var_def_ctx_config1.json @@ -194,54 +194,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -266,14 +218,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -290,22 +234,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -598,62 +526,6 @@ "command": "editor.action.triggerParameterHints" } }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -759,14 +631,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -799,6 +663,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/project_var_def_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/project_var_def_ctx_config2.json index 12d8c8c5cea8..361a6f4a4592 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/project_var_def_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/project_var_def_ctx_config2.json @@ -194,54 +194,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -266,14 +218,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -290,22 +234,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -606,62 +534,6 @@ "command": "editor.action.triggerParameterHints" } }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -767,14 +639,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -807,6 +671,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/project_var_def_ctx_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/project_var_def_ctx_config3.json index 1cdba9a09435..835713efe37d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/project_var_def_ctx_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/project_var_def_ctx_config3.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -565,62 +493,6 @@ "insertText": "Vehicle", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "new(string name)", "kind": "Function", @@ -744,14 +616,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -784,6 +648,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config1.json index bf5cfb5cb23e..25a4150290c4 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config1.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -510,62 +438,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -671,14 +543,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -711,6 +575,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config12.json b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config12.json index 10f7b956f663..384e0d732e57 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config12.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config12.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -518,62 +446,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "commit", "kind": "Snippet", @@ -688,14 +560,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -728,6 +592,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "AL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config13.json b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config13.json index 329ffb3c93ef..0077a6a61b37 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config13.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config13.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -592,62 +520,6 @@ "insertText": "var2", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "func", "kind": "Variable", @@ -761,14 +633,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -801,6 +665,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config14.json b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config14.json index 6a28f0327c15..b60895f82905 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config14.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config14.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -649,62 +577,6 @@ "insertText": "var2", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -819,14 +691,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -859,6 +723,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config15.json b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config15.json index 6de31be528a6..d04b4ff38fe5 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config15.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config15.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -592,62 +520,6 @@ "insertText": "var2", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "func", "kind": "Variable", @@ -761,14 +633,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -801,6 +665,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config2.json index 1b29c579a4e8..d9e1b44613fc 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config2.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -510,62 +438,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -671,14 +543,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -711,6 +575,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config20.json b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config20.json index b40711594ac9..6879e418ad20 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config20.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config20.json @@ -281,54 +281,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -353,14 +305,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -377,22 +321,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -728,62 +656,6 @@ "insertText": "getStr2()", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "function (..) {..}", "kind": "Snippet", @@ -793,14 +665,6 @@ "insertText": "function (int i) returns string {\n return \"\";\n}", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -833,6 +697,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config7.json b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config7.json index 855dc6c4ea4a..eb50c5089c8f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_config7.json @@ -170,54 +170,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -242,14 +194,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -266,22 +210,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -510,62 +438,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "new(int field1, int field2)", "kind": "Function", @@ -689,14 +561,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "DR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -729,6 +593,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "DN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "DL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "DN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "DN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "DN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "DN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "DN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "DN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "DN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "DN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "DN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "DN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "DN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "DN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "DN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "DN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "DN", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_with_escape_char_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_with_escape_char_config1.json index 13d54e8fb0d2..eea3cb5540d4 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_with_escape_char_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_ctx_with_escape_char_config1.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -519,62 +447,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "a\\\\b", "kind": "Variable", @@ -679,14 +551,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -719,6 +583,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_in_obj_constructor_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_in_obj_constructor_config1.json index eb48e003fe88..b5a6e5ec28ba 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_in_obj_constructor_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_in_obj_constructor_config1.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -566,62 +494,6 @@ "insertText": "obj", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "new()", "kind": "Function", @@ -732,14 +604,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -772,6 +636,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_with_anon_func_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_with_anon_func_config1.json index cc968f55fa9e..ee9ab1f3e76f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_with_anon_func_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_with_anon_func_config1.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -487,62 +415,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -703,14 +575,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -743,6 +607,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_with_anon_func_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_with_anon_func_config2.json index 3991b2f4b50f..f200e670a361 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_with_anon_func_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_with_anon_func_config2.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -487,62 +415,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -703,14 +575,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -743,6 +607,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_with_anon_func_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_with_anon_func_config3.json index 76a91a42b1fd..3ac511e4c4a3 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_with_anon_func_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_with_anon_func_config3.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -487,62 +415,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -695,14 +567,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -735,6 +599,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_with_anon_func_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_with_anon_func_config4.json index a746bd092cd7..2ad456f21945 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_with_anon_func_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/variable-declaration/config/var_def_with_anon_func_config4.json @@ -185,54 +185,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -257,14 +209,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -281,22 +225,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -487,62 +415,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "null", "kind": "Keyword", @@ -719,14 +591,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -759,6 +623,142 @@ "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } From b4743e0669c3eb4b1ced026742a31a4a6f6372ff Mon Sep 17 00:00:00 2001 From: malinthar Date: Fri, 2 Dec 2022 00:50:18 +0530 Subject: [PATCH 155/450] Address review suggestions --- .../providers/AbstractCompletionProvider.java | 2 +- .../util/ModulePartNodeContextUtil.java | 34 ++++++------------- .../annotation_decl/config/config21.json | 2 +- .../completion/class_def/config/config22.json | 2 +- .../enum_decl_ctx/config/config5.json | 2 +- ...ule_client_declaration_client_keyword.json | 2 +- .../module_part_context/config/config1.json | 2 +- .../module_part_context/config/config13.json | 2 +- .../module_part_context/config/config14.json | 2 +- .../module_part_context/config/config15.json | 2 +- .../config/config15_client_declaration.json | 2 +- .../module_part_context/config/config16.json | 2 +- .../module_part_context/config/config2.json | 2 +- .../module_part_context/config/config3.json | 2 +- .../module_part_context/config/config6.json | 2 +- .../module_part_context/config/config8.json | 2 +- ...le_level_after_annotation_decl_config.json | 2 +- .../module_level_after_class_defn_config.json | 2 +- .../module_level_after_const_decl_config.json | 2 +- .../module_level_after_enum_decl_config.json | 2 +- ...dule_level_after_funciton_defn_config.json | 2 +- ...module_level_after_import_decl_config.json | 2 +- ...dule_level_after_listener_decl_config.json | 2 +- ...odule_level_after_service_decl_config.json | 2 +- .../module_level_after_type_defn_config.json | 2 +- .../module_level_after_var_decl_config.json | 2 +- .../module_level_after_xmlns_decl_config.json | 2 +- ...e_level_before_annotation_decl_config.json | 2 +- ...module_level_before_class_defn_config.json | 2 +- ...module_level_before_const_decl_config.json | 2 +- .../module_level_before_enum_decl_config.json | 2 +- ...ule_level_before_function_defn_config.json | 2 +- ...odule_level_before_import_decl_config.json | 2 +- ...ule_level_before_listener_decl_config.json | 2 +- ...dule_level_before_service_decl_config.json | 2 +- .../module_level_before_type_defn_config.json | 2 +- .../module_level_before_var_decl_config.json | 2 +- ...module_level_before_xmlns_decl_config.json | 2 +- .../service_decl/config/config17.json | 2 +- .../service_decl/config/config18.json | 2 +- .../service_decl/config/config7.json | 2 +- 41 files changed, 50 insertions(+), 64 deletions(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/AbstractCompletionProvider.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/AbstractCompletionProvider.java index 69b0b19e8c83..95e7d92c0f53 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/AbstractCompletionProvider.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/AbstractCompletionProvider.java @@ -668,7 +668,7 @@ protected List getPredeclaredLangLibCompletions(BallerinaCompl return completionItems; } - protected List getInBuildTypes(BallerinaCompletionContext context) { + protected List getBuiltInTypes(BallerinaCompletionContext context) { List visibleSymbols = context.visibleSymbols(context.getCursorPosition()); List completionItems = new ArrayList<>(); visibleSymbols.stream() diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ModulePartNodeContextUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ModulePartNodeContextUtil.java index 7d652bf3fb5c..9a46d4f7122b 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ModulePartNodeContextUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ModulePartNodeContextUtil.java @@ -21,10 +21,8 @@ import io.ballerina.compiler.api.symbols.SymbolKind; import io.ballerina.compiler.api.symbols.TypeDescKind; import io.ballerina.compiler.api.symbols.TypeSymbol; -import io.ballerina.compiler.syntax.tree.FunctionDefinitionNode; import io.ballerina.compiler.syntax.tree.Minutiae; import io.ballerina.compiler.syntax.tree.ModulePartNode; -import io.ballerina.compiler.syntax.tree.NonTerminalNode; import io.ballerina.compiler.syntax.tree.SyntaxKind; import io.ballerina.compiler.syntax.tree.SyntaxTree; import io.ballerina.compiler.syntax.tree.Token; @@ -48,7 +46,6 @@ import java.util.stream.Collectors; import static org.ballerinalang.langserver.completions.util.SortingUtil.genSortText; -import static org.ballerinalang.langserver.completions.util.SortingUtil.isLangLibModuleCompletionItem; /** * Utilities for the module part node context. @@ -91,29 +88,16 @@ public static List getTopLevelItems(BallerinaCompletionContext } private static boolean isMainFunctionAvailable(BallerinaCompletionContext context) { - Optional modulePartNode = getModulePartNode(context); - if (modulePartNode.isEmpty()) { - return false; - } - return modulePartNode.get().members().stream().anyMatch(moduleMemberDeclarationNode -> - moduleMemberDeclarationNode.kind() == SyntaxKind.FUNCTION_DEFINITION - && "main".equals(((FunctionDefinitionNode) moduleMemberDeclarationNode).functionName().text())); - } - - private static Optional getModulePartNode(BallerinaCompletionContext context) { - NonTerminalNode node = context.getNodeAtCursor(); - while (node != null && node.kind() != SyntaxKind.MODULE_PART) { - node = node.parent(); - } - if (node == null) { - return Optional.empty(); - } - return Optional.of((ModulePartNode) node); + Optional modulePartNode = context.currentSyntaxTree().map(SyntaxTree::rootNode); + return modulePartNode.filter(partNode -> + context.visibleSymbols(PositionUtil.toPosition(partNode.lineRange().startLine())) + .stream().anyMatch(symbol -> symbol.kind() == SymbolKind.FUNCTION + && symbol.nameEquals("main"))).isPresent(); } private static boolean isInImportStatementsContext(BallerinaCompletionContext context) { Optional syntaxTree = context.currentSyntaxTree(); - Optional modulePartNode = getModulePartNode(context); + Optional modulePartNode = syntaxTree.map(SyntaxTree::rootNode); if (syntaxTree.isEmpty() || modulePartNode.isEmpty()) { return false; } @@ -164,7 +148,7 @@ public static void sort(List items) { continue; } if (SortingUtil.isTypeCompletionItem(item)) { - if (isLangLibModuleCompletionItem(item)) { + if (SortingUtil.isLangLibModuleCompletionItem(item)) { cItem.setSortText(genSortText(3) + genSortText(2)); continue; } @@ -172,7 +156,9 @@ public static void sort(List items) { continue; } if (isKeyword(item)) { - if (((SnippetCompletionItem) item).id().equals(Snippet.KW_SERVICE.name())) { + SnippetCompletionItem snippet = (SnippetCompletionItem) item; + if (Snippet.KW_SERVICE.name().equals(snippet.id()) + || Snippet.KW_FUNCTION.name().equals(snippet.id())) { cItem.setSortText(genSortText(1) + genSortText(4)); continue; } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_decl/config/config21.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_decl/config/config21.json index 32bbaf24c7cb..775f799c04de 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_decl/config/config21.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_decl/config/config21.json @@ -27,7 +27,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config22.json b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config22.json index 82dddeedde79..873eafa9471e 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config22.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config22.json @@ -296,7 +296,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/enum_decl_ctx/config/config5.json b/language-server/modules/langserver-core/src/test/resources/completion/enum_decl_ctx/config/config5.json index 0f7aae7b3c33..210bd38fab95 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/enum_decl_ctx/config/config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/enum_decl_ctx/config/config5.json @@ -305,7 +305,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_client_keyword.json b/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_client_keyword.json index 0b93d724f2c7..3e2713d908d5 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_client_keyword.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_client_declaration_context/config/module_client_declaration_client_keyword.json @@ -298,7 +298,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config1.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config1.json index e91e0c8744c8..82adfb4be3fa 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config1.json @@ -289,7 +289,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config13.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config13.json index e95d63a24771..123e853d87eb 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config13.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config13.json @@ -18,7 +18,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config14.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config14.json index 7f4cf92a9c90..6326f02499d9 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config14.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config14.json @@ -271,7 +271,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config15.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config15.json index 71bbe77f6834..3df848cdb5b2 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config15.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config15.json @@ -287,7 +287,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config15_client_declaration.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config15_client_declaration.json index dd6da31d81a4..e2eb866b204f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config15_client_declaration.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config15_client_declaration.json @@ -262,7 +262,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config16.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config16.json index c11d1cb7133f..f7abf5dbf4d5 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config16.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config16.json @@ -271,7 +271,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config2.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config2.json index fd371fcaba77..f654c73b145a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config2.json @@ -289,7 +289,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config3.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config3.json index 04aa16320719..d9f00f454fb5 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config3.json @@ -289,7 +289,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config6.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config6.json index fca3985d5433..a9c66da63304 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config6.json @@ -280,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config8.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config8.json index 3a679f4f2d23..bc22ca1fa38b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config8.json @@ -73,7 +73,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_annotation_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_annotation_decl_config.json index 2f374770a12a..d2070b78aa38 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_annotation_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_annotation_decl_config.json @@ -280,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_class_defn_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_class_defn_config.json index 0b4c8a25018e..8a9d62ac8f24 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_class_defn_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_class_defn_config.json @@ -280,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_const_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_const_decl_config.json index 3bb94be78e28..d05e4e2e191b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_const_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_const_decl_config.json @@ -280,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_enum_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_enum_decl_config.json index 0a20922a549d..4a51a884432d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_enum_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_enum_decl_config.json @@ -280,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_funciton_defn_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_funciton_defn_config.json index c93cf1880ecc..0387c1fd8378 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_funciton_defn_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_funciton_defn_config.json @@ -280,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_import_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_import_decl_config.json index f69185a34807..1e30bb28ea19 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_import_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_import_decl_config.json @@ -289,7 +289,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_listener_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_listener_decl_config.json index 1cb2614a25dc..9e4204ce6332 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_listener_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_listener_decl_config.json @@ -280,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_service_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_service_decl_config.json index fcc023ef4d8f..c88f7a932907 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_service_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_service_decl_config.json @@ -280,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_type_defn_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_type_defn_config.json index 931a402652c5..8ccc5e8abb64 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_type_defn_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_type_defn_config.json @@ -280,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_var_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_var_decl_config.json index 16db167387f3..c24737465fe9 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_var_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_var_decl_config.json @@ -280,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_xmlns_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_xmlns_decl_config.json index 804c7f424f3e..d428596a141b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_xmlns_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_xmlns_decl_config.json @@ -280,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_annotation_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_annotation_decl_config.json index 1983be273bc3..3bc9be9fea11 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_annotation_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_annotation_decl_config.json @@ -280,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_class_defn_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_class_defn_config.json index 96fde9eb2684..489c289272f9 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_class_defn_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_class_defn_config.json @@ -280,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_const_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_const_decl_config.json index 13f4ca0a5b84..9f0a37ec6c6b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_const_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_const_decl_config.json @@ -280,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_enum_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_enum_decl_config.json index b71af7f62b64..cbd2543ee9f7 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_enum_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_enum_decl_config.json @@ -280,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_function_defn_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_function_defn_config.json index 5ae7d7a2642e..4da70dc57228 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_function_defn_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_function_defn_config.json @@ -280,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_import_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_import_decl_config.json index d24ad3a834f2..192668fa06b1 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_import_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_import_decl_config.json @@ -289,7 +289,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_listener_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_listener_decl_config.json index 5a83915287e3..d3f5b919561a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_listener_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_listener_decl_config.json @@ -289,7 +289,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_service_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_service_decl_config.json index 67cfc4d4986a..3ed6bce74a0f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_service_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_service_decl_config.json @@ -280,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_type_defn_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_type_defn_config.json index 26dc09d7b4e3..2cd27cf933a2 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_type_defn_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_type_defn_config.json @@ -280,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_var_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_var_decl_config.json index e22bed4518b2..1518c168b51d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_var_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_var_decl_config.json @@ -280,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_xmlns_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_xmlns_decl_config.json index 023f2d28ed0e..269136365c9d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_xmlns_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_xmlns_decl_config.json @@ -280,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config17.json b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config17.json index 04268e464277..97bbff73d960 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config17.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config17.json @@ -288,7 +288,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config18.json b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config18.json index 4b0177ee55f1..6ede6dbd0124 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config18.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config18.json @@ -288,7 +288,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config7.json b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config7.json index 235607dc30ac..31a776f57e19 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config7.json @@ -288,7 +288,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "D", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" From 8db240f2dc639519cb8cefa2385ca0622ee118ab Mon Sep 17 00:00:00 2001 From: mohan Date: Fri, 2 Dec 2022 07:38:30 +0530 Subject: [PATCH 156/450] Add initial examples related to string operations --- .../lang.string/src/main/ballerina/string.bal | 127 +++++++++++++++++- 1 file changed, 121 insertions(+), 6 deletions(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index 3c28d0f98fab..fac8d47375e3 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -24,7 +24,12 @@ type Char string; public type RegExp regexp:RegExp; # Returns the length of the string. -# +# +# ```ballerina +# string hello = "Hello, World!"; +# int length = hello.length(); +# ``` +# # + str - the string # + return - the number of characters (code points) in parameter `str` public isolated function length(string str) returns int = @java:Method { @@ -35,7 +40,14 @@ public isolated function length(string str) returns int = @java:Method { # Returns an iterator over the string. # # The iterator will yield the substrings of length 1 in order. -# +# +# ```ballerina +# string greeting = "Hello, World. This is from Ballerina!"; +# object { +# public isolated function next() returns record {|string:Char value;|}?; +# } iterator = greeting.iterator(); +# ``` +# # + str - the string to be iterated over # + return - a new iterator object public isolated function iterator(string str) returns object { @@ -47,6 +59,13 @@ public isolated function iterator(string str) returns object { # Concatenates zero or more strings. # +# ```ballerina +# string hostname = "http://worldtimeapi.org"; +# string continent = "Asia"; +# string city = "Colombo"; +# string worldTimeAPIUrl = hostname.concat("/api/timezone/", continent, "/", city); +# +# ``` # + strs - strings to be concatenated # + return - concatenation of all of the parameter `strs`; empty string if parameter `strs` is empty public isolated function concat(string... strs) returns string = @java:Method { @@ -54,8 +73,13 @@ public isolated function concat(string... strs) returns string = @java:Method { name: "concat" } external; -# Returns the code point of a character in a string. +# Returns the unicode code point of a character in a string. # +# ```ballerina +# string hello = "Hello, World!"; +# int codePoint = hello.getCodePoint(3); +# ``` +# # + str - the string # + index - an index in parameter `str` # + return - the Unicode code point of the character at parameter `index` in parameter `str` @@ -66,6 +90,11 @@ public isolated function getCodePoint(string str, int index) returns int = @java # Returns a substring of a string. # +# ```ballerina +# string intro = "Hello, my name is John"; +# string name = intro.substring(18, 22); +# ``` +# # + str - source string. # + startIndex - the starting index, inclusive # + endIndex - the ending index, exclusive @@ -81,6 +110,10 @@ public isolated function substring(string str, int startIndex, int endIndex = st # This orders strings in a consistent and well-defined way, # but the ordering will often not be consistent with cultural expectations # for sorted order. +# +# ```ballerina +# int codePointCompare = "Austria".codePointCompare("Australia"); +# ``` # # + str1 - the first string to be compared # + str2 - the second string to be compared @@ -93,6 +126,12 @@ public isolated function codePointCompare(string str1, string str2) returns int # Joins zero or more strings together with a separator. # +# ```ballerina +# string introString = string:'join(" ", "Ballerina", "is", "a", "statically", "typed,", "concurrent", "programming", "language"); +# +# string student = string:'join(",", "John", "23", "USA", "Computer Science", "Swimmer"); +# ``` +# # + separator - separator string # + strs - strings to be joined # + return - a string consisting of all of parameter `strs` concatenated in order @@ -103,7 +142,10 @@ public isolated function 'join(string separator, string... strs) returns string } external; # Finds the first occurrence of one string in another string. -# +# ```ballerina +# int? firstIndex = "Newzeland".indexOf("land"); +# ``` +# # + str - the string in which to search # + substr - the string to search for # + startIndex - index to start searching from @@ -115,6 +157,10 @@ public isolated function indexOf(string str, string substr, int startIndex = 0) } external; # Finds the last occurrence of one string in another string. +# +# ```ballerina +# int? lastIndex = "There are multiple programming languages. Ballerinalang is unique among them".lastIndexOf("lang"); +# ``` # # + str - the string in which to search # + substr - the string to search for @@ -129,6 +175,10 @@ returns int? = @java:Method { # Tests whether a string includes another string. # +# ```ballerina +# boolean isIncludes = "Hello World! from Ballerina".includes("Bal"); +# ``` +# # + str - the string in which to search # + substr - the string to search for # + startIndex - index to start searching from @@ -141,6 +191,10 @@ public isolated function includes(string str, string substr, int startIndex = 0) # Tests whether a string starts with another string. # +# ```ballerina +# boolean isStarts = "Welcome to Ballerina programming language".includes("Welcome"); +# ``` +# # + str - the string to be tested # + substr - the starting string # + return - true if parameter `str` starts with parameter `substr`; false otherwise @@ -151,6 +205,10 @@ public isolated function startsWith(string str, string substr) returns boolean = # Tests whether a string ends with another string. # +# ```ballerina +# boolean isEnds = "Welcome to Ballerina programming language".includes("language"); +# ``` +# # + str - the string to be tested # + substr - the ending string # + return - true if parameter `str` ends with parameter `substr`; false otherwise @@ -166,6 +224,10 @@ public isolated function endsWith(string str, string substr) returns boolean = @ # Converts occurrences of A-Z to a-z. # # Other characters are left unchanged. +# +# ```ballerina +# string lowerCaseString = "HELLO, World!".toLowerAscii(); +# ``` # # + str - the string to be converted # + return - parameter `str` with any occurrences of A-Z converted to a-z @@ -177,6 +239,10 @@ public isolated function toLowerAscii(string str) returns string = @java:Method # Converts occurrences of a-z to A-Z. # # Other characters are left unchanged. +# +# ```ballerina +# string lowerCaseString = "hello, World!".toUpperAscii(); +# ``` # # + str - the string to be converted # + return - parameter `str` with any occurrences of a-z converted to A-Z @@ -189,6 +255,10 @@ public isolated function toUpperAscii(string str) returns string = @java:Method # # A character in the range a-z is treated the same as the corresponding character in the range A-Z. # +# ```ballerina +# boolean isEquals = "BALLERINA".equalsIgnoreCaseAscii("ballerina"); +# ``` +# # + str1 - the first string to be compared # + str2 - the second string to be compared # + return - true if parameter `str1` is the same as parameter `str2`, treating upper-case and lower-case @@ -202,6 +272,10 @@ public isolated function equalsIgnoreCaseAscii(string str1, string str2) returns # # The ASCII white space characters are 0x9...0xD, 0x20. # +# ```ballerina +# string trimedString = " BALLERINA ".trim(); +# ``` +# # + str - the string # + return - parameter `str` with leading or trailing ASCII white space characters removed public isolated function trim(string str) returns string = @java:Method { @@ -211,6 +285,10 @@ public isolated function trim(string str) returns string = @java:Method { # Represents a string as an array of bytes using UTF-8. # +# ```ballerina +# byte[] stringAsBytes = "Hello, World!".toBytes(); +# ``` +# # + str - the string # + return - UTF-8 byte array public isolated function toBytes(string str) returns byte[] = @java:Method { @@ -220,6 +298,11 @@ public isolated function toBytes(string str) returns byte[] = @java:Method { # Constructs a string from its UTF-8 representation in bytes. # +# ```ballerin +# byte[] bytes = [72, 101, 108, 108, 111, 32, 66, 97, 108, 108, 101, 114, 105, 110, 97, 33]; +# string stringValue = check string:fromBytes(bytes); +# ``` +# # + bytes - UTF-8 byte array # + return - parameter `bytes` converted to string or error public isolated function fromBytes(byte[] bytes) returns string|error = @java:Method { @@ -229,6 +312,11 @@ public isolated function fromBytes(byte[] bytes) returns string|error = @java:Me # Converts a string to an array of code points. # +# ```ballerina +# string hello = "Hello, world 🌎 from Ballerina. Tryout Ballerina"; +# int[] charCodePoints = hello.toCodePointInts(); +# ``` +# # + str - the string # + return - an array with a code point for each character of parameter `str` public isolated function toCodePointInts(string str) returns int[] = @java:Method { @@ -237,6 +325,10 @@ public isolated function toCodePointInts(string str) returns int[] = @java:Metho } external; # Converts a single character string to a code point. +# +# ```ballerina +# int charCodePoint = string:toCodePointInt("a"); +# ``` # # + ch - a single character string # + return - the code point of parameter `ch` @@ -249,6 +341,11 @@ public isolated function toCodePointInt(Char ch) returns int = @java:Method { # # An int is a valid code point if it is in the range 0 to 0x10FFFF inclusive, # but not in the range 0xD800 or 0xDFFF inclusive. +# +# ```ballerina +# int[] codePoints = [66,97,108,108,101,114,105,110,97]; +# string stringValue = check string:fromCodePointInts(codePoints); +# ``` # # + codePoints - an array of ints, each specifying a code point # + return - a string with a character for each code point in parameter `codePoints`; or an error @@ -262,6 +359,10 @@ public isolated function fromCodePointInts(int[] codePoints) returns string|erro # # An int is a valid code point if it is in the range 0 to 0x10FFFF inclusive, # but not in the range 0xD800 or 0xDFFF inclusive. +# +# ```ballerina +# string:Char charValue = check string:fromCodePointInt(97); +# ``` # # + codePoint - an int specifying a code point # + return - a single character string whose code point is parameter `codePoint`; or an error @@ -275,6 +376,11 @@ public isolated function fromCodePointInt(int codePoint) returns Char|error = @j # Adds sufficient `padChar` characters at the start of `str` to make its length be `len`. # If the length of `str` is >= `len`, returns `str`. # +# ```ballerina +# // Providing "0" as the custom padding char +# string distanceAsFixedLengthString = "100Km".padStart(10, "0"); +# ``` +# # + str - the string to pad # + len - the length of the string to be returned # + padChar - the character to use for padding `str`; defaults to a space character @@ -287,6 +393,11 @@ public isolated function padStart(string str, int len, Char padChar = " ") retur # Adds padding to the end of a string. # Adds sufficient `padChar` characters to the end of `str` to make its length be `len`. # If the length of `str` is >= `len`, returns `str`. +# +# ```ballerina +# // Providing "!" as the custom padding char +# string quote = "Ballerina for developers".padEnd(30, "!"); +# ``` # # + str - the string to pad # + len - the length of the string to be returned @@ -302,6 +413,10 @@ public isolated function padEnd(string str, int len, Char padChar = " ") returns # Sufficient zero characters are added to `str` to make its length be `len`. # If the length of `str` is >= `len`, returns `str`. # +# ```ballerina +# string paddedString = "-256".padZero(9); +# ``` +# # + str - the string to pad # + len - the length of the string to be returned # + zeroChar - the character to use for the zero; defaults to ASCII zero `0` @@ -313,11 +428,11 @@ public isolated function padZero(string str, int len, Char zeroChar = "0") retur # True if there is a match of `re` against all of `str`. # Use `includesMatch` to test whether `re` matches somewhere in `str`. -public function matches(string str, RegExp 're) returns boolean { +public isolated function matches(string str, RegExp 're) returns boolean { return 're.isFullMatch(str); } # True if there is a match for `re` anywhere in `str` -public function includesMatch(string str, RegExp 're, int startIndex = 0) returns boolean { +public isolated function includesMatch(string str, RegExp 're, int startIndex = 0) returns boolean { return 're.find(str, startIndex) != (); } From b9e4ed20c67487bbab9e9d76bca98d90f5823f3c Mon Sep 17 00:00:00 2001 From: mohan Date: Fri, 2 Dec 2022 10:08:40 +0530 Subject: [PATCH 157/450] Add minor fix --- langlib/lang.string/src/main/ballerina/string.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index fac8d47375e3..db343861d721 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -298,7 +298,7 @@ public isolated function toBytes(string str) returns byte[] = @java:Method { # Constructs a string from its UTF-8 representation in bytes. # -# ```ballerin +# ```ballerina # byte[] bytes = [72, 101, 108, 108, 111, 32, 66, 97, 108, 108, 101, 114, 105, 110, 97, 33]; # string stringValue = check string:fromBytes(bytes); # ``` From e3d25831c20feb1e6d02bc1c83b7a6350b0cb932 Mon Sep 17 00:00:00 2001 From: mohan Date: Fri, 2 Dec 2022 12:20:41 +0530 Subject: [PATCH 158/450] Revert "Add initial examples related to string operations" This reverts commit 8db240f2 --- .../lang.string/src/main/ballerina/string.bal | 127 +----------------- 1 file changed, 6 insertions(+), 121 deletions(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index db343861d721..3c28d0f98fab 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -24,12 +24,7 @@ type Char string; public type RegExp regexp:RegExp; # Returns the length of the string. -# -# ```ballerina -# string hello = "Hello, World!"; -# int length = hello.length(); -# ``` -# +# # + str - the string # + return - the number of characters (code points) in parameter `str` public isolated function length(string str) returns int = @java:Method { @@ -40,14 +35,7 @@ public isolated function length(string str) returns int = @java:Method { # Returns an iterator over the string. # # The iterator will yield the substrings of length 1 in order. -# -# ```ballerina -# string greeting = "Hello, World. This is from Ballerina!"; -# object { -# public isolated function next() returns record {|string:Char value;|}?; -# } iterator = greeting.iterator(); -# ``` -# +# # + str - the string to be iterated over # + return - a new iterator object public isolated function iterator(string str) returns object { @@ -59,13 +47,6 @@ public isolated function iterator(string str) returns object { # Concatenates zero or more strings. # -# ```ballerina -# string hostname = "http://worldtimeapi.org"; -# string continent = "Asia"; -# string city = "Colombo"; -# string worldTimeAPIUrl = hostname.concat("/api/timezone/", continent, "/", city); -# -# ``` # + strs - strings to be concatenated # + return - concatenation of all of the parameter `strs`; empty string if parameter `strs` is empty public isolated function concat(string... strs) returns string = @java:Method { @@ -73,13 +54,8 @@ public isolated function concat(string... strs) returns string = @java:Method { name: "concat" } external; -# Returns the unicode code point of a character in a string. +# Returns the code point of a character in a string. # -# ```ballerina -# string hello = "Hello, World!"; -# int codePoint = hello.getCodePoint(3); -# ``` -# # + str - the string # + index - an index in parameter `str` # + return - the Unicode code point of the character at parameter `index` in parameter `str` @@ -90,11 +66,6 @@ public isolated function getCodePoint(string str, int index) returns int = @java # Returns a substring of a string. # -# ```ballerina -# string intro = "Hello, my name is John"; -# string name = intro.substring(18, 22); -# ``` -# # + str - source string. # + startIndex - the starting index, inclusive # + endIndex - the ending index, exclusive @@ -110,10 +81,6 @@ public isolated function substring(string str, int startIndex, int endIndex = st # This orders strings in a consistent and well-defined way, # but the ordering will often not be consistent with cultural expectations # for sorted order. -# -# ```ballerina -# int codePointCompare = "Austria".codePointCompare("Australia"); -# ``` # # + str1 - the first string to be compared # + str2 - the second string to be compared @@ -126,12 +93,6 @@ public isolated function codePointCompare(string str1, string str2) returns int # Joins zero or more strings together with a separator. # -# ```ballerina -# string introString = string:'join(" ", "Ballerina", "is", "a", "statically", "typed,", "concurrent", "programming", "language"); -# -# string student = string:'join(",", "John", "23", "USA", "Computer Science", "Swimmer"); -# ``` -# # + separator - separator string # + strs - strings to be joined # + return - a string consisting of all of parameter `strs` concatenated in order @@ -142,10 +103,7 @@ public isolated function 'join(string separator, string... strs) returns string } external; # Finds the first occurrence of one string in another string. -# ```ballerina -# int? firstIndex = "Newzeland".indexOf("land"); -# ``` -# +# # + str - the string in which to search # + substr - the string to search for # + startIndex - index to start searching from @@ -157,10 +115,6 @@ public isolated function indexOf(string str, string substr, int startIndex = 0) } external; # Finds the last occurrence of one string in another string. -# -# ```ballerina -# int? lastIndex = "There are multiple programming languages. Ballerinalang is unique among them".lastIndexOf("lang"); -# ``` # # + str - the string in which to search # + substr - the string to search for @@ -175,10 +129,6 @@ returns int? = @java:Method { # Tests whether a string includes another string. # -# ```ballerina -# boolean isIncludes = "Hello World! from Ballerina".includes("Bal"); -# ``` -# # + str - the string in which to search # + substr - the string to search for # + startIndex - index to start searching from @@ -191,10 +141,6 @@ public isolated function includes(string str, string substr, int startIndex = 0) # Tests whether a string starts with another string. # -# ```ballerina -# boolean isStarts = "Welcome to Ballerina programming language".includes("Welcome"); -# ``` -# # + str - the string to be tested # + substr - the starting string # + return - true if parameter `str` starts with parameter `substr`; false otherwise @@ -205,10 +151,6 @@ public isolated function startsWith(string str, string substr) returns boolean = # Tests whether a string ends with another string. # -# ```ballerina -# boolean isEnds = "Welcome to Ballerina programming language".includes("language"); -# ``` -# # + str - the string to be tested # + substr - the ending string # + return - true if parameter `str` ends with parameter `substr`; false otherwise @@ -224,10 +166,6 @@ public isolated function endsWith(string str, string substr) returns boolean = @ # Converts occurrences of A-Z to a-z. # # Other characters are left unchanged. -# -# ```ballerina -# string lowerCaseString = "HELLO, World!".toLowerAscii(); -# ``` # # + str - the string to be converted # + return - parameter `str` with any occurrences of A-Z converted to a-z @@ -239,10 +177,6 @@ public isolated function toLowerAscii(string str) returns string = @java:Method # Converts occurrences of a-z to A-Z. # # Other characters are left unchanged. -# -# ```ballerina -# string lowerCaseString = "hello, World!".toUpperAscii(); -# ``` # # + str - the string to be converted # + return - parameter `str` with any occurrences of a-z converted to A-Z @@ -255,10 +189,6 @@ public isolated function toUpperAscii(string str) returns string = @java:Method # # A character in the range a-z is treated the same as the corresponding character in the range A-Z. # -# ```ballerina -# boolean isEquals = "BALLERINA".equalsIgnoreCaseAscii("ballerina"); -# ``` -# # + str1 - the first string to be compared # + str2 - the second string to be compared # + return - true if parameter `str1` is the same as parameter `str2`, treating upper-case and lower-case @@ -272,10 +202,6 @@ public isolated function equalsIgnoreCaseAscii(string str1, string str2) returns # # The ASCII white space characters are 0x9...0xD, 0x20. # -# ```ballerina -# string trimedString = " BALLERINA ".trim(); -# ``` -# # + str - the string # + return - parameter `str` with leading or trailing ASCII white space characters removed public isolated function trim(string str) returns string = @java:Method { @@ -285,10 +211,6 @@ public isolated function trim(string str) returns string = @java:Method { # Represents a string as an array of bytes using UTF-8. # -# ```ballerina -# byte[] stringAsBytes = "Hello, World!".toBytes(); -# ``` -# # + str - the string # + return - UTF-8 byte array public isolated function toBytes(string str) returns byte[] = @java:Method { @@ -298,11 +220,6 @@ public isolated function toBytes(string str) returns byte[] = @java:Method { # Constructs a string from its UTF-8 representation in bytes. # -# ```ballerina -# byte[] bytes = [72, 101, 108, 108, 111, 32, 66, 97, 108, 108, 101, 114, 105, 110, 97, 33]; -# string stringValue = check string:fromBytes(bytes); -# ``` -# # + bytes - UTF-8 byte array # + return - parameter `bytes` converted to string or error public isolated function fromBytes(byte[] bytes) returns string|error = @java:Method { @@ -312,11 +229,6 @@ public isolated function fromBytes(byte[] bytes) returns string|error = @java:Me # Converts a string to an array of code points. # -# ```ballerina -# string hello = "Hello, world 🌎 from Ballerina. Tryout Ballerina"; -# int[] charCodePoints = hello.toCodePointInts(); -# ``` -# # + str - the string # + return - an array with a code point for each character of parameter `str` public isolated function toCodePointInts(string str) returns int[] = @java:Method { @@ -325,10 +237,6 @@ public isolated function toCodePointInts(string str) returns int[] = @java:Metho } external; # Converts a single character string to a code point. -# -# ```ballerina -# int charCodePoint = string:toCodePointInt("a"); -# ``` # # + ch - a single character string # + return - the code point of parameter `ch` @@ -341,11 +249,6 @@ public isolated function toCodePointInt(Char ch) returns int = @java:Method { # # An int is a valid code point if it is in the range 0 to 0x10FFFF inclusive, # but not in the range 0xD800 or 0xDFFF inclusive. -# -# ```ballerina -# int[] codePoints = [66,97,108,108,101,114,105,110,97]; -# string stringValue = check string:fromCodePointInts(codePoints); -# ``` # # + codePoints - an array of ints, each specifying a code point # + return - a string with a character for each code point in parameter `codePoints`; or an error @@ -359,10 +262,6 @@ public isolated function fromCodePointInts(int[] codePoints) returns string|erro # # An int is a valid code point if it is in the range 0 to 0x10FFFF inclusive, # but not in the range 0xD800 or 0xDFFF inclusive. -# -# ```ballerina -# string:Char charValue = check string:fromCodePointInt(97); -# ``` # # + codePoint - an int specifying a code point # + return - a single character string whose code point is parameter `codePoint`; or an error @@ -376,11 +275,6 @@ public isolated function fromCodePointInt(int codePoint) returns Char|error = @j # Adds sufficient `padChar` characters at the start of `str` to make its length be `len`. # If the length of `str` is >= `len`, returns `str`. # -# ```ballerina -# // Providing "0" as the custom padding char -# string distanceAsFixedLengthString = "100Km".padStart(10, "0"); -# ``` -# # + str - the string to pad # + len - the length of the string to be returned # + padChar - the character to use for padding `str`; defaults to a space character @@ -393,11 +287,6 @@ public isolated function padStart(string str, int len, Char padChar = " ") retur # Adds padding to the end of a string. # Adds sufficient `padChar` characters to the end of `str` to make its length be `len`. # If the length of `str` is >= `len`, returns `str`. -# -# ```ballerina -# // Providing "!" as the custom padding char -# string quote = "Ballerina for developers".padEnd(30, "!"); -# ``` # # + str - the string to pad # + len - the length of the string to be returned @@ -413,10 +302,6 @@ public isolated function padEnd(string str, int len, Char padChar = " ") returns # Sufficient zero characters are added to `str` to make its length be `len`. # If the length of `str` is >= `len`, returns `str`. # -# ```ballerina -# string paddedString = "-256".padZero(9); -# ``` -# # + str - the string to pad # + len - the length of the string to be returned # + zeroChar - the character to use for the zero; defaults to ASCII zero `0` @@ -428,11 +313,11 @@ public isolated function padZero(string str, int len, Char zeroChar = "0") retur # True if there is a match of `re` against all of `str`. # Use `includesMatch` to test whether `re` matches somewhere in `str`. -public isolated function matches(string str, RegExp 're) returns boolean { +public function matches(string str, RegExp 're) returns boolean { return 're.isFullMatch(str); } # True if there is a match for `re` anywhere in `str` -public isolated function includesMatch(string str, RegExp 're, int startIndex = 0) returns boolean { +public function includesMatch(string str, RegExp 're, int startIndex = 0) returns boolean { return 're.find(str, startIndex) != (); } From acc7b5d4d79a12d1d71c80c59d0886adece32e41 Mon Sep 17 00:00:00 2001 From: Azeem Muzammil <33729295+AzeemMuzammil@users.noreply.github.com> Date: Fri, 2 Dec 2022 17:58:20 +0530 Subject: [PATCH 159/450] Implement compiler plugin to generate component model JSON (#38831) * Restructure model-generator core logic * Add model generator compiler plugin module * Add cli build flag to generate component model * Add compiler plugin to generate component model * Add diagnostics for write op failures * Address review comments * Update --export-component-model build flag Make --export-component-model build flag hidden and update the help text * Update model-dump path resolve logic --- .../io/ballerina/cli/cmd/BuildCommand.java | 6 ++ .../io/ballerina/projects/BuildOptions.java | 10 +++ .../projects/CompilationOptions.java | 21 ++++- .../zip/jballerina-tools/build.gradle | 1 + .../architecture-model-generator/build.gradle | 56 ++++++++++++ .../ComponentModel.java | 6 +- .../ComponentModelBuilder.java | 20 +++-- .../ProjectComponentRequest.java | 2 +- .../ProjectComponentResponse.java | 4 +- .../ProjectDesignConstants.java | 2 +- .../diagnostics/ComponentModelException.java | 2 +- .../ComponentModelingDiagnostics.java | 2 +- .../diagnostics/DiagnosticMessage.java | 2 +- .../diagnostics/DiagnosticUtils.java | 4 +- .../generators/GeneratorUtils.java | 14 +-- .../entity/EntityModelGenerator.java | 26 +++--- .../service/ServiceModelGenerator.java | 8 +- .../nodevisitors/ActionNodeVisitor.java | 16 ++-- .../ServiceDeclarationNodeVisitor.java | 14 +-- .../ServiceMemberFunctionNodeVisitor.java | 22 ++--- .../nodevisitors/StatementNodeVisitor.java | 6 +- .../model/ElementLocation.java | 2 +- .../model/ModelElement.java | 2 +- .../model/entity/Association.java | 2 +- .../model/entity/Attribute.java | 6 +- .../model/entity/Entity.java | 6 +- .../model/service/FunctionParameter.java | 6 +- .../model/service/Interaction.java | 6 +- .../model/service/RemoteFunction.java | 6 +- .../model/service/Resource.java | 6 +- .../model/service/ResourceId.java | 2 +- .../model/service/ResourceParameter.java | 6 +- .../model/service/Service.java | 6 +- .../model/service/ServiceAnnotation.java | 4 +- .../src/main/java/module-info.java | 27 ++++++ .../build.gradle | 40 +++++++++ .../CompilationAnalysisTask.java | 87 +++++++++++++++++++ .../ModelGeneratorCodeAnalyzer.java | 33 +++++++ .../ModelGeneratorCompilerPlugin.java | 32 +++++++ .../PluginConstants.java | 27 ++++++ .../diagnostic/DiagnosticMessage.java | 52 +++++++++++ .../src/main/java/module-info.java | 27 ++++++ ....ballerina.projects.plugins.CompilerPlugin | 1 + .../project-design-service/build.gradle | 10 +-- .../ProjectDesignClientCapabilities.java | 1 + .../ProjectDesignClientCapabilitySetter.java | 1 + .../ProjectDesignServerCapabilities.java | 1 + .../ProjectDesignServerCapabilitySetter.java | 1 + .../projectdesign/ProjectDesignService.java | 10 ++- .../io/ballerina/projectdesign/Utils.java | 20 ++++- .../src/main/java/module-info.java | 23 ++++- settings.gradle | 4 + 52 files changed, 581 insertions(+), 120 deletions(-) create mode 100644 misc/architecture-model-generator/build.gradle rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/ComponentModel.java (92%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/ComponentModelBuilder.java (78%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/ProjectComponentRequest.java (95%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/ProjectComponentResponse.java (93%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/ProjectDesignConstants.java (98%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/diagnostics/ComponentModelException.java (94%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/diagnostics/ComponentModelingDiagnostics.java (97%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/diagnostics/DiagnosticMessage.java (97%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/diagnostics/DiagnosticUtils.java (91%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/generators/GeneratorUtils.java (91%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/generators/entity/EntityModelGenerator.java (95%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/generators/service/ServiceModelGenerator.java (88%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/generators/service/nodevisitors/ActionNodeVisitor.java (94%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java (92%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java (95%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/generators/service/nodevisitors/StatementNodeVisitor.java (96%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/model/ElementLocation.java (97%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/model/ModelElement.java (95%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/model/entity/Association.java (96%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/model/entity/Attribute.java (90%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/model/entity/Entity.java (88%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/model/service/FunctionParameter.java (87%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/model/service/Interaction.java (86%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/model/service/RemoteFunction.java (89%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/model/service/Resource.java (90%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/model/service/ResourceId.java (95%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/model/service/ResourceParameter.java (88%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/model/service/Service.java (91%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/model/service/ServiceAnnotation.java (91%) create mode 100644 misc/architecture-model-generator/src/main/java/module-info.java create mode 100644 misc/compiler-plugins/modules/architecture-model-generator-pligin/build.gradle create mode 100644 misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/CompilationAnalysisTask.java create mode 100644 misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCodeAnalyzer.java create mode 100644 misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCompilerPlugin.java create mode 100644 misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/PluginConstants.java create mode 100644 misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/diagnostic/DiagnosticMessage.java create mode 100644 misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/module-info.java create mode 100644 misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/resources/META-INF/services/io.ballerina.projects.plugins.CompilerPlugin diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/BuildCommand.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/BuildCommand.java index b8ba8c4bb680..c54aeeded171 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/BuildCommand.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/BuildCommand.java @@ -171,6 +171,11 @@ public BuildCommand() { " the services in the current package") private Boolean exportOpenAPI; + @CommandLine.Option(names = "--export-component-model", description = "generate a model to represent " + + "interactions between the package components (i.e. service/type definitions) and, export it in JSON format", + hidden = true) + private Boolean exportComponentModel; + @CommandLine.Option(names = "--enable-cache", description = "enable caches for the compilation", hidden = true) private Boolean enableCache; @@ -294,6 +299,7 @@ private BuildOptions constructBuildOptions() { .setSticky(sticky) .setConfigSchemaGen(configSchemaGen) .setExportOpenAPI(exportOpenAPI) + .setExportComponentModel(exportComponentModel) .setEnableCache(enableCache) .setNativeImage(nativeImage); diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/BuildOptions.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/BuildOptions.java index e46cf3da4c02..1ce3ae25e87c 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/BuildOptions.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/BuildOptions.java @@ -99,6 +99,10 @@ public boolean exportOpenAPI() { return this.compilationOptions.exportOpenAPI(); } + public boolean exportComponentModel() { + return this.compilationOptions.exportComponentModel(); + } + public boolean enableCache() { return this.compilationOptions.enableCache(); } @@ -163,6 +167,7 @@ public BuildOptions acceptTheirs(BuildOptions theirOptions) { buildOptionsBuilder.setSticky(compilationOptions.sticky); buildOptionsBuilder.setConfigSchemaGen(compilationOptions.configSchemaGen); buildOptionsBuilder.setExportOpenAPI(compilationOptions.exportOpenAPI); + buildOptionsBuilder.setExportComponentModel(compilationOptions.exportComponentModel); buildOptionsBuilder.setEnableCache(compilationOptions.enableCache); return buildOptionsBuilder.build(); @@ -323,6 +328,11 @@ public BuildOptionsBuilder setExportOpenAPI(Boolean value) { return this; } + public BuildOptionsBuilder setExportComponentModel(Boolean value) { + compilationOptionsBuilder.setExportComponentModel(value); + return this; + } + public BuildOptionsBuilder setEnableCache(Boolean value) { compilationOptionsBuilder.setEnableCache(value); enableCache = value; diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/CompilationOptions.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/CompilationOptions.java index e7272dd685b2..2d985b73f48d 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/CompilationOptions.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/CompilationOptions.java @@ -37,13 +37,14 @@ public class CompilationOptions { Boolean withIDLGenerators; Boolean configSchemaGen; Boolean exportOpenAPI; + Boolean exportComponentModel; Boolean enableCache; CompilationOptions(Boolean offlineBuild, Boolean observabilityIncluded, Boolean dumpBir, Boolean dumpBirFile, String cloud, Boolean listConflictedClasses, Boolean sticky, Boolean dumpGraph, Boolean dumpRawGraphs, Boolean withCodeGenerators, Boolean withCodeModifiers, Boolean withIDLGenerators, Boolean configSchemaGen, - Boolean exportOpenAPI, Boolean enableCache) { + Boolean exportOpenAPI, Boolean exportComponentModel, Boolean enableCache) { this.offlineBuild = offlineBuild; this.observabilityIncluded = observabilityIncluded; this.dumpBir = dumpBir; @@ -58,6 +59,7 @@ public class CompilationOptions { this.withIDLGenerators = withIDLGenerators; this.configSchemaGen = configSchemaGen; this.exportOpenAPI = exportOpenAPI; + this.exportComponentModel = exportComponentModel; this.enableCache = enableCache; } @@ -117,6 +119,10 @@ public boolean exportOpenAPI() { return toBooleanDefaultIfNull(this.exportOpenAPI); } + public boolean exportComponentModel() { + return toBooleanDefaultIfNull(this.exportComponentModel); + } + public boolean enableCache() { return toBooleanDefaultIfNull(this.enableCache); } @@ -199,6 +205,11 @@ CompilationOptions acceptTheirs(CompilationOptions theirOptions) { } else { compilationOptionsBuilder.setExportOpenAPI(this.exportOpenAPI); } + if (theirOptions.exportComponentModel != null) { + compilationOptionsBuilder.setExportComponentModel(theirOptions.exportComponentModel); + } else { + compilationOptionsBuilder.setExportComponentModel(this.exportComponentModel); + } if (theirOptions.enableCache != null) { compilationOptionsBuilder.setEnableCache(theirOptions.enableCache); } else { @@ -252,6 +263,7 @@ public static class CompilationOptionsBuilder { private Boolean withIDLGenerators; private Boolean configSchemaGen; private Boolean exportOpenAPI; + private Boolean exportComponentModel; private Boolean enableCache; public CompilationOptionsBuilder setOffline(Boolean value) { @@ -324,6 +336,11 @@ CompilationOptionsBuilder setExportOpenAPI(Boolean value) { return this; } + CompilationOptionsBuilder setExportComponentModel(Boolean value) { + exportComponentModel = value; + return this; + } + public CompilationOptionsBuilder setEnableCache(Boolean value) { enableCache = value; return this; @@ -333,7 +350,7 @@ public CompilationOptions build() { return new CompilationOptions(offline, observabilityIncluded, dumpBir, dumpBirFile, cloud, listConflictedClasses, sticky, dumpGraph, dumpRawGraph, withCodeGenerators, withCodeModifiers, withIDLGenerators, configSchemaGen, exportOpenAPI, - enableCache); + exportComponentModel, enableCache); } } } diff --git a/distribution/zip/jballerina-tools/build.gradle b/distribution/zip/jballerina-tools/build.gradle index 1d46c6f24f34..3033493710d1 100644 --- a/distribution/zip/jballerina-tools/build.gradle +++ b/distribution/zip/jballerina-tools/build.gradle @@ -123,6 +123,7 @@ dependencies { dist project(':ballerina-shell:shell-cli') dist project(':compiler-plugins:package-semantic-analyzer') dist project(':compiler-plugins:configurable-schema-generator') + dist project(':compiler-plugins:architecture-model-generator-pligin') dist project(':identifier-util') datamapperLib project(':ballerinalang-data-mapper') diff --git a/misc/architecture-model-generator/build.gradle b/misc/architecture-model-generator/build.gradle new file mode 100644 index 000000000000..ef93d96b342b --- /dev/null +++ b/misc/architecture-model-generator/build.gradle @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +apply from: "$rootDir/gradle/javaProject.gradle" +apply from: "$rootDir/gradle/ballerinaLangLibLoad.gradle" + +configurations { + compile.transitive = false + compileClasspath.extendsFrom(compileOnly) +} + +dependencies { + compileOnly project(':ballerina-parser') + compileOnly project(':ballerina-lang') + + implementation project(':ballerina-tools-api') + implementation "com.google.code.gson:gson:${project.gsonVersion}" + + testCompile 'org.testng:testng' + +} + +test { + useTestNG() { + suites 'src/test/resources/testng.xml' + } +} + +description = 'Model generator core for project design diagram generation' + +ext.moduleName = 'io.ballerina.architecturemodelgenerator' + +compileJava { + inputs.property("moduleName", moduleName) + doFirst { + options.compilerArgs = [ + '--module-path', classpath.asPath, + ] + classpath = files() + } +} diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModel.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ComponentModel.java similarity index 92% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModel.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ComponentModel.java index 8f2e2606dacf..39cf3b3311bd 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModel.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ComponentModel.java @@ -16,10 +16,10 @@ * under the License. */ -package io.ballerina.projectdesign; +package io.ballerina.architecturemodelgenerator; -import io.ballerina.projectdesign.model.entity.Entity; -import io.ballerina.projectdesign.model.service.Service; +import io.ballerina.architecturemodelgenerator.model.entity.Entity; +import io.ballerina.architecturemodelgenerator.model.service.Service; import io.ballerina.projects.Package; import java.util.Map; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModelBuilder.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ComponentModelBuilder.java similarity index 78% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModelBuilder.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ComponentModelBuilder.java index f3b16b4230da..9fb153048b2b 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModelBuilder.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ComponentModelBuilder.java @@ -16,14 +16,14 @@ * under the License. */ -package io.ballerina.projectdesign; +package io.ballerina.architecturemodelgenerator; +import io.ballerina.architecturemodelgenerator.ComponentModel.PackageId; +import io.ballerina.architecturemodelgenerator.generators.entity.EntityModelGenerator; +import io.ballerina.architecturemodelgenerator.generators.service.ServiceModelGenerator; +import io.ballerina.architecturemodelgenerator.model.entity.Entity; +import io.ballerina.architecturemodelgenerator.model.service.Service; import io.ballerina.compiler.api.SemanticModel; -import io.ballerina.projectdesign.ComponentModel.PackageId; -import io.ballerina.projectdesign.generators.entity.EntityModelGenerator; -import io.ballerina.projectdesign.generators.service.ServiceModelGenerator; -import io.ballerina.projectdesign.model.entity.Entity; -import io.ballerina.projectdesign.model.service.Service; import io.ballerina.projects.DocumentId; import io.ballerina.projects.Package; import io.ballerina.projects.PackageCompilation; @@ -42,11 +42,14 @@ public class ComponentModelBuilder { public ComponentModel constructComponentModel(Package currentPackage) { + return constructComponentModel(currentPackage, null); + } + + public ComponentModel constructComponentModel(Package currentPackage, PackageCompilation packageCompilation) { Map services = new HashMap<>(); // todo: Change to TypeDefinition Map entities = new HashMap<>(); - PackageId packageId = new PackageId(currentPackage); AtomicBoolean hasDiagnosticErrors = new AtomicBoolean(false); @@ -57,7 +60,8 @@ public ComponentModel constructComponentModel(Package currentPackage) { moduleRootPath = moduleRootPath.resolve(module.moduleName().moduleNamePart()); } Collection documentIds = module.documentIds(); - PackageCompilation currentPackageCompilation = currentPackage.getCompilation(); + PackageCompilation currentPackageCompilation = packageCompilation == null ? + currentPackage.getCompilation() : packageCompilation; SemanticModel currentSemanticModel = currentPackageCompilation.getSemanticModel(module.moduleId()); if (currentPackageCompilation.diagnosticResult().hasErrors() && !hasDiagnosticErrors.get()) { hasDiagnosticErrors.set(true); diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectComponentRequest.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectComponentRequest.java similarity index 95% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectComponentRequest.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectComponentRequest.java index 799362afa3cf..75eb6095bbde 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectComponentRequest.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectComponentRequest.java @@ -16,7 +16,7 @@ * under the License. */ -package io.ballerina.projectdesign; +package io.ballerina.architecturemodelgenerator; import java.util.ArrayList; import java.util.List; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectComponentResponse.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectComponentResponse.java similarity index 93% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectComponentResponse.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectComponentResponse.java index 542b6dbdbcc1..043bdbac8821 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectComponentResponse.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectComponentResponse.java @@ -16,10 +16,10 @@ * under the License. */ -package io.ballerina.projectdesign; +package io.ballerina.architecturemodelgenerator; import com.google.gson.JsonObject; -import io.ballerina.projectdesign.diagnostics.ComponentModelingDiagnostics; +import io.ballerina.architecturemodelgenerator.diagnostics.ComponentModelingDiagnostics; import java.util.ArrayList; import java.util.HashMap; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignConstants.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectDesignConstants.java similarity index 98% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignConstants.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectDesignConstants.java index f3635c9de9b4..51fb52bab040 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignConstants.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectDesignConstants.java @@ -16,7 +16,7 @@ * under the License. */ -package io.ballerina.projectdesign; +package io.ballerina.architecturemodelgenerator; import io.ballerina.compiler.syntax.tree.SyntaxKind; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/diagnostics/ComponentModelException.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/ComponentModelException.java similarity index 94% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/diagnostics/ComponentModelException.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/ComponentModelException.java index 66d3b28efd7d..29fc1c8dbeb2 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/diagnostics/ComponentModelException.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/ComponentModelException.java @@ -16,7 +16,7 @@ * under the License. */ -package io.ballerina.projectdesign.diagnostics; +package io.ballerina.architecturemodelgenerator.diagnostics; /** * Exception for component model generation. diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/diagnostics/ComponentModelingDiagnostics.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/ComponentModelingDiagnostics.java similarity index 97% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/diagnostics/ComponentModelingDiagnostics.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/ComponentModelingDiagnostics.java index 5c908735b2c5..4d162d5a3ce9 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/diagnostics/ComponentModelingDiagnostics.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/ComponentModelingDiagnostics.java @@ -16,7 +16,7 @@ * under the License. */ -package io.ballerina.projectdesign.diagnostics; +package io.ballerina.architecturemodelgenerator.diagnostics; import io.ballerina.tools.diagnostics.Diagnostic; import io.ballerina.tools.diagnostics.DiagnosticInfo; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/diagnostics/DiagnosticMessage.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/DiagnosticMessage.java similarity index 97% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/diagnostics/DiagnosticMessage.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/DiagnosticMessage.java index 14fa397dab88..ab7bd766e560 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/diagnostics/DiagnosticMessage.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/DiagnosticMessage.java @@ -16,7 +16,7 @@ * under the License. */ -package io.ballerina.projectdesign.diagnostics; +package io.ballerina.architecturemodelgenerator.diagnostics; import io.ballerina.tools.diagnostics.DiagnosticSeverity; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/diagnostics/DiagnosticUtils.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/DiagnosticUtils.java similarity index 91% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/diagnostics/DiagnosticUtils.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/DiagnosticUtils.java index e45d47f7e0f5..01e57cfa53ca 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/diagnostics/DiagnosticUtils.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/DiagnosticUtils.java @@ -16,9 +16,9 @@ * under the License. */ -package io.ballerina.projectdesign.diagnostics; +package io.ballerina.architecturemodelgenerator.diagnostics; -import io.ballerina.projectdesign.ProjectComponentResponse; +import io.ballerina.architecturemodelgenerator.ProjectComponentResponse; import java.util.List; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/GeneratorUtils.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/GeneratorUtils.java similarity index 91% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/GeneratorUtils.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/GeneratorUtils.java index 2df257d19920..115f17e8fcb0 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/GeneratorUtils.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/GeneratorUtils.java @@ -16,8 +16,10 @@ * under the License. */ -package io.ballerina.projectdesign.generators; +package io.ballerina.architecturemodelgenerator.generators; +import io.ballerina.architecturemodelgenerator.model.ElementLocation; +import io.ballerina.architecturemodelgenerator.model.service.ServiceAnnotation; import io.ballerina.compiler.api.SemanticModel; import io.ballerina.compiler.api.symbols.Annotatable; import io.ballerina.compiler.api.symbols.AnnotationAttachmentSymbol; @@ -32,8 +34,6 @@ import io.ballerina.compiler.syntax.tree.SeparatedNodeList; import io.ballerina.compiler.syntax.tree.SpecificFieldNode; import io.ballerina.compiler.syntax.tree.SyntaxKind; -import io.ballerina.projectdesign.model.ElementLocation; -import io.ballerina.projectdesign.model.service.ServiceAnnotation; import io.ballerina.tools.text.LineRange; import java.util.LinkedHashMap; @@ -41,10 +41,10 @@ import java.util.Optional; import java.util.UUID; -import static io.ballerina.projectdesign.ProjectDesignConstants.CLIENT; -import static io.ballerina.projectdesign.ProjectDesignConstants.DISPLAY_ANNOTATION; -import static io.ballerina.projectdesign.ProjectDesignConstants.ID; -import static io.ballerina.projectdesign.ProjectDesignConstants.LABEL; +import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.CLIENT; +import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.DISPLAY_ANNOTATION; +import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.ID; +import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.LABEL; /** * Provide utils functions for component model generating. diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/entity/EntityModelGenerator.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/entity/EntityModelGenerator.java similarity index 95% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/entity/EntityModelGenerator.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/entity/EntityModelGenerator.java index e690a62bb300..9ea53aa5a8d5 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/entity/EntityModelGenerator.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/entity/EntityModelGenerator.java @@ -16,8 +16,16 @@ * under the License. */ -package io.ballerina.projectdesign.generators.entity; - +package io.ballerina.architecturemodelgenerator.generators.entity; + +import io.ballerina.architecturemodelgenerator.ComponentModel; +import io.ballerina.architecturemodelgenerator.ComponentModel.PackageId; +import io.ballerina.architecturemodelgenerator.ProjectDesignConstants.CardinalityValue; +import io.ballerina.architecturemodelgenerator.generators.GeneratorUtils; +import io.ballerina.architecturemodelgenerator.model.ElementLocation; +import io.ballerina.architecturemodelgenerator.model.entity.Association; +import io.ballerina.architecturemodelgenerator.model.entity.Attribute; +import io.ballerina.architecturemodelgenerator.model.entity.Entity; import io.ballerina.compiler.api.SemanticModel; import io.ballerina.compiler.api.symbols.ArrayTypeSymbol; import io.ballerina.compiler.api.symbols.NilTypeSymbol; @@ -30,14 +38,6 @@ import io.ballerina.compiler.api.symbols.TypeReferenceTypeSymbol; import io.ballerina.compiler.api.symbols.TypeSymbol; import io.ballerina.compiler.api.symbols.UnionTypeSymbol; -import io.ballerina.projectdesign.ComponentModel; -import io.ballerina.projectdesign.ComponentModel.PackageId; -import io.ballerina.projectdesign.ProjectDesignConstants.CardinalityValue; -import io.ballerina.projectdesign.generators.GeneratorUtils; -import io.ballerina.projectdesign.model.ElementLocation; -import io.ballerina.projectdesign.model.entity.Association; -import io.ballerina.projectdesign.model.entity.Attribute; -import io.ballerina.projectdesign.model.entity.Entity; import io.ballerina.tools.text.LineRange; import java.nio.file.Path; @@ -49,9 +49,9 @@ import java.util.Map; import java.util.stream.Collectors; -import static io.ballerina.projectdesign.ProjectDesignConstants.ARRAY; -import static io.ballerina.projectdesign.ProjectDesignConstants.COLON; -import static io.ballerina.projectdesign.ProjectDesignConstants.FORWARD_SLASH; +import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.ARRAY; +import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.COLON; +import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.FORWARD_SLASH; /** * Build entity model to represent relationship between records. diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/ServiceModelGenerator.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/ServiceModelGenerator.java similarity index 88% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/ServiceModelGenerator.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/ServiceModelGenerator.java index d773ed905079..adef3cfdbf86 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/ServiceModelGenerator.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/ServiceModelGenerator.java @@ -16,13 +16,13 @@ * under the License. */ -package io.ballerina.projectdesign.generators.service; +package io.ballerina.architecturemodelgenerator.generators.service; +import io.ballerina.architecturemodelgenerator.ComponentModel; +import io.ballerina.architecturemodelgenerator.generators.service.nodevisitors.ServiceDeclarationNodeVisitor; +import io.ballerina.architecturemodelgenerator.model.service.Service; import io.ballerina.compiler.api.SemanticModel; import io.ballerina.compiler.syntax.tree.SyntaxTree; -import io.ballerina.projectdesign.ComponentModel; -import io.ballerina.projectdesign.generators.service.nodevisitors.ServiceDeclarationNodeVisitor; -import io.ballerina.projectdesign.model.service.Service; import io.ballerina.projects.DocumentId; import io.ballerina.projects.Module; import io.ballerina.projects.Package; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ActionNodeVisitor.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ActionNodeVisitor.java similarity index 94% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ActionNodeVisitor.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ActionNodeVisitor.java index 3f710a42c003..a98ce1531cbf 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ActionNodeVisitor.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ActionNodeVisitor.java @@ -16,8 +16,11 @@ * under the License. */ -package io.ballerina.projectdesign.generators.service.nodevisitors; +package io.ballerina.architecturemodelgenerator.generators.service.nodevisitors; +import io.ballerina.architecturemodelgenerator.generators.GeneratorUtils; +import io.ballerina.architecturemodelgenerator.model.service.Interaction; +import io.ballerina.architecturemodelgenerator.model.service.ResourceId; import io.ballerina.compiler.api.ModuleID; import io.ballerina.compiler.api.SemanticModel; import io.ballerina.compiler.api.symbols.Annotatable; @@ -43,9 +46,6 @@ import io.ballerina.compiler.syntax.tree.SimpleNameReferenceNode; import io.ballerina.compiler.syntax.tree.SyntaxKind; import io.ballerina.compiler.syntax.tree.SyntaxTree; -import io.ballerina.projectdesign.generators.GeneratorUtils; -import io.ballerina.projectdesign.model.service.Interaction; -import io.ballerina.projectdesign.model.service.ResourceId; import io.ballerina.projects.DocumentId; import io.ballerina.projects.Package; import io.ballerina.tools.diagnostics.Location; @@ -56,10 +56,10 @@ import java.util.Objects; import java.util.Optional; -import static io.ballerina.projectdesign.ProjectDesignConstants.FORWARD_SLASH; -import static io.ballerina.projectdesign.ProjectDesignConstants.TYPE_MAP; -import static io.ballerina.projectdesign.generators.GeneratorUtils.getClientModuleName; -import static io.ballerina.projectdesign.generators.GeneratorUtils.getServiceAnnotation; +import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.FORWARD_SLASH; +import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.TYPE_MAP; +import static io.ballerina.architecturemodelgenerator.generators.GeneratorUtils.getClientModuleName; +import static io.ballerina.architecturemodelgenerator.generators.GeneratorUtils.getServiceAnnotation; /** * Visitor class for RemoteMethodCallAction nodes. diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java similarity index 92% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java index 33912549e28f..496d247e66ce 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java @@ -16,8 +16,12 @@ * under the License. */ -package io.ballerina.projectdesign.generators.service.nodevisitors; +package io.ballerina.architecturemodelgenerator.generators.service.nodevisitors; +import io.ballerina.architecturemodelgenerator.ComponentModel; +import io.ballerina.architecturemodelgenerator.generators.GeneratorUtils; +import io.ballerina.architecturemodelgenerator.model.service.Service; +import io.ballerina.architecturemodelgenerator.model.service.ServiceAnnotation; import io.ballerina.compiler.api.SemanticModel; import io.ballerina.compiler.api.symbols.Symbol; import io.ballerina.compiler.api.symbols.TypeDescKind; @@ -41,10 +45,6 @@ import io.ballerina.compiler.syntax.tree.TypeDefinitionNode; import io.ballerina.compiler.syntax.tree.TypeDescriptorNode; import io.ballerina.compiler.syntax.tree.VariableDeclarationNode; -import io.ballerina.projectdesign.ComponentModel; -import io.ballerina.projectdesign.generators.GeneratorUtils; -import io.ballerina.projectdesign.model.service.Service; -import io.ballerina.projectdesign.model.service.ServiceAnnotation; import io.ballerina.projects.Package; import java.nio.file.Path; @@ -53,8 +53,8 @@ import java.util.Optional; import java.util.UUID; -import static io.ballerina.projectdesign.ProjectDesignConstants.FORWARD_SLASH; -import static io.ballerina.projectdesign.ProjectDesignConstants.LISTENER; +import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.FORWARD_SLASH; +import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.LISTENER; /** * Visitor class for ServiceDeclaration nodes. diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java similarity index 95% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java index c37c31a4c44e..208c43faf3d3 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java @@ -16,8 +16,17 @@ * under the License. */ -package io.ballerina.projectdesign.generators.service.nodevisitors; - +package io.ballerina.architecturemodelgenerator.generators.service.nodevisitors; + +import io.ballerina.architecturemodelgenerator.ComponentModel; +import io.ballerina.architecturemodelgenerator.ProjectDesignConstants.ParameterIn; +import io.ballerina.architecturemodelgenerator.generators.GeneratorUtils; +import io.ballerina.architecturemodelgenerator.model.ElementLocation; +import io.ballerina.architecturemodelgenerator.model.service.FunctionParameter; +import io.ballerina.architecturemodelgenerator.model.service.RemoteFunction; +import io.ballerina.architecturemodelgenerator.model.service.Resource; +import io.ballerina.architecturemodelgenerator.model.service.ResourceId; +import io.ballerina.architecturemodelgenerator.model.service.ResourceParameter; import io.ballerina.compiler.api.SemanticModel; import io.ballerina.compiler.api.symbols.ArrayTypeSymbol; import io.ballerina.compiler.api.symbols.MethodSymbol; @@ -44,15 +53,6 @@ import io.ballerina.compiler.syntax.tree.SeparatedNodeList; import io.ballerina.compiler.syntax.tree.SyntaxKind; import io.ballerina.compiler.syntax.tree.VariableDeclarationNode; -import io.ballerina.projectdesign.ComponentModel; -import io.ballerina.projectdesign.ProjectDesignConstants.ParameterIn; -import io.ballerina.projectdesign.generators.GeneratorUtils; -import io.ballerina.projectdesign.model.ElementLocation; -import io.ballerina.projectdesign.model.service.FunctionParameter; -import io.ballerina.projectdesign.model.service.RemoteFunction; -import io.ballerina.projectdesign.model.service.Resource; -import io.ballerina.projectdesign.model.service.ResourceId; -import io.ballerina.projectdesign.model.service.ResourceParameter; import io.ballerina.projects.Package; import java.util.ArrayList; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/StatementNodeVisitor.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/StatementNodeVisitor.java similarity index 96% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/StatementNodeVisitor.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/StatementNodeVisitor.java index 5274561bad89..b92ed08d2640 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/StatementNodeVisitor.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/StatementNodeVisitor.java @@ -16,8 +16,9 @@ * under the License. */ -package io.ballerina.projectdesign.generators.service.nodevisitors; +package io.ballerina.architecturemodelgenerator.generators.service.nodevisitors; +import io.ballerina.architecturemodelgenerator.generators.GeneratorUtils; import io.ballerina.compiler.api.SemanticModel; import io.ballerina.compiler.api.symbols.Symbol; import io.ballerina.compiler.api.symbols.TypeReferenceTypeSymbol; @@ -36,11 +37,10 @@ import io.ballerina.compiler.syntax.tree.TypeDefinitionNode; import io.ballerina.compiler.syntax.tree.TypeDescriptorNode; import io.ballerina.compiler.syntax.tree.VariableDeclarationNode; -import io.ballerina.projectdesign.generators.GeneratorUtils; import java.util.Optional; -import static io.ballerina.projectdesign.ProjectDesignConstants.CLIENT; +import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.CLIENT; /** * Visitor class to identify client declaration nodes inside a Ballerina service. diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/ElementLocation.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/ElementLocation.java similarity index 97% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/ElementLocation.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/ElementLocation.java index 190d7f5051d8..1314cf753161 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/ElementLocation.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/ElementLocation.java @@ -16,7 +16,7 @@ * under the License. */ -package io.ballerina.projectdesign.model; +package io.ballerina.architecturemodelgenerator.model; /** * Represent the location of a component model element. diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/ModelElement.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/ModelElement.java similarity index 95% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/ModelElement.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/ModelElement.java index 34524cc40e0a..a58f3929a909 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/ModelElement.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/ModelElement.java @@ -16,7 +16,7 @@ * under the License. */ -package io.ballerina.projectdesign.model; +package io.ballerina.architecturemodelgenerator.model; /** * Represents the abstract model for a component model item. diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Association.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Association.java similarity index 96% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Association.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Association.java index 828a0d731f82..1d10b08234cb 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Association.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Association.java @@ -16,7 +16,7 @@ * under the License. */ -package io.ballerina.projectdesign.model.entity; +package io.ballerina.architecturemodelgenerator.model.entity; /** * Represent the relationship between records. diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Attribute.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Attribute.java similarity index 90% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Attribute.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Attribute.java index 6fe16a846c73..b0b03039f833 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Attribute.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Attribute.java @@ -16,10 +16,10 @@ * under the License. */ -package io.ballerina.projectdesign.model.entity; +package io.ballerina.architecturemodelgenerator.model.entity; -import io.ballerina.projectdesign.model.ElementLocation; -import io.ballerina.projectdesign.model.ModelElement; +import io.ballerina.architecturemodelgenerator.model.ElementLocation; +import io.ballerina.architecturemodelgenerator.model.ModelElement; import java.util.List; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Entity.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Entity.java similarity index 88% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Entity.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Entity.java index 1dd54ca8b9b5..5c3c8e3d135e 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Entity.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Entity.java @@ -16,10 +16,10 @@ * under the License. */ -package io.ballerina.projectdesign.model.entity; +package io.ballerina.architecturemodelgenerator.model.entity; -import io.ballerina.projectdesign.model.ElementLocation; -import io.ballerina.projectdesign.model.ModelElement; +import io.ballerina.architecturemodelgenerator.model.ElementLocation; +import io.ballerina.architecturemodelgenerator.model.ModelElement; import java.util.List; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/FunctionParameter.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/FunctionParameter.java similarity index 87% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/FunctionParameter.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/FunctionParameter.java index 63f991f1bb6d..2a3bbafd6c96 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/FunctionParameter.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/FunctionParameter.java @@ -16,10 +16,10 @@ * under the License. */ -package io.ballerina.projectdesign.model.service; +package io.ballerina.architecturemodelgenerator.model.service; -import io.ballerina.projectdesign.model.ElementLocation; -import io.ballerina.projectdesign.model.ModelElement; +import io.ballerina.architecturemodelgenerator.model.ElementLocation; +import io.ballerina.architecturemodelgenerator.model.ModelElement; import java.util.List; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/Interaction.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Interaction.java similarity index 86% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/Interaction.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Interaction.java index 94746d683160..be4d59bab049 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/Interaction.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Interaction.java @@ -16,10 +16,10 @@ * under the License. */ -package io.ballerina.projectdesign.model.service; +package io.ballerina.architecturemodelgenerator.model.service; -import io.ballerina.projectdesign.model.ElementLocation; -import io.ballerina.projectdesign.model.ModelElement; +import io.ballerina.architecturemodelgenerator.model.ElementLocation; +import io.ballerina.architecturemodelgenerator.model.ModelElement; /** * Represent interaction with another service. diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/RemoteFunction.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/RemoteFunction.java similarity index 89% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/RemoteFunction.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/RemoteFunction.java index da833b24961e..d6e10bbcf14a 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/RemoteFunction.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/RemoteFunction.java @@ -16,10 +16,10 @@ * under the License. */ -package io.ballerina.projectdesign.model.service; +package io.ballerina.architecturemodelgenerator.model.service; -import io.ballerina.projectdesign.model.ElementLocation; -import io.ballerina.projectdesign.model.ModelElement; +import io.ballerina.architecturemodelgenerator.model.ElementLocation; +import io.ballerina.architecturemodelgenerator.model.ModelElement; import java.util.List; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/Resource.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Resource.java similarity index 90% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/Resource.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Resource.java index feb093b12999..9fb03acdec8c 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/Resource.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Resource.java @@ -16,10 +16,10 @@ * under the License. */ -package io.ballerina.projectdesign.model.service; +package io.ballerina.architecturemodelgenerator.model.service; -import io.ballerina.projectdesign.model.ElementLocation; -import io.ballerina.projectdesign.model.ModelElement; +import io.ballerina.architecturemodelgenerator.model.ElementLocation; +import io.ballerina.architecturemodelgenerator.model.ModelElement; import java.util.List; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/ResourceId.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ResourceId.java similarity index 95% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/ResourceId.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ResourceId.java index e3ed9f2d9ebd..69136d21dc60 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/ResourceId.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ResourceId.java @@ -16,7 +16,7 @@ * under the License. */ -package io.ballerina.projectdesign.model.service; +package io.ballerina.architecturemodelgenerator.model.service; /** * Provide resource information. diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/ResourceParameter.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ResourceParameter.java similarity index 88% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/ResourceParameter.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ResourceParameter.java index ce4d8bcd9f47..a28acec9530b 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/ResourceParameter.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ResourceParameter.java @@ -16,10 +16,10 @@ * under the License. */ -package io.ballerina.projectdesign.model.service; +package io.ballerina.architecturemodelgenerator.model.service; -import io.ballerina.projectdesign.model.ElementLocation; -import io.ballerina.projectdesign.model.ModelElement; +import io.ballerina.architecturemodelgenerator.model.ElementLocation; +import io.ballerina.architecturemodelgenerator.model.ModelElement; import java.util.List; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/Service.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Service.java similarity index 91% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/Service.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Service.java index 47ba071edb20..e5a8814bdc45 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/Service.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Service.java @@ -16,10 +16,10 @@ * under the License. */ -package io.ballerina.projectdesign.model.service; +package io.ballerina.architecturemodelgenerator.model.service; -import io.ballerina.projectdesign.model.ElementLocation; -import io.ballerina.projectdesign.model.ModelElement; +import io.ballerina.architecturemodelgenerator.model.ElementLocation; +import io.ballerina.architecturemodelgenerator.model.ModelElement; import java.util.List; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/ServiceAnnotation.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ServiceAnnotation.java similarity index 91% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/ServiceAnnotation.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ServiceAnnotation.java index edbff1754656..ab1f7111c9a7 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/ServiceAnnotation.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ServiceAnnotation.java @@ -16,9 +16,9 @@ * under the License. */ -package io.ballerina.projectdesign.model.service; +package io.ballerina.architecturemodelgenerator.model.service; -import io.ballerina.projectdesign.model.ElementLocation; +import io.ballerina.architecturemodelgenerator.model.ElementLocation; /** * Represents display annotation. diff --git a/misc/architecture-model-generator/src/main/java/module-info.java b/misc/architecture-model-generator/src/main/java/module-info.java new file mode 100644 index 000000000000..83356dfebb95 --- /dev/null +++ b/misc/architecture-model-generator/src/main/java/module-info.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +module io.ballerina.architecturemodelgenerator { + requires com.google.gson; + requires io.ballerina.lang; + requires io.ballerina.parser; + requires io.ballerina.tools.api; + + exports io.ballerina.architecturemodelgenerator; + exports io.ballerina.architecturemodelgenerator.diagnostics; +} diff --git a/misc/compiler-plugins/modules/architecture-model-generator-pligin/build.gradle b/misc/compiler-plugins/modules/architecture-model-generator-pligin/build.gradle new file mode 100644 index 000000000000..252d1adc5be1 --- /dev/null +++ b/misc/compiler-plugins/modules/architecture-model-generator-pligin/build.gradle @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (http://wso2.com) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +apply from: "$rootDir/gradle/javaProject.gradle" +apply from: "$rootDir/gradle/ballerinaLangLibLoad.gradle" + +description = 'Ballerina Component Model Generator' + +dependencies { + implementation project(':ballerina-lang') + implementation project(':ballerina-parser') + implementation project(':ballerina-tools-api') + + implementation project(':architecture-model-generator') + implementation "com.google.code.gson:gson:${project.gsonVersion}" +} + +ext.moduleName = 'io.ballerina.modelgenerator.plugin' + +compileJava { + doFirst { + options.compilerArgs = [ + '--module-path', classpath.asPath, + ] + classpath = files() + } +} diff --git a/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/CompilationAnalysisTask.java b/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/CompilationAnalysisTask.java new file mode 100644 index 000000000000..dff9de53890e --- /dev/null +++ b/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/CompilationAnalysisTask.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (http://wso2.com) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.ballerina.architecturemodelgeneratorplugin; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import io.ballerina.architecturemodelgenerator.ComponentModel; +import io.ballerina.architecturemodelgenerator.ComponentModelBuilder; +import io.ballerina.architecturemodelgeneratorplugin.diagnostic.DiagnosticMessage; +import io.ballerina.projects.BuildOptions; +import io.ballerina.projects.Project; +import io.ballerina.projects.plugins.AnalysisTask; +import io.ballerina.projects.plugins.CompilationAnalysisContext; +import io.ballerina.tools.diagnostics.Diagnostic; +import io.ballerina.tools.diagnostics.DiagnosticFactory; +import io.ballerina.tools.diagnostics.DiagnosticInfo; + +import java.io.FileWriter; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.InvalidPathException; +import java.nio.file.Path; + +import static io.ballerina.architecturemodelgeneratorplugin.PluginConstants.MODEL_DIR_NAME; +import static io.ballerina.architecturemodelgeneratorplugin.PluginConstants.MODEL_JSON_NAME; + +/** + * Compilation analyzer to generate component model. + * + * @since 2201.4.0 + */ +public class CompilationAnalysisTask implements AnalysisTask { + @Override + public void perform(CompilationAnalysisContext compilationAnalysisContext) { + Project project = compilationAnalysisContext.currentPackage().project(); + + //Used build option exportComponentModel() to enable plugin at the build time. + BuildOptions buildOptions = project.buildOptions(); + if (buildOptions.exportComponentModel()) { + Path outPath = project.targetDir(); + ComponentModelBuilder componentModelBuilder = new ComponentModelBuilder(); + ComponentModel projectModel = componentModelBuilder + .constructComponentModel(compilationAnalysisContext.currentPackage(), + compilationAnalysisContext.compilation()); + Gson gson = new GsonBuilder().setPrettyPrinting().serializeNulls().create(); + String componentModelJson = gson.toJson(projectModel) + System.lineSeparator(); + writeComponentModelJson(outPath, componentModelJson, compilationAnalysisContext); + } + } + + private void writeComponentModelJson(Path outPath, String componentModelJson, CompilationAnalysisContext context) { + try { + // Create ComponentModel directory if not exists in the path. If exists do not throw an error + Path componentModelExportDir = outPath.resolve(MODEL_DIR_NAME); + Files.createDirectories(componentModelExportDir); + Path writePath = componentModelExportDir.resolve(MODEL_JSON_NAME); + writeFile(writePath, componentModelJson); + } catch (InvalidPathException | SecurityException | IOException e) { + DiagnosticMessage diagnosticMessage = DiagnosticMessage.ERROR_100; + DiagnosticInfo diagnosticInfo = new DiagnosticInfo(diagnosticMessage.getCode(), + diagnosticMessage.getMessageFormat(), diagnosticMessage.getSeverity()); + Diagnostic diagnostic = DiagnosticFactory.createDiagnostic(diagnosticInfo, null, e.getMessage()); + context.reportDiagnostic(diagnostic); + } + } + + private void writeFile(Path filePath, String content) throws IOException { + try (FileWriter writer = new FileWriter(filePath.toString(), StandardCharsets.UTF_8)) { + writer.write(content); + } + } +} diff --git a/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCodeAnalyzer.java b/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCodeAnalyzer.java new file mode 100644 index 000000000000..eb4d62a1be87 --- /dev/null +++ b/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCodeAnalyzer.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (http://wso2.com) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package io.ballerina.architecturemodelgeneratorplugin; + +import io.ballerina.projects.plugins.CodeAnalysisContext; +import io.ballerina.projects.plugins.CodeAnalyzer; + +/** + * CodeAnalyzer for Component model generator compiler plugin. + * + * @since 2201.4.0 + */ +public class ModelGeneratorCodeAnalyzer extends CodeAnalyzer { + @Override + public void init(CodeAnalysisContext analysisContext) { + analysisContext.addCompilationAnalysisTask(new CompilationAnalysisTask()); + } +} diff --git a/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCompilerPlugin.java b/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCompilerPlugin.java new file mode 100644 index 000000000000..0526a04d3d18 --- /dev/null +++ b/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCompilerPlugin.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (http://wso2.com) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.ballerina.architecturemodelgeneratorplugin; + +import io.ballerina.projects.plugins.CompilerPlugin; +import io.ballerina.projects.plugins.CompilerPluginContext; + +/** + * Compiler Plugin to generate Component Models. + * + * @since 2201.4.0 + */ +public class ModelGeneratorCompilerPlugin extends CompilerPlugin { + @Override + public void init(CompilerPluginContext pluginContext) { + pluginContext.addCodeAnalyzer(new ModelGeneratorCodeAnalyzer()); + } +} diff --git a/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/PluginConstants.java b/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/PluginConstants.java new file mode 100644 index 000000000000..30b339bb21b4 --- /dev/null +++ b/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/PluginConstants.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (http://wso2.com) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.ballerina.architecturemodelgeneratorplugin; + +/** + * Plugin Constants. + * + * @since 2201.4.0 + */ +public class PluginConstants { + public static final String MODEL_DIR_NAME = "component-model"; + public static final String MODEL_JSON_NAME = "component-model.json"; +} diff --git a/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/diagnostic/DiagnosticMessage.java b/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/diagnostic/DiagnosticMessage.java new file mode 100644 index 000000000000..c361d3533876 --- /dev/null +++ b/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/diagnostic/DiagnosticMessage.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (http://wso2.com) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.ballerina.architecturemodelgeneratorplugin.diagnostic; + +import io.ballerina.tools.diagnostics.DiagnosticSeverity; + +/** + * Model Generator compiler plugin diagnostic messages. + * + * @since 2201.4.0 + */ +public enum DiagnosticMessage { + ERROR_100("MODEL_GENERATOR_PLUGIN_ERROR_100", + "Failed to write the generated Component Model JSON to the target directory: {0}.", + DiagnosticSeverity.ERROR); + + private final String code; + private final String messageFormat; + private final DiagnosticSeverity severity; + + DiagnosticMessage(String code, String messageFormat, DiagnosticSeverity severity) { + this.code = code; + this.messageFormat = messageFormat; + this.severity = severity; + } + + public String getCode() { + return this.code; + } + + public String getMessageFormat() { + return this.messageFormat; + } + + public DiagnosticSeverity getSeverity() { + return this.severity; + } +} diff --git a/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/module-info.java b/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/module-info.java new file mode 100644 index 000000000000..3f9fc5362750 --- /dev/null +++ b/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/module-info.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +module io.ballerina.modelgenerator.plugin { + requires com.google.gson; + requires io.ballerina.lang; + requires io.ballerina.parser; + requires io.ballerina.tools.api; + requires io.ballerina.architecturemodelgenerator; + + exports io.ballerina.architecturemodelgeneratorplugin; +} diff --git a/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/resources/META-INF/services/io.ballerina.projects.plugins.CompilerPlugin b/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/resources/META-INF/services/io.ballerina.projects.plugins.CompilerPlugin new file mode 100644 index 000000000000..8901ab6d2807 --- /dev/null +++ b/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/resources/META-INF/services/io.ballerina.projects.plugins.CompilerPlugin @@ -0,0 +1 @@ +io.ballerina.architecturemodelgeneratorplugin.ModelGeneratorCompilerPlugin diff --git a/misc/ls-extensions/modules/project-design-service/build.gradle b/misc/ls-extensions/modules/project-design-service/build.gradle index 2689b406d6e1..526a5ac6b0ea 100644 --- a/misc/ls-extensions/modules/project-design-service/build.gradle +++ b/misc/ls-extensions/modules/project-design-service/build.gradle @@ -25,7 +25,6 @@ configurations { } dependencies { - compileOnly project(':ballerina-parser') compileOnly project(':ballerina-lang') compileOnly project(':ballerina-tools-api') compileOnly project(':language-server:language-server-commons') @@ -33,14 +32,9 @@ dependencies { compileOnly(group: 'org.eclipse.lsp4j', name: 'org.eclipse.lsp4j', version: "${project.eclipseLsp4jVersion}") + implementation project(":architecture-model-generator") + testCompile 'org.testng:testng' - testCompile project(':ballerina-parser') - testCompile project(':language-server:language-server-commons') - testCompile project(':language-server:language-server-core') - testCompile 'com.google.code.gson:gson:"${project.gsonVersion}"' - testCompile(group: 'org.eclipse.lsp4j', name: 'org.eclipse.lsp4j', version: "${project.eclipseLsp4jVersion}") - testCompile(group: 'net.javacrumbs.json-unit', name: 'json-unit-assertj', version: '2.28.0') - testCompile(group: 'net.javacrumbs.json-unit', name: 'json-unit-json-path', version: '2.28.0') } diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignClientCapabilities.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignClientCapabilities.java index 8d01b2687efe..e24f7fda6402 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignClientCapabilities.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignClientCapabilities.java @@ -18,6 +18,7 @@ package io.ballerina.projectdesign; +import io.ballerina.architecturemodelgenerator.ProjectDesignConstants; import org.ballerinalang.langserver.commons.registration.BallerinaClientCapability; /** diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignClientCapabilitySetter.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignClientCapabilitySetter.java index ce81429f66f8..bd0f33236c6a 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignClientCapabilitySetter.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignClientCapabilitySetter.java @@ -18,6 +18,7 @@ package io.ballerina.projectdesign; +import io.ballerina.architecturemodelgenerator.ProjectDesignConstants; import org.ballerinalang.annotation.JavaSPIService; import org.ballerinalang.langserver.commons.registration.BallerinaClientCapabilitySetter; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignServerCapabilities.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignServerCapabilities.java index 89255f0f49ee..a91877d9acd2 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignServerCapabilities.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignServerCapabilities.java @@ -18,6 +18,7 @@ package io.ballerina.projectdesign; +import io.ballerina.architecturemodelgenerator.ProjectDesignConstants; import org.ballerinalang.langserver.commons.registration.BallerinaServerCapability; /** diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignServerCapabilitySetter.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignServerCapabilitySetter.java index 3089a7e88941..a36002e9683a 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignServerCapabilitySetter.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignServerCapabilitySetter.java @@ -18,6 +18,7 @@ package io.ballerina.projectdesign; +import io.ballerina.architecturemodelgenerator.ProjectDesignConstants; import org.ballerinalang.annotation.JavaSPIService; import org.ballerinalang.langserver.commons.registration.BallerinaServerCapabilitySetter; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignService.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignService.java index d9bd0205a1ae..f60447d81eb4 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignService.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignService.java @@ -21,9 +21,13 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; -import io.ballerina.projectdesign.diagnostics.ComponentModelException; -import io.ballerina.projectdesign.diagnostics.DiagnosticMessage; -import io.ballerina.projectdesign.diagnostics.DiagnosticUtils; +import io.ballerina.architecturemodelgenerator.ComponentModel; +import io.ballerina.architecturemodelgenerator.ComponentModelBuilder; +import io.ballerina.architecturemodelgenerator.ProjectComponentRequest; +import io.ballerina.architecturemodelgenerator.ProjectComponentResponse; +import io.ballerina.architecturemodelgenerator.diagnostics.ComponentModelException; +import io.ballerina.architecturemodelgenerator.diagnostics.DiagnosticMessage; +import io.ballerina.architecturemodelgenerator.diagnostics.DiagnosticUtils; import io.ballerina.projects.Project; import org.ballerinalang.annotation.JavaSPIService; import org.ballerinalang.langserver.commons.eventsync.exceptions.EventSyncException; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/Utils.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/Utils.java index 9e2b353f106c..46697533a3de 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/Utils.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/Utils.java @@ -1,6 +1,25 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + package io.ballerina.projectdesign; import com.google.gson.JsonObject; +import io.ballerina.architecturemodelgenerator.ComponentModel; import io.ballerina.projects.Package; import java.util.Map; @@ -11,7 +30,6 @@ * @since 2201.2.2 */ public class Utils { - public static String getQualifiedPackageName(ComponentModel.PackageId packageId) { return String.format("%s/%s:%s", packageId.getOrg(), diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/module-info.java b/misc/ls-extensions/modules/project-design-service/src/main/java/module-info.java index a9a33f316f6d..9cdff86a2c12 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/module-info.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/module-info.java @@ -1,11 +1,28 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + module io.ballerina.LSExtensions.ProjectDesignService { requires io.ballerina.language.server.commons; requires io.ballerina.lang; requires org.eclipse.lsp4j.jsonrpc; requires org.eclipse.lsp4j; - requires io.ballerina.parser; requires com.google.gson; requires io.ballerina.tools.api; requires io.ballerina.language.server.core; - -} \ No newline at end of file + requires io.ballerina.architecturemodelgenerator; +} diff --git a/settings.gradle b/settings.gradle index f11f02d5a257..b43c28bdaeb0 100644 --- a/settings.gradle +++ b/settings.gradle @@ -98,6 +98,7 @@ include(':language-server-simulator') // TODO: enable at 'dependsOn' of tools-intergration-tests // and 'mustRunAfter' of vs-code-pluggin +include(':architecture-model-generator') include(':benchmarks') include(':build-config:checkstyle') include(':debug-adapter:debug-adapter-core') @@ -105,6 +106,7 @@ include(':debug-adapter:debug-adapter-cli') include(':debug-adapter:debug-adapter-runtime') include('semver-checker:semver-checker-cli') include('semver-checker:semver-checker-core') +include(':compiler-plugins:architecture-model-generator-pligin') include(':compiler-plugins:package-semantic-analyzer') include(':compiler-plugins:configurable-schema-generator') include(':formatter:formatter-core') @@ -185,6 +187,7 @@ project(':ballerina-runtime').projectDir = file('bvm/ballerina-runtime') project(':ballerina-rt').projectDir = file('bvm/ballerina-rt') project(':ballerina-treegen').projectDir = file('compiler/ballerina-treegen') project(':ballerina-test-utils').projectDir = file('tests/ballerina-test-utils') +project(':architecture-model-generator').projectDir = file('misc/architecture-model-generator') project(':ballerina-io-internal').projectDir = file('misc/io-internal') project(':json-mapper').projectDir = file('misc/json-to-record-converter') project(':lib-creator').projectDir = file('misc/lib-creator') @@ -247,6 +250,7 @@ project(':debug-adapter:debug-adapter-cli').projectDir = file('misc/debug-adapte project(':debug-adapter:debug-adapter-runtime').projectDir = file('misc/debug-adapter/modules/debug-adapter-runtime') project(':semver-checker:semver-checker-core').projectDir = file('misc/semver-checker/modules/semver-checker-core') project(':semver-checker:semver-checker-cli').projectDir = file('misc/semver-checker/modules/semver-checker-cli') +project(':compiler-plugins:architecture-model-generator-pligin').projectDir = file('misc/compiler-plugins/modules/architecture-model-generator-pligin') project(':compiler-plugins:package-semantic-analyzer').projectDir = file('misc/compiler-plugins/modules/package-semantic-analyzer') project(':compiler-plugins:configurable-schema-generator').projectDir = file('misc/compiler-plugins/modules/configurable-schema-generator') project(':formatter:formatter-core').projectDir = file('misc/formatter/modules/formatter-core') From cd61de20d8fe0b83f513b550cd9cd2e756ca83bf Mon Sep 17 00:00:00 2001 From: gabilang Date: Mon, 5 Dec 2022 07:14:02 +0530 Subject: [PATCH 160/450] Address review suggestions --- .../runtime/internal/TypeConverter.java | 17 +++++++++++++++-- .../ballerina/runtime/internal/cli/Option.java | 9 +++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeConverter.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeConverter.java index 41586961e529..186609d57388 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeConverter.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeConverter.java @@ -923,13 +923,26 @@ public static int stringToByte(String value) throws NumberFormatException, BErro } public static Double stringToFloat(String value) throws NumberFormatException { - String upperCaseValue = value.toUpperCase(); - if (upperCaseValue.endsWith("F") || upperCaseValue.endsWith("D")) { + if (hasFloatOrDecimalLiteralSuffix(value)) { throw new NumberFormatException(); } return Double.parseDouble(value); } + public static boolean hasFloatOrDecimalLiteralSuffix(String value) { + int length = value.length(); + if (length != 0) { + switch (value.substring(value.length() - 1)) { + case "F": + case "f": + case "D": + case "d": + return true; + } + } + return false; + } + public static Boolean stringToBoolean(String value) throws NumberFormatException { if ("true".equalsIgnoreCase(value) || "1".equalsIgnoreCase(value)) { return true; diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java index ba5a0d6eb953..c748c008a08e 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/cli/Option.java @@ -30,6 +30,7 @@ import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BMap; import io.ballerina.runtime.api.values.BString; +import io.ballerina.runtime.internal.TypeConverter; import java.util.ArrayList; import java.util.HashSet; @@ -92,12 +93,8 @@ private boolean isShortOption(String arg) { } private boolean isNumeric(String stringVal) { - if (stringVal.length() == 0) { - return false; - } - String upperCaseValue = stringVal.toUpperCase(); - if (upperCaseValue.endsWith("F") || upperCaseValue.endsWith("D")) { - stringVal = upperCaseValue.substring(0, stringVal.length() - 1); + if (TypeConverter.hasFloatOrDecimalLiteralSuffix(stringVal)) { + stringVal = stringVal.substring(0, stringVal.length() - 1); } return NUMBER_PATTERN.matcher(stringVal).matches() || HEX_LITERAL.matcher(stringVal).matches(); } From 330112b1a7b75a7131f0151658eea20d84619e68 Mon Sep 17 00:00:00 2001 From: Imesha Sudasingha Date: Mon, 5 Dec 2022 10:48:41 +0530 Subject: [PATCH 161/450] Update LS simulator to use main branch of nBallerina --- .github/workflows/language_server_simulator.yml | 2 +- tests/language-server-simulator/build.gradle | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/language_server_simulator.yml b/.github/workflows/language_server_simulator.yml index 4ac000d9649a..543a029a4761 100644 --- a/.github/workflows/language_server_simulator.yml +++ b/.github/workflows/language_server_simulator.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - branch: ["master", "2201.1.x", "2201.2.x", "2201.2.2-stage", "2201.3.x", "2201.3.0-stage"] + branch: ["master", "2201.2.x", "2201.3.x", "2201.3.0-stage"] skipGenerators: ["", "IMPORT_STATEMENT"] steps: diff --git a/tests/language-server-simulator/build.gradle b/tests/language-server-simulator/build.gradle index c451fd3f41e0..463a447e1201 100644 --- a/tests/language-server-simulator/build.gradle +++ b/tests/language-server-simulator/build.gradle @@ -77,7 +77,7 @@ jacocoTestReport { task downloadBalTestProject(type: Download) { // Download nBallerina latest tag - src "https://github.com/ballerina-platform/nballerina/archive/refs/tags/subset13.zip" + src "https://github.com/ballerina-platform/nballerina/archive/refs/heads/main.zip" onlyIfModified true dest new File("${buildDir}/nballeirna-src.zip") } @@ -94,7 +94,7 @@ task runLSSimulator(type: JavaExec) { dependsOn loadDistributionCache dependsOn unpackBalTestProject - def extractedBalSrcDir = "${buildDir}/${balSourceDir}/nballerina-subset13/compiler" + def extractedBalSrcDir = "${buildDir}/${balSourceDir}/nballerina-main/compiler" systemProperty "ls.simulation.src", "${extractedBalSrcDir}" systemProperty "ballerina.home", "$buildDir/" From db3274ccad796631b056d85d76535288f0970b5f Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Mon, 5 Dec 2022 11:00:14 +0530 Subject: [PATCH 162/450] Enable builds for PRs to langlib-examples --- .github/workflows/pull_request_ubuntu_build.yml | 1 + .github/workflows/pull_request_windows_build.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/pull_request_ubuntu_build.yml b/.github/workflows/pull_request_ubuntu_build.yml index 56f697eecf04..783664c2fd34 100644 --- a/.github/workflows/pull_request_ubuntu_build.yml +++ b/.github/workflows/pull_request_ubuntu_build.yml @@ -13,6 +13,7 @@ on: - 2201.[0-9]+.x - 2201.[0-9]+.[0-9]+-stage - native-build + - langlib-examples jobs: ubuntu_build: diff --git a/.github/workflows/pull_request_windows_build.yml b/.github/workflows/pull_request_windows_build.yml index 03ebfdbe648c..4d1cc215374a 100644 --- a/.github/workflows/pull_request_windows_build.yml +++ b/.github/workflows/pull_request_windows_build.yml @@ -13,6 +13,7 @@ on: - 2201.[0-9]+.x - 2201.[0-9]+.[0-9]+-stage - native-build + - langlib-examples jobs: windows_build: From 0d16536b142d709d752ccad6a6f38a4e28f96642 Mon Sep 17 00:00:00 2001 From: malinthar Date: Mon, 5 Dec 2022 11:30:52 +0530 Subject: [PATCH 163/450] Improve record field completions in named args --- .../completions/util/ContextTypeResolver.java | 3 +++ .../config/mapping_expr_in_named_arg.json | 26 +++++++++++++++++++ .../source/mapping_expr_in_named_arg.bal | 12 +++++++++ 3 files changed, 41 insertions(+) create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_in_named_arg.json create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/expression_context/source/mapping_expr_in_named_arg.bal diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/ContextTypeResolver.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/ContextTypeResolver.java index f65d438d44c2..0a56460fe3c5 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/ContextTypeResolver.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/ContextTypeResolver.java @@ -567,7 +567,10 @@ public Optional transform(NamedArgumentNode namedArgumentNode) { if (fieldSymbol.isPresent()) { return Optional.of(fieldSymbol.get().typeDescriptor()); } + break; } + case PARENTHESIZED_ARG_LIST: + return this.visit(namedArgumentNode.parent()); } return Optional.empty(); diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_in_named_arg.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_in_named_arg.json new file mode 100644 index 000000000000..f0ab49245bfe --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/mapping_expr_in_named_arg.json @@ -0,0 +1,26 @@ +{ + "position": { + "line": 11, + "character": 43 + }, + "source": "expression_context/source/mapping_expr_in_named_arg.bal", + "items": [ + { + "label": "readonly", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "U", + "filterText": "readonly", + "insertText": "readonly ", + "insertTextFormat": "Snippet" + }, + { + "label": "name", + "kind": "Field", + "detail": "Config.name", + "sortText": "K", + "insertText": "name: ${1:\"\"}", + "insertTextFormat": "Snippet" + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/source/mapping_expr_in_named_arg.bal b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/source/mapping_expr_in_named_arg.bal new file mode 100644 index 000000000000..0cda2221d1eb --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/source/mapping_expr_in_named_arg.bal @@ -0,0 +1,12 @@ +type Config record {| + int count = 10; + string name = "mock"; +|}; + +client class MyClient { + function init(string url, *Config config) { + + } +} + +MyClient cli = new ("", config = {count: 0,}); From 7a9c993a561010de53802674ec8fa42a7b544495 Mon Sep 17 00:00:00 2001 From: Shammi Kolonne Date: Mon, 5 Dec 2022 12:21:30 +0530 Subject: [PATCH 164/450] fix issues in bal init command --- .../resources/cli-help/ballerina-init.help | 2 +- .../io/ballerina/cli/cmd/InitCommandTest.java | 28 +++++++++++++++++-- .../ballerina/projects/util/ProjectUtils.java | 5 +++- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/cli/ballerina-cli/src/main/resources/cli-help/ballerina-init.help b/cli/ballerina-cli/src/main/resources/cli-help/ballerina-init.help index 3914ccbd1ce4..f9d664012549 100755 --- a/cli/ballerina-cli/src/main/resources/cli-help/ballerina-init.help +++ b/cli/ballerina-cli/src/main/resources/cli-help/ballerina-init.help @@ -1,5 +1,5 @@ NAME - ballerina-init - Create a new Ballerina package inside the current + ballerina-init - Initialize a Ballerina package inside the current directory SYNOPSIS diff --git a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/InitCommandTest.java b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/InitCommandTest.java index d52441a4ee3a..ccfe865fd4f7 100644 --- a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/InitCommandTest.java +++ b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/InitCommandTest.java @@ -260,7 +260,7 @@ public void testInitCommandArgAndHelp() throws IOException { initCommand.execute(); Assert.assertTrue(readOutput().contains( - " ballerina-init - Create a new Ballerina package inside the current\n")); + " ballerina-init - Initialize a Ballerina package inside the current\n")); } @@ -273,7 +273,7 @@ public void testInitCommandWithHelp() throws IOException { initCommand.execute(); Assert.assertTrue(readOutput().contains( - "ballerina-init - Create a new Ballerina package inside the current\n")); + "ballerina-init - Initialize a Ballerina package inside the current\n")); } @Test(description = "Test init command inside a directory with invalid package name") @@ -357,6 +357,30 @@ public void testInitCommandWithPackageNameHasInvalidUnderscores(String pkgName, Assert.assertTrue(readOutput().contains("invalid package name : '" + pkgName + "' :\n" + errMessage)); } + @DataProvider(name = "PackageNameHasOnlyDots") + public Object[][] providePackageNameHasOnlyDots() { + return new Object[][] { + { ".", "Package name can only contain alphanumerics and underscores." }, + { "..", "Package name can only contain alphanumerics and underscores." } + }; + } + @Test(description = "Test init command with package name has only dots", + dataProvider = "PackageNameHasOnlyDots") + public void testInitCommandWithPackageNameHasOnlyDots(String pkgName, String errMessage) + throws IOException { + Path projectPath = tmpDir.resolve("sample5"); + if (Files.notExists(projectPath)) { + Files.createDirectory(projectPath); + } + + String[] args = { pkgName }; + InitCommand initCommand = new InitCommand(projectPath, printStream, false); + new CommandLine(initCommand).parseArgs(args); + initCommand.execute(); + + Assert.assertTrue(readOutput().contains("invalid package name : '" + pkgName + "' :\n" + errMessage)); + } + @Test(description = "Test init command inside a ballerina project", dependsOnMethods = "testInitCommand") public void testInitCommandInsideProject() throws IOException { // Test if no arguments was passed in diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectUtils.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectUtils.java index 5b1668f77894..215e6d1e848d 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectUtils.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectUtils.java @@ -124,6 +124,7 @@ public class ProjectUtils { private static final String USER_HOME = "user.home"; private static final Pattern separatedIdentifierPattern = Pattern.compile("^[a-zA-Z0-9_.]*$"); + private static final Pattern onlyDotsPattern = Pattern.compile("^[.]+$"); private static final Pattern orgNamePattern = Pattern.compile("^[a-zA-Z0-9_]*$"); /** @@ -721,7 +722,9 @@ public static void checkExecutePermission(Path path) { private static boolean validateDotSeparatedIdentifiers(String identifiers) { Matcher m = separatedIdentifierPattern.matcher(identifiers); - return m.matches(); + Matcher mm = onlyDotsPattern.matcher(identifiers); + + return m.matches() && !mm.matches(); } /** From 4261ae79d7bb2145ffe8985f1fc763d4774cbe26 Mon Sep 17 00:00:00 2001 From: Sasindu Alahakoon Date: Mon, 5 Dec 2022 13:09:49 +0530 Subject: [PATCH 165/450] Sync with master branch --- .../io/ballerina/cli/cmd/BuildCommand.java | 6 + .../cli/task/RunNativeImageTestTask.java | 24 +- .../protobuf/1.0.1/java11/docs/Package.md | 2 +- .../io/ballerina/projects/BuildOptions.java | 10 + .../projects/CompilationOptions.java | 22 +- .../compiler/bir/codegen/JvmConstants.java | 5 +- .../compiler/bir/codegen/JvmSignatures.java | 2 + .../compiler/bir/codegen/JvmTypeGen.java | 12 +- .../bir/codegen/split/JvmConstantsGen.java | 13 + .../bir/codegen/split/JvmCreateTypeGen.java | 4 + .../constants/JvmErrorTypeConstantsGen.java | 150 ++++ distribution/zip/jballerina-tools/README.md | 4 +- .../zip/jballerina-tools/build.gradle | 1 + distribution/zip/jballerina/README.md | 4 +- language-server/README.md | 2 +- .../commons/DocumentServiceContext.java | 2 +- .../langserver/commons/HoverContext.java | 8 - .../context/ImportDeclarationNodeContext.java | 34 +- .../context/ImportOrgNameNodeContext.java | 2 +- .../AbstractDocumentServiceContext.java | 49 +- .../BallerinaDefinitionContextImpl.java | 29 +- .../contexts/CompletionContextImpl.java | 31 +- .../langserver/contexts/HoverContextImpl.java | 31 +- .../PositionedOperationContextImpl.java | 57 +- .../contexts/ReferencesContextImpl.java | 26 +- .../contexts/SignatureContextImpl.java | 25 +- .../BallerinaSymbolClientCapabilities.java | 10 + .../BallerinaSymbolServerCapabilities.java | 10 + .../symbol/BallerinaSymbolService.java | 141 +++- ...naSymbolServiceServerCapabilitySetter.java | 1 + .../ballerina/symbol/SymbolContext.java | 3 +- .../symbol/TypesFromFnDefinitionRequest.java | 52 ++ .../BallerinaTomlCompletionContext.java | 14 +- .../extensions/LSExtensionTestUtil.java | 24 + .../symbol/SymbolServiceTestUtil.java | 54 ++ .../symbol/TypeFromExpressionTest.java | 52 +- .../extensions/symbol/TypeFromSymbolTest.java | 19 +- .../symbol/TypesFromFnDefinitionTest.java | 676 ++++++++++++++++++ .../import_decl_with_no_module_name1.json | 38 + ...import_decl_with_partial_module_name1.json | 515 +++++++++++++ ...import_decl_with_partial_module_name2.json | 515 +++++++++++++ .../import_decl_with_no_module_name1.bal | 1 + .../import_decl_with_partial_module_name1.bal | 1 + .../import_decl_with_partial_module_name2.bal | 1 + .../symbol/typesFromFnDefinition.bal | 60 ++ .../architecture-model-generator/build.gradle | 56 ++ .../ComponentModel.java | 19 +- .../ComponentModelBuilder.java | 31 +- .../ProjectComponentRequest.java | 2 +- .../ProjectComponentResponse.java | 4 +- .../ProjectDesignConstants.java | 2 +- .../diagnostics/ComponentModelException.java | 2 +- .../ComponentModelingDiagnostics.java | 2 +- .../diagnostics/DiagnosticMessage.java | 2 +- .../diagnostics/DiagnosticUtils.java | 4 +- .../generators/GeneratorUtils.java | 68 +- .../entity/EntityModelGenerator.java | 118 ++- .../service/ServiceModelGenerator.java | 8 +- .../nodevisitors/ActionNodeVisitor.java | 75 +- .../ServiceDeclarationNodeVisitor.java | 14 +- .../ServiceMemberFunctionNodeVisitor.java | 22 +- .../nodevisitors/StatementNodeVisitor.java | 6 +- .../model/ElementLocation.java | 2 +- .../model/ModelElement.java | 2 +- .../model/entity/Association.java | 2 +- .../model/entity/Attribute.java | 6 +- .../model/entity/Entity.java | 15 +- .../model/service/FunctionParameter.java | 6 +- .../model/service/Interaction.java | 6 +- .../model/service/RemoteFunction.java | 6 +- .../model/service/Resource.java | 6 +- .../model/service/ResourceId.java | 2 +- .../model/service/ResourceParameter.java | 6 +- .../model/service/Service.java | 6 +- .../model/service/ServiceAnnotation.java | 4 +- .../src/main/java/module-info.java | 27 + .../build.gradle | 40 ++ .../CompilationAnalysisTask.java | 87 +++ .../ModelGeneratorCodeAnalyzer.java | 33 + .../ModelGeneratorCompilerPlugin.java | 32 + .../PluginConstants.java | 27 + .../diagnostic/DiagnosticMessage.java | 52 ++ .../src/main/java/module-info.java | 27 + ....ballerina.projects.plugins.CompilerPlugin | 1 + .../connector/models/connector/Type.java | 9 + misc/json-to-record-converter/README.md | 2 +- .../project-design-service/build.gradle | 10 +- .../ProjectDesignClientCapabilities.java | 1 + .../ProjectDesignClientCapabilitySetter.java | 1 + .../ProjectDesignServerCapabilities.java | 1 + .../ProjectDesignServerCapabilitySetter.java | 1 + .../projectdesign/ProjectDesignService.java | 10 +- .../io/ballerina/projectdesign/Utils.java | 20 +- .../src/main/java/module-info.java | 23 +- settings.gradle | 4 + .../binaryoperations/TypeTestExprTest.java | 3 +- .../deprecated_annotation_project/main.bal | 12 +- .../multi_line_docs_project/main.bal | 10 +- .../record_object_fields_project/main.bal | 10 +- .../binaryoperations/type-test-expr.bal | 174 +++++ 100 files changed, 3378 insertions(+), 485 deletions(-) create mode 100644 compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmErrorTypeConstantsGen.java create mode 100644 language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/TypesFromFnDefinitionRequest.java create mode 100644 language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolServiceTestUtil.java create mode 100644 language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnDefinitionTest.java create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_no_module_name1.json create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_partial_module_name1.json create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_partial_module_name2.json create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/import_decl/source/import_decl_with_no_module_name1.bal create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/import_decl/source/import_decl_with_partial_module_name1.bal create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/import_decl/source/import_decl_with_partial_module_name2.bal create mode 100644 language-server/modules/langserver-core/src/test/resources/extensions/symbol/typesFromFnDefinition.bal create mode 100644 misc/architecture-model-generator/build.gradle rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/ComponentModel.java (81%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/ComponentModelBuilder.java (63%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/ProjectComponentRequest.java (95%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/ProjectComponentResponse.java (93%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/ProjectDesignConstants.java (98%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/diagnostics/ComponentModelException.java (94%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/diagnostics/ComponentModelingDiagnostics.java (97%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/diagnostics/DiagnosticMessage.java (97%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/diagnostics/DiagnosticUtils.java (91%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/generators/GeneratorUtils.java (51%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/generators/entity/EntityModelGenerator.java (72%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/generators/service/ServiceModelGenerator.java (88%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/generators/service/nodevisitors/ActionNodeVisitor.java (80%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java (92%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java (95%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/generators/service/nodevisitors/StatementNodeVisitor.java (96%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/model/ElementLocation.java (97%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/model/ModelElement.java (95%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/model/entity/Association.java (96%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/model/entity/Attribute.java (90%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/model/entity/Entity.java (76%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/model/service/FunctionParameter.java (87%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/model/service/Interaction.java (86%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/model/service/RemoteFunction.java (89%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/model/service/Resource.java (90%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/model/service/ResourceId.java (95%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/model/service/ResourceParameter.java (88%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/model/service/Service.java (91%) rename misc/{ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign => architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator}/model/service/ServiceAnnotation.java (91%) create mode 100644 misc/architecture-model-generator/src/main/java/module-info.java create mode 100644 misc/compiler-plugins/modules/architecture-model-generator-pligin/build.gradle create mode 100644 misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/CompilationAnalysisTask.java create mode 100644 misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCodeAnalyzer.java create mode 100644 misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCompilerPlugin.java create mode 100644 misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/PluginConstants.java create mode 100644 misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/diagnostic/DiagnosticMessage.java create mode 100644 misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/module-info.java create mode 100644 misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/resources/META-INF/services/io.ballerina.projects.plugins.CompilerPlugin diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/BuildCommand.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/BuildCommand.java index b8ba8c4bb680..c54aeeded171 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/BuildCommand.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/BuildCommand.java @@ -171,6 +171,11 @@ public BuildCommand() { " the services in the current package") private Boolean exportOpenAPI; + @CommandLine.Option(names = "--export-component-model", description = "generate a model to represent " + + "interactions between the package components (i.e. service/type definitions) and, export it in JSON format", + hidden = true) + private Boolean exportComponentModel; + @CommandLine.Option(names = "--enable-cache", description = "enable caches for the compilation", hidden = true) private Boolean enableCache; @@ -294,6 +299,7 @@ private BuildOptions constructBuildOptions() { .setSticky(sticky) .setConfigSchemaGen(configSchemaGen) .setExportOpenAPI(exportOpenAPI) + .setExportComponentModel(exportComponentModel) .setEnableCache(enableCache) .setNativeImage(nativeImage); diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java index 298610719b54..df245085c315 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java @@ -241,17 +241,21 @@ private int runTestSuiteWithNativeImage(Package currentPackage, JBallerinaBacken String jacocoAgentJarPath = ""; String nativeImageCommand = System.getenv("GRAALVM_HOME"); - if (nativeImageCommand == null) { - throw new ProjectException("GraalVM installation directory not found. Set GRAALVM_HOME as an " + - "environment variable"); - } - nativeImageCommand += File.separator + BIN_DIR_NAME + File.separator - + (OS.contains("win") ? "native-image.cmd" : "native-image"); + try { + if (nativeImageCommand == null) { + throw new ProjectException("GraalVM installation directory not found. Set GRAALVM_HOME as an " + + "environment variable"); + } + nativeImageCommand += File.separator + BIN_DIR_NAME + File.separator + + (OS.contains("win") ? "native-image.cmd" : "native-image"); - File commandExecutable = Paths.get(nativeImageCommand).toFile(); - if (!commandExecutable.exists()) { - throw new ProjectException("Cannot find '" + commandExecutable.getName() + "' in the GRAALVM_HOME. " + - "Install it using: gu install native-image"); + File commandExecutable = Paths.get(nativeImageCommand).toFile(); + if (!commandExecutable.exists()) { + throw new ProjectException("Cannot find '" + commandExecutable.getName() + "' in the GRAALVM_HOME. " + + "Install it using: gu install native-image"); + } + } catch (ProjectException e) { + throw createLauncherException(e.getMessage()); } if (coverage) { diff --git a/cli/ballerina-cli/src/test/resources/test-resources/balacache-template/ballerina/protobuf/1.0.1/java11/docs/Package.md b/cli/ballerina-cli/src/test/resources/test-resources/balacache-template/ballerina/protobuf/1.0.1/java11/docs/Package.md index f3913df59766..e9a0380de011 100644 --- a/cli/ballerina-cli/src/test/resources/test-resources/balacache-template/ballerina/protobuf/1.0.1/java11/docs/Package.md +++ b/cli/ballerina-cli/src/test/resources/test-resources/balacache-template/ballerina/protobuf/1.0.1/java11/docs/Package.md @@ -9,5 +9,5 @@ This package contains a set of pre-defined protobuf types. To report bugs, request new features, start new discussions, view project boards, etc., go to the Ballerina standard library parent repository. ## Useful Links -- Chat live with us via our Slack channel. +- Chat live with us via our Discord server. - Post all technical questions on Stack Overflow with the #ballerina tag. diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/BuildOptions.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/BuildOptions.java index e46cf3da4c02..1ce3ae25e87c 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/BuildOptions.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/BuildOptions.java @@ -99,6 +99,10 @@ public boolean exportOpenAPI() { return this.compilationOptions.exportOpenAPI(); } + public boolean exportComponentModel() { + return this.compilationOptions.exportComponentModel(); + } + public boolean enableCache() { return this.compilationOptions.enableCache(); } @@ -163,6 +167,7 @@ public BuildOptions acceptTheirs(BuildOptions theirOptions) { buildOptionsBuilder.setSticky(compilationOptions.sticky); buildOptionsBuilder.setConfigSchemaGen(compilationOptions.configSchemaGen); buildOptionsBuilder.setExportOpenAPI(compilationOptions.exportOpenAPI); + buildOptionsBuilder.setExportComponentModel(compilationOptions.exportComponentModel); buildOptionsBuilder.setEnableCache(compilationOptions.enableCache); return buildOptionsBuilder.build(); @@ -323,6 +328,11 @@ public BuildOptionsBuilder setExportOpenAPI(Boolean value) { return this; } + public BuildOptionsBuilder setExportComponentModel(Boolean value) { + compilationOptionsBuilder.setExportComponentModel(value); + return this; + } + public BuildOptionsBuilder setEnableCache(Boolean value) { compilationOptionsBuilder.setEnableCache(value); enableCache = value; diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/CompilationOptions.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/CompilationOptions.java index 1263b6ff0040..766d36a29d28 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/CompilationOptions.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/CompilationOptions.java @@ -36,13 +36,14 @@ public class CompilationOptions { Boolean withCodeModifiers; Boolean configSchemaGen; Boolean exportOpenAPI; + Boolean exportComponentModel; Boolean enableCache; CompilationOptions(Boolean offlineBuild, Boolean observabilityIncluded, Boolean dumpBir, Boolean dumpBirFile, String cloud, Boolean listConflictedClasses, Boolean sticky, Boolean dumpGraph, Boolean dumpRawGraphs, Boolean withCodeGenerators, Boolean withCodeModifiers, Boolean configSchemaGen, Boolean exportOpenAPI, - Boolean enableCache) { + Boolean exportComponentModel, Boolean enableCache) { this.offlineBuild = offlineBuild; this.observabilityIncluded = observabilityIncluded; this.dumpBir = dumpBir; @@ -56,6 +57,7 @@ public class CompilationOptions { this.withCodeModifiers = withCodeModifiers; this.configSchemaGen = configSchemaGen; this.exportOpenAPI = exportOpenAPI; + this.exportComponentModel = exportComponentModel; this.enableCache = enableCache; } @@ -111,6 +113,10 @@ public boolean exportOpenAPI() { return toBooleanDefaultIfNull(this.exportOpenAPI); } + public boolean exportComponentModel() { + return toBooleanDefaultIfNull(this.exportComponentModel); + } + public boolean enableCache() { return toBooleanDefaultIfNull(this.enableCache); } @@ -188,6 +194,11 @@ CompilationOptions acceptTheirs(CompilationOptions theirOptions) { } else { compilationOptionsBuilder.setExportOpenAPI(this.exportOpenAPI); } + if (theirOptions.exportComponentModel != null) { + compilationOptionsBuilder.setExportComponentModel(theirOptions.exportComponentModel); + } else { + compilationOptionsBuilder.setExportComponentModel(this.exportComponentModel); + } if (theirOptions.enableCache != null) { compilationOptionsBuilder.setEnableCache(theirOptions.enableCache); } else { @@ -240,6 +251,7 @@ public static class CompilationOptionsBuilder { private Boolean withCodeModifiers; private Boolean configSchemaGen; private Boolean exportOpenAPI; + private Boolean exportComponentModel; private Boolean enableCache; public CompilationOptionsBuilder setOffline(Boolean value) { @@ -307,6 +319,11 @@ CompilationOptionsBuilder setExportOpenAPI(Boolean value) { return this; } + CompilationOptionsBuilder setExportComponentModel(Boolean value) { + exportComponentModel = value; + return this; + } + public CompilationOptionsBuilder setEnableCache(Boolean value) { enableCache = value; return this; @@ -315,7 +332,8 @@ public CompilationOptionsBuilder setEnableCache(Boolean value) { public CompilationOptions build() { return new CompilationOptions(offline, observabilityIncluded, dumpBir, dumpBirFile, cloud, listConflictedClasses, sticky, dumpGraph, dumpRawGraph, - withCodeGenerators, withCodeModifiers, configSchemaGen, exportOpenAPI, enableCache); + withCodeGenerators, withCodeModifiers, configSchemaGen, exportOpenAPI, + exportComponentModel, enableCache); } } } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java index 7eeaa922f298..8dcd8ada020a 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java @@ -177,6 +177,7 @@ public class JvmConstants { public static final String LARGE_STRING_VAR_PREFIX = "$stringChunk"; public static final String GET_SURROGATE_ARRAY_METHOD_PREFIX = "getSurrogateArray"; public static final String UNION_TYPE_VAR_PREFIX = "$unionType"; + public static final String ERROR_TYPE_VAR_PREFIX = "$errorType"; public static final String TYPEREF_TYPE_VAR_PREFIX = "$typeRefType$"; public static final String TUPLE_TYPE_VAR_PREFIX = "$tupleType"; public static final String ARRAY_TYPE_VAR_PREFIX = "$arrayType"; @@ -292,7 +293,8 @@ public class JvmConstants { // code generation related constants. public static final String MODULE_INIT_CLASS_NAME = "$_init"; - public static final String UNION_TYPE_CONSTANT_CLASS_NAME = "constants/$_bunion_type_constants"; + public static final String UNION_TYPE_CONSTANT_CLASS_NAME = "constants/$_union_type_constants"; + public static final String ERROR_TYPE_CONSTANT_CLASS_NAME = "constants/$_error_type_constants"; public static final String TUPLE_TYPE_CONSTANT_CLASS_NAME = "constants/$_tuple_type_constants"; public static final String ARRAY_TYPE_CONSTANT_CLASS_NAME = "constants/$_array_type_constants"; public static final String TYPEREF_TYPE_CONSTANT_CLASS_NAME = "constants/$_typeref_type_constants"; @@ -314,6 +316,7 @@ public class JvmConstants { public static final String MODULE_ANNOTATIONS_CLASS_NAME = "annotations/$_annotations"; public static final String B_STRING_INIT_METHOD_PREFIX = "$string_init"; public static final String B_UNION_TYPE_INIT_METHOD_PREFIX = "$union_type_init"; + public static final String B_ERROR_TYPE_INIT_METHOD_PREFIX = "$error_type_init"; public static final String B_TUPLE_TYPE_INIT_METHOD_PREFIX = "$tuple_type_init"; public static final String B_ARRAY_TYPE_INIT_METHOD_PREFIX = "$array_type_init"; public static final String B_TYPEREF_TYPE_INIT_METHOD_PREFIX = "$typeref_type_init"; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java index 5d893d1aa283..8675ebe0548c 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java @@ -44,6 +44,7 @@ import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.DECIMAL_VALUE; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.DOUBLE_VALUE; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.ERROR_TYPE; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.ERROR_TYPE_IMPL; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.ERROR_VALUE; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.FLOAT_TYPE; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.FUNCTION; @@ -257,6 +258,7 @@ public class JvmSignatures { public static final String GET_TYPEDESC = "L" + TYPEDESC_VALUE + ";"; public static final String GET_TYPEDESC_OF_OBJECT = "(L" + OBJECT + ";)L" + TYPEDESC_VALUE + ";"; public static final String GET_UNION_TYPE_IMPL = "L" + UNION_TYPE_IMPL + ";"; + public static final String GET_ERROR_TYPE_IMPL = "L" + ERROR_TYPE_IMPL + ";"; public static final String GET_TYPE_REF_TYPE_IMPL = "L" + TYPE_REF_TYPE_IMPL + ";"; public static final String GET_WD_CHANNELS = "L" + WD_CHANNELS + ";"; public static final String GET_WORKER_DATA_CHANNEL = "(L" + STRING_VALUE + ";)L" + WORKER_DATA_CHANNEL + ";"; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeGen.java index 3220052c25a6..7a3164312cd6 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeGen.java @@ -694,10 +694,14 @@ private void loadErrorType(MethodVisitor mv, BErrorType errorType) { mv.visitFieldInsn(GETSTATIC, PREDEFINED_TYPES, TYPES_ERROR, GET_ERROR_TYPE); return; } - String typeOwner = - JvmCodeGenUtil.getPackageName(pkgID) + MODULE_INIT_CLASS_NAME; - String fieldName = getTypeFieldName(toNameString(errorType)); - mv.visitFieldInsn(GETSTATIC, typeOwner, fieldName, GET_TYPE); + + if (Symbols.isFlagOn(errorType.flags, Flags.ANONYMOUS)) { + jvmConstantsGen.generateGetBErrorType(mv, jvmConstantsGen.getTypeConstantsVar(errorType, symbolTable)); + } else { + String typeOwner = JvmCodeGenUtil.getPackageName(pkgID) + MODULE_INIT_CLASS_NAME; + String fieldName = getTypeFieldName(toNameString(errorType)); + mv.visitFieldInsn(GETSTATIC, typeOwner, fieldName, GET_TYPE); + } } public boolean loadUnionName(MethodVisitor mv, BUnionType unionType) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmConstantsGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmConstantsGen.java index 3551c00c35d4..373593ae42e2 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmConstantsGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmConstantsGen.java @@ -23,6 +23,7 @@ import org.wso2.ballerinalang.compiler.bir.codegen.split.constants.JvmArrayTypeConstantsGen; import org.wso2.ballerinalang.compiler.bir.codegen.split.constants.JvmBStringConstantsGen; import org.wso2.ballerinalang.compiler.bir.codegen.split.constants.JvmBallerinaConstantsGen; +import org.wso2.ballerinalang.compiler.bir.codegen.split.constants.JvmErrorTypeConstantsGen; import org.wso2.ballerinalang.compiler.bir.codegen.split.constants.JvmModuleConstantsGen; import org.wso2.ballerinalang.compiler.bir.codegen.split.constants.JvmRefTypeConstantsGen; import org.wso2.ballerinalang.compiler.bir.codegen.split.constants.JvmTupleTypeConstantsGen; @@ -32,6 +33,7 @@ import org.wso2.ballerinalang.compiler.semantics.analyzer.Types; import org.wso2.ballerinalang.compiler.semantics.model.SymbolTable; import org.wso2.ballerinalang.compiler.semantics.model.types.BArrayType; +import org.wso2.ballerinalang.compiler.semantics.model.types.BErrorType; import org.wso2.ballerinalang.compiler.semantics.model.types.BTupleType; import org.wso2.ballerinalang.compiler.semantics.model.types.BType; import org.wso2.ballerinalang.compiler.semantics.model.types.BTypeReferenceType; @@ -51,6 +53,8 @@ public class JvmConstantsGen { private final JvmUnionTypeConstantsGen unionTypeConstantsGen; + private final JvmErrorTypeConstantsGen errorTypeConstantsGen; + private final JvmBStringConstantsGen stringConstantsGen; private final JvmModuleConstantsGen moduleConstantsGen; @@ -70,6 +74,7 @@ public JvmConstantsGen(BIRNode.BIRPackage module, String moduleInitClass, Types this.moduleConstantsGen = new JvmModuleConstantsGen(module); this.jvmBallerinaConstantsGen = new JvmBallerinaConstantsGen(module, moduleInitClass, this); this.unionTypeConstantsGen = new JvmUnionTypeConstantsGen(module.packageID, bTypeHashComparator); + this.errorTypeConstantsGen = new JvmErrorTypeConstantsGen(module.packageID, bTypeHashComparator); this.tupleTypeConstantsGen = new JvmTupleTypeConstantsGen(module.packageID, bTypeHashComparator); this.arrayTypeConstantsGen = new JvmArrayTypeConstantsGen(module.packageID, bTypeHashComparator, types); this.refTypeConstantsGen = new JvmRefTypeConstantsGen(module.packageID, bTypeHashComparator); @@ -85,6 +90,7 @@ public String getModuleConstantVar(PackageID packageID) { public void setJvmCreateTypeGen(JvmCreateTypeGen jvmCreateTypeGen) { unionTypeConstantsGen.setJvmUnionTypeGen(jvmCreateTypeGen.getJvmUnionTypeGen()); + errorTypeConstantsGen.setJvmErrorTypeGen(jvmCreateTypeGen.getJvmErrorTypeGen()); tupleTypeConstantsGen.setJvmTupleTypeGen(jvmCreateTypeGen.getJvmTupleTypeGen()); arrayTypeConstantsGen.setJvmArrayTypeGen(jvmCreateTypeGen.getJvmArrayTypeGen()); refTypeConstantsGen.setJvmRefTypeGen(jvmCreateTypeGen.getJvmRefTypeGen()); @@ -93,6 +99,7 @@ public void setJvmCreateTypeGen(JvmCreateTypeGen jvmCreateTypeGen) { public void generateConstants(Map jarEntries) { jvmBallerinaConstantsGen.generateConstantInit(jarEntries); unionTypeConstantsGen.generateClass(jarEntries); + errorTypeConstantsGen.generateClass(jarEntries); moduleConstantsGen.generateConstantInit(jarEntries); stringConstantsGen.generateConstantInit(jarEntries); tupleTypeConstantsGen.generateClass(jarEntries); @@ -100,6 +107,10 @@ public void generateConstants(Map jarEntries) { refTypeConstantsGen.generateClass(jarEntries); } + public void generateGetBErrorType(MethodVisitor mv, String varName) { + errorTypeConstantsGen.generateGetBErrorType(mv, varName); + } + public void generateGetBUnionType(MethodVisitor mv, String varName) { unionTypeConstantsGen.generateGetBUnionType(mv, varName); } @@ -114,6 +125,8 @@ public void generateGetBTypeRefType(MethodVisitor mv, String varName) { public String getTypeConstantsVar(BType type, SymbolTable symbolTable) { switch (type.tag) { + case TypeTags.ERROR: + return errorTypeConstantsGen.add((BErrorType) type); case TypeTags.ARRAY: return arrayTypeConstantsGen.add((BArrayType) type); case TypeTags.TUPLE: diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmCreateTypeGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmCreateTypeGen.java index 07c4fefeb19b..a690d6797869 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmCreateTypeGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmCreateTypeGen.java @@ -671,6 +671,10 @@ public JvmUnionTypeGen getJvmUnionTypeGen() { return jvmUnionTypeGen; } + public JvmErrorTypeGen getJvmErrorTypeGen() { + return jvmErrorTypeGen; + } + public JvmTupleTypeGen getJvmTupleTypeGen() { return jvmTupleTypeGen; } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmErrorTypeConstantsGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmErrorTypeConstantsGen.java new file mode 100644 index 000000000000..94117c3df3ca --- /dev/null +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmErrorTypeConstantsGen.java @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com) All Rights Reserved. + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.ballerinalang.compiler.bir.codegen.split.constants; + +import org.ballerinalang.model.elements.PackageID; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.FieldVisitor; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; +import org.wso2.ballerinalang.compiler.bir.codegen.BallerinaClassWriter; +import org.wso2.ballerinalang.compiler.bir.codegen.JvmCodeGenUtil; +import org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants; +import org.wso2.ballerinalang.compiler.bir.codegen.internal.BTypeHashComparator; +import org.wso2.ballerinalang.compiler.bir.codegen.split.types.JvmErrorTypeGen; +import org.wso2.ballerinalang.compiler.semantics.model.types.BErrorType; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +import static org.objectweb.asm.ClassWriter.COMPUTE_FRAMES; +import static org.objectweb.asm.Opcodes.ACC_FINAL; +import static org.objectweb.asm.Opcodes.ACC_PUBLIC; +import static org.objectweb.asm.Opcodes.ACC_STATIC; +import static org.objectweb.asm.Opcodes.GETSTATIC; +import static org.objectweb.asm.Opcodes.INVOKESTATIC; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_ERROR_TYPE_INIT_METHOD_PREFIX; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_ERROR_TYPE_IMPL; +import static org.wso2.ballerinalang.compiler.bir.codegen.split.constants.JvmConstantGenCommons.genMethodReturn; +import static org.wso2.ballerinalang.compiler.bir.codegen.split.constants.JvmConstantGenCommons.generateConstantsClassInit; + +/** + * Generates the JVM class for the ballerina error types as constants for a given module. + * Anonymous distinct error types are generated in this class. + * + * @since 2201.4.0 + */ +public class JvmErrorTypeConstantsGen { + + private final String errorVarConstantsClass; + private int constantIndex = 0; + private JvmErrorTypeGen jvmErrorTypeGen; + private final ClassWriter cw; + private MethodVisitor mv; + private int methodCount; + private final List funcNames; + private final Map errorTypeVarMap; + + public JvmErrorTypeConstantsGen(PackageID packageID, BTypeHashComparator bTypeHashComparator) { + errorVarConstantsClass = JvmCodeGenUtil.getModuleLevelClassName(packageID, + JvmConstants.ERROR_TYPE_CONSTANT_CLASS_NAME); + cw = new BallerinaClassWriter(COMPUTE_FRAMES); + generateConstantsClassInit(cw, errorVarConstantsClass); + visitErrorTypeInitMethod(); + funcNames = new ArrayList<>(); + errorTypeVarMap = new TreeMap<>(bTypeHashComparator); + } + + public void setJvmErrorTypeGen(JvmErrorTypeGen jvmErrorTypeGen) { + this.jvmErrorTypeGen = jvmErrorTypeGen; + } + + public String add(BErrorType type) { + String varName = errorTypeVarMap.get(type); + if (varName == null) { + varName = generateBErrorInits(type); + errorTypeVarMap.put(type, varName); + } + return varName; + } + + private void visitErrorTypeInitMethod() { + mv = cw.visitMethod(ACC_STATIC, B_ERROR_TYPE_INIT_METHOD_PREFIX + methodCount++, + "()V", null, null); + } + + private String generateBErrorInits(BErrorType type) { + String varName = JvmConstants.ERROR_TYPE_VAR_PREFIX + constantIndex++; + visitBErrorField(varName); + createBErrorType(mv, type, varName); + genPopulateMethod(type, varName); + return varName; + } + + private void genPopulateMethod(BErrorType type, String varName) { + String methodName = "$populate" + varName; + funcNames.add(methodName); + MethodVisitor methodVisitor = cw.visitMethod(ACC_STATIC, methodName, "()V", null, null); + methodVisitor.visitCode(); + generateGetBErrorType(methodVisitor, varName); + jvmErrorTypeGen.populateError(methodVisitor, type); + genMethodReturn(methodVisitor); + } + + private void createBErrorType(MethodVisitor mv, BErrorType errorType, String varName) { + jvmErrorTypeGen.createErrorType(mv, errorType, errorType.tsymbol.name.value); + mv.visitFieldInsn(Opcodes.PUTSTATIC, errorVarConstantsClass, varName, + GET_ERROR_TYPE_IMPL); + } + + private void visitBErrorField(String varName) { + FieldVisitor fv = cw.visitField(ACC_PUBLIC + ACC_FINAL + ACC_STATIC, varName, + GET_ERROR_TYPE_IMPL, null, null); + fv.visitEnd(); + } + + public void generateGetBErrorType(MethodVisitor mv, String varName) { + mv.visitFieldInsn(GETSTATIC, errorVarConstantsClass, varName, + GET_ERROR_TYPE_IMPL); + } + + public void generateClass(Map jarEntries) { + genMethodReturn(mv); + visitErrorTypeInitMethod(); + for (String funcName : funcNames) { + mv.visitMethodInsn(INVOKESTATIC, errorVarConstantsClass, funcName, "()V", false); + } + genMethodReturn(mv); + generateStaticInitializer(cw); + cw.visitEnd(); + jarEntries.put(errorVarConstantsClass + ".class", cw.toByteArray()); + } + + private void generateStaticInitializer(ClassWriter cw) { + MethodVisitor methodVisitor = cw.visitMethod(ACC_STATIC, "", "()V", null, null); + for (int i = 0; i < methodCount; i++) { + methodVisitor.visitMethodInsn(INVOKESTATIC, errorVarConstantsClass, + B_ERROR_TYPE_INIT_METHOD_PREFIX + i, + "()V", false); + } + genMethodReturn(methodVisitor); + } +} diff --git a/distribution/zip/jballerina-tools/README.md b/distribution/zip/jballerina-tools/README.md index 9c8b72c9add8..1a0c1737a0b5 100644 --- a/distribution/zip/jballerina-tools/README.md +++ b/distribution/zip/jballerina-tools/README.md @@ -26,5 +26,5 @@ Ballerina code is distributed under [Apache license 2.0](https://github.com/ball ## Useful links - The ballerina-dev@googlegroups.com mailing list is for discussing code changes to the Ballerina project. -- Chat live with us on our [Slack channel](https://ballerina-platform.slack.com/). -- Technical questions should be posted on Stack Overflow with the [#ballerina](https://stackoverflow.com/questions/tagged/ballerina) tag. \ No newline at end of file +- Chat live with us on our [Discord server](https://discord.gg/ballerinalang). +- Technical questions should be posted on Stack Overflow with the [#ballerina](https://stackoverflow.com/questions/tagged/ballerina) tag. diff --git a/distribution/zip/jballerina-tools/build.gradle b/distribution/zip/jballerina-tools/build.gradle index 1d46c6f24f34..3033493710d1 100644 --- a/distribution/zip/jballerina-tools/build.gradle +++ b/distribution/zip/jballerina-tools/build.gradle @@ -123,6 +123,7 @@ dependencies { dist project(':ballerina-shell:shell-cli') dist project(':compiler-plugins:package-semantic-analyzer') dist project(':compiler-plugins:configurable-schema-generator') + dist project(':compiler-plugins:architecture-model-generator-pligin') dist project(':identifier-util') datamapperLib project(':ballerinalang-data-mapper') diff --git a/distribution/zip/jballerina/README.md b/distribution/zip/jballerina/README.md index 9c8b72c9add8..1a0c1737a0b5 100644 --- a/distribution/zip/jballerina/README.md +++ b/distribution/zip/jballerina/README.md @@ -26,5 +26,5 @@ Ballerina code is distributed under [Apache license 2.0](https://github.com/ball ## Useful links - The ballerina-dev@googlegroups.com mailing list is for discussing code changes to the Ballerina project. -- Chat live with us on our [Slack channel](https://ballerina-platform.slack.com/). -- Technical questions should be posted on Stack Overflow with the [#ballerina](https://stackoverflow.com/questions/tagged/ballerina) tag. \ No newline at end of file +- Chat live with us on our [Discord server](https://discord.gg/ballerinalang). +- Technical questions should be posted on Stack Overflow with the [#ballerina](https://stackoverflow.com/questions/tagged/ballerina) tag. diff --git a/language-server/README.md b/language-server/README.md index 0974f63d3a04..6af6efe6863d 100644 --- a/language-server/README.md +++ b/language-server/README.md @@ -40,4 +40,4 @@ Ballerina Language Server is currently work in progress and feel free to follow ## Contact Us Managed By [WSO2 Inc.](https://wso2.com/) -Slack channel : [Ballerina Platform](https://ballerina-platform.slack.com/) +Discord server: [Ballerina](https://discord.gg/ballerinalang) diff --git a/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/DocumentServiceContext.java b/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/DocumentServiceContext.java index 2accdee10d86..137201062cc4 100644 --- a/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/DocumentServiceContext.java +++ b/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/DocumentServiceContext.java @@ -76,7 +76,7 @@ public interface DocumentServiceContext { * @return {@link LSOperation} */ LSOperation operation(); - + /** * Get the imports in the current document. * This API is deprecated. Instead, use {@link #currentDocImportsMap} diff --git a/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/HoverContext.java b/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/HoverContext.java index c09e84df8cdc..531ba0c88686 100644 --- a/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/HoverContext.java +++ b/language-server/modules/langserver-commons/src/main/java/org/ballerinalang/langserver/commons/HoverContext.java @@ -19,7 +19,6 @@ import io.ballerina.compiler.syntax.tree.NonTerminalNode; import io.ballerina.compiler.syntax.tree.Token; -import org.eclipse.lsp4j.Position; /** * Represents the hover operation context. @@ -43,13 +42,6 @@ public interface HoverContext extends PositionedOperationContext { */ Token getTokenAtCursor(); - /** - * Get the cursor position. - * - * @return {@link Position} - */ - Position getCursorPosition(); - /** * Set the node at cursor. * diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportDeclarationNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportDeclarationNodeContext.java index b1cb028561bb..036dafd35c24 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportDeclarationNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportDeclarationNodeContext.java @@ -27,10 +27,12 @@ import io.ballerina.projects.PackageName; import io.ballerina.projects.Project; import io.ballerina.projects.ProjectKind; +import io.ballerina.tools.text.LinePosition; import org.ballerinalang.annotation.JavaSPIService; import org.ballerinalang.langserver.LSPackageLoader; import org.ballerinalang.langserver.common.utils.CommonUtil; import org.ballerinalang.langserver.common.utils.ModuleUtil; +import org.ballerinalang.langserver.common.utils.PositionUtil; import org.ballerinalang.langserver.commons.BallerinaCompletionContext; import org.ballerinalang.langserver.commons.LanguageServerContext; import org.ballerinalang.langserver.commons.completion.LSCompletionItem; @@ -38,6 +40,8 @@ import org.ballerinalang.langserver.completions.providers.AbstractCompletionProvider; import org.ballerinalang.langserver.completions.util.Snippet; import org.eclipse.lsp4j.CompletionItem; +import org.eclipse.lsp4j.Range; +import org.eclipse.lsp4j.TextEdit; import org.wso2.ballerinalang.compiler.util.Names; import java.util.ArrayList; @@ -79,6 +83,7 @@ public List getCompletions(BallerinaCompletionContext ctx, Imp (3) import abc.xy (4) import org/mod (5) import org/mod v + (6) import org/mod. Suggests org names and the module names within the same directory */ @@ -103,8 +108,7 @@ public List getCompletions(BallerinaCompletionContext ctx, Imp /* Covers case (4) */ - String orgName = node.orgName().get().orgName().text(); - completionItems.addAll(this.moduleNameContextCompletions(ctx, orgName)); + completionItems.addAll(this.moduleNameContextCompletions(ctx, node)); contextScope = ContextScope.SCOPE2; } else { /* @@ -266,7 +270,27 @@ private List getCurrentProjectModules(BallerinaCompletionConte } private ArrayList moduleNameContextCompletions(BallerinaCompletionContext context, - String orgName) { + ImportDeclarationNode node) { + String orgName = node.orgName().get().orgName().text(); + List additionalEdits = new ArrayList<>(); + // If the module name contains a dot, we should replace what's before the last dot to make sure a part + // of the module name is not repeated. + if (node.moduleName().size() > 1) { + // There can be 2 cases: + // 1) orgName/mod.xx + // 2) orgName/mod. + IdentifierToken lastModeNamePart = node.moduleName().get(node.moduleName().size() - 1); + LinePosition startPos = node.orgName().get().lineRange().endLine(); + LinePosition endPos = lastModeNamePart.lineRange().endLine(); + if (!lastModeNamePart.isMissing()) { + // Case (2) above + endPos = lastModeNamePart.lineRange().startLine(); + } + Range editRange = new Range(PositionUtil.toPosition(startPos), PositionUtil.toPosition(endPos)); + TextEdit removeModNameEdit = new TextEdit(editRange, ""); + additionalEdits.add(removeModNameEdit); + } + ArrayList completionItems = new ArrayList<>(); List addedPkgNames = new ArrayList<>(); LanguageServerContext serverContext = context.languageServercontext(); @@ -285,7 +309,9 @@ private ArrayList moduleNameContextCompletions(BallerinaComple } addedPkgNames.add(packageName); // Do not add the semi colon at the end of the insert text since the user might type the as keyword - completionItems.add(getImportCompletion(context, packageName, insertText)); + LSCompletionItem completionItem = getImportCompletion(context, packageName, insertText); + completionItem.getCompletionItem().setAdditionalTextEdits(additionalEdits); + completionItems.add(completionItem); } }); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportOrgNameNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportOrgNameNodeContext.java index 621ea75ead47..baac84937ed5 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportOrgNameNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportOrgNameNodeContext.java @@ -56,7 +56,7 @@ public List getCompletions(BallerinaCompletionContext ctx, Imp } List moduleList = - new ArrayList<>(LSPackageLoader.getInstance(ctx.languageServercontext()).getDistributionRepoPackages()); + new ArrayList<>(LSPackageLoader.getInstance(ctx.languageServercontext()).getAllVisiblePackages(ctx)); ArrayList completionItems = moduleNameContextCompletions(ctx, orgName, moduleList); this.sort(ctx, node, completionItems); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/AbstractDocumentServiceContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/AbstractDocumentServiceContext.java index 42ddb36a1b42..df2ebade2f90 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/AbstractDocumentServiceContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/AbstractDocumentServiceContext.java @@ -61,10 +61,6 @@ public class AbstractDocumentServiceContext implements DocumentServiceContext { private final WorkspaceManager workspaceManager; - private List visibleSymbols; - - private List currentDocImports; - private Map currentDocImportsMap; private Module currentModule; @@ -132,26 +128,23 @@ public LSOperation operation() { @Override public List visibleSymbols(Position position) { - if (this.visibleSymbols == null) { - Optional semanticModel; - if (this.cancelChecker == null) { - semanticModel = this.workspaceManager.semanticModel(this.filePath); - } else { - semanticModel = this.workspaceManager.semanticModel(this.filePath, this.cancelChecker); - } - Optional srcFile = this.workspaceManager.document(filePath); - - if (semanticModel.isEmpty() || srcFile.isEmpty()) { - return Collections.emptyList(); - } + Optional semanticModel; + if (this.cancelChecker == null) { + semanticModel = this.workspaceManager.semanticModel(this.filePath); + } else { + semanticModel = this.workspaceManager.semanticModel(this.filePath, this.cancelChecker); + } + Optional srcFile = this.workspaceManager.document(filePath); - this.checkCancelled(); - visibleSymbols = semanticModel.get().visibleSymbols(srcFile.get(), - LinePosition.from(position.getLine(), - position.getCharacter()), DiagnosticState.VALID, DiagnosticState.REDECLARED); + if (semanticModel.isEmpty() || srcFile.isEmpty()) { + return Collections.emptyList(); } - return visibleSymbols; + this.checkCancelled(); + + return semanticModel.get().visibleSymbols(srcFile.get(), + LinePosition.from(position.getLine(), + position.getCharacter()), DiagnosticState.VALID, DiagnosticState.REDECLARED); } @Override @@ -161,16 +154,12 @@ public WorkspaceManager workspace() { @Override public List currentDocImports() { - if (this.currentDocImports == null) { - Optional document = this.workspace().document(this.filePath); - if (document.isEmpty()) { - throw new RuntimeException("Cannot find a valid document"); - } - this.currentDocImports = ((ModulePartNode) document.get().syntaxTree().rootNode()).imports().stream() - .collect(Collectors.toList()); + Optional document = this.workspace().document(this.filePath); + if (document.isEmpty()) { + throw new RuntimeException("Cannot find a valid document"); } - - return this.currentDocImports; + return ((ModulePartNode) document.get().syntaxTree().rootNode()).imports().stream() + .collect(Collectors.toList()); } @Override diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/BallerinaDefinitionContextImpl.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/BallerinaDefinitionContextImpl.java index fc398dd2e12f..11c760b43dd5 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/BallerinaDefinitionContextImpl.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/BallerinaDefinitionContextImpl.java @@ -34,12 +34,10 @@ * * @since 2.0.0 */ -public class BallerinaDefinitionContextImpl - extends AbstractDocumentServiceContext implements BallerinaDefinitionContext { +public class BallerinaDefinitionContextImpl + extends PositionedOperationContextImpl implements BallerinaDefinitionContext { private boolean capturedEnclosingNode = false; private ModuleMemberDeclarationNode enclosingNode = null; - private int cursorPosInTree = -1; - private final Position cursorPosition; BallerinaDefinitionContextImpl(LSOperation operation, String fileUri, @@ -47,8 +45,7 @@ public class BallerinaDefinitionContextImpl Position position, LanguageServerContext serverContext, CancelChecker cancelChecker) { - super(operation, fileUri, wsManager, serverContext, cancelChecker); - this.cursorPosition = position; + super(operation, fileUri, position, wsManager, serverContext, cancelChecker); } @Override @@ -65,25 +62,7 @@ public Optional enclosedModuleMember() { return Optional.ofNullable(this.enclosingNode); } - - @Override - public void setCursorPositionInTree(int offset) { - if (this.cursorPosInTree > -1) { - throw new RuntimeException("Setting the cursor offset more than once is not allowed"); - } - this.cursorPosInTree = offset; - } - - @Override - public int getCursorPositionInTree() { - return this.cursorPosInTree; - } - - @Override - public Position getCursorPosition() { - return this.cursorPosition; - } - + /** * Represents Language server completion context Builder. * diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/CompletionContextImpl.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/CompletionContextImpl.java index c9a5bcb859eb..30883e008d2a 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/CompletionContextImpl.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/CompletionContextImpl.java @@ -31,11 +31,9 @@ * * @since 1.2.0 */ -public class CompletionContextImpl extends AbstractDocumentServiceContext implements CompletionContext { +public class CompletionContextImpl extends PositionedOperationContextImpl implements CompletionContext { private final CompletionCapabilities capabilities; - private final Position cursorPosition; - private int cursorPosInTree = -1; CompletionContextImpl(LSOperation operation, String fileUri, @@ -43,9 +41,7 @@ public class CompletionContextImpl extends AbstractDocumentServiceContext implem CompletionCapabilities capabilities, Position cursorPosition, LanguageServerContext serverContext) { - super(operation, fileUri, wsManager, serverContext); - this.capabilities = capabilities; - this.cursorPosition = cursorPosition; + this(operation, fileUri, wsManager, capabilities, cursorPosition, serverContext, null); } CompletionContextImpl(LSOperation operation, @@ -55,34 +51,15 @@ public class CompletionContextImpl extends AbstractDocumentServiceContext implem Position cursorPosition, LanguageServerContext serverContext, CancelChecker cancelChecker) { - super(operation, fileUri, wsManager, serverContext, cancelChecker); + super(operation, fileUri, cursorPosition, wsManager, serverContext, cancelChecker); this.capabilities = capabilities; - this.cursorPosition = cursorPosition; } @Override public CompletionCapabilities getCapabilities() { return this.capabilities; } - - @Override - public void setCursorPositionInTree(int offset) { - if (this.cursorPosInTree > -1) { - throw new RuntimeException("Setting the cursor offset more than once is not allowed"); - } - this.cursorPosInTree = offset; - } - - @Override - public int getCursorPositionInTree() { - return this.cursorPosInTree; - } - - @Override - public Position getCursorPosition() { - return this.cursorPosition; - } - + /** * Represents Language server completion context Builder. * diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/HoverContextImpl.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/HoverContextImpl.java index 6d1cabbe6b58..d393afbcd045 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/HoverContextImpl.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/HoverContextImpl.java @@ -34,14 +34,10 @@ * * @since 1.2.0 */ -public class HoverContextImpl extends AbstractDocumentServiceContext implements HoverContext { +public class HoverContextImpl extends PositionedOperationContextImpl implements HoverContext { private Token tokenAtCursor; - - private final Position cursorPosition; - - private int cursorPositionInTree = -1; - + private NonTerminalNode nodeAtCursor; HoverContextImpl(LSOperation operation, @@ -50,8 +46,7 @@ public class HoverContextImpl extends AbstractDocumentServiceContext implements Position cursorPosition, LanguageServerContext serverContext, CancelChecker cancelChecker) { - super(operation, fileUri, wsManager, serverContext, cancelChecker); - this.cursorPosition = cursorPosition; + super(operation, fileUri, cursorPosition, wsManager, serverContext, cancelChecker); } @Override @@ -67,25 +62,7 @@ public Token getTokenAtCursor() { return this.tokenAtCursor; } - - @Override - public void setCursorPositionInTree(int offset) { - if (this.cursorPositionInTree > -1) { - throw new RuntimeException("Setting the cursor offset more than once is not allowed"); - } - this.cursorPositionInTree = offset; - } - - @Override - public int getCursorPositionInTree() { - return this.cursorPositionInTree; - } - - @Override - public Position getCursorPosition() { - return this.cursorPosition; - } - + @Override public void setNodeAtCursor(NonTerminalNode node) { if (this.nodeAtCursor != null) { diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/PositionedOperationContextImpl.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/PositionedOperationContextImpl.java index b7c3a45c072f..e55da165018e 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/PositionedOperationContextImpl.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/PositionedOperationContextImpl.java @@ -15,6 +15,7 @@ */ package org.ballerinalang.langserver.contexts; +import io.ballerina.compiler.api.symbols.Symbol; import org.ballerinalang.langserver.LSContextOperation; import org.ballerinalang.langserver.commons.DocumentServiceContext; import org.ballerinalang.langserver.commons.LSOperation; @@ -24,6 +25,8 @@ import org.eclipse.lsp4j.Position; import org.eclipse.lsp4j.jsonrpc.CancelChecker; +import java.util.List; + /** * Abstract implementation of the {@link PositionedOperationContext}. * @@ -32,20 +35,60 @@ public abstract class PositionedOperationContextImpl extends AbstractDocumentServiceContext implements PositionedOperationContext { - @Deprecated(forRemoval = true) - PositionedOperationContextImpl(LSOperation operation, - String fileUri, - WorkspaceManager wsManager, - LanguageServerContext serverContext) { - super(operation, fileUri, wsManager, serverContext); - } + private final Position cursorPosition; + + private int cursorPositionInTree = -1; + + private List visibleSymbols; PositionedOperationContextImpl(LSOperation operation, String fileUri, + Position cursorPosition, WorkspaceManager wsManager, LanguageServerContext serverContext, CancelChecker cancelChecker) { super(operation, fileUri, wsManager, serverContext, cancelChecker); + this.cursorPosition = cursorPosition; + } + + /** + * {@inheritDoc} + *

+ * Since we know the cursor position here, we can cache the visible symbols for the cursor position. This will be + * good for the performance since the chance of accessing the visible symbols of the cursor position repetitively + * is high. + * + * @param position Position at which visible symbols are needed + * @return Visible symbols + */ + @Override + public List visibleSymbols(Position position) { + if (this.cursorPosition.equals(position)) { + if (this.visibleSymbols == null) { + this.visibleSymbols = super.visibleSymbols(position); + } + return this.visibleSymbols; + } else { + return super.visibleSymbols(position); + } + } + + @Override + public void setCursorPositionInTree(int offset) { + if (this.cursorPositionInTree > -1) { + throw new RuntimeException("Setting the cursor offset more than once is not allowed"); + } + this.cursorPositionInTree = offset; + } + + @Override + public int getCursorPositionInTree() { + return this.cursorPositionInTree; + } + + @Override + public Position getCursorPosition() { + return this.cursorPosition; } /** diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/ReferencesContextImpl.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/ReferencesContextImpl.java index 782ad0af4d54..6ca824c71fd3 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/ReferencesContextImpl.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/ReferencesContextImpl.java @@ -32,37 +32,15 @@ */ public class ReferencesContextImpl extends PositionedOperationContextImpl implements ReferencesContext { - private final Position cursorPos; - private int cursorPosInTree = -1; - ReferencesContextImpl(LSOperation operation, String fileUri, WorkspaceManager wsManager, Position cursorPos, LanguageServerContext serverContext, CancelChecker cancelChecker) { - super(operation, fileUri, wsManager, serverContext, cancelChecker); - this.cursorPos = cursorPos; - } - - @Override - public Position getCursorPosition() { - return this.cursorPos; + super(operation, fileUri, cursorPos, wsManager, serverContext, cancelChecker); } - - @Override - public void setCursorPositionInTree(int offset) { - if (this.cursorPosInTree > -1) { - throw new RuntimeException("Setting the cursor offset more than once is not allowed"); - } - this.cursorPosInTree = offset; - } - - @Override - public int getCursorPositionInTree() { - return this.cursorPosInTree; - } - + /** * Represents Language server references context Builder. * diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/SignatureContextImpl.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/SignatureContextImpl.java index ffa7a4878c23..3d93735e944c 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/SignatureContextImpl.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/contexts/SignatureContextImpl.java @@ -34,11 +34,9 @@ * * @since 1.2.0 */ -public class SignatureContextImpl extends AbstractDocumentServiceContext implements SignatureContext { +public class SignatureContextImpl extends PositionedOperationContextImpl implements SignatureContext { private final SignatureHelpCapabilities capabilities; - private final Position cursorPos; - private int cursorPosInTree = -1; private NonTerminalNode nodeAtCursor; SignatureContextImpl(LSOperation operation, @@ -48,9 +46,8 @@ public class SignatureContextImpl extends AbstractDocumentServiceContext impleme Position cursorPos, LanguageServerContext serverContext, CancelChecker cancelChecker) { - super(operation, fileUri, wsManager, serverContext, cancelChecker); + super(operation, fileUri, cursorPos, wsManager, serverContext, cancelChecker); this.capabilities = capabilities; - this.cursorPos = cursorPos; } @Override @@ -58,24 +55,6 @@ public SignatureHelpCapabilities capabilities() { return this.capabilities; } - @Override - public Position getCursorPosition() { - return this.cursorPos; - } - - @Override - public void setCursorPositionInTree(int offset) { - if (this.cursorPosInTree > -1) { - throw new RuntimeException("Setting the cursor offset more than once is not allowed"); - } - this.cursorPosInTree = offset; - } - - @Override - public int getCursorPositionInTree() { - return this.cursorPosInTree; - } - @Override public Optional getNodeAtCursor() { return Optional.ofNullable(this.nodeAtCursor); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolClientCapabilities.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolClientCapabilities.java index a66ab062ab19..1a7f70e8a02b 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolClientCapabilities.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolClientCapabilities.java @@ -34,6 +34,8 @@ public class BallerinaSymbolClientCapabilities extends BallerinaClientCapability private boolean getTypeFromSymbol; + private boolean getTypesFromFnDefinition; + public boolean isGetSymbol() { return getSymbol; } @@ -74,6 +76,14 @@ public void setGetTypeFromSymbol(boolean getTypeFromSymbol) { this.getTypeFromSymbol = getTypeFromSymbol; } + public boolean isGetTypesFromFnDefinition() { + return getTypesFromFnDefinition; + } + + public void setGetTypesFromFnDefinition(boolean getTypesFromFnDefinition) { + this.getTypesFromFnDefinition = getTypesFromFnDefinition; + } + public BallerinaSymbolClientCapabilities() { super(Constants.CAPABILITY_NAME); } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolServerCapabilities.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolServerCapabilities.java index fb6f8bd29d33..e438fad60090 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolServerCapabilities.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolServerCapabilities.java @@ -34,6 +34,8 @@ public class BallerinaSymbolServerCapabilities extends BallerinaServerCapability private boolean getTypeFromSymbol; + private boolean getTypesFromFnDefinition; + public boolean isGetSymbol() { return getSymbol; } @@ -74,6 +76,14 @@ public void setGetTypeFromSymbol(boolean getTypeFromSymbol) { this.getTypeFromSymbol = getTypeFromSymbol; } + public boolean isGetTypesFromFnDefinition() { + return getTypesFromFnDefinition; + } + + public void setGetTypesFromFnDefinition(boolean getTypesFromFnDefinition) { + this.getTypesFromFnDefinition = getTypesFromFnDefinition; + } + public BallerinaSymbolServerCapabilities() { super(Constants.CAPABILITY_NAME); } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolService.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolService.java index 7c49e9f4dfd9..f0e4bb13a1f1 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolService.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolService.java @@ -20,6 +20,7 @@ import io.ballerina.compiler.api.symbols.Documentable; import io.ballerina.compiler.api.symbols.Documentation; import io.ballerina.compiler.api.symbols.FunctionSymbol; +import io.ballerina.compiler.api.symbols.FunctionTypeSymbol; import io.ballerina.compiler.api.symbols.MethodSymbol; import io.ballerina.compiler.api.symbols.ParameterSymbol; import io.ballerina.compiler.api.symbols.Symbol; @@ -33,6 +34,7 @@ import io.ballerina.compiler.syntax.tree.NonTerminalNode; import io.ballerina.compiler.syntax.tree.SyntaxKind; import io.ballerina.projects.Document; +import io.ballerina.tools.diagnostics.Location; import io.ballerina.tools.text.LinePosition; import io.ballerina.tools.text.LineRange; import org.ballerinalang.annotation.JavaSPIService; @@ -146,31 +148,26 @@ public CompletableFuture getTypeFromExpression(Type String fileUri = request.getDocumentIdentifier().getUri(); String[] pathSegments = fileUri.split("/"); String fileName = pathSegments[pathSegments.length - 1]; - Optional filePath = PathUtil.getPathFromURI(fileUri); - if (filePath.isEmpty()) { - return typesResponse; - } List types = new ArrayList<>(); try { + Path filePath = PathUtil.getPathFromURI(fileUri).orElseThrow(); for (LineRange range: request.getExpressionRanges()) { ResolvedTypeForExpression resolvedType = new ResolvedTypeForExpression(range); - - Optional semanticModel = - this.workspaceManagerProxy.get(fileUri).semanticModel(filePath.get()); - if (semanticModel.isEmpty()) { - return typesResponse; - } - LinePosition start = range.startLine(); - LinePosition end = range.endLine(); - LineRange lineRange = LineRange.from(fileName, start, end); - Optional typeSymbol; - if (semanticModel.get().typeOf(lineRange).isPresent()) { - typeSymbol = semanticModel.get().typeOf(lineRange); - Type.clearParentSymbols(); - Type type = typeSymbol.map(Type::fromSemanticSymbol).orElse(null); - resolvedType.setType(type); - types.add(resolvedType); - } + SemanticModel semanticModel = this.workspaceManagerProxy + .get(fileUri) + .semanticModel(filePath) + .orElseThrow(); + LinePosition start = range.startLine(); + LinePosition end = range.endLine(); + LineRange lineRange = LineRange.from(fileName, start, end); + Optional typeSymbol; + if (semanticModel.typeOf(lineRange).isPresent()) { + typeSymbol = semanticModel.typeOf(lineRange); + Type.clearParentSymbols(); + Type type = typeSymbol.map(Type::fromSemanticSymbol).orElse(null); + resolvedType.setType(type); + types.add(resolvedType); + } } typesResponse.setTypes(types); return typesResponse; @@ -188,26 +185,25 @@ public CompletableFuture getTypeFromSymbol(TypeFromSymb return CompletableFuture.supplyAsync(() -> { TypesFromSymbolResponse typeFromSymbolResponse = new TypesFromSymbolResponse(); String fileUri = request.getDocumentIdentifier().getUri(); - Optional filePath = PathUtil.getPathFromURI(fileUri); - if (filePath.isEmpty()) { - return typeFromSymbolResponse; - } List types = new ArrayList<>(); try { + Path filePath = PathUtil.getPathFromURI(fileUri).orElseThrow(); for (LinePosition position: request.getPositions()) { ResolvedTypeForSymbol resolvedType = new ResolvedTypeForSymbol(position); - Optional semanticModel = - this.workspaceManagerProxy.get(fileUri).semanticModel(filePath.get()); - Optional document = workspaceManagerProxy.get(fileUri).document(filePath.get()); - if (semanticModel.isEmpty() || document.isEmpty()) { - return typeFromSymbolResponse; - } - LinePosition linePosition = LinePosition.from(position.line(), position.offset()); - Optional symbol = semanticModel.get().symbol(document.get(), linePosition); - Type.clearParentSymbols(); - Type type = symbol.map(Type::fromSemanticSymbol).orElse(null); - resolvedType.setType(type); - types.add(resolvedType); + SemanticModel semanticModel = this.workspaceManagerProxy + .get(fileUri) + .semanticModel(filePath) + .orElseThrow(); + Document document = this.workspaceManagerProxy + .get(fileUri) + .document(filePath) + .orElseThrow(); + LinePosition linePosition = LinePosition.from(position.line(), position.offset()); + Optional symbol = semanticModel.symbol(document, linePosition); + Type.clearParentSymbols(); + Type type = symbol.map(Type::fromSemanticSymbol).orElse(null); + resolvedType.setType(type); + types.add(resolvedType); } typeFromSymbolResponse.setTypes(types); return typeFromSymbolResponse; @@ -220,6 +216,45 @@ public CompletableFuture getTypeFromSymbol(TypeFromSymb }); } + @JsonRequest + public CompletableFuture getTypesFromFnDefinition(TypesFromFnDefinitionRequest request) { + return CompletableFuture.supplyAsync(() -> { + TypesFromSymbolResponse typeFromSymbolResponse = new TypesFromSymbolResponse(); + String fileUri = request.getDocumentIdentifier().getUri(); + List types = new ArrayList<>(); + try { + Path filePath = PathUtil.getPathFromURI(fileUri).orElseThrow(); + SemanticModel semanticModel = this.workspaceManagerProxy + .get(fileUri) + .semanticModel(filePath) + .orElseThrow(); + Document document = this.workspaceManagerProxy + .get(fileUri) + .document(filePath) + .orElseThrow(); + LinePosition fnPosition = request.getFnPosition(); + Symbol fnSymbol = semanticModel.symbol(document, fnPosition).orElseThrow(); + if (fnSymbol instanceof FunctionSymbol) { + FunctionTypeSymbol fnTypeSymbol = ((FunctionSymbol) fnSymbol).typeDescriptor(); + + Optional returnType = + getTypeForReturnTypeDesc(fnTypeSymbol, request.getReturnTypeDescPosition()); + returnType.ifPresent(types::add); + + List paramTypes = getTypesForFnParams(fnTypeSymbol); + types.addAll(paramTypes); + } + typeFromSymbolResponse.setTypes(types); + return typeFromSymbolResponse; + } catch (Throwable e) { + String msg = "Operation 'ballerinaSymbol/getTypesFromFnDefinition' failed!"; + this.clientLogger.logError(SymbolContext.SC_GET_TYPE_FROM_FN_DEFINITION_API, msg, e, + request.getDocumentIdentifier(), (Position) null); + return typeFromSymbolResponse; + } + }); + } + @JsonRequest public CompletableFuture getSymbol(SymbolInfoRequest request) { return CompletableFuture.supplyAsync(() -> { @@ -416,6 +451,38 @@ private boolean skipFirstParam(Symbol symbolAtCursor, NonTerminalNode nodeAtCurs nodeAtCursor.kind() != SyntaxKind.QUALIFIED_NAME_REFERENCE); } + private Optional getTypeForReturnTypeDesc(FunctionTypeSymbol functionTypeSymbol, + LinePosition typeDescPosition) { + Optional typeSymbol = functionTypeSymbol.returnTypeDescriptor(); + if (typeSymbol.isEmpty()) { + return Optional.empty(); + } + ResolvedTypeForSymbol resolvedType = new ResolvedTypeForSymbol(typeDescPosition); + Type type = Type.fromSemanticSymbol(typeSymbol.get()); + Type.clearParentSymbols(); + resolvedType.setType(type); + return Optional.of(resolvedType); + } + + private List getTypesForFnParams(FunctionTypeSymbol fnTypeSymbol) { + List types = new ArrayList<>(); + Optional> params = fnTypeSymbol.params(); + if (params.isPresent()) { + for (ParameterSymbol param: params.get()) { + Optional location = param.getLocation(); + if (location.isPresent()) { + LinePosition paramPosition = location.get().lineRange().startLine(); + ResolvedTypeForSymbol resolvedType = new ResolvedTypeForSymbol(paramPosition); + Type type = Type.fromSemanticSymbol(param); + Type.clearParentSymbols(); + resolvedType.setType(type); + types.add(resolvedType); + } + } + } + return types; + } + @Override public Class getRemoteInterface() { return getClass(); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolServiceServerCapabilitySetter.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolServiceServerCapabilitySetter.java index d8cf8f175a45..29b453d975da 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolServiceServerCapabilitySetter.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/BallerinaSymbolServiceServerCapabilitySetter.java @@ -37,6 +37,7 @@ public Optional build() { capabilities.setGetSymbol(true); capabilities.setGetTypeFromExpression(true); capabilities.setGetTypeFromSymbol(true); + capabilities.setGetTypesFromFnDefinition(true); return Optional.of(capabilities); } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/SymbolContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/SymbolContext.java index a8d65e21725c..6cd49ffe7ddb 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/SymbolContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/SymbolContext.java @@ -26,7 +26,8 @@ public enum SymbolContext implements LSOperation { SC_TYPE_API("ballerinaSymbol/type"), SC_GET_TYPE_FROM_EXPRESSION_API("ballerinaSymbol/getTypeFromExpression"), SC_GET_SYMBOL_API("ballerinaSymbol/getSymbol"), - SC_GET_TYPE_FROM_SYMBOL_API("ballerinaSymbol/getTypeFromSymbol"); + SC_GET_TYPE_FROM_SYMBOL_API("ballerinaSymbol/getTypeFromSymbol"), + SC_GET_TYPE_FROM_FN_DEFINITION_API("ballerinaSymbol/getTypesFromFnDefinition"); private final String name; SymbolContext(String name) { diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/TypesFromFnDefinitionRequest.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/TypesFromFnDefinitionRequest.java new file mode 100644 index 000000000000..0c53c5040cf8 --- /dev/null +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/extensions/ballerina/symbol/TypesFromFnDefinitionRequest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2022, WSO2 Inc. (http://wso2.com) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.ballerinalang.langserver.extensions.ballerina.symbol; + +import io.ballerina.tools.text.LinePosition; +import org.eclipse.lsp4j.TextDocumentIdentifier; + +/** + * Represents a request to get type info of params and return type desc of a given function definition. + */ +public class TypesFromFnDefinitionRequest { + private TextDocumentIdentifier documentIdentifier; + private LinePosition fnPosition; + private LinePosition returnTypeDescPosition; + + public LinePosition getFnPosition() { + return fnPosition; + } + + public void setFnPosition(LinePosition fnPosition) { + this.fnPosition = fnPosition; + } + + public LinePosition getReturnTypeDescPosition() { + return returnTypeDescPosition; + } + + public void setReturnTypeDescPosition(LinePosition returnTypeDescPosition) { + this.returnTypeDescPosition = returnTypeDescPosition; + } + + public TextDocumentIdentifier getDocumentIdentifier() { + return documentIdentifier; + } + + public void setDocumentIdentifier(TextDocumentIdentifier documentIdentifier) { + this.documentIdentifier = documentIdentifier; + } +} diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/toml/ballerinatoml/completion/BallerinaTomlCompletionContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/toml/ballerinatoml/completion/BallerinaTomlCompletionContext.java index 273d45b51ebe..61a98182c73c 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/toml/ballerinatoml/completion/BallerinaTomlCompletionContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/toml/ballerinatoml/completion/BallerinaTomlCompletionContext.java @@ -52,7 +52,6 @@ public class BallerinaTomlCompletionContext implements TomlCompletionContext { private List visibleSymbols; - private List currentDocImports; private Map currentDocImportsMap; private final LanguageServerContext languageServerContext; private final CompletionCapabilities capabilities; @@ -97,16 +96,13 @@ public List visibleSymbols(Position position) { @Override public List currentDocImports() { - if (this.currentDocImports == null) { - Optional document = this.workspace().document(this.filePath()); - if (document.isEmpty()) { - throw new RuntimeException("Cannot find a valid document"); - } - this.currentDocImports = ((ModulePartNode) document.get().syntaxTree().rootNode()).imports().stream() - .collect(Collectors.toList()); + Optional document = this.workspace().document(this.filePath()); + if (document.isEmpty()) { + throw new RuntimeException("Cannot find a valid document"); } - return this.currentDocImports; + return ((ModulePartNode) document.get().syntaxTree().rootNode()).imports().stream() + .collect(Collectors.toList()); } @Override diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/LSExtensionTestUtil.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/LSExtensionTestUtil.java index 4261e1c4ea3a..1d060f60bdc5 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/LSExtensionTestUtil.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/LSExtensionTestUtil.java @@ -35,6 +35,7 @@ import org.ballerinalang.langserver.extensions.ballerina.symbol.TypeFromExpressionRequest; import org.ballerinalang.langserver.extensions.ballerina.symbol.TypeFromSymbolRequest; import org.ballerinalang.langserver.extensions.ballerina.symbol.TypesFromExpressionResponse; +import org.ballerinalang.langserver.extensions.ballerina.symbol.TypesFromFnDefinitionRequest; import org.ballerinalang.langserver.extensions.ballerina.symbol.TypesFromSymbolResponse; import org.ballerinalang.langserver.util.FileUtils; import org.ballerinalang.langserver.util.TestUtil; @@ -66,6 +67,7 @@ public class LSExtensionTestUtil { private static final String GET_SYMBOL = "ballerinaSymbol/getSymbol"; private static final String GET_TYPE_FROM_SYMBOL = "ballerinaSymbol/getTypeFromSymbol"; private static final String GET_TYPE_FROM_EXPRESSION = "ballerinaSymbol/getTypeFromExpression"; + private static final String GET_TYPE_FROM_FN_DEFINITION = "ballerinaSymbol/getTypesFromFnDefinition"; private static final Gson GSON = new Gson(); private static final JsonParser parser = new JsonParser(); @@ -235,4 +237,26 @@ public static TypesFromExpressionResponse getTypeFromExpression(URI filePath, Li CompletableFuture result = serviceEndpoint.request(GET_TYPE_FROM_EXPRESSION, typeFromExpressionRequest); return (TypesFromExpressionResponse) result.get(); } + + /** + * Get the ballerinaDocument/getTypesFromFnDefinition response. + * + * @param filePath Path of the Bal file + * @param fnPosition Ranges of the expressions to get associated types + * @param returnTypeDescPosition Service Endpoint to Language Server + * @param serviceEndpoint Service Endpoint to Language Server + * @return {@link String} Response as String + */ + public static TypesFromSymbolResponse getTypesFromFnDefinition(URI filePath, + LinePosition fnPosition, + LinePosition returnTypeDescPosition, + Endpoint serviceEndpoint) + throws ExecutionException, InterruptedException { + TypesFromFnDefinitionRequest typesFromFnDefRequest = new TypesFromFnDefinitionRequest(); + typesFromFnDefRequest.setFnPosition(fnPosition); + typesFromFnDefRequest.setReturnTypeDescPosition(returnTypeDescPosition); + typesFromFnDefRequest.setDocumentIdentifier(TestUtil.getTextDocumentIdentifier(filePath)); + CompletableFuture result = serviceEndpoint.request(GET_TYPE_FROM_FN_DEFINITION, typesFromFnDefRequest); + return (TypesFromSymbolResponse) result.get(); + } } diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolServiceTestUtil.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolServiceTestUtil.java new file mode 100644 index 000000000000..9c613ddbcf0b --- /dev/null +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolServiceTestUtil.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2022, WSO2 Inc. (http://wso2.com) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.ballerinalang.langserver.extensions.symbol; + +import io.ballerina.tools.text.LinePosition; +import io.ballerina.tools.text.LineRange; + +/** + * Provides util methods for testing symbol service apis. + */ +public class SymbolServiceTestUtil { + + public static final String INTEGER = "int"; + public static final String STRING = "string"; + public static final String FLOAT = "float"; + public static final String RECORD = "record"; + public static final String ARRAY = "array"; + public static final String UNION = "union"; + public static final String ERROR = "error"; + public static final String NULL = "()"; + public static final String INTERSECTION = "intersection"; + public static final String READ_ONLY = "readonly"; + + public static boolean isPositionsEquals(LinePosition expectedPosition, LinePosition actualPosition) { + return expectedPosition.line() == actualPosition.line() + && expectedPosition.offset() == actualPosition.offset(); + } + + public static LineRange getExpressionRange(int startLine, int startColumn, int endLine, int endColumn) { + LinePosition start = LinePosition.from(startLine, startColumn); + LinePosition end = LinePosition.from(endLine, endColumn); + return LineRange.from(null, start, end); + } + + public static boolean isRangesEquals(LineRange expectedRange, LineRange actualRange) { + return expectedRange.startLine().line() == actualRange.startLine().line() + && expectedRange.startLine().offset() == actualRange.startLine().offset() + && expectedRange.endLine().line() == actualRange.endLine().line() + && expectedRange.endLine().line() == actualRange.endLine().line(); + } +} diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypeFromExpressionTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypeFromExpressionTest.java index e58cd00cd161..4f1ac2f37b25 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypeFromExpressionTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypeFromExpressionTest.java @@ -15,7 +15,6 @@ */ package org.ballerinalang.langserver.extensions.symbol; -import io.ballerina.tools.text.LinePosition; import io.ballerina.tools.text.LineRange; import org.ballerinalang.diagramutil.connector.models.connector.types.ArrayType; import org.ballerinalang.diagramutil.connector.models.connector.types.PrimitiveType; @@ -56,7 +55,7 @@ public void testTypeForConditionalExprNode() throws IOException, ExecutionExcept URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); - LineRange[] ranges = {getExpressionRange(39, 15, 39, 68)}; + LineRange[] ranges = {SymbolServiceTestUtil.getExpressionRange(39, 15, 39, 68)}; TypesFromExpressionResponse typesFromExpression = LSExtensionTestUtil.getTypeFromExpression( uri, ranges, this.serviceEndpoint); @@ -64,7 +63,7 @@ public void testTypeForConditionalExprNode() throws IOException, ExecutionExcept Assert.assertNotNull(typesFromExpression.getTypes()); ResolvedTypeForExpression type = typesFromExpression.getTypes().get(0); - Assert.assertTrue(isRangesEquals(ranges[0], type.getRequestedRange())); + Assert.assertTrue(SymbolServiceTestUtil.isRangesEquals(ranges[0], type.getRequestedRange())); Assert.assertTrue(type.getType() instanceof RecordType); RecordType recordType = (RecordType) type.getType(); @@ -83,7 +82,7 @@ public void testTypeForFunctionCallExprNode() throws IOException, ExecutionExcep URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); - LineRange[] ranges = {getExpressionRange(40, 39, 40, 53)}; + LineRange[] ranges = {SymbolServiceTestUtil.getExpressionRange(40, 39, 40, 53)}; TypesFromExpressionResponse typesFromExpression = LSExtensionTestUtil.getTypeFromExpression( uri, ranges, this.serviceEndpoint); @@ -91,7 +90,7 @@ public void testTypeForFunctionCallExprNode() throws IOException, ExecutionExcep Assert.assertNotNull(typesFromExpression.getTypes()); ResolvedTypeForExpression type = typesFromExpression.getTypes().get(0); - Assert.assertTrue(isRangesEquals(ranges[0], type.getRequestedRange())); + Assert.assertTrue(SymbolServiceTestUtil.isRangesEquals(ranges[0], type.getRequestedRange())); Assert.assertTrue(type.getType() instanceof ArrayType); ArrayType arrayType = (ArrayType) type.getType(); @@ -113,7 +112,7 @@ public void testPrimitiveTypeForFunctionCallNode() throws IOException, Execution URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); - LineRange[] ranges = {getExpressionRange(42, 24, 42, 57)}; + LineRange[] ranges = {SymbolServiceTestUtil.getExpressionRange(42, 24, 42, 57)}; TypesFromExpressionResponse typesFromExpression = LSExtensionTestUtil.getTypeFromExpression( uri, ranges, this.serviceEndpoint); @@ -121,7 +120,7 @@ public void testPrimitiveTypeForFunctionCallNode() throws IOException, Execution Assert.assertNotNull(typesFromExpression.getTypes()); ResolvedTypeForExpression type = typesFromExpression.getTypes().get(0); - Assert.assertTrue(isRangesEquals(ranges[0], type.getRequestedRange())); + Assert.assertTrue(SymbolServiceTestUtil.isRangesEquals(ranges[0], type.getRequestedRange())); Assert.assertTrue(type.getType() instanceof PrimitiveType); } @@ -131,7 +130,7 @@ public void testTypeForFieldAccessExprNode() throws IOException, ExecutionExcept URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); - LineRange[] ranges = {getExpressionRange(43, 40, 43, 50)}; + LineRange[] ranges = {SymbolServiceTestUtil.getExpressionRange(43, 40, 43, 50)}; TypesFromExpressionResponse typesFromExpression = LSExtensionTestUtil.getTypeFromExpression( uri, ranges, this.serviceEndpoint); @@ -139,7 +138,7 @@ public void testTypeForFieldAccessExprNode() throws IOException, ExecutionExcept Assert.assertNotNull(typesFromExpression.getTypes()); ResolvedTypeForExpression type = typesFromExpression.getTypes().get(0); - Assert.assertTrue(isRangesEquals(ranges[0], type.getRequestedRange())); + Assert.assertTrue(SymbolServiceTestUtil.isRangesEquals(ranges[0], type.getRequestedRange())); Assert.assertTrue(type.getType() instanceof ArrayType); ArrayType arrayType = (ArrayType) type.getType(); @@ -163,11 +162,11 @@ public void testTypeForMultipleExprNodes() throws IOException, ExecutionExceptio URI uri = URI.create(inputFile.toUri().toString()); TestUtil.openDocument(serviceEndpoint, inputFile); - LineRange range1 = getExpressionRange(39, 15, 39, 68); - LineRange range2 = getExpressionRange(40, 39, 40, 53); - LineRange range3 = getExpressionRange(42, 24, 42, 57); - LineRange range4 = getExpressionRange(43, 40, 43, 50); - LineRange range5 = getExpressionRange(47, 32, 47, 44); + LineRange range1 = SymbolServiceTestUtil.getExpressionRange(39, 15, 39, 68); + LineRange range2 = SymbolServiceTestUtil.getExpressionRange(40, 39, 40, 53); + LineRange range3 = SymbolServiceTestUtil.getExpressionRange(42, 24, 42, 57); + LineRange range4 = SymbolServiceTestUtil.getExpressionRange(43, 40, 43, 50); + LineRange range5 = SymbolServiceTestUtil.getExpressionRange(47, 32, 47, 44); LineRange[] ranges = {range1, range2, range3, range4, range5}; TypesFromExpressionResponse typesFromExpression = LSExtensionTestUtil.getTypeFromExpression( @@ -176,23 +175,23 @@ public void testTypeForMultipleExprNodes() throws IOException, ExecutionExceptio Assert.assertNotNull(typesFromExpression.getTypes()); ResolvedTypeForExpression type1 = typesFromExpression.getTypes().get(0); - Assert.assertTrue(isRangesEquals(range1, type1.getRequestedRange())); + Assert.assertTrue(SymbolServiceTestUtil.isRangesEquals(range1, type1.getRequestedRange())); Assert.assertTrue(type1.getType() instanceof RecordType); ResolvedTypeForExpression type2 = typesFromExpression.getTypes().get(1); - Assert.assertTrue(isRangesEquals(range2, type2.getRequestedRange())); + Assert.assertTrue(SymbolServiceTestUtil.isRangesEquals(range2, type2.getRequestedRange())); Assert.assertTrue(type2.getType() instanceof ArrayType); ResolvedTypeForExpression type3 = typesFromExpression.getTypes().get(2); - Assert.assertTrue(isRangesEquals(range3, type3.getRequestedRange())); + Assert.assertTrue(SymbolServiceTestUtil.isRangesEquals(range3, type3.getRequestedRange())); Assert.assertTrue(type3.getType() instanceof PrimitiveType); ResolvedTypeForExpression type4 = typesFromExpression.getTypes().get(3); - Assert.assertTrue(isRangesEquals(range4, type4.getRequestedRange())); + Assert.assertTrue(SymbolServiceTestUtil.isRangesEquals(range4, type4.getRequestedRange())); Assert.assertTrue(type4.getType() instanceof ArrayType); ResolvedTypeForExpression type5 = typesFromExpression.getTypes().get(4); - Assert.assertTrue(isRangesEquals(range5, type5.getRequestedRange())); + Assert.assertTrue(SymbolServiceTestUtil.isRangesEquals(range5, type5.getRequestedRange())); Assert.assertTrue(type5.getType() instanceof PrimitiveType); TestUtil.closeDocument(this.serviceEndpoint, inputFile); @@ -200,7 +199,7 @@ public void testTypeForMultipleExprNodes() throws IOException, ExecutionExceptio @Test(description = "test invalid file path") public void testInvalidFilePath() throws ExecutionException, InterruptedException { - LineRange[] ranges = {getExpressionRange(67, 19, 67, 45)}; + LineRange[] ranges = {SymbolServiceTestUtil.getExpressionRange(67, 19, 67, 45)}; TypesFromExpressionResponse typesFromExpression = LSExtensionTestUtil.getTypeFromExpression( URI.create("file://+"), ranges, this.serviceEndpoint); @@ -221,17 +220,4 @@ public void testEmptyRanges() throws IOException, ExecutionException, Interrupte TestUtil.closeDocument(this.serviceEndpoint, inputFile); } - - public static LineRange getExpressionRange(int startLine, int startColumn, int endLine, int endColumn) { - LinePosition start = LinePosition.from(startLine, startColumn); - LinePosition end = LinePosition.from(endLine, endColumn); - return LineRange.from(null, start, end); - } - - public static boolean isRangesEquals(LineRange expectedRange, LineRange actualRange) { - return expectedRange.startLine().line() == actualRange.startLine().line() - && expectedRange.startLine().offset() == actualRange.startLine().offset() - && expectedRange.endLine().line() == actualRange.endLine().line() - && expectedRange.endLine().line() == actualRange.endLine().line(); - } } diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypeFromSymbolTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypeFromSymbolTest.java index 8b7ce428f4ce..4b568620ec99 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypeFromSymbolTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypeFromSymbolTest.java @@ -63,7 +63,7 @@ public void testTypeForReturnTypeNode() throws IOException, ExecutionException, Assert.assertNotNull(typesFromSymbolResponse.getTypes()); ResolvedTypeForSymbol type = typesFromSymbolResponse.getTypes().get(0); - Assert.assertTrue(isPositionsEquals(position, type.getRequestedPosition())); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(position, type.getRequestedPosition())); Assert.assertEquals(type.getType().name, "Output"); Assert.assertTrue(type.getType() instanceof RecordType); @@ -87,7 +87,7 @@ public void testTypeForRequiredParamTypeNameNode() throws IOException, Execution Assert.assertNotNull(typesFromSymbolResponse.getTypes()); ResolvedTypeForSymbol type = typesFromSymbolResponse.getTypes().get(0); - Assert.assertTrue(isPositionsEquals(position, type.getRequestedPosition())); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(position, type.getRequestedPosition())); Assert.assertTrue(type.getType() instanceof RecordType); RecordType outerRecordType = (RecordType) type.getType(); @@ -122,25 +122,25 @@ public void testTypesForMultipleSymbols() throws IOException, ExecutionException Assert.assertEquals(typesFromSymbolResponse.getTypes().size(), positions.length); ResolvedTypeForSymbol type1 = typesFromSymbolResponse.getTypes().get(0); - Assert.assertTrue(isPositionsEquals(position1, type1.getRequestedPosition())); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(position1, type1.getRequestedPosition())); Assert.assertTrue(type1.getType() instanceof RecordType); Assert.assertEquals(type1.getType().name, "Input"); ResolvedTypeForSymbol type2 = typesFromSymbolResponse.getTypes().get(1); - Assert.assertTrue(isPositionsEquals(position2, type2.getRequestedPosition())); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(position2, type2.getRequestedPosition())); Assert.assertTrue(type2.getType() instanceof RecordType); Assert.assertEquals(type2.getType().name, "Input2"); ResolvedTypeForSymbol type3 = typesFromSymbolResponse.getTypes().get(2); - Assert.assertTrue(isPositionsEquals(position3, type3.getRequestedPosition())); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(position3, type3.getRequestedPosition())); Assert.assertTrue(type3.getType() instanceof RecordType); ResolvedTypeForSymbol type4 = typesFromSymbolResponse.getTypes().get(3); - Assert.assertTrue(isPositionsEquals(position4, type4.getRequestedPosition())); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(position4, type4.getRequestedPosition())); Assert.assertTrue(type4.getType() instanceof ArrayType); ResolvedTypeForSymbol type5 = typesFromSymbolResponse.getTypes().get(4); - Assert.assertTrue(isPositionsEquals(position5, type5.getRequestedPosition())); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(position5, type5.getRequestedPosition())); Assert.assertTrue(type5.getType() instanceof PrimitiveType); TestUtil.closeDocument(this.serviceEndpoint, inputFile); @@ -170,9 +170,4 @@ public void testEmptyPositions() throws IOException, ExecutionException, Interru TestUtil.closeDocument(this.serviceEndpoint, inputFile); } - - public static boolean isPositionsEquals(LinePosition expectedPosition, LinePosition actualPosition) { - return expectedPosition.line() == actualPosition.line() - && expectedPosition.offset() == actualPosition.offset(); - } } diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnDefinitionTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnDefinitionTest.java new file mode 100644 index 000000000000..a43d87aceb53 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/TypesFromFnDefinitionTest.java @@ -0,0 +1,676 @@ +/* + * Copyright (c) 2022, WSO2 Inc. (http://wso2.com) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.ballerinalang.langserver.extensions.symbol; + +import io.ballerina.tools.text.LinePosition; +import org.ballerinalang.diagramutil.connector.models.connector.Type; +import org.ballerinalang.diagramutil.connector.models.connector.types.ArrayType; +import org.ballerinalang.diagramutil.connector.models.connector.types.IntersectionType; +import org.ballerinalang.diagramutil.connector.models.connector.types.RecordType; +import org.ballerinalang.diagramutil.connector.models.connector.types.UnionType; +import org.ballerinalang.langserver.extensions.LSExtensionTestUtil; +import org.ballerinalang.langserver.extensions.ballerina.symbol.ResolvedTypeForSymbol; +import org.ballerinalang.langserver.extensions.ballerina.symbol.TypesFromSymbolResponse; +import org.ballerinalang.langserver.util.FileUtils; +import org.ballerinalang.langserver.util.TestUtil; +import org.eclipse.lsp4j.jsonrpc.Endpoint; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.io.IOException; +import java.net.URI; +import java.nio.file.Path; +import java.util.concurrent.ExecutionException; + +/** + * Test type info retrieved via getTypesFromFnDefinition endpoint. + */ +public class TypesFromFnDefinitionTest { + private Endpoint serviceEndpoint; + + private final Path typesFromFnDefinitionBalFile = FileUtils.RES_DIR.resolve("extensions") + .resolve("symbol") + .resolve("typesFromFnDefinition.bal"); + + @BeforeClass + public void startLangServer() { + this.serviceEndpoint = TestUtil.initializeLanguageSever(); + } + + @Test(description = "type info retrieved for primitive type param and primitive type return") + public void testTypesForPrimitiveTypeParamAndPrimitiveTypeReturn() + throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + LinePosition fnPosition = LinePosition.from(32, 9); + LinePosition paramPosition = LinePosition.from(32, 27); + LinePosition returnTypeDescPosition = LinePosition.from(32, 40); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( + uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); + + Assert.assertNotNull(typesFromSymbolResponse.getTypes()); + + ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); + Assert.assertEquals(returnType.getType().typeName, SymbolServiceTestUtil.STRING); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals( + returnTypeDescPosition, returnType.getRequestedPosition())); + + ResolvedTypeForSymbol paramType = typesFromSymbolResponse.getTypes().get(1); + Assert.assertEquals(paramType.getType().typeName, SymbolServiceTestUtil.STRING); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(paramPosition, paramType.getRequestedPosition())); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + + @Test(description = "type info retrieved for record type param and record type return") + public void testTypesForRecordTypeParamAndRecordTypeReturn() + throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + LinePosition fnPosition = LinePosition.from(34, 9); + LinePosition paramPosition = LinePosition.from(34, 27); + LinePosition returnTypeDescPosition = LinePosition.from(34, 43); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( + uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); + + Assert.assertNotNull(typesFromSymbolResponse.getTypes()); + + ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); + assertStudentType(returnType.getType()); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals( + returnTypeDescPosition, returnType.getRequestedPosition())); + + ResolvedTypeForSymbol paramType = typesFromSymbolResponse.getTypes().get(1); + assertPersonType(paramType.getType()); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(paramPosition, paramType.getRequestedPosition())); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + + @Test(description = "type info retrieved for multiple params and record type return") + public void testTypesForMultipleParamsAndRecordTypeReturn() + throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + LinePosition fnPosition = LinePosition.from(36, 9); + LinePosition param1Position = LinePosition.from(36, 27); + LinePosition param2Position = LinePosition.from(36, 42); + LinePosition param3Position = LinePosition.from(36, 61); + LinePosition returnTypeDescPosition = LinePosition.from(36, 81); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( + uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); + + Assert.assertNotNull(typesFromSymbolResponse.getTypes()); + + ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); + assertStudentType(returnType.getType()); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals( + returnTypeDescPosition, returnType.getRequestedPosition())); + + ResolvedTypeForSymbol param1Type = typesFromSymbolResponse.getTypes().get(1); + assertPersonType(param1Type.getType()); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(param1Position, param1Type.getRequestedPosition())); + + ResolvedTypeForSymbol param2Type = typesFromSymbolResponse.getTypes().get(2); + assertCourseType(param2Type.getType()); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(param2Position, param2Type.getRequestedPosition())); + + ResolvedTypeForSymbol param3Type = typesFromSymbolResponse.getTypes().get(3); + assertSubmissionType(param3Type.getType()); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(param3Position, param3Type.getRequestedPosition())); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + + @Test(description = "type info retrieved for multiple params and primitive type return") + public void testTypesForMultipleParamsAndPrimitiveTypeReturn() + throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + LinePosition fnPosition = LinePosition.from(38, 9); + LinePosition param1Position = LinePosition.from(38, 27); + LinePosition param2Position = LinePosition.from(38, 39); + LinePosition returnTypeDescPosition = LinePosition.from(38, 50); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( + uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); + + Assert.assertNotNull(typesFromSymbolResponse.getTypes()); + + ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); + Assert.assertEquals(returnType.getType().typeName, SymbolServiceTestUtil.FLOAT); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals( + returnTypeDescPosition, returnType.getRequestedPosition())); + + ResolvedTypeForSymbol param1Type = typesFromSymbolResponse.getTypes().get(1); + assertPersonType(param1Type.getType()); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(param1Position, param1Type.getRequestedPosition())); + + ResolvedTypeForSymbol param2Type = typesFromSymbolResponse.getTypes().get(2); + Assert.assertEquals(param2Type.getType().typeName, SymbolServiceTestUtil.INTEGER); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(param2Position, param2Type.getRequestedPosition())); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + + @Test(description = "type info retrieved for record type param and record type return (types from modules)") + public void testTypesForRecordTypeParamAndRecordTypeReturn2() + throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + LinePosition fnPosition = LinePosition.from(40, 9); + LinePosition paramPosition = LinePosition.from(40, 39); + LinePosition returnTypeDescPosition = LinePosition.from(40, 57); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( + uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); + + Assert.assertNotNull(typesFromSymbolResponse.getTypes()); + + ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); + assertTypeIdType(returnType.getType()); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals( + returnTypeDescPosition, returnType.getRequestedPosition())); + + ResolvedTypeForSymbol paramType = typesFromSymbolResponse.getTypes().get(1); + assertModuleIdType(paramType.getType()); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(paramPosition, paramType.getRequestedPosition())); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + + @Test(description = "type info retrieved for primitive type array param and primitive type array return") + public void testTypesForPrimitiveTypeArrayParamAndPrimitiveTypeArrayReturn() + throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + LinePosition fnPosition = LinePosition.from(42, 9); + LinePosition paramPosition = LinePosition.from(42, 29); + LinePosition returnTypeDescPosition = LinePosition.from(42, 44); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( + uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); + + Assert.assertNotNull(typesFromSymbolResponse.getTypes()); + + ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); + Assert.assertEquals(returnType.getType().typeName, SymbolServiceTestUtil.ARRAY); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals( + returnTypeDescPosition, returnType.getRequestedPosition())); + Assert.assertTrue(returnType.getType() instanceof ArrayType); + ArrayType arrayReturnType = (ArrayType) returnType.getType(); + Assert.assertEquals(arrayReturnType.memberType.typeName, SymbolServiceTestUtil.STRING); + + ResolvedTypeForSymbol paramType = typesFromSymbolResponse.getTypes().get(1); + Assert.assertEquals(paramType.getType().typeName, SymbolServiceTestUtil.ARRAY); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(paramPosition, paramType.getRequestedPosition())); + Assert.assertTrue(paramType.getType() instanceof ArrayType); + ArrayType arrayParamType = (ArrayType) paramType.getType(); + Assert.assertEquals(arrayParamType.memberType.typeName, SymbolServiceTestUtil.STRING); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + + @Test(description = "type info retrieved for record type array params and record type array return") + public void testTypesForRecordTypeArrayParamsAndRecordTypeArrayReturn() + throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + LinePosition fnPosition = LinePosition.from(44, 9); + LinePosition param1Position = LinePosition.from(44, 29); + LinePosition param2Position = LinePosition.from(44, 46); + LinePosition returnTypeDescPosition = LinePosition.from(44, 63); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( + uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); + + Assert.assertNotNull(typesFromSymbolResponse.getTypes()); + + ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); + Assert.assertEquals(returnType.getType().typeName, SymbolServiceTestUtil.ARRAY); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals( + returnTypeDescPosition, returnType.getRequestedPosition())); + Assert.assertTrue(returnType.getType() instanceof ArrayType); + ArrayType arrayReturnType = (ArrayType) returnType.getType(); + assertStudentType(arrayReturnType.memberType); + + ResolvedTypeForSymbol param1Type = typesFromSymbolResponse.getTypes().get(1); + Assert.assertEquals(param1Type.getType().typeName, SymbolServiceTestUtil.ARRAY); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(param1Position, param1Type.getRequestedPosition())); + Assert.assertTrue(param1Type.getType() instanceof ArrayType); + ArrayType arrayParamType1 = (ArrayType) param1Type.getType(); + assertPersonType(arrayParamType1.memberType); + + ResolvedTypeForSymbol param2Type = typesFromSymbolResponse.getTypes().get(2); + Assert.assertEquals(param2Type.getType().typeName, SymbolServiceTestUtil.ARRAY); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(param2Position, param2Type.getRequestedPosition())); + Assert.assertTrue(param2Type.getType() instanceof ArrayType); + ArrayType arrayParamType2 = (ArrayType) param2Type.getType(); + assertCourseType(arrayParamType2.memberType); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + + @Test(description = "type info retrieved for record array params and record array return (types from modules)") + public void testTypesForRecordTypeArrayParamsAndRecordTypeArrayReturn2() + throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + LinePosition fnPosition = LinePosition.from(46, 9); + LinePosition paramPosition = LinePosition.from(46, 41); + LinePosition returnTypeDescPosition = LinePosition.from(46, 60); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( + uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); + + Assert.assertNotNull(typesFromSymbolResponse.getTypes()); + + ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); + Assert.assertEquals(returnType.getType().typeName, SymbolServiceTestUtil.ARRAY); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals( + returnTypeDescPosition, returnType.getRequestedPosition())); + Assert.assertTrue(returnType.getType() instanceof ArrayType); + ArrayType arrayReturnType = (ArrayType) returnType.getType(); + assertTypeIdType(arrayReturnType.memberType); + + ResolvedTypeForSymbol paramType = typesFromSymbolResponse.getTypes().get(1); + Assert.assertEquals(paramType.getType().typeName, SymbolServiceTestUtil.ARRAY); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(paramPosition, paramType.getRequestedPosition())); + Assert.assertTrue(paramType.getType() instanceof ArrayType); + ArrayType arrayParamType = (ArrayType) paramType.getType(); + assertModuleIdType(arrayParamType.memberType); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + + @Test(description = "type info retrieved for optional record type param and optional record type return") + public void testTypesForOptionalRecordTypeParamAndOptionalRecordTypeReturn() + throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + LinePosition fnPosition = LinePosition.from(48, 9); + LinePosition paramPosition = LinePosition.from(48, 28); + LinePosition returnTypeDescPosition = LinePosition.from(48, 44); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( + uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); + + Assert.assertNotNull(typesFromSymbolResponse.getTypes()); + + ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); + Assert.assertEquals(returnType.getType().typeName, SymbolServiceTestUtil.UNION); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals( + returnTypeDescPosition, returnType.getRequestedPosition())); + Assert.assertTrue(returnType.getType() instanceof UnionType); + UnionType unionReturnType = (UnionType) returnType.getType(); + Assert.assertEquals(unionReturnType.members.size(), 2); + assertStudentType(unionReturnType.members.get(0)); + Assert.assertEquals(unionReturnType.members.get(1).typeName, SymbolServiceTestUtil.NULL); + + ResolvedTypeForSymbol paramType = typesFromSymbolResponse.getTypes().get(1); + Assert.assertEquals(returnType.getType().typeName, SymbolServiceTestUtil.UNION); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(paramPosition, paramType.getRequestedPosition())); + Assert.assertTrue(paramType.getType() instanceof UnionType); + UnionType unionParamType = (UnionType) paramType.getType(); + Assert.assertEquals(unionParamType.members.size(), 2); + assertPersonType(unionParamType.members.get(0)); + Assert.assertEquals(unionParamType.members.get(1).typeName, SymbolServiceTestUtil.NULL); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + + @Test(description = "type info retrieved for primitive type defaultable param and primitive type return") + public void testTypesForPrimitiveTypeDefaultableParamAndPrimitiveTypeReturn() + throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + LinePosition fnPosition = LinePosition.from(50, 9); + LinePosition paramPosition = LinePosition.from(50, 28); + LinePosition returnTypeDescPosition = LinePosition.from(50, 46); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( + uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); + + Assert.assertNotNull(typesFromSymbolResponse.getTypes()); + + ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); + Assert.assertEquals(returnType.getType().typeName, SymbolServiceTestUtil.UNION); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals( + returnTypeDescPosition, returnType.getRequestedPosition())); + Assert.assertTrue(returnType.getType() instanceof UnionType); + UnionType unionReturnType = (UnionType) returnType.getType(); + Assert.assertEquals(unionReturnType.members.size(), 2); + Assert.assertEquals(unionReturnType.members.get(0).typeName, SymbolServiceTestUtil.STRING); + Assert.assertEquals(unionReturnType.members.get(1).typeName, SymbolServiceTestUtil.ERROR); + + ResolvedTypeForSymbol paramType = typesFromSymbolResponse.getTypes().get(1); + Assert.assertEquals(paramType.getType().typeName, SymbolServiceTestUtil.STRING); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(paramPosition, paramType.getRequestedPosition())); + Assert.assertTrue(paramType.getType().defaultable); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + + @Test(description = "type info retrieved for inline record type param and inline record type return") + public void testTypesForInlineRecordTypeParamAndInlineRecordTypeReturn() + throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + LinePosition fnPosition = LinePosition.from(52, 9); + LinePosition paramPosition = LinePosition.from(52, 74); + LinePosition returnTypeDescPosition = LinePosition.from(53, 12); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( + uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); + + Assert.assertNotNull(typesFromSymbolResponse.getTypes()); + + ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); + Assert.assertEquals(returnType.getType().typeName, SymbolServiceTestUtil.RECORD); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals( + returnTypeDescPosition, returnType.getRequestedPosition())); + Assert.assertNull(returnType.getType().name); + Assert.assertTrue(returnType.getType() instanceof RecordType); + RecordType inlineRecordType1 = (RecordType) returnType.getType(); + Assert.assertEquals(inlineRecordType1.fields.size(), 4); + Assert.assertEquals(inlineRecordType1.fields.get(3).typeName, SymbolServiceTestUtil.INTEGER); + Assert.assertEquals(inlineRecordType1.fields.get(3).name, "zip"); + + ResolvedTypeForSymbol paramType = typesFromSymbolResponse.getTypes().get(1); + Assert.assertEquals(paramType.getType().typeName, SymbolServiceTestUtil.RECORD); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(paramPosition, paramType.getRequestedPosition())); + Assert.assertNull(paramType.getType().name); + Assert.assertTrue(paramType.getType() instanceof RecordType); + RecordType inlineRecordType2 = (RecordType) paramType.getType(); + Assert.assertEquals(inlineRecordType2.fields.size(), 3); + Assert.assertEquals(inlineRecordType2.fields.get(2).typeName, SymbolServiceTestUtil.STRING); + Assert.assertEquals(inlineRecordType2.fields.get(2).name, "city"); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + + @Test(description = "test no params and no return type") + public void testNoParamsAndNoReturnType() + throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + LinePosition fnPosition = LinePosition.from(55, 9); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( + uri, fnPosition, null, this.serviceEndpoint); + + Assert.assertNotNull(typesFromSymbolResponse.getTypes()); + + Assert.assertEquals(typesFromSymbolResponse.getTypes().size(), 1); + ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); + Assert.assertEquals(returnType.getType().typeName, SymbolServiceTestUtil.NULL); + Assert.assertNull(returnType.getType().name); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + + @Test(description = "test primitive type param and no return type") + public void testPrimitiveTypeParamAndNoReturnType() + throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + LinePosition fnPosition = LinePosition.from(57, 9); + LinePosition paramPosition = LinePosition.from(57, 28); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( + uri, fnPosition, null, this.serviceEndpoint); + + Assert.assertNotNull(typesFromSymbolResponse.getTypes()); + + ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); + Assert.assertEquals(returnType.getType().typeName, SymbolServiceTestUtil.NULL); + Assert.assertNull(returnType.getType().name); + + ResolvedTypeForSymbol paramType = typesFromSymbolResponse.getTypes().get(1); + Assert.assertEquals(paramType.getType().typeName, SymbolServiceTestUtil.STRING); + Assert.assertTrue(SymbolServiceTestUtil.isPositionsEquals(paramPosition, paramType.getRequestedPosition())); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + + @Test(description = "test no params and primitive return type") + public void testNoParamsAndPrimitiveReturnType() + throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + LinePosition fnPosition = LinePosition.from(59, 9); + LinePosition returnTypeDescPosition = LinePosition.from(59, 31); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( + uri, fnPosition, returnTypeDescPosition, this.serviceEndpoint); + + Assert.assertNotNull(typesFromSymbolResponse.getTypes()); + + Assert.assertEquals(typesFromSymbolResponse.getTypes().size(), 1); + ResolvedTypeForSymbol returnType = typesFromSymbolResponse.getTypes().get(0); + Assert.assertEquals(returnType.getType().typeName, SymbolServiceTestUtil.STRING); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + + @Test(description = "test invalid file path") + public void testInvalidFilePath() throws ExecutionException, InterruptedException { + LinePosition fnPosition = LinePosition.from(59, 9); + LinePosition returnTypeDescPosition = LinePosition.from(59, 31); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( + URI.create("file://+"), fnPosition, returnTypeDescPosition, this.serviceEndpoint); + + Assert.assertEquals(typesFromSymbolResponse.getTypes().size(), 0); + } + + @Test(description = "test empty positions") + public void testEmptyPositions() throws IOException, ExecutionException, InterruptedException { + Path inputFile = LSExtensionTestUtil.createTempFile(typesFromFnDefinitionBalFile); + URI uri = URI.create(inputFile.toUri().toString()); + TestUtil.openDocument(serviceEndpoint, inputFile); + + TypesFromSymbolResponse typesFromSymbolResponse = LSExtensionTestUtil.getTypesFromFnDefinition( + uri, null, null, this.serviceEndpoint); + + Assert.assertEquals(typesFromSymbolResponse.getTypes().size(), 0); + + TestUtil.closeDocument(this.serviceEndpoint, inputFile); + } + + private void assertPersonType(Type resolvedType) { + Assert.assertEquals(resolvedType.typeName, SymbolServiceTestUtil.RECORD); + Assert.assertEquals(resolvedType.name, "Person"); + Assert.assertTrue(resolvedType instanceof RecordType); + RecordType personRecordType = (RecordType) resolvedType; + Assert.assertEquals(personRecordType.fields.size(), 4); + + Assert.assertEquals(personRecordType.fields.get(0).name, "id"); + Assert.assertEquals(personRecordType.fields.get(0).typeName, SymbolServiceTestUtil.INTEGER); + + Assert.assertEquals(personRecordType.fields.get(1).name, "firstName"); + Assert.assertEquals(personRecordType.fields.get(1).typeName, SymbolServiceTestUtil.STRING); + + Assert.assertEquals(personRecordType.fields.get(2).name, "lastName"); + Assert.assertEquals(personRecordType.fields.get(2).typeName, SymbolServiceTestUtil.STRING); + + Assert.assertEquals(personRecordType.fields.get(3).name, "age"); + Assert.assertEquals(personRecordType.fields.get(3).typeName, SymbolServiceTestUtil.INTEGER); + Assert.assertTrue(personRecordType.fields.get(3).optional); + } + + private void assertCourseType(Type resolvedType) { + Assert.assertEquals(resolvedType.typeName, SymbolServiceTestUtil.RECORD); + Assert.assertEquals(resolvedType.name, "Course"); + Assert.assertTrue(resolvedType instanceof RecordType); + RecordType courseRecordType = (RecordType) resolvedType; + Assert.assertEquals(courseRecordType.fields.size(), 3); + + Assert.assertEquals(courseRecordType.fields.get(0).name, "id"); + Assert.assertEquals(courseRecordType.fields.get(0).typeName, SymbolServiceTestUtil.STRING); + + Assert.assertEquals(courseRecordType.fields.get(1).name, "name"); + Assert.assertEquals(courseRecordType.fields.get(1).typeName, SymbolServiceTestUtil.STRING); + + Assert.assertEquals(courseRecordType.fields.get(2).name, "credits"); + Assert.assertEquals(courseRecordType.fields.get(2).typeName, SymbolServiceTestUtil.INTEGER); + } + + private void assertSubmissionType(Type resolvedType) { + Assert.assertEquals(resolvedType.typeName, SymbolServiceTestUtil.RECORD); + Assert.assertEquals(resolvedType.name, "Submission"); + Assert.assertTrue(resolvedType instanceof RecordType); + RecordType submissionRecordType = (RecordType) resolvedType; + Assert.assertEquals(submissionRecordType.fields.size(), 3); + + Assert.assertEquals(submissionRecordType.fields.get(0).name, "id"); + Assert.assertEquals(submissionRecordType.fields.get(0).typeName, SymbolServiceTestUtil.INTEGER); + Assert.assertTrue(submissionRecordType.fields.get(0).defaultable); + + Assert.assertEquals(submissionRecordType.fields.get(1).name, "date"); + Assert.assertEquals(submissionRecordType.fields.get(1).typeName, SymbolServiceTestUtil.STRING); + + assertModuleIdType(submissionRecordType.fields.get(2)); + } + + private void assertStudentType(Type resolvedType) { + Assert.assertEquals(resolvedType.typeName, SymbolServiceTestUtil.RECORD); + Assert.assertEquals(resolvedType.name, "Student"); + Assert.assertTrue(resolvedType instanceof RecordType); + RecordType studentRecordType = (RecordType) resolvedType; + Assert.assertEquals(studentRecordType.fields.size(), 5); + + Assert.assertEquals(studentRecordType.fields.get(0).typeName, SymbolServiceTestUtil.UNION); + Assert.assertEquals(studentRecordType.fields.get(0).name, "id"); + Assert.assertTrue(studentRecordType.fields.get(0) instanceof UnionType); + UnionType unionType = (UnionType) studentRecordType.fields.get(0); + Assert.assertEquals(unionType.members.size(), 2); + Assert.assertEquals(unionType.members.get(0).typeName, SymbolServiceTestUtil.INTEGER); + Assert.assertEquals(unionType.members.get(1).typeName, SymbolServiceTestUtil.NULL); + + Assert.assertEquals(studentRecordType.fields.get(1).name, "fullName"); + Assert.assertEquals(studentRecordType.fields.get(1).typeName, SymbolServiceTestUtil.STRING); + + Assert.assertEquals(studentRecordType.fields.get(2).name, "age"); + Assert.assertEquals(studentRecordType.fields.get(2).typeName, SymbolServiceTestUtil.STRING); + + Assert.assertEquals(studentRecordType.fields.get(3).name, "courses"); + Assert.assertTrue(studentRecordType.fields.get(3) instanceof ArrayType); + ArrayType coursesArrayType = (ArrayType) studentRecordType.fields.get(3); + Assert.assertTrue(coursesArrayType.memberType instanceof RecordType); + RecordType courseRecordType = (RecordType) coursesArrayType.memberType; + Assert.assertEquals(courseRecordType.fields.size(), 2); + Assert.assertEquals(courseRecordType.fields.get(0).name, "title"); + Assert.assertEquals(courseRecordType.fields.get(0).typeName, SymbolServiceTestUtil.STRING); + Assert.assertEquals(courseRecordType.fields.get(1).name, "credits"); + Assert.assertEquals(courseRecordType.fields.get(1).typeName, SymbolServiceTestUtil.INTEGER); + + Assert.assertEquals(studentRecordType.fields.get(4).name, "totalCredits"); + Assert.assertEquals(studentRecordType.fields.get(4).typeName, SymbolServiceTestUtil.INTEGER); + } + + private void assertModuleIdType(Type resolvedType) { + Assert.assertEquals(resolvedType.typeName, SymbolServiceTestUtil.INTERSECTION); + Assert.assertEquals(resolvedType.typeInfo.name, "ModuleId"); + Assert.assertEquals(resolvedType.typeInfo.orgName, "ballerina"); + Assert.assertEquals(resolvedType.typeInfo.moduleName, "lang.typedesc"); + Assert.assertTrue(resolvedType instanceof IntersectionType); + IntersectionType moduleIdRecordType = (IntersectionType) resolvedType; + Assert.assertEquals(moduleIdRecordType.members.size(), 2); + + Assert.assertEquals(moduleIdRecordType.members.get(0).typeName, SymbolServiceTestUtil.RECORD); + Assert.assertNull(moduleIdRecordType.members.get(0).name); + Assert.assertTrue(moduleIdRecordType.members.get(0) instanceof RecordType); + RecordType recordType = (RecordType) moduleIdRecordType.members.get(0); + + Assert.assertEquals(recordType.fields.size(), 3); + Assert.assertEquals(recordType.fields.get(0).name, "organization"); + Assert.assertEquals(recordType.fields.get(0).typeName, SymbolServiceTestUtil.STRING); + Assert.assertEquals(recordType.fields.get(1).name, "name"); + Assert.assertEquals(recordType.fields.get(1).typeName, SymbolServiceTestUtil.STRING); + Assert.assertEquals(recordType.fields.get(2).name, "platformParts"); + Assert.assertEquals(recordType.fields.get(2).typeName, SymbolServiceTestUtil.ARRAY); + Assert.assertTrue(recordType.fields.get(2) instanceof ArrayType); + ArrayType arrayReturnType = (ArrayType) recordType.fields.get(2); + Assert.assertEquals(arrayReturnType.memberType.typeName, SymbolServiceTestUtil.STRING); + + Assert.assertEquals(moduleIdRecordType.members.get(1).typeName, SymbolServiceTestUtil.READ_ONLY); + Assert.assertNull(moduleIdRecordType.members.get(1).name); + } + + private void assertTypeIdType(Type resolvedType) { + Assert.assertEquals(resolvedType.typeName, SymbolServiceTestUtil.INTERSECTION); + Assert.assertEquals(resolvedType.typeInfo.name, "TypeId"); + Assert.assertEquals(resolvedType.typeInfo.orgName, "ballerina"); + Assert.assertEquals(resolvedType.typeInfo.moduleName, "lang.typedesc"); + Assert.assertTrue(resolvedType instanceof IntersectionType); + IntersectionType typeIdRecordType = (IntersectionType) resolvedType; + Assert.assertEquals(typeIdRecordType.members.size(), 2); + + Assert.assertEquals(typeIdRecordType.members.get(0).typeName, SymbolServiceTestUtil.RECORD); + Assert.assertNull(typeIdRecordType.members.get(0).name); + Assert.assertTrue(typeIdRecordType.members.get(0) instanceof RecordType); + RecordType recordType = (RecordType) typeIdRecordType.members.get(0); + + Assert.assertEquals(recordType.fields.size(), 2); + Assert.assertEquals(recordType.fields.get(0).name, "moduleId"); + Assert.assertEquals(recordType.fields.get(0).typeName, SymbolServiceTestUtil.INTERSECTION); + assertModuleIdType(recordType.fields.get(0)); + Assert.assertEquals(recordType.fields.get(1).name, "localId"); + Assert.assertEquals(recordType.fields.get(1).typeName, SymbolServiceTestUtil.UNION); + + Assert.assertTrue(recordType.fields.get(1) instanceof UnionType); + UnionType unionType = (UnionType) recordType.fields.get(1); + Assert.assertEquals(unionType.members.size(), 2); + Assert.assertEquals(unionType.members.get(0).typeName, SymbolServiceTestUtil.STRING); + Assert.assertEquals(unionType.members.get(1).typeName, SymbolServiceTestUtil.INTEGER); + + Assert.assertEquals(typeIdRecordType.members.get(1).typeName, SymbolServiceTestUtil.READ_ONLY); + Assert.assertNull(typeIdRecordType.members.get(1).name); + } +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_no_module_name1.json b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_no_module_name1.json new file mode 100644 index 000000000000..d8590062a44f --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_no_module_name1.json @@ -0,0 +1,38 @@ +{ + "position": { + "line": 0, + "character": 12 + }, + "source": "import_decl/source/import_decl_with_no_module_name1.bal", + "description": "Test completions in import declaration node: import orgName/", + "items": [ + { + "label": "project2", + "kind": "Module", + "detail": "Module", + "insertText": "project2", + "insertTextFormat": "Snippet" + }, + { + "label": "project1", + "kind": "Module", + "detail": "Module", + "insertText": "project1", + "insertTextFormat": "Snippet" + }, + { + "label": "local_project2", + "kind": "Module", + "detail": "Module", + "insertText": "local_project2", + "insertTextFormat": "Snippet" + }, + { + "label": "local_project1", + "kind": "Module", + "detail": "Module", + "insertText": "local_project1", + "insertTextFormat": "Snippet" + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_partial_module_name1.json b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_partial_module_name1.json new file mode 100644 index 000000000000..c3373bb56d24 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_partial_module_name1.json @@ -0,0 +1,515 @@ +{ + "position": { + "line": 0, + "character": 22 + }, + "source": "import_decl/source/import_decl_with_partial_module_name1.bal", + "items": [ + { + "label": "module1", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "module1", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.int", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'int;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.boolean", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'boolean;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.decimal", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'decimal;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.runtime", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.runtime;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.future", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'future;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.error", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'error;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.regexp", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.regexp;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.transaction", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'transaction;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.object", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'object;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.function", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'function;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.typedesc", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'typedesc;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.table", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'table;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.string", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'string;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.test", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.test;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.value", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.value;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.xml", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'xml;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "jballerina.java", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "jballerina.java", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.stream", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'stream;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.map", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'map;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.array", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.array;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.float", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'float;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_partial_module_name2.json b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_partial_module_name2.json new file mode 100644 index 000000000000..ebd166e06df8 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_partial_module_name2.json @@ -0,0 +1,515 @@ +{ + "position": { + "line": 0, + "character": 25 + }, + "source": "import_decl/source/import_decl_with_partial_module_name2.bal", + "items": [ + { + "label": "module1", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "module1", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.int", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'int;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.boolean", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'boolean;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.decimal", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'decimal;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.runtime", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.runtime;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.future", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'future;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.error", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'error;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.regexp", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.regexp;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.transaction", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'transaction;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.object", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'object;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.function", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'function;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.typedesc", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'typedesc;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.table", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'table;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.string", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'string;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.test", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.test;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.value", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.value;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.xml", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'xml;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "jballerina.java", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "jballerina.java", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.stream", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'stream;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.map", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'map;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.array", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.array;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": "lang.float", + "kind": "Module", + "detail": "Module", + "sortText": "C", + "insertText": "lang.'float;", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 17 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": "" + } + ] + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/source/import_decl_with_no_module_name1.bal b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/source/import_decl_with_no_module_name1.bal new file mode 100644 index 000000000000..a3107191b7e1 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/source/import_decl_with_no_module_name1.bal @@ -0,0 +1 @@ +import test/ \ No newline at end of file diff --git a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/source/import_decl_with_partial_module_name1.bal b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/source/import_decl_with_partial_module_name1.bal new file mode 100644 index 000000000000..183764d89a05 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/source/import_decl_with_partial_module_name1.bal @@ -0,0 +1 @@ +import ballerina/lang. \ No newline at end of file diff --git a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/source/import_decl_with_partial_module_name2.bal b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/source/import_decl_with_partial_module_name2.bal new file mode 100644 index 000000000000..2c578b061df6 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/source/import_decl_with_partial_module_name2.bal @@ -0,0 +1 @@ +import ballerina/lang.arr \ No newline at end of file diff --git a/language-server/modules/langserver-core/src/test/resources/extensions/symbol/typesFromFnDefinition.bal b/language-server/modules/langserver-core/src/test/resources/extensions/symbol/typesFromFnDefinition.bal new file mode 100644 index 000000000000..a6b0e54f30ce --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/extensions/symbol/typesFromFnDefinition.bal @@ -0,0 +1,60 @@ +import ballerina/lang.'typedesc; + +type Person record { + int id; + string firstName; + string lastName; + int age?; +}; + +type Course record { + string id; + string name; + int credits; +}; + +type Submission record { + int id = 0; + string date; + 'typedesc:ModuleId moduleId; +}; + +type Student record { + int? id; + string fullName; + string age; + record { + string title; + int credits; + }[] courses; + int totalCredits; +}; + +function transform1(string str) returns string => ""; + +function transform2(Person person) returns Student => {}; + +function transform3(Person person, Course course, Submission submission) returns Student => {}; + +function transform4(Person person, int i) returns float => 0.0; + +function transform5('typedesc:ModuleId moduleId) returns 'typedesc:TypeId => {}; + +function transform6(string[] names) returns string[] => []; + +function transform7(Person[] people, Course[] courses) returns Student[] => []; + +function transform8('typedesc:ModuleId[] moduleIds) returns 'typedesc:TypeId[] => []; + +function transform9(Person? person) returns Student? => {}; + +function transform10(string str = "") returns string|error => ""; + +function transform11(record {string houseNo; string street; string city;} address) + returns record {string number; string street; string city; int zip;} => {}; + +function transform12() => (); + +function transform13(string str) => (); + +function transform14() returns string => ""; diff --git a/misc/architecture-model-generator/build.gradle b/misc/architecture-model-generator/build.gradle new file mode 100644 index 000000000000..ef93d96b342b --- /dev/null +++ b/misc/architecture-model-generator/build.gradle @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +apply from: "$rootDir/gradle/javaProject.gradle" +apply from: "$rootDir/gradle/ballerinaLangLibLoad.gradle" + +configurations { + compile.transitive = false + compileClasspath.extendsFrom(compileOnly) +} + +dependencies { + compileOnly project(':ballerina-parser') + compileOnly project(':ballerina-lang') + + implementation project(':ballerina-tools-api') + implementation "com.google.code.gson:gson:${project.gsonVersion}" + + testCompile 'org.testng:testng' + +} + +test { + useTestNG() { + suites 'src/test/resources/testng.xml' + } +} + +description = 'Model generator core for project design diagram generation' + +ext.moduleName = 'io.ballerina.architecturemodelgenerator' + +compileJava { + inputs.property("moduleName", moduleName) + doFirst { + options.compilerArgs = [ + '--module-path', classpath.asPath, + ] + classpath = files() + } +} diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModel.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ComponentModel.java similarity index 81% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModel.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ComponentModel.java index d60c751ada68..39cf3b3311bd 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModel.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ComponentModel.java @@ -16,10 +16,10 @@ * under the License. */ -package io.ballerina.projectdesign; +package io.ballerina.architecturemodelgenerator; -import io.ballerina.projectdesign.model.entity.Entity; -import io.ballerina.projectdesign.model.service.Service; +import io.ballerina.architecturemodelgenerator.model.entity.Entity; +import io.ballerina.architecturemodelgenerator.model.service.Service; import io.ballerina.projects.Package; import java.util.Map; @@ -32,14 +32,17 @@ public class ComponentModel { private final PackageId packageId; + private final boolean hasCompilationErrors; private final Map services; private final Map entities; - public ComponentModel(PackageId packageId, Map services, Map entities) { + public ComponentModel(PackageId packageId, Map services, Map entities, + boolean hasCompilationErrors) { this.packageId = packageId; this.services = services; this.entities = entities; + this.hasCompilationErrors = hasCompilationErrors; } public PackageId getPackageId() { @@ -57,6 +60,10 @@ public Map getEntities() { return entities; } + public boolean hasCompilationErrors() { + return hasCompilationErrors; + } + /** * Represent current package information. */ @@ -74,18 +81,16 @@ public PackageId(Package currentPackage) { } public String getName() { - return name; } public String getOrg() { - return org; } public String getVersion() { - return version; } + } } diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModelBuilder.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ComponentModelBuilder.java similarity index 63% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModelBuilder.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ComponentModelBuilder.java index a8a5209a1535..9fb153048b2b 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ComponentModelBuilder.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ComponentModelBuilder.java @@ -16,21 +16,23 @@ * under the License. */ -package io.ballerina.projectdesign; +package io.ballerina.architecturemodelgenerator; +import io.ballerina.architecturemodelgenerator.ComponentModel.PackageId; +import io.ballerina.architecturemodelgenerator.generators.entity.EntityModelGenerator; +import io.ballerina.architecturemodelgenerator.generators.service.ServiceModelGenerator; +import io.ballerina.architecturemodelgenerator.model.entity.Entity; +import io.ballerina.architecturemodelgenerator.model.service.Service; import io.ballerina.compiler.api.SemanticModel; -import io.ballerina.projectdesign.ComponentModel.PackageId; -import io.ballerina.projectdesign.generators.entity.EntityModelGenerator; -import io.ballerina.projectdesign.generators.service.ServiceModelGenerator; -import io.ballerina.projectdesign.model.entity.Entity; -import io.ballerina.projectdesign.model.service.Service; import io.ballerina.projects.DocumentId; import io.ballerina.projects.Package; +import io.ballerina.projects.PackageCompilation; import java.nio.file.Path; import java.util.Collection; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; /** * Construct component model fpr project with multiple service. @@ -40,21 +42,30 @@ public class ComponentModelBuilder { public ComponentModel constructComponentModel(Package currentPackage) { + return constructComponentModel(currentPackage, null); + } + + public ComponentModel constructComponentModel(Package currentPackage, PackageCompilation packageCompilation) { Map services = new HashMap<>(); // todo: Change to TypeDefinition Map entities = new HashMap<>(); - PackageId packageId = new PackageId(currentPackage); + AtomicBoolean hasDiagnosticErrors = new AtomicBoolean(false); + currentPackage.modules().forEach(module -> { Path moduleRootPath = module.project().sourceRoot().toAbsolutePath(); if (module.moduleName().moduleNamePart() != null) { moduleRootPath = moduleRootPath.resolve(module.moduleName().moduleNamePart()); } Collection documentIds = module.documentIds(); - SemanticModel currentSemanticModel = - currentPackage.getCompilation().getSemanticModel(module.moduleId()); + PackageCompilation currentPackageCompilation = packageCompilation == null ? + currentPackage.getCompilation() : packageCompilation; + SemanticModel currentSemanticModel = currentPackageCompilation.getSemanticModel(module.moduleId()); + if (currentPackageCompilation.diagnosticResult().hasErrors() && !hasDiagnosticErrors.get()) { + hasDiagnosticErrors.set(true); + } // todo : Check project diagnostics ServiceModelGenerator serviceModelGenerator = new ServiceModelGenerator( currentSemanticModel, packageId, moduleRootPath); @@ -65,6 +76,6 @@ public ComponentModel constructComponentModel(Package currentPackage) { entities.putAll(entityModelGenerator.generate()); }); - return new ComponentModel(packageId, services, entities); + return new ComponentModel(packageId, services, entities, hasDiagnosticErrors.get()); } } diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectComponentRequest.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectComponentRequest.java similarity index 95% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectComponentRequest.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectComponentRequest.java index 799362afa3cf..75eb6095bbde 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectComponentRequest.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectComponentRequest.java @@ -16,7 +16,7 @@ * under the License. */ -package io.ballerina.projectdesign; +package io.ballerina.architecturemodelgenerator; import java.util.ArrayList; import java.util.List; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectComponentResponse.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectComponentResponse.java similarity index 93% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectComponentResponse.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectComponentResponse.java index 542b6dbdbcc1..043bdbac8821 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectComponentResponse.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectComponentResponse.java @@ -16,10 +16,10 @@ * under the License. */ -package io.ballerina.projectdesign; +package io.ballerina.architecturemodelgenerator; import com.google.gson.JsonObject; -import io.ballerina.projectdesign.diagnostics.ComponentModelingDiagnostics; +import io.ballerina.architecturemodelgenerator.diagnostics.ComponentModelingDiagnostics; import java.util.ArrayList; import java.util.HashMap; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignConstants.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectDesignConstants.java similarity index 98% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignConstants.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectDesignConstants.java index f3635c9de9b4..51fb52bab040 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignConstants.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectDesignConstants.java @@ -16,7 +16,7 @@ * under the License. */ -package io.ballerina.projectdesign; +package io.ballerina.architecturemodelgenerator; import io.ballerina.compiler.syntax.tree.SyntaxKind; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/diagnostics/ComponentModelException.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/ComponentModelException.java similarity index 94% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/diagnostics/ComponentModelException.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/ComponentModelException.java index 66d3b28efd7d..29fc1c8dbeb2 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/diagnostics/ComponentModelException.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/ComponentModelException.java @@ -16,7 +16,7 @@ * under the License. */ -package io.ballerina.projectdesign.diagnostics; +package io.ballerina.architecturemodelgenerator.diagnostics; /** * Exception for component model generation. diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/diagnostics/ComponentModelingDiagnostics.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/ComponentModelingDiagnostics.java similarity index 97% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/diagnostics/ComponentModelingDiagnostics.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/ComponentModelingDiagnostics.java index 5c908735b2c5..4d162d5a3ce9 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/diagnostics/ComponentModelingDiagnostics.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/ComponentModelingDiagnostics.java @@ -16,7 +16,7 @@ * under the License. */ -package io.ballerina.projectdesign.diagnostics; +package io.ballerina.architecturemodelgenerator.diagnostics; import io.ballerina.tools.diagnostics.Diagnostic; import io.ballerina.tools.diagnostics.DiagnosticInfo; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/diagnostics/DiagnosticMessage.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/DiagnosticMessage.java similarity index 97% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/diagnostics/DiagnosticMessage.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/DiagnosticMessage.java index 14fa397dab88..ab7bd766e560 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/diagnostics/DiagnosticMessage.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/DiagnosticMessage.java @@ -16,7 +16,7 @@ * under the License. */ -package io.ballerina.projectdesign.diagnostics; +package io.ballerina.architecturemodelgenerator.diagnostics; import io.ballerina.tools.diagnostics.DiagnosticSeverity; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/diagnostics/DiagnosticUtils.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/DiagnosticUtils.java similarity index 91% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/diagnostics/DiagnosticUtils.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/DiagnosticUtils.java index e45d47f7e0f5..01e57cfa53ca 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/diagnostics/DiagnosticUtils.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/DiagnosticUtils.java @@ -16,9 +16,9 @@ * under the License. */ -package io.ballerina.projectdesign.diagnostics; +package io.ballerina.architecturemodelgenerator.diagnostics; -import io.ballerina.projectdesign.ProjectComponentResponse; +import io.ballerina.architecturemodelgenerator.ProjectComponentResponse; import java.util.List; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/GeneratorUtils.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/GeneratorUtils.java similarity index 51% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/GeneratorUtils.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/GeneratorUtils.java index 0b470fe21f29..115f17e8fcb0 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/GeneratorUtils.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/GeneratorUtils.java @@ -16,24 +16,35 @@ * under the License. */ -package io.ballerina.projectdesign.generators; +package io.ballerina.architecturemodelgenerator.generators; +import io.ballerina.architecturemodelgenerator.model.ElementLocation; +import io.ballerina.architecturemodelgenerator.model.service.ServiceAnnotation; +import io.ballerina.compiler.api.SemanticModel; +import io.ballerina.compiler.api.symbols.Annotatable; +import io.ballerina.compiler.api.symbols.AnnotationAttachmentSymbol; +import io.ballerina.compiler.api.symbols.AnnotationSymbol; +import io.ballerina.compiler.api.symbols.TypeSymbol; +import io.ballerina.compiler.api.values.ConstantValue; import io.ballerina.compiler.syntax.tree.AnnotationNode; import io.ballerina.compiler.syntax.tree.ExpressionNode; import io.ballerina.compiler.syntax.tree.MappingFieldNode; +import io.ballerina.compiler.syntax.tree.Node; import io.ballerina.compiler.syntax.tree.NodeList; import io.ballerina.compiler.syntax.tree.SeparatedNodeList; import io.ballerina.compiler.syntax.tree.SpecificFieldNode; import io.ballerina.compiler.syntax.tree.SyntaxKind; -import io.ballerina.projectdesign.model.ElementLocation; -import io.ballerina.projectdesign.model.service.ServiceAnnotation; import io.ballerina.tools.text.LineRange; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Optional; import java.util.UUID; -import static io.ballerina.projectdesign.ProjectDesignConstants.DISPLAY_ANNOTATION; -import static io.ballerina.projectdesign.ProjectDesignConstants.ID; -import static io.ballerina.projectdesign.ProjectDesignConstants.LABEL; +import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.CLIENT; +import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.DISPLAY_ANNOTATION; +import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.ID; +import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.LABEL; /** * Provide utils functions for component model generating. @@ -88,4 +99,49 @@ public static ServiceAnnotation getServiceAnnotation(NodeList an return new ServiceAnnotation(id, label, elementLocation); } + + public static ServiceAnnotation getServiceAnnotation(Annotatable annotableSymbol, String filePath) { + + String id = null; + String label = ""; + ElementLocation elementLocation = null; + + List annotSymbols = annotableSymbol.annotations(); + List annotAttachmentSymbols = annotableSymbol.annotAttachments(); + if (annotSymbols.size() == annotAttachmentSymbols.size()) { + for (int i = 0; i < annotSymbols.size(); i++) { + AnnotationSymbol annotSymbol = annotSymbols.get(i); + AnnotationAttachmentSymbol annotAttachmentSymbol = annotAttachmentSymbols.get(i); + String annotName = annotSymbol.getName().orElse(""); + elementLocation = annotSymbol.getLocation().isPresent() ? + getElementLocation(filePath, annotSymbol.getLocation().get().lineRange()) : null; + if (!annotName.equals(DISPLAY_ANNOTATION) || annotAttachmentSymbol.attachmentValue().isEmpty() || + !(annotAttachmentSymbol.attachmentValue().get().value() instanceof LinkedHashMap) || + !annotAttachmentSymbol.isConstAnnotation()) { + continue; + } + LinkedHashMap attachmentValue = (LinkedHashMap) annotAttachmentSymbol.attachmentValue().get().value(); + if (attachmentValue.containsKey(ID)) { + id = ((ConstantValue) attachmentValue.get(ID)).value().toString(); + } + if (attachmentValue.containsKey(LABEL)) { + label = ((ConstantValue) attachmentValue.get(LABEL)).value().toString(); + } + break; + } + } + + return new ServiceAnnotation(id, label, elementLocation); + } + + public static String getClientModuleName(Node clientNode, SemanticModel semanticModel) { + + String clientModuleName = null; + Optional clientTypeSymbol = semanticModel.typeOf(clientNode); + if (clientTypeSymbol.isPresent()) { + clientModuleName = clientTypeSymbol.get().signature().trim().replace(CLIENT, ""); + } + + return clientModuleName; + } } diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/entity/EntityModelGenerator.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/entity/EntityModelGenerator.java similarity index 72% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/entity/EntityModelGenerator.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/entity/EntityModelGenerator.java index 195533433be6..9ea53aa5a8d5 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/entity/EntityModelGenerator.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/entity/EntityModelGenerator.java @@ -16,8 +16,16 @@ * under the License. */ -package io.ballerina.projectdesign.generators.entity; +package io.ballerina.architecturemodelgenerator.generators.entity; +import io.ballerina.architecturemodelgenerator.ComponentModel; +import io.ballerina.architecturemodelgenerator.ComponentModel.PackageId; +import io.ballerina.architecturemodelgenerator.ProjectDesignConstants.CardinalityValue; +import io.ballerina.architecturemodelgenerator.generators.GeneratorUtils; +import io.ballerina.architecturemodelgenerator.model.ElementLocation; +import io.ballerina.architecturemodelgenerator.model.entity.Association; +import io.ballerina.architecturemodelgenerator.model.entity.Attribute; +import io.ballerina.architecturemodelgenerator.model.entity.Entity; import io.ballerina.compiler.api.SemanticModel; import io.ballerina.compiler.api.symbols.ArrayTypeSymbol; import io.ballerina.compiler.api.symbols.NilTypeSymbol; @@ -26,29 +34,24 @@ import io.ballerina.compiler.api.symbols.Symbol; import io.ballerina.compiler.api.symbols.SymbolKind; import io.ballerina.compiler.api.symbols.TypeDefinitionSymbol; +import io.ballerina.compiler.api.symbols.TypeDescKind; import io.ballerina.compiler.api.symbols.TypeReferenceTypeSymbol; import io.ballerina.compiler.api.symbols.TypeSymbol; import io.ballerina.compiler.api.symbols.UnionTypeSymbol; -import io.ballerina.projectdesign.ComponentModel; -import io.ballerina.projectdesign.ComponentModel.PackageId; -import io.ballerina.projectdesign.ProjectDesignConstants.CardinalityValue; -import io.ballerina.projectdesign.generators.GeneratorUtils; -import io.ballerina.projectdesign.model.ElementLocation; -import io.ballerina.projectdesign.model.entity.Association; -import io.ballerina.projectdesign.model.entity.Attribute; -import io.ballerina.projectdesign.model.entity.Entity; import io.ballerina.tools.text.LineRange; import java.nio.file.Path; import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedList; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.stream.Collectors; -import static io.ballerina.projectdesign.ProjectDesignConstants.ARRAY; -import static io.ballerina.projectdesign.ProjectDesignConstants.COLON; -import static io.ballerina.projectdesign.ProjectDesignConstants.FORWARD_SLASH; +import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.ARRAY; +import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.COLON; +import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.FORWARD_SLASH; /** * Build entity model to represent relationship between records. @@ -61,6 +64,8 @@ public class EntityModelGenerator { private final ComponentModel.PackageId packageId; private final Path moduleRootPath; + private final Map types = new HashMap<>(); + public EntityModelGenerator(SemanticModel semanticModel, ComponentModel.PackageId packageId, Path moduleRootPath) { @@ -70,42 +75,79 @@ public EntityModelGenerator(SemanticModel semanticModel, ComponentModel.PackageI } public Map generate() { - - Map entities = new HashMap<>(); List symbols = semanticModel.moduleSymbols(); for (Symbol symbol : symbols) { if (symbol.kind().equals(SymbolKind.TYPE_DEFINITION)) { TypeDefinitionSymbol typeDefinitionSymbol = (TypeDefinitionSymbol) symbol; if (typeDefinitionSymbol.typeDescriptor() instanceof RecordTypeSymbol) { String entityName = getEntityName(packageId, typeDefinitionSymbol.moduleQualifiedName()); - List attributeList = new ArrayList<>(); - List inclusionList = new ArrayList<>(); RecordTypeSymbol recordTypeSymbol = (RecordTypeSymbol) typeDefinitionSymbol.typeDescriptor(); - Map recordFieldSymbolMap = - getOriginalFieldMap(recordTypeSymbol, inclusionList, entityName); - for (Map.Entry fieldEntry : recordFieldSymbolMap.entrySet()) { - - RecordFieldSymbol fieldEntryValue = fieldEntry.getValue(); - // when is the field name is optional? Tested with record inclusion and res types - String fieldName = fieldEntryValue.getName().get(); // need to handle - String fieldType = fieldEntryValue.typeDescriptor().signature(); - boolean optional = fieldEntryValue.isOptional(); - String defaultValue = ""; //need to address - boolean nillable = isNillable(fieldEntryValue.typeDescriptor()); - List associations = - getAssociations(fieldEntryValue.typeDescriptor(), entityName, optional, nillable); - Attribute attribute = - new Attribute(fieldName, fieldType, optional, nillable, defaultValue, associations, - getElementLocation(fieldEntryValue)); - attributeList.add(attribute); - } - - Entity entity = new Entity(attributeList, inclusionList, getElementLocation(typeDefinitionSymbol)); - entities.put(entityName, entity); + this.types.put(entityName, getType(recordTypeSymbol, entityName, + getElementLocation(typeDefinitionSymbol), false)); } } } - return entities; + return types; + } + + private Entity getType(RecordTypeSymbol recordTypeSymbol, String entityName, ElementLocation elementLocation, + boolean isAnonymous) { + List attributeList = new ArrayList<>(); + List inclusionList = new ArrayList<>(); + Map recordFieldSymbolMap = + getOriginalFieldMap(recordTypeSymbol, inclusionList, entityName); + for (RecordFieldSymbol recordFieldSymbol : recordFieldSymbolMap.values()) { + attributeList.add(getAttribute(recordFieldSymbol, entityName)); + } + return new Entity(attributeList, inclusionList, elementLocation, isAnonymous); + } + + private Attribute getAttribute(RecordFieldSymbol recordFieldSymbol, String entityName) { + TypeDescKind fieldTypeDescKind = recordFieldSymbol.typeDescriptor().typeKind(); + TypeSymbol fieldTypeSymbol = recordFieldSymbol.typeDescriptor(); + + String fieldName = recordFieldSymbol.getName().get(); // need to handle + String fieldType = recordFieldSymbol.typeDescriptor().signature(); + List associations; + boolean optional = recordFieldSymbol.isOptional(); + String defaultValue = ""; //need to address + boolean nillable = isNillable(recordFieldSymbol.typeDescriptor()); + + if (fieldTypeDescKind.equals(TypeDescKind.RECORD)) { + RecordTypeSymbol inlineRecordTypeSymbol = (RecordTypeSymbol) fieldTypeSymbol; + fieldType = TypeDescKind.RECORD.getName(); + String inlineRecordName = entityName + fieldName.substring(0, 1).toUpperCase(Locale.ROOT) + + fieldName.substring(1); + this.types.put(inlineRecordName, getType(inlineRecordTypeSymbol, inlineRecordName, + getElementLocation(recordFieldSymbol), true)); + String associateCardinality = optional ? CardinalityValue.ZERO_OR_ONE.getValue() : + CardinalityValue.ONE_AND_ONLY_ONE.getValue(); + Association association = new Association(inlineRecordName, new Association.Cardinality( + CardinalityValue.ONE_AND_ONLY_ONE.getValue(), associateCardinality)); + associations = new LinkedList<>(List.of(association)); + } else if (fieldTypeDescKind.equals(TypeDescKind.ARRAY) && + ((ArrayTypeSymbol) fieldTypeSymbol).memberTypeDescriptor().typeKind().equals(TypeDescKind.RECORD)) { + RecordTypeSymbol inlineRecordTypeSymbol = (RecordTypeSymbol) ((ArrayTypeSymbol) + fieldTypeSymbol).memberTypeDescriptor(); + String inlineRecordName = entityName + fieldName.substring(0, 1).toUpperCase(Locale.ROOT) + + fieldName.substring(1); + fieldType = TypeDescKind.RECORD.getName() + ARRAY; + String associateCardinality = optional ? CardinalityValue.ZERO_OR_MANY.getValue() : + CardinalityValue.ONE_OR_MANY.getValue(); + Association association = new Association(inlineRecordName, new Association.Cardinality( + CardinalityValue.ONE_AND_ONLY_ONE.getValue(), associateCardinality)); + associations = new LinkedList<>(List.of(association)); + this.types.put(inlineRecordName, getType(inlineRecordTypeSymbol, inlineRecordName, + getElementLocation(recordFieldSymbol), true)); + + } else { + associations = + getAssociations(recordFieldSymbol.typeDescriptor(), entityName, optional, nillable); + + } + // todo: address when union types has anonymous records + return new Attribute(fieldName, fieldType, optional, nillable, defaultValue, associations, + getElementLocation(recordFieldSymbol)); } private Map getOriginalFieldMap( diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/ServiceModelGenerator.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/ServiceModelGenerator.java similarity index 88% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/ServiceModelGenerator.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/ServiceModelGenerator.java index d773ed905079..adef3cfdbf86 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/ServiceModelGenerator.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/ServiceModelGenerator.java @@ -16,13 +16,13 @@ * under the License. */ -package io.ballerina.projectdesign.generators.service; +package io.ballerina.architecturemodelgenerator.generators.service; +import io.ballerina.architecturemodelgenerator.ComponentModel; +import io.ballerina.architecturemodelgenerator.generators.service.nodevisitors.ServiceDeclarationNodeVisitor; +import io.ballerina.architecturemodelgenerator.model.service.Service; import io.ballerina.compiler.api.SemanticModel; import io.ballerina.compiler.syntax.tree.SyntaxTree; -import io.ballerina.projectdesign.ComponentModel; -import io.ballerina.projectdesign.generators.service.nodevisitors.ServiceDeclarationNodeVisitor; -import io.ballerina.projectdesign.model.service.Service; import io.ballerina.projects.DocumentId; import io.ballerina.projects.Module; import io.ballerina.projects.Package; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ActionNodeVisitor.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ActionNodeVisitor.java similarity index 80% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ActionNodeVisitor.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ActionNodeVisitor.java index c01fd4c8c27c..a98ce1531cbf 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ActionNodeVisitor.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ActionNodeVisitor.java @@ -16,10 +16,14 @@ * under the License. */ -package io.ballerina.projectdesign.generators.service.nodevisitors; +package io.ballerina.architecturemodelgenerator.generators.service.nodevisitors; +import io.ballerina.architecturemodelgenerator.generators.GeneratorUtils; +import io.ballerina.architecturemodelgenerator.model.service.Interaction; +import io.ballerina.architecturemodelgenerator.model.service.ResourceId; import io.ballerina.compiler.api.ModuleID; import io.ballerina.compiler.api.SemanticModel; +import io.ballerina.compiler.api.symbols.Annotatable; import io.ballerina.compiler.api.symbols.ModuleSymbol; import io.ballerina.compiler.api.symbols.Symbol; import io.ballerina.compiler.syntax.tree.BasicLiteralNode; @@ -42,9 +46,6 @@ import io.ballerina.compiler.syntax.tree.SimpleNameReferenceNode; import io.ballerina.compiler.syntax.tree.SyntaxKind; import io.ballerina.compiler.syntax.tree.SyntaxTree; -import io.ballerina.projectdesign.generators.GeneratorUtils; -import io.ballerina.projectdesign.model.service.Interaction; -import io.ballerina.projectdesign.model.service.ResourceId; import io.ballerina.projects.DocumentId; import io.ballerina.projects.Package; import io.ballerina.tools.diagnostics.Location; @@ -55,8 +56,10 @@ import java.util.Objects; import java.util.Optional; -import static io.ballerina.projectdesign.ProjectDesignConstants.FORWARD_SLASH; -import static io.ballerina.projectdesign.ProjectDesignConstants.TYPE_MAP; +import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.FORWARD_SLASH; +import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.TYPE_MAP; +import static io.ballerina.architecturemodelgenerator.generators.GeneratorUtils.getClientModuleName; +import static io.ballerina.architecturemodelgenerator.generators.GeneratorUtils.getServiceAnnotation; /** * Visitor class for RemoteMethodCallAction nodes. @@ -83,68 +86,54 @@ public List getInteractionList() { @Override public void visit(ClientResourceAccessActionNode clientResourceAccessActionNode) { - - String clientName = String.valueOf(clientResourceAccessActionNode.expression()).trim(); + ExpressionNode clientNode = clientResourceAccessActionNode.expression(); String resourceMethod = String.valueOf(clientResourceAccessActionNode.methodName().get().name().text()); String resourcePath = getResourcePath(clientResourceAccessActionNode.resourceAccessPath()); - StatementNodeVisitor statementVisitor = new StatementNodeVisitor(clientName, semanticModel, filePath); - NonTerminalNode parent = clientResourceAccessActionNode.parent().parent(); - - // todo: get the connector type using semantic model - //todo : implement using semantic model. Need to wait till bug fix - while (statementVisitor.getServiceId() == null || statementVisitor.getServiceId().isEmpty()) { //isEmpty - parent = parent.parent(); - if (parent != null) { - parent.accept(statementVisitor); - } else { - break; - } + String serviceId = null; + Optional clientSymbol = semanticModel.symbol(clientNode); + if (clientSymbol.isPresent()) { + Annotatable annotatableSymbol = (Annotatable) clientSymbol.get(); + serviceId = getServiceAnnotation(annotatableSymbol, filePath).getId(); } Interaction interaction = new Interaction( - new ResourceId(statementVisitor.getServiceId(), resourceMethod, resourcePath), - statementVisitor.getConnectorType(), GeneratorUtils.getElementLocation(filePath, + new ResourceId(serviceId, resourceMethod, resourcePath), + getClientModuleName(clientNode, semanticModel), GeneratorUtils.getElementLocation(filePath, clientResourceAccessActionNode.lineRange())); interactionList.add(interaction); - } @Override public void visit(RemoteMethodCallActionNode remoteMethodCallActionNode) { - - String clientName = String.valueOf(remoteMethodCallActionNode.expression()).trim(); + SimpleNameReferenceNode clientNode = null; if (remoteMethodCallActionNode.expression() instanceof FieldAccessExpressionNode) { NameReferenceNode fieldName = ((FieldAccessExpressionNode) remoteMethodCallActionNode.expression()).fieldName(); if (fieldName instanceof SimpleNameReferenceNode) { - clientName = ((SimpleNameReferenceNode) fieldName).name().text(); + clientNode = (SimpleNameReferenceNode) fieldName; } // todo : Other combinations } else if (remoteMethodCallActionNode.expression() instanceof SimpleNameReferenceNode) { - clientName = ((SimpleNameReferenceNode) remoteMethodCallActionNode.expression()).name().text(); + clientNode = (SimpleNameReferenceNode) remoteMethodCallActionNode.expression(); } // todo : Other combinations - String resourceMethod = remoteMethodCallActionNode.methodName().name().text(); - NonTerminalNode parent = remoteMethodCallActionNode.parent().parent(); - StatementNodeVisitor statementVisitor = new StatementNodeVisitor(clientName, semanticModel, filePath); - //todo : implement using semantic model. Need to wait till bug fix - // semanticModel.symbol(remoteMethodCallActionNode.expression()); -> returns null + if (clientNode != null) { + String resourceMethod = remoteMethodCallActionNode.methodName().name().text(); - while (statementVisitor.getServiceId() == null || statementVisitor.getServiceId().isEmpty()) { - parent = parent.parent(); - if (parent != null) { - parent.accept(statementVisitor); - } else { - break; + String serviceId = null; + Optional clientSymbol = semanticModel.symbol(clientNode); + if (clientSymbol.isPresent()) { + Annotatable annotatableSymbol = (Annotatable) clientSymbol.get(); + serviceId = getServiceAnnotation(annotatableSymbol, filePath).getId(); } - } - Interaction interaction = new Interaction(new ResourceId(statementVisitor.getServiceId(), - resourceMethod, null), statementVisitor.getConnectorType(), - GeneratorUtils.getElementLocation(filePath, remoteMethodCallActionNode.lineRange())); - interactionList.add(interaction); + Interaction interaction = new Interaction(new ResourceId(serviceId, + resourceMethod, null), getClientModuleName(clientNode, semanticModel), + GeneratorUtils.getElementLocation(filePath, remoteMethodCallActionNode.lineRange())); + interactionList.add(interaction); + } } @Override diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java similarity index 92% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java index 33912549e28f..496d247e66ce 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java @@ -16,8 +16,12 @@ * under the License. */ -package io.ballerina.projectdesign.generators.service.nodevisitors; +package io.ballerina.architecturemodelgenerator.generators.service.nodevisitors; +import io.ballerina.architecturemodelgenerator.ComponentModel; +import io.ballerina.architecturemodelgenerator.generators.GeneratorUtils; +import io.ballerina.architecturemodelgenerator.model.service.Service; +import io.ballerina.architecturemodelgenerator.model.service.ServiceAnnotation; import io.ballerina.compiler.api.SemanticModel; import io.ballerina.compiler.api.symbols.Symbol; import io.ballerina.compiler.api.symbols.TypeDescKind; @@ -41,10 +45,6 @@ import io.ballerina.compiler.syntax.tree.TypeDefinitionNode; import io.ballerina.compiler.syntax.tree.TypeDescriptorNode; import io.ballerina.compiler.syntax.tree.VariableDeclarationNode; -import io.ballerina.projectdesign.ComponentModel; -import io.ballerina.projectdesign.generators.GeneratorUtils; -import io.ballerina.projectdesign.model.service.Service; -import io.ballerina.projectdesign.model.service.ServiceAnnotation; import io.ballerina.projects.Package; import java.nio.file.Path; @@ -53,8 +53,8 @@ import java.util.Optional; import java.util.UUID; -import static io.ballerina.projectdesign.ProjectDesignConstants.FORWARD_SLASH; -import static io.ballerina.projectdesign.ProjectDesignConstants.LISTENER; +import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.FORWARD_SLASH; +import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.LISTENER; /** * Visitor class for ServiceDeclaration nodes. diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java similarity index 95% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java index c37c31a4c44e..208c43faf3d3 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java @@ -16,8 +16,17 @@ * under the License. */ -package io.ballerina.projectdesign.generators.service.nodevisitors; - +package io.ballerina.architecturemodelgenerator.generators.service.nodevisitors; + +import io.ballerina.architecturemodelgenerator.ComponentModel; +import io.ballerina.architecturemodelgenerator.ProjectDesignConstants.ParameterIn; +import io.ballerina.architecturemodelgenerator.generators.GeneratorUtils; +import io.ballerina.architecturemodelgenerator.model.ElementLocation; +import io.ballerina.architecturemodelgenerator.model.service.FunctionParameter; +import io.ballerina.architecturemodelgenerator.model.service.RemoteFunction; +import io.ballerina.architecturemodelgenerator.model.service.Resource; +import io.ballerina.architecturemodelgenerator.model.service.ResourceId; +import io.ballerina.architecturemodelgenerator.model.service.ResourceParameter; import io.ballerina.compiler.api.SemanticModel; import io.ballerina.compiler.api.symbols.ArrayTypeSymbol; import io.ballerina.compiler.api.symbols.MethodSymbol; @@ -44,15 +53,6 @@ import io.ballerina.compiler.syntax.tree.SeparatedNodeList; import io.ballerina.compiler.syntax.tree.SyntaxKind; import io.ballerina.compiler.syntax.tree.VariableDeclarationNode; -import io.ballerina.projectdesign.ComponentModel; -import io.ballerina.projectdesign.ProjectDesignConstants.ParameterIn; -import io.ballerina.projectdesign.generators.GeneratorUtils; -import io.ballerina.projectdesign.model.ElementLocation; -import io.ballerina.projectdesign.model.service.FunctionParameter; -import io.ballerina.projectdesign.model.service.RemoteFunction; -import io.ballerina.projectdesign.model.service.Resource; -import io.ballerina.projectdesign.model.service.ResourceId; -import io.ballerina.projectdesign.model.service.ResourceParameter; import io.ballerina.projects.Package; import java.util.ArrayList; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/StatementNodeVisitor.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/StatementNodeVisitor.java similarity index 96% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/StatementNodeVisitor.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/StatementNodeVisitor.java index 5274561bad89..b92ed08d2640 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/generators/service/nodevisitors/StatementNodeVisitor.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/StatementNodeVisitor.java @@ -16,8 +16,9 @@ * under the License. */ -package io.ballerina.projectdesign.generators.service.nodevisitors; +package io.ballerina.architecturemodelgenerator.generators.service.nodevisitors; +import io.ballerina.architecturemodelgenerator.generators.GeneratorUtils; import io.ballerina.compiler.api.SemanticModel; import io.ballerina.compiler.api.symbols.Symbol; import io.ballerina.compiler.api.symbols.TypeReferenceTypeSymbol; @@ -36,11 +37,10 @@ import io.ballerina.compiler.syntax.tree.TypeDefinitionNode; import io.ballerina.compiler.syntax.tree.TypeDescriptorNode; import io.ballerina.compiler.syntax.tree.VariableDeclarationNode; -import io.ballerina.projectdesign.generators.GeneratorUtils; import java.util.Optional; -import static io.ballerina.projectdesign.ProjectDesignConstants.CLIENT; +import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.CLIENT; /** * Visitor class to identify client declaration nodes inside a Ballerina service. diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/ElementLocation.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/ElementLocation.java similarity index 97% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/ElementLocation.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/ElementLocation.java index 190d7f5051d8..1314cf753161 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/ElementLocation.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/ElementLocation.java @@ -16,7 +16,7 @@ * under the License. */ -package io.ballerina.projectdesign.model; +package io.ballerina.architecturemodelgenerator.model; /** * Represent the location of a component model element. diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/ModelElement.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/ModelElement.java similarity index 95% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/ModelElement.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/ModelElement.java index 34524cc40e0a..a58f3929a909 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/ModelElement.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/ModelElement.java @@ -16,7 +16,7 @@ * under the License. */ -package io.ballerina.projectdesign.model; +package io.ballerina.architecturemodelgenerator.model; /** * Represents the abstract model for a component model item. diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Association.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Association.java similarity index 96% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Association.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Association.java index 828a0d731f82..1d10b08234cb 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Association.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Association.java @@ -16,7 +16,7 @@ * under the License. */ -package io.ballerina.projectdesign.model.entity; +package io.ballerina.architecturemodelgenerator.model.entity; /** * Represent the relationship between records. diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Attribute.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Attribute.java similarity index 90% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Attribute.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Attribute.java index 6fe16a846c73..b0b03039f833 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Attribute.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Attribute.java @@ -16,10 +16,10 @@ * under the License. */ -package io.ballerina.projectdesign.model.entity; +package io.ballerina.architecturemodelgenerator.model.entity; -import io.ballerina.projectdesign.model.ElementLocation; -import io.ballerina.projectdesign.model.ModelElement; +import io.ballerina.architecturemodelgenerator.model.ElementLocation; +import io.ballerina.architecturemodelgenerator.model.ModelElement; import java.util.List; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Entity.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Entity.java similarity index 76% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Entity.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Entity.java index 9c6a48cfe598..5c3c8e3d135e 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/entity/Entity.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Entity.java @@ -16,10 +16,10 @@ * under the License. */ -package io.ballerina.projectdesign.model.entity; +package io.ballerina.architecturemodelgenerator.model.entity; -import io.ballerina.projectdesign.model.ElementLocation; -import io.ballerina.projectdesign.model.ModelElement; +import io.ballerina.architecturemodelgenerator.model.ElementLocation; +import io.ballerina.architecturemodelgenerator.model.ModelElement; import java.util.List; @@ -32,13 +32,16 @@ public class Entity extends ModelElement { private List attributes; private final List inclusions; + private final boolean isAnonymous; // todo : send the location - public Entity(List attributes, List inclusions, ElementLocation elementLocation) { + public Entity(List attributes, List inclusions, ElementLocation elementLocation, + boolean isAnonymous) { super(elementLocation); this.attributes = attributes; this.inclusions = inclusions; + this.isAnonymous = isAnonymous; } public List getAttributes() { @@ -52,5 +55,9 @@ public void setAttributes(List attributes) { public List getInclusions() { return inclusions; } + + public boolean isAnonymous() { + return isAnonymous; + } } diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/FunctionParameter.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/FunctionParameter.java similarity index 87% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/FunctionParameter.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/FunctionParameter.java index 63f991f1bb6d..2a3bbafd6c96 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/FunctionParameter.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/FunctionParameter.java @@ -16,10 +16,10 @@ * under the License. */ -package io.ballerina.projectdesign.model.service; +package io.ballerina.architecturemodelgenerator.model.service; -import io.ballerina.projectdesign.model.ElementLocation; -import io.ballerina.projectdesign.model.ModelElement; +import io.ballerina.architecturemodelgenerator.model.ElementLocation; +import io.ballerina.architecturemodelgenerator.model.ModelElement; import java.util.List; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/Interaction.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Interaction.java similarity index 86% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/Interaction.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Interaction.java index 94746d683160..be4d59bab049 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/Interaction.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Interaction.java @@ -16,10 +16,10 @@ * under the License. */ -package io.ballerina.projectdesign.model.service; +package io.ballerina.architecturemodelgenerator.model.service; -import io.ballerina.projectdesign.model.ElementLocation; -import io.ballerina.projectdesign.model.ModelElement; +import io.ballerina.architecturemodelgenerator.model.ElementLocation; +import io.ballerina.architecturemodelgenerator.model.ModelElement; /** * Represent interaction with another service. diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/RemoteFunction.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/RemoteFunction.java similarity index 89% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/RemoteFunction.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/RemoteFunction.java index da833b24961e..d6e10bbcf14a 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/RemoteFunction.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/RemoteFunction.java @@ -16,10 +16,10 @@ * under the License. */ -package io.ballerina.projectdesign.model.service; +package io.ballerina.architecturemodelgenerator.model.service; -import io.ballerina.projectdesign.model.ElementLocation; -import io.ballerina.projectdesign.model.ModelElement; +import io.ballerina.architecturemodelgenerator.model.ElementLocation; +import io.ballerina.architecturemodelgenerator.model.ModelElement; import java.util.List; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/Resource.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Resource.java similarity index 90% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/Resource.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Resource.java index feb093b12999..9fb03acdec8c 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/Resource.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Resource.java @@ -16,10 +16,10 @@ * under the License. */ -package io.ballerina.projectdesign.model.service; +package io.ballerina.architecturemodelgenerator.model.service; -import io.ballerina.projectdesign.model.ElementLocation; -import io.ballerina.projectdesign.model.ModelElement; +import io.ballerina.architecturemodelgenerator.model.ElementLocation; +import io.ballerina.architecturemodelgenerator.model.ModelElement; import java.util.List; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/ResourceId.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ResourceId.java similarity index 95% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/ResourceId.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ResourceId.java index e3ed9f2d9ebd..69136d21dc60 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/ResourceId.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ResourceId.java @@ -16,7 +16,7 @@ * under the License. */ -package io.ballerina.projectdesign.model.service; +package io.ballerina.architecturemodelgenerator.model.service; /** * Provide resource information. diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/ResourceParameter.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ResourceParameter.java similarity index 88% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/ResourceParameter.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ResourceParameter.java index ce4d8bcd9f47..a28acec9530b 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/ResourceParameter.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ResourceParameter.java @@ -16,10 +16,10 @@ * under the License. */ -package io.ballerina.projectdesign.model.service; +package io.ballerina.architecturemodelgenerator.model.service; -import io.ballerina.projectdesign.model.ElementLocation; -import io.ballerina.projectdesign.model.ModelElement; +import io.ballerina.architecturemodelgenerator.model.ElementLocation; +import io.ballerina.architecturemodelgenerator.model.ModelElement; import java.util.List; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/Service.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Service.java similarity index 91% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/Service.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Service.java index 47ba071edb20..e5a8814bdc45 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/Service.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Service.java @@ -16,10 +16,10 @@ * under the License. */ -package io.ballerina.projectdesign.model.service; +package io.ballerina.architecturemodelgenerator.model.service; -import io.ballerina.projectdesign.model.ElementLocation; -import io.ballerina.projectdesign.model.ModelElement; +import io.ballerina.architecturemodelgenerator.model.ElementLocation; +import io.ballerina.architecturemodelgenerator.model.ModelElement; import java.util.List; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/ServiceAnnotation.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ServiceAnnotation.java similarity index 91% rename from misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/ServiceAnnotation.java rename to misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ServiceAnnotation.java index edbff1754656..ab1f7111c9a7 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/model/service/ServiceAnnotation.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ServiceAnnotation.java @@ -16,9 +16,9 @@ * under the License. */ -package io.ballerina.projectdesign.model.service; +package io.ballerina.architecturemodelgenerator.model.service; -import io.ballerina.projectdesign.model.ElementLocation; +import io.ballerina.architecturemodelgenerator.model.ElementLocation; /** * Represents display annotation. diff --git a/misc/architecture-model-generator/src/main/java/module-info.java b/misc/architecture-model-generator/src/main/java/module-info.java new file mode 100644 index 000000000000..83356dfebb95 --- /dev/null +++ b/misc/architecture-model-generator/src/main/java/module-info.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +module io.ballerina.architecturemodelgenerator { + requires com.google.gson; + requires io.ballerina.lang; + requires io.ballerina.parser; + requires io.ballerina.tools.api; + + exports io.ballerina.architecturemodelgenerator; + exports io.ballerina.architecturemodelgenerator.diagnostics; +} diff --git a/misc/compiler-plugins/modules/architecture-model-generator-pligin/build.gradle b/misc/compiler-plugins/modules/architecture-model-generator-pligin/build.gradle new file mode 100644 index 000000000000..252d1adc5be1 --- /dev/null +++ b/misc/compiler-plugins/modules/architecture-model-generator-pligin/build.gradle @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (http://wso2.com) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +apply from: "$rootDir/gradle/javaProject.gradle" +apply from: "$rootDir/gradle/ballerinaLangLibLoad.gradle" + +description = 'Ballerina Component Model Generator' + +dependencies { + implementation project(':ballerina-lang') + implementation project(':ballerina-parser') + implementation project(':ballerina-tools-api') + + implementation project(':architecture-model-generator') + implementation "com.google.code.gson:gson:${project.gsonVersion}" +} + +ext.moduleName = 'io.ballerina.modelgenerator.plugin' + +compileJava { + doFirst { + options.compilerArgs = [ + '--module-path', classpath.asPath, + ] + classpath = files() + } +} diff --git a/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/CompilationAnalysisTask.java b/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/CompilationAnalysisTask.java new file mode 100644 index 000000000000..dff9de53890e --- /dev/null +++ b/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/CompilationAnalysisTask.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (http://wso2.com) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.ballerina.architecturemodelgeneratorplugin; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import io.ballerina.architecturemodelgenerator.ComponentModel; +import io.ballerina.architecturemodelgenerator.ComponentModelBuilder; +import io.ballerina.architecturemodelgeneratorplugin.diagnostic.DiagnosticMessage; +import io.ballerina.projects.BuildOptions; +import io.ballerina.projects.Project; +import io.ballerina.projects.plugins.AnalysisTask; +import io.ballerina.projects.plugins.CompilationAnalysisContext; +import io.ballerina.tools.diagnostics.Diagnostic; +import io.ballerina.tools.diagnostics.DiagnosticFactory; +import io.ballerina.tools.diagnostics.DiagnosticInfo; + +import java.io.FileWriter; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.InvalidPathException; +import java.nio.file.Path; + +import static io.ballerina.architecturemodelgeneratorplugin.PluginConstants.MODEL_DIR_NAME; +import static io.ballerina.architecturemodelgeneratorplugin.PluginConstants.MODEL_JSON_NAME; + +/** + * Compilation analyzer to generate component model. + * + * @since 2201.4.0 + */ +public class CompilationAnalysisTask implements AnalysisTask { + @Override + public void perform(CompilationAnalysisContext compilationAnalysisContext) { + Project project = compilationAnalysisContext.currentPackage().project(); + + //Used build option exportComponentModel() to enable plugin at the build time. + BuildOptions buildOptions = project.buildOptions(); + if (buildOptions.exportComponentModel()) { + Path outPath = project.targetDir(); + ComponentModelBuilder componentModelBuilder = new ComponentModelBuilder(); + ComponentModel projectModel = componentModelBuilder + .constructComponentModel(compilationAnalysisContext.currentPackage(), + compilationAnalysisContext.compilation()); + Gson gson = new GsonBuilder().setPrettyPrinting().serializeNulls().create(); + String componentModelJson = gson.toJson(projectModel) + System.lineSeparator(); + writeComponentModelJson(outPath, componentModelJson, compilationAnalysisContext); + } + } + + private void writeComponentModelJson(Path outPath, String componentModelJson, CompilationAnalysisContext context) { + try { + // Create ComponentModel directory if not exists in the path. If exists do not throw an error + Path componentModelExportDir = outPath.resolve(MODEL_DIR_NAME); + Files.createDirectories(componentModelExportDir); + Path writePath = componentModelExportDir.resolve(MODEL_JSON_NAME); + writeFile(writePath, componentModelJson); + } catch (InvalidPathException | SecurityException | IOException e) { + DiagnosticMessage diagnosticMessage = DiagnosticMessage.ERROR_100; + DiagnosticInfo diagnosticInfo = new DiagnosticInfo(diagnosticMessage.getCode(), + diagnosticMessage.getMessageFormat(), diagnosticMessage.getSeverity()); + Diagnostic diagnostic = DiagnosticFactory.createDiagnostic(diagnosticInfo, null, e.getMessage()); + context.reportDiagnostic(diagnostic); + } + } + + private void writeFile(Path filePath, String content) throws IOException { + try (FileWriter writer = new FileWriter(filePath.toString(), StandardCharsets.UTF_8)) { + writer.write(content); + } + } +} diff --git a/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCodeAnalyzer.java b/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCodeAnalyzer.java new file mode 100644 index 000000000000..eb4d62a1be87 --- /dev/null +++ b/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCodeAnalyzer.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (http://wso2.com) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package io.ballerina.architecturemodelgeneratorplugin; + +import io.ballerina.projects.plugins.CodeAnalysisContext; +import io.ballerina.projects.plugins.CodeAnalyzer; + +/** + * CodeAnalyzer for Component model generator compiler plugin. + * + * @since 2201.4.0 + */ +public class ModelGeneratorCodeAnalyzer extends CodeAnalyzer { + @Override + public void init(CodeAnalysisContext analysisContext) { + analysisContext.addCompilationAnalysisTask(new CompilationAnalysisTask()); + } +} diff --git a/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCompilerPlugin.java b/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCompilerPlugin.java new file mode 100644 index 000000000000..0526a04d3d18 --- /dev/null +++ b/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCompilerPlugin.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (http://wso2.com) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.ballerina.architecturemodelgeneratorplugin; + +import io.ballerina.projects.plugins.CompilerPlugin; +import io.ballerina.projects.plugins.CompilerPluginContext; + +/** + * Compiler Plugin to generate Component Models. + * + * @since 2201.4.0 + */ +public class ModelGeneratorCompilerPlugin extends CompilerPlugin { + @Override + public void init(CompilerPluginContext pluginContext) { + pluginContext.addCodeAnalyzer(new ModelGeneratorCodeAnalyzer()); + } +} diff --git a/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/PluginConstants.java b/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/PluginConstants.java new file mode 100644 index 000000000000..30b339bb21b4 --- /dev/null +++ b/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/PluginConstants.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (http://wso2.com) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.ballerina.architecturemodelgeneratorplugin; + +/** + * Plugin Constants. + * + * @since 2201.4.0 + */ +public class PluginConstants { + public static final String MODEL_DIR_NAME = "component-model"; + public static final String MODEL_JSON_NAME = "component-model.json"; +} diff --git a/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/diagnostic/DiagnosticMessage.java b/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/diagnostic/DiagnosticMessage.java new file mode 100644 index 000000000000..c361d3533876 --- /dev/null +++ b/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/diagnostic/DiagnosticMessage.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (http://wso2.com) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.ballerina.architecturemodelgeneratorplugin.diagnostic; + +import io.ballerina.tools.diagnostics.DiagnosticSeverity; + +/** + * Model Generator compiler plugin diagnostic messages. + * + * @since 2201.4.0 + */ +public enum DiagnosticMessage { + ERROR_100("MODEL_GENERATOR_PLUGIN_ERROR_100", + "Failed to write the generated Component Model JSON to the target directory: {0}.", + DiagnosticSeverity.ERROR); + + private final String code; + private final String messageFormat; + private final DiagnosticSeverity severity; + + DiagnosticMessage(String code, String messageFormat, DiagnosticSeverity severity) { + this.code = code; + this.messageFormat = messageFormat; + this.severity = severity; + } + + public String getCode() { + return this.code; + } + + public String getMessageFormat() { + return this.messageFormat; + } + + public DiagnosticSeverity getSeverity() { + return this.severity; + } +} diff --git a/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/module-info.java b/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/module-info.java new file mode 100644 index 000000000000..3f9fc5362750 --- /dev/null +++ b/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/module-info.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +module io.ballerina.modelgenerator.plugin { + requires com.google.gson; + requires io.ballerina.lang; + requires io.ballerina.parser; + requires io.ballerina.tools.api; + requires io.ballerina.architecturemodelgenerator; + + exports io.ballerina.architecturemodelgeneratorplugin; +} diff --git a/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/resources/META-INF/services/io.ballerina.projects.plugins.CompilerPlugin b/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/resources/META-INF/services/io.ballerina.projects.plugins.CompilerPlugin new file mode 100644 index 000000000000..8901ab6d2807 --- /dev/null +++ b/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/resources/META-INF/services/io.ballerina.projects.plugins.CompilerPlugin @@ -0,0 +1 @@ +io.ballerina.architecturemodelgeneratorplugin.ModelGeneratorCompilerPlugin diff --git a/misc/diagram-util/src/main/java/org/ballerinalang/diagramutil/connector/models/connector/Type.java b/misc/diagram-util/src/main/java/org/ballerinalang/diagramutil/connector/models/connector/Type.java index 5fdb436ac8d0..83022d36298f 100644 --- a/misc/diagram-util/src/main/java/org/ballerinalang/diagramutil/connector/models/connector/Type.java +++ b/misc/diagram-util/src/main/java/org/ballerinalang/diagramutil/connector/models/connector/Type.java @@ -24,6 +24,8 @@ import io.ballerina.compiler.api.symbols.ErrorTypeSymbol; import io.ballerina.compiler.api.symbols.IntersectionTypeSymbol; import io.ballerina.compiler.api.symbols.ObjectTypeSymbol; +import io.ballerina.compiler.api.symbols.ParameterKind; +import io.ballerina.compiler.api.symbols.ParameterSymbol; import io.ballerina.compiler.api.symbols.RecordFieldSymbol; import io.ballerina.compiler.api.symbols.RecordTypeSymbol; import io.ballerina.compiler.api.symbols.StreamTypeSymbol; @@ -254,6 +256,7 @@ public static Type fromSemanticSymbol(Symbol symbol) { Type restType = recordTypeSymbol.restTypeDescriptor().isPresent() ? fromSemanticSymbol(recordTypeSymbol.restTypeDescriptor().get()) : null; type = new RecordType(fields, restType); + parentSymbols.remove(parentSymbols.size() - 1); } else if (symbol instanceof ArrayTypeSymbol) { ArrayTypeSymbol arrayTypeSymbol = (ArrayTypeSymbol) symbol; type = new ArrayType(fromSemanticSymbol(arrayTypeSymbol.memberTypeDescriptor())); @@ -313,6 +316,12 @@ public static Type fromSemanticSymbol(Symbol symbol) { } else if (symbol instanceof RecordFieldSymbol) { RecordFieldSymbol recordFieldSymbol = (RecordFieldSymbol) symbol; type = fromSemanticSymbol(recordFieldSymbol.typeDescriptor()); + } else if (symbol instanceof ParameterSymbol) { + ParameterSymbol parameterSymbol = (ParameterSymbol) symbol; + type = fromSemanticSymbol(parameterSymbol.typeDescriptor()); + if (type != null) { + type.defaultable = parameterSymbol.paramKind() == ParameterKind.DEFAULTABLE; + } } else if (symbol instanceof TypeSymbol) { type = new PrimitiveType(((TypeSymbol) symbol).signature()); } diff --git a/misc/json-to-record-converter/README.md b/misc/json-to-record-converter/README.md index 15e2449b1763..1fd52de7f277 100644 --- a/misc/json-to-record-converter/README.md +++ b/misc/json-to-record-converter/README.md @@ -511,4 +511,4 @@ The implementation can handle complex scenarios having many values with differen ## Contact Us Managed By [WSO2 Inc.](https://wso2.com/) -Slack channel : [Ballerina Platform](https://ballerina-platform.slack.com/) +Discord server: [Ballerina](https://discord.gg/ballerinalang) diff --git a/misc/ls-extensions/modules/project-design-service/build.gradle b/misc/ls-extensions/modules/project-design-service/build.gradle index 2689b406d6e1..526a5ac6b0ea 100644 --- a/misc/ls-extensions/modules/project-design-service/build.gradle +++ b/misc/ls-extensions/modules/project-design-service/build.gradle @@ -25,7 +25,6 @@ configurations { } dependencies { - compileOnly project(':ballerina-parser') compileOnly project(':ballerina-lang') compileOnly project(':ballerina-tools-api') compileOnly project(':language-server:language-server-commons') @@ -33,14 +32,9 @@ dependencies { compileOnly(group: 'org.eclipse.lsp4j', name: 'org.eclipse.lsp4j', version: "${project.eclipseLsp4jVersion}") + implementation project(":architecture-model-generator") + testCompile 'org.testng:testng' - testCompile project(':ballerina-parser') - testCompile project(':language-server:language-server-commons') - testCompile project(':language-server:language-server-core') - testCompile 'com.google.code.gson:gson:"${project.gsonVersion}"' - testCompile(group: 'org.eclipse.lsp4j', name: 'org.eclipse.lsp4j', version: "${project.eclipseLsp4jVersion}") - testCompile(group: 'net.javacrumbs.json-unit', name: 'json-unit-assertj', version: '2.28.0') - testCompile(group: 'net.javacrumbs.json-unit', name: 'json-unit-json-path', version: '2.28.0') } diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignClientCapabilities.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignClientCapabilities.java index 8d01b2687efe..e24f7fda6402 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignClientCapabilities.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignClientCapabilities.java @@ -18,6 +18,7 @@ package io.ballerina.projectdesign; +import io.ballerina.architecturemodelgenerator.ProjectDesignConstants; import org.ballerinalang.langserver.commons.registration.BallerinaClientCapability; /** diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignClientCapabilitySetter.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignClientCapabilitySetter.java index ce81429f66f8..bd0f33236c6a 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignClientCapabilitySetter.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignClientCapabilitySetter.java @@ -18,6 +18,7 @@ package io.ballerina.projectdesign; +import io.ballerina.architecturemodelgenerator.ProjectDesignConstants; import org.ballerinalang.annotation.JavaSPIService; import org.ballerinalang.langserver.commons.registration.BallerinaClientCapabilitySetter; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignServerCapabilities.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignServerCapabilities.java index 89255f0f49ee..a91877d9acd2 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignServerCapabilities.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignServerCapabilities.java @@ -18,6 +18,7 @@ package io.ballerina.projectdesign; +import io.ballerina.architecturemodelgenerator.ProjectDesignConstants; import org.ballerinalang.langserver.commons.registration.BallerinaServerCapability; /** diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignServerCapabilitySetter.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignServerCapabilitySetter.java index 3089a7e88941..a36002e9683a 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignServerCapabilitySetter.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignServerCapabilitySetter.java @@ -18,6 +18,7 @@ package io.ballerina.projectdesign; +import io.ballerina.architecturemodelgenerator.ProjectDesignConstants; import org.ballerinalang.annotation.JavaSPIService; import org.ballerinalang.langserver.commons.registration.BallerinaServerCapabilitySetter; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignService.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignService.java index d9bd0205a1ae..f60447d81eb4 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignService.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignService.java @@ -21,9 +21,13 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; -import io.ballerina.projectdesign.diagnostics.ComponentModelException; -import io.ballerina.projectdesign.diagnostics.DiagnosticMessage; -import io.ballerina.projectdesign.diagnostics.DiagnosticUtils; +import io.ballerina.architecturemodelgenerator.ComponentModel; +import io.ballerina.architecturemodelgenerator.ComponentModelBuilder; +import io.ballerina.architecturemodelgenerator.ProjectComponentRequest; +import io.ballerina.architecturemodelgenerator.ProjectComponentResponse; +import io.ballerina.architecturemodelgenerator.diagnostics.ComponentModelException; +import io.ballerina.architecturemodelgenerator.diagnostics.DiagnosticMessage; +import io.ballerina.architecturemodelgenerator.diagnostics.DiagnosticUtils; import io.ballerina.projects.Project; import org.ballerinalang.annotation.JavaSPIService; import org.ballerinalang.langserver.commons.eventsync.exceptions.EventSyncException; diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/Utils.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/Utils.java index 9e2b353f106c..46697533a3de 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/Utils.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/Utils.java @@ -1,6 +1,25 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + package io.ballerina.projectdesign; import com.google.gson.JsonObject; +import io.ballerina.architecturemodelgenerator.ComponentModel; import io.ballerina.projects.Package; import java.util.Map; @@ -11,7 +30,6 @@ * @since 2201.2.2 */ public class Utils { - public static String getQualifiedPackageName(ComponentModel.PackageId packageId) { return String.format("%s/%s:%s", packageId.getOrg(), diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/module-info.java b/misc/ls-extensions/modules/project-design-service/src/main/java/module-info.java index a9a33f316f6d..9cdff86a2c12 100644 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/module-info.java +++ b/misc/ls-extensions/modules/project-design-service/src/main/java/module-info.java @@ -1,11 +1,28 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + module io.ballerina.LSExtensions.ProjectDesignService { requires io.ballerina.language.server.commons; requires io.ballerina.lang; requires org.eclipse.lsp4j.jsonrpc; requires org.eclipse.lsp4j; - requires io.ballerina.parser; requires com.google.gson; requires io.ballerina.tools.api; requires io.ballerina.language.server.core; - -} \ No newline at end of file + requires io.ballerina.architecturemodelgenerator; +} diff --git a/settings.gradle b/settings.gradle index 5804057a2fed..79b65ff923fe 100644 --- a/settings.gradle +++ b/settings.gradle @@ -98,6 +98,7 @@ include(':language-server-simulator') // TODO: enable at 'dependsOn' of tools-intergration-tests // and 'mustRunAfter' of vs-code-pluggin +include(':architecture-model-generator') include(':benchmarks') include(':build-config:checkstyle') include(':debug-adapter:debug-adapter-core') @@ -105,6 +106,7 @@ include(':debug-adapter:debug-adapter-cli') include(':debug-adapter:debug-adapter-runtime') include('semver-checker:semver-checker-cli') include('semver-checker:semver-checker-core') +include(':compiler-plugins:architecture-model-generator-pligin') include(':compiler-plugins:package-semantic-analyzer') include(':compiler-plugins:configurable-schema-generator') include(':formatter:formatter-core') @@ -181,6 +183,7 @@ project(':ballerina-runtime').projectDir = file('bvm/ballerina-runtime') project(':ballerina-rt').projectDir = file('bvm/ballerina-rt') project(':ballerina-treegen').projectDir = file('compiler/ballerina-treegen') project(':ballerina-test-utils').projectDir = file('tests/ballerina-test-utils') +project(':architecture-model-generator').projectDir = file('misc/architecture-model-generator') project(':ballerina-io-internal').projectDir = file('misc/io-internal') project(':json-mapper').projectDir = file('misc/json-to-record-converter') project(':lib-creator').projectDir = file('misc/lib-creator') @@ -243,6 +246,7 @@ project(':debug-adapter:debug-adapter-cli').projectDir = file('misc/debug-adapte project(':debug-adapter:debug-adapter-runtime').projectDir = file('misc/debug-adapter/modules/debug-adapter-runtime') project(':semver-checker:semver-checker-core').projectDir = file('misc/semver-checker/modules/semver-checker-core') project(':semver-checker:semver-checker-cli').projectDir = file('misc/semver-checker/modules/semver-checker-cli') +project(':compiler-plugins:architecture-model-generator-pligin').projectDir = file('misc/compiler-plugins/modules/architecture-model-generator-pligin') project(':compiler-plugins:package-semantic-analyzer').projectDir = file('misc/compiler-plugins/modules/package-semantic-analyzer') project(':compiler-plugins:configurable-schema-generator').projectDir = file('misc/compiler-plugins/modules/configurable-schema-generator') project(':formatter:formatter-core').projectDir = file('misc/formatter/modules/formatter-core') diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/binaryoperations/TypeTestExprTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/binaryoperations/TypeTestExprTest.java index afd327ebf822..fa9c126b066c 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/binaryoperations/TypeTestExprTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/binaryoperations/TypeTestExprTest.java @@ -769,7 +769,8 @@ public Object[] dataToTypeTestExpressions() { "testRecordsWithOptionalFields", "testReadOnlyArrays", "testTypeTestExprWithSingletons", - "testResourceMethodTyping" + "testResourceMethodTyping", + "testIsExpressionWithDistinctErrors" }; } } diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/documentation/deprecated_annotation_project/main.bal b/tests/jballerina-unit-test/src/test/resources/test-src/documentation/deprecated_annotation_project/main.bal index a8db593af491..31c888fa523b 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/documentation/deprecated_annotation_project/main.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/documentation/deprecated_annotation_project/main.bal @@ -1,4 +1,4 @@ -import ballerina/io; +import ballerina/jballerina.java; //========== MODULE-LEVEL CONST DECL ======================== @@ -175,7 +175,7 @@ public function createPerson(string fname, string lname, string street, # # + name - name person want to say hello public function sayHello(string name) { - io:println("Hello " + name); + println("Hello " + name); } //========= REQUIRED AND DEFAULTABLE FUNCTION PARAMS ====== @@ -213,5 +213,11 @@ public class Player { public function main() { Person p = createPerson("Jane", "Doe", "Castro Street", "Mountain View", USA); - io:println(p.getFullName()); + println(p.getFullName()); } + +// helper functions + +function println(any|error... values) = @java:Method { + 'class: "org.ballerinalang.test.utils.interop.Utils" +} external; diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/documentation/multi_line_docs_project/main.bal b/tests/jballerina-unit-test/src/test/resources/test-src/documentation/multi_line_docs_project/main.bal index dde5e4d23528..6895f4f00cc4 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/documentation/multi_line_docs_project/main.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/documentation/multi_line_docs_project/main.bal @@ -1,4 +1,4 @@ -import ballerina/io; +import ballerina/jballerina.java; # Returns a formatted string using the specified format string and arguments. Following format specifiers are allowed. # @@ -57,5 +57,11 @@ public function deprecatedMultilineDocsFunction(string format) returns string { } public function main() { - io:println(multilineDocsFunction("world")); + println(multilineDocsFunction("world")); } + +// helper functions + +function println(any|error... values) = @java:Method { + 'class: "org.ballerinalang.test.utils.interop.Utils" +} external; diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/documentation/record_object_fields_project/main.bal b/tests/jballerina-unit-test/src/test/resources/test-src/documentation/record_object_fields_project/main.bal index fbdd580df1aa..691eed706160 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/documentation/record_object_fields_project/main.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/documentation/record_object_fields_project/main.bal @@ -1,4 +1,4 @@ -import ballerina/io; +import ballerina/jballerina.java; public const string LKA = "LKA"; public const string LK = "LK"; @@ -74,5 +74,11 @@ public class Employee { # Prints `Hello World`. public function main() { - io:println("Hello World!"); + println("Hello World!"); } + +// helper functions + +function println(any|error... values) = @java:Method { + 'class: "org.ballerinalang.test.utils.interop.Utils" +} external; diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/expressions/binaryoperations/type-test-expr.bal b/tests/jballerina-unit-test/src/test/resources/test-src/expressions/binaryoperations/type-test-expr.bal index e88e423b69c0..73afce23d6b3 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/expressions/binaryoperations/type-test-expr.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/expressions/binaryoperations/type-test-expr.bal @@ -1808,3 +1808,177 @@ function testResourceMethodTyping() { test:assertTrue(result); } + +// ========================== distinct types ========================== + +type ListenerError distinct error; + +type ClientError distinct error; + +type DistictListenerError distinct ListenerError; + +type ErrType error; + +distinct error err1 = error("err1"); +distinct error err2 = error("err2"); +ErrType errtype1 = error("errtype1"); +error err3 = error("error!"); +ListenerError listerr1 = error("listerr1"); +ListenerError listerr2 = error("listerr2"); +ClientError clierr1 = error("clierr1"); +distinct ListenerError distlisterr1 = error("distlisterr1"); +distinct ListenerError distlisterr2 = error("distlisterr2"); +distinct ClientError distclierr1 = error("distclierr1"); + +function testIsExpressionWithDistinctErrors() { + distinct error err11 = error("err11"); + distinct error err21 = error("err21"); + ErrType errtype11 = error("errtype11"); + error err31 = error("error1!"); + ListenerError listerr11 = error("listerr11"); + ListenerError listerr21 = error("listerr21"); + ClientError clierr11 = error("clierr11"); + distinct ListenerError distlisterr11 = error("distlisterr11"); + distinct ListenerError distlisterr21 = error("distlisterr21"); + distinct ClientError distclierr11 = error("distclierr11"); + + // global variables + test:assertEquals(err1 is distinct error, false); + test:assertEquals(err1 is ErrType, true); + test:assertEquals(err1 is error, true); + test:assertEquals(err1 is ListenerError, false); + test:assertEquals(err1 is distinct ListenerError, false); + test:assertEquals(err1 is DistictListenerError, false); + + test:assertEquals(errtype1 is distinct error, false); + test:assertEquals(errtype1 is ErrType, true); + test:assertEquals(errtype1 is error, true); + test:assertEquals(errtype1 is ListenerError, false); + test:assertEquals(errtype1 is distinct ListenerError, false); + test:assertEquals(errtype1 is DistictListenerError, false); + + test:assertEquals(err3 is distinct error, false); + test:assertEquals(err3 is ErrType, true); + test:assertEquals(err3 is error, true); + test:assertEquals(err3 is ListenerError, false); + test:assertEquals(err3 is distinct ListenerError, false); + test:assertEquals(err3 is DistictListenerError, false); + + test:assertEquals(listerr1 is distinct error, false); + test:assertEquals(listerr1 is ErrType, true); + test:assertEquals(listerr1 is error, true); + test:assertEquals(listerr1 is ListenerError, true); + // https://github.com/ballerina-platform/ballerina-lang/issues/38130 + // test:assertEquals(listerr1 is distinct ListenerError, false); + test:assertEquals(listerr1 is ClientError, false); + test:assertEquals(listerr1 is distinct ClientError, false); + test:assertEquals(listerr1 is DistictListenerError, false); + + test:assertEquals(distlisterr1 is distinct error, false); + test:assertEquals(distlisterr1 is ErrType, true); + test:assertEquals(distlisterr1 is error, true); + test:assertEquals(distlisterr1 is ListenerError, true); + // https://github.com/ballerina-platform/ballerina-lang/issues/38130 + // test:assertEquals(distlisterr1 is distinct ListenerError, false); + test:assertEquals(distlisterr1 is ClientError, false); + test:assertEquals(distlisterr1 is distinct ClientError, false); + test:assertEquals(distlisterr1 is DistictListenerError, false); + + // local variables + test:assertEquals(err11 is distinct error, false); + test:assertEquals(err11 is ErrType, true); + test:assertEquals(err11 is error, true); + test:assertEquals(err11 is ListenerError, false); + test:assertEquals(err11 is distinct ListenerError, false); + test:assertEquals(err11 is DistictListenerError, false); + + test:assertEquals(errtype11 is distinct error, false); + test:assertEquals(errtype11 is ErrType, true); + test:assertEquals(errtype11 is error, true); + test:assertEquals(errtype11 is ListenerError, false); + test:assertEquals(errtype11 is distinct ListenerError, false); + test:assertEquals(errtype11 is DistictListenerError, false); + + test:assertEquals(err31 is distinct error, false); + test:assertEquals(err31 is ErrType, true); + test:assertEquals(err31 is error, true); + test:assertEquals(err31 is ListenerError, false); + test:assertEquals(err31 is distinct ListenerError, false); + test:assertEquals(err31 is DistictListenerError, false); + + test:assertEquals(listerr11 is distinct error, false); + test:assertEquals(listerr11 is ErrType, true); + test:assertEquals(listerr11 is error, true); + test:assertEquals(listerr11 is ListenerError, true); + // https://github.com/ballerina-platform/ballerina-lang/issues/38130 + // test:assertEquals(listerr11 is distinct ListenerError, false); + test:assertEquals(listerr11 is ClientError, false); + test:assertEquals(listerr11 is distinct ClientError, false); + test:assertEquals(listerr11 is DistictListenerError, false); + + test:assertEquals(distlisterr11 is distinct error, false); + test:assertEquals(distlisterr11 is ErrType, true); + test:assertEquals(distlisterr11 is error, true); + test:assertEquals(distlisterr11 is ListenerError, true); + // https://github.com/ballerina-platform/ballerina-lang/issues/38130 + // test:assertEquals(distlisterr11 is distinct ListenerError, false); + test:assertEquals(distlisterr11 is ClientError, false); + test:assertEquals(distlisterr11 is distinct ClientError, false); + test:assertEquals(distlisterr11 is DistictListenerError, false); + + testIsExpressionWithDistinctErrors2(); +} + +function testIsExpressionWithDistinctErrors2() { + distinct error err12 = error("err12"); + distinct error err22 = error("err22"); + ErrType errtype12 = error("errtype12"); + error err32 = error("error2!"); + ListenerError listerr12 = error("listerr12"); + ListenerError listerr22 = error("listerr22"); + ClientError clierr12 = error("clierr12"); + distinct ListenerError distlisterr12 = error("distlisterr12"); + distinct ListenerError distlisterr22 = error("distlisterr22"); + distinct ClientError distclierr12 = error("distclierr12"); + + test:assertEquals(err12 is distinct error, false); + test:assertEquals(err12 is ErrType, true); + test:assertEquals(err12 is error, true); + test:assertEquals(err12 is ListenerError, false); + test:assertEquals(err12 is distinct ListenerError, false); + test:assertEquals(err12 is DistictListenerError, false); + + test:assertEquals(errtype12 is distinct error, false); + test:assertEquals(errtype12 is ErrType, true); + test:assertEquals(errtype12 is error, true); + test:assertEquals(errtype12 is ListenerError, false); + test:assertEquals(errtype12 is distinct ListenerError, false); + test:assertEquals(errtype12 is DistictListenerError, false); + + test:assertEquals(err32 is distinct error, false); + test:assertEquals(err32 is ErrType, true); + test:assertEquals(err32 is error, true); + test:assertEquals(err32 is ListenerError, false); + test:assertEquals(err32 is distinct ListenerError, false); + test:assertEquals(err32 is DistictListenerError, false); + + test:assertEquals(listerr12 is distinct error, false); + test:assertEquals(listerr12 is ErrType, true); + test:assertEquals(listerr12 is error, true); + test:assertEquals(listerr12 is ListenerError, true); + // https://github.com/ballerina-platform/ballerina-lang/issues/38130 + // test:assertEquals(listerr12 is distinct ListenerError, false); + test:assertEquals(listerr12 is ClientError, false); + test:assertEquals(listerr12 is distinct ClientError, false); + test:assertEquals(listerr12 is DistictListenerError, false); + + test:assertEquals(distlisterr12 is distinct error, false); + test:assertEquals(distlisterr12 is ErrType, true); + test:assertEquals(distlisterr12 is error, true); + test:assertEquals(distlisterr12 is ListenerError, true); + // https://github.com/ballerina-platform/ballerina-lang/issues/38130 + // test:assertEquals(distlisterr12 is distinct ListenerError, false); + test:assertEquals(distlisterr12 is ClientError, false); + test:assertEquals(distlisterr12 is distinct ClientError, false); + test:assertEquals(distlisterr12 is DistictListenerError, false); +} From 847b8c208a865269eafbdc517df0748ac9365399 Mon Sep 17 00:00:00 2001 From: Kavindu Gimhan Zoysa Date: Fri, 21 Oct 2022 11:35:30 +0530 Subject: [PATCH 166/450] Disallow field expressions that are refered to a field --- .../semantics/analyzer/SemanticAnalyzer.java | 16 +++++++- .../ballerinalang/test/klass/ClassTest.java | 10 +++++ .../test/object/AnonymousObjectTest.java | 5 +++ .../ballerinalang/test/object/ObjectTest.java | 3 +- .../klass/class-def-field-negative.bal | 40 +++++++++++++++++++ .../resources/test-src/object/anon_object.bal | 20 ++++++++++ .../test-src/object/object_field_negative.bal | 12 ++++++ 7 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 tests/jballerina-unit-test/src/test/resources/test-src/klass/class-def-field-negative.bal diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java index 8dd5856d2d85..43eacfab20db 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java @@ -37,6 +37,7 @@ import org.ballerinalang.util.diagnostic.DiagnosticWarningCode; import org.wso2.ballerinalang.compiler.diagnostic.BLangDiagnosticLog; import org.wso2.ballerinalang.compiler.parser.BLangAnonymousModelHelper; +import org.wso2.ballerinalang.compiler.semantics.model.Scope; import org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv; import org.wso2.ballerinalang.compiler.semantics.model.SymbolTable; import org.wso2.ballerinalang.compiler.semantics.model.TypeVisitor; @@ -737,7 +738,8 @@ public void visit(BLangClassDefinition classDefinition, AnalyzerData data) { private void analyzeClassDefinition(BLangClassDefinition classDefinition, AnalyzerData data) { SymbolEnv currentEnv = data.env; - SymbolEnv classEnv = SymbolEnv.createClassEnv(classDefinition, classDefinition.symbol.scope, currentEnv); + SymbolEnv classEnv = SymbolEnv.createClassEnv(classDefinition, + fieldsRemovedScope(classDefinition.symbol.scope), currentEnv); for (BLangSimpleVariable field : classDefinition.fields) { data.env = classEnv; analyzeNode(field, data); @@ -770,6 +772,18 @@ private void analyzeClassDefinition(BLangClassDefinition classDefinition, Analyz analyzerClassInitMethod(classDefinition, data); } + private Scope fieldsRemovedScope(Scope classScope) { + Scope scope = new Scope(classScope.owner); + for (Name key : classScope.entries.keySet()) { + Scope.ScopeEntry entry = classScope.entries.get(key); + BSymbol fieldSymbol = entry.symbol; + if (!Symbols.isFlagOn(fieldSymbol.flags, Flags.FIELD)) { + scope.entries.put(key, entry); + } + } + return scope; + } + private void analyzerClassInitMethod(BLangClassDefinition classDefinition, AnalyzerData data) { if (classDefinition.initFunction == null) { return; diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/klass/ClassTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/klass/ClassTest.java index 907626052b08..9547c63c9498 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/klass/ClassTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/klass/ClassTest.java @@ -114,6 +114,16 @@ public void classDefNegativeSemanticErrors() { Assert.assertEquals(negative.getErrorCount(), i); } + @Test(description = "Negative tests to check fields that have initialized using another field") + public void classDefFieldsInitializedUsingAnotherField() { + CompileResult negative = BCompileUtil.compile("test-src/klass/class-def-field-negative.bal"); + int i = 0; + BAssertUtil.validateError(negative, i++, "undefined symbol 'a'", 19, 13); + BAssertUtil.validateError(negative, i++, "undefined symbol 'a'", 27, 19); + BAssertUtil.validateError(negative, i++, "undefined symbol 'name'", 36, 20); + Assert.assertEquals(negative.getErrorCount(), i); + } + @Test(description = "Dataflow negative tests for class defn") public void classDefDataflowNegative() { CompileResult negative = BCompileUtil.compile("test-src/klass/class-dataflow-negative.bal"); diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/object/AnonymousObjectTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/object/AnonymousObjectTest.java index 9709b6579a34..df1b3ad176ec 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/object/AnonymousObjectTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/object/AnonymousObjectTest.java @@ -169,6 +169,11 @@ public void testCodeAnalyzerRunningOnAnonymousObjectsForDeprecatedFunctionAnnota BAssertUtil.validateWarning(compileResult, 1, "usage of construct 'Test' is deprecated", 287, 25); } + @Test + public void testLocalVariablesFromFields() { + BRunUtil.invoke(compileResult, "testLocalVariablesFromFields"); + } + @AfterClass public void tearDown() { compileResult = null; diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/object/ObjectTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/object/ObjectTest.java index 840fe2869de6..8aab2abe3a5c 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/object/ObjectTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/object/ObjectTest.java @@ -803,7 +803,8 @@ public void testObjectAttachFuncReturningTuple() { public void testDuplicateFields() { CompileResult result = BCompileUtil.compile("test-src/object/object_field_negative.bal"); BAssertUtil.validateError(result, 0, "redeclared symbol 'error'", 20, 18); - Assert.assertEquals(result.getErrorCount(), 1); + BAssertUtil.validateError(result, 1, "undefined symbol 'x'", 33, 17); + Assert.assertEquals(result.getErrorCount(), 2); } @Test(description = "Test lang lib object type inclusion") diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/klass/class-def-field-negative.bal b/tests/jballerina-unit-test/src/test/resources/test-src/klass/class-def-field-negative.bal new file mode 100644 index 000000000000..7202b039fc72 --- /dev/null +++ b/tests/jballerina-unit-test/src/test/resources/test-src/klass/class-def-field-negative.bal @@ -0,0 +1,40 @@ +// Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +// +// WSO2 Inc. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +class ClassA { + any a = 12; + any b = a; // error + + function init() { + } +} + +class ClassB { + any a = 12; + int b = a; // error + + function init() { + } +} + +class ClassC { + string name = "John Doe"; + int age = 25; + string lname = name; // error + + function init() { + } +} diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/object/anon_object.bal b/tests/jballerina-unit-test/src/test/resources/test-src/object/anon_object.bal index 2dd73e547cdd..778ecd5bfc45 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/object/anon_object.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/object/anon_object.bal @@ -292,3 +292,23 @@ function testCodeAnalyzerRunningOnAnonymousObjectsForDeprecatedFunctionAnnotatio isolated function Test() returns int { return 0; } + +function testLocalVariablesFromFields() { + int a = 10; + + var _ = object { + int x = a; + + function init() { + assertEquality(self.x, 10); + } + }; +} + +isolated function assertEquality(anydata expected, anydata actual) { + if expected == actual { + return; + } + + panic error(string `expected '${expected.toString()}', found '${actual.toString()}'`); +} diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/object/object_field_negative.bal b/tests/jballerina-unit-test/src/test/resources/test-src/object/object_field_negative.bal index 64c5d455eef7..f1a90b8ffb5a 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/object/object_field_negative.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/object/object_field_negative.bal @@ -24,3 +24,15 @@ class Person { self.'error = er; } } + +function testFieldInitializationUsingAnotherField() { + int a = 10; + + var _ = object { + int x = a; + int y = x; // error + + function init() { + } + }; +} From 1b7deda4f7b3684ca028beb479547a40d820790a Mon Sep 17 00:00:00 2001 From: Kavindu Gimhan Zoysa Date: Thu, 3 Nov 2022 12:29:07 +0530 Subject: [PATCH 167/450] Fix review suggestions --- .../semantics/analyzer/SemanticAnalyzer.java | 4 ++-- .../ballerinalang/test/klass/ClassTest.java | 2 +- .../test/object/AnonymousObjectTest.java | 5 ----- .../ballerinalang/test/object/ObjectTest.java | 11 ++++++++-- ...ative.bal => class_def_field_negative.bal} | 0 .../resources/test-src/object/anon_object.bal | 20 ------------------ .../test-src/object/object_constructor.bal | 21 +++++++++++++++++++ 7 files changed, 33 insertions(+), 30 deletions(-) rename tests/jballerina-unit-test/src/test/resources/test-src/klass/{class-def-field-negative.bal => class_def_field_negative.bal} (100%) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java index 43eacfab20db..7cb9bee56f4c 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java @@ -739,7 +739,7 @@ public void visit(BLangClassDefinition classDefinition, AnalyzerData data) { private void analyzeClassDefinition(BLangClassDefinition classDefinition, AnalyzerData data) { SymbolEnv currentEnv = data.env; SymbolEnv classEnv = SymbolEnv.createClassEnv(classDefinition, - fieldsRemovedScope(classDefinition.symbol.scope), currentEnv); + createFieldsRemovedScope(classDefinition.symbol.scope), currentEnv); for (BLangSimpleVariable field : classDefinition.fields) { data.env = classEnv; analyzeNode(field, data); @@ -772,7 +772,7 @@ private void analyzeClassDefinition(BLangClassDefinition classDefinition, Analyz analyzerClassInitMethod(classDefinition, data); } - private Scope fieldsRemovedScope(Scope classScope) { + private Scope createFieldsRemovedScope(Scope classScope) { Scope scope = new Scope(classScope.owner); for (Name key : classScope.entries.keySet()) { Scope.ScopeEntry entry = classScope.entries.get(key); diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/klass/ClassTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/klass/ClassTest.java index 9547c63c9498..5e2298c4606d 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/klass/ClassTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/klass/ClassTest.java @@ -116,7 +116,7 @@ public void classDefNegativeSemanticErrors() { @Test(description = "Negative tests to check fields that have initialized using another field") public void classDefFieldsInitializedUsingAnotherField() { - CompileResult negative = BCompileUtil.compile("test-src/klass/class-def-field-negative.bal"); + CompileResult negative = BCompileUtil.compile("test-src/klass/class_def_field_negative.bal"); int i = 0; BAssertUtil.validateError(negative, i++, "undefined symbol 'a'", 19, 13); BAssertUtil.validateError(negative, i++, "undefined symbol 'a'", 27, 19); diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/object/AnonymousObjectTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/object/AnonymousObjectTest.java index df1b3ad176ec..9709b6579a34 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/object/AnonymousObjectTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/object/AnonymousObjectTest.java @@ -169,11 +169,6 @@ public void testCodeAnalyzerRunningOnAnonymousObjectsForDeprecatedFunctionAnnota BAssertUtil.validateWarning(compileResult, 1, "usage of construct 'Test' is deprecated", 287, 25); } - @Test - public void testLocalVariablesFromFields() { - BRunUtil.invoke(compileResult, "testLocalVariablesFromFields"); - } - @AfterClass public void tearDown() { compileResult = null; diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/object/ObjectTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/object/ObjectTest.java index 8aab2abe3a5c..51a79fe39323 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/object/ObjectTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/object/ObjectTest.java @@ -46,11 +46,14 @@ public class ObjectTest { private CompileResult checkInInitializerResult; private CompileResult checkFunctionReferencesResult; + private CompileResult objectCtrResult; @BeforeClass public void setUp() { checkInInitializerResult = BCompileUtil.compile("test-src/object/object_field_initializer_with_check.bal"); checkFunctionReferencesResult = BCompileUtil.compile("test-src/object/object_function_pointer.bal"); + objectCtrResult = BCompileUtil.compile("test-src/object/object_constructor.bal"); + } @AfterClass @@ -601,13 +604,17 @@ public void testStructPrint() { @Test public void testObjectInit() { - CompileResult compileResult = BCompileUtil.compile("test-src/object/object_constructor.bal"); - Object returns = BRunUtil.invoke(compileResult, "testObjectInit"); + Object returns = BRunUtil.invoke(objectCtrResult, "testObjectInit"); Assert.assertSame(returns.getClass(), Long.class); Assert.assertEquals(returns, 1L); } + @Test + public void testLocalVariablesAssignmentToFields() { + BRunUtil.invoke(objectCtrResult, "testLocalVariablesAssignmentToFields"); + } + @Test public void testObjectPrivateMethods() { CompileResult compileResult = BCompileUtil.compile("test-src/object/object_private_method.bal"); diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/klass/class-def-field-negative.bal b/tests/jballerina-unit-test/src/test/resources/test-src/klass/class_def_field_negative.bal similarity index 100% rename from tests/jballerina-unit-test/src/test/resources/test-src/klass/class-def-field-negative.bal rename to tests/jballerina-unit-test/src/test/resources/test-src/klass/class_def_field_negative.bal diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/object/anon_object.bal b/tests/jballerina-unit-test/src/test/resources/test-src/object/anon_object.bal index 778ecd5bfc45..2dd73e547cdd 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/object/anon_object.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/object/anon_object.bal @@ -292,23 +292,3 @@ function testCodeAnalyzerRunningOnAnonymousObjectsForDeprecatedFunctionAnnotatio isolated function Test() returns int { return 0; } - -function testLocalVariablesFromFields() { - int a = 10; - - var _ = object { - int x = a; - - function init() { - assertEquality(self.x, 10); - } - }; -} - -isolated function assertEquality(anydata expected, anydata actual) { - if expected == actual { - return; - } - - panic error(string `expected '${expected.toString()}', found '${actual.toString()}'`); -} diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/object/object_constructor.bal b/tests/jballerina-unit-test/src/test/resources/test-src/object/object_constructor.bal index aa2fac76e393..c8315ba46a4d 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/object/object_constructor.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/object/object_constructor.bal @@ -12,3 +12,24 @@ public function testObjectInit() returns int { p = new; return a; } + +function testLocalVariablesAssignmentToFields() { + int a = 10; + + var obj = object { + int x = a; + + function init() { + assertEquality(self.x, 10); + } + }; + assertEquality(obj.x, 10); +} + +isolated function assertEquality(anydata expected, anydata actual) { + if expected == actual { + return; + } + + panic error(string `expected '${expected.toString()}', found '${actual.toString()}'`); +} From afda39717570f3a33fa24e23b4111fd29e60948d Mon Sep 17 00:00:00 2001 From: Kavindu Gimhan Zoysa Date: Thu, 3 Nov 2022 13:02:57 +0530 Subject: [PATCH 168/450] Add more tests --- .../org/ballerinalang/test/klass/ClassTest.java | 1 + .../resources/test-src/klass/class_def_test.bal | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/klass/ClassTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/klass/ClassTest.java index 5e2298c4606d..ad3d899ec2ba 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/klass/ClassTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/klass/ClassTest.java @@ -141,6 +141,7 @@ public void classDefTest() { CompileResult result = BCompileUtil.compile("test-src/klass/class_def_test.bal"); Assert.assertEquals(result.getErrorCount(), 0); BRunUtil.invoke(result, "testFooClass"); + BRunUtil.invoke(result, "testGlobalVariablesAssignmentToFields"); } @AfterClass diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/klass/class_def_test.bal b/tests/jballerina-unit-test/src/test/resources/test-src/klass/class_def_test.bal index 390ae9419023..898b03020483 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/klass/class_def_test.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/klass/class_def_test.bal @@ -31,6 +31,22 @@ function testFooClass() { assertEquality(f.s, COMMA); } +int a = 3; + +public class Bar { + int a = 4; + int b = a; + + function init() { + assertEquality(self.b, 3); + } +} + +function testGlobalVariablesAssignmentToFields() { + Bar b = new(); + assertEquality(b.b, 3); +} + const ASSERTION_ERROR_REASON = "AssertionError"; function assertEquality(anydata actual, anydata expected) { From 64bf3379621db828a266e3bf3cdc7aedf321d81f Mon Sep 17 00:00:00 2001 From: Kavindu Gimhan Zoysa Date: Wed, 9 Nov 2022 12:58:57 +0530 Subject: [PATCH 169/450] Change the test cases --- .../semantics/analyzer/SemanticAnalyzer.java | 17 +++++---- .../type_cast_in_obj_field_config1.json | 10 ++--- .../type_cast_in_obj_field_config2.json | 6 +-- .../source/type_cast_in_obj_fields.bal | 8 ++-- .../object/ObjectConstructorTest.java | 15 +++++++- .../ballerinalang/test/klass/ClassTest.java | 23 ++++++++---- .../ballerinalang/test/object/ObjectTest.java | 14 ++----- .../object/object_constructor_expression.bal | 27 ++++++++++++++ .../object_constructor_fields_negative.bal | 37 +++++++++++++++++++ .../klass/class_def_field_negative.bal | 9 +++++ .../test-src/klass/class_def_test.bal | 8 ++-- .../test-src/object/object_constructor.bal | 21 ----------- .../test-src/object/object_field_negative.bal | 12 ------ 13 files changed, 131 insertions(+), 76 deletions(-) create mode 100644 tests/jballerina-unit-test/src/test/resources/test-src/expressions/object/object_constructor_fields_negative.bal diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java index 7cb9bee56f4c..18cde3248ecb 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java @@ -739,7 +739,7 @@ public void visit(BLangClassDefinition classDefinition, AnalyzerData data) { private void analyzeClassDefinition(BLangClassDefinition classDefinition, AnalyzerData data) { SymbolEnv currentEnv = data.env; SymbolEnv classEnv = SymbolEnv.createClassEnv(classDefinition, - createFieldsRemovedScope(classDefinition.symbol.scope), currentEnv); + createClassScopeWithoutFields(classDefinition.symbol.scope), currentEnv); for (BLangSimpleVariable field : classDefinition.fields) { data.env = classEnv; analyzeNode(field, data); @@ -772,14 +772,15 @@ private void analyzeClassDefinition(BLangClassDefinition classDefinition, Analyz analyzerClassInitMethod(classDefinition, data); } - private Scope createFieldsRemovedScope(Scope classScope) { + private Scope createClassScopeWithoutFields(Scope classScope) { Scope scope = new Scope(classScope.owner); - for (Name key : classScope.entries.keySet()) { - Scope.ScopeEntry entry = classScope.entries.get(key); - BSymbol fieldSymbol = entry.symbol; - if (!Symbols.isFlagOn(fieldSymbol.flags, Flags.FIELD)) { - scope.entries.put(key, entry); - } + Map classScopeEntries = classScope.entries; + Map scopeEntries = scope.entries; + for (Name key : classScopeEntries.keySet()) { + Scope.ScopeEntry entry = classScopeEntries.get(key); + if (!Symbols.isFlagOn(entry.symbol.flags, Flags.FIELD)) { + scopeEntries.put(key, entry); + } } return scope; } diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/config/type_cast_in_obj_field_config1.json b/language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/config/type_cast_in_obj_field_config1.json index a0f8bd0ffc04..863a6e69bb54 100644 --- a/language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/config/type_cast_in_obj_field_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/config/type_cast_in_obj_field_config1.json @@ -1,6 +1,6 @@ { "position": { - "line": 2, + "line": 4, "character": 12 }, "source": "type_cast_in_obj_fields.bal", @@ -12,11 +12,11 @@ { "range": { "start": { - "line": 2, + "line": 4, "character": 12 }, "end": { - "line": 2, + "line": 4, "character": 12 } }, @@ -32,11 +32,11 @@ { "range": { "start": { - "line": 2, + "line": 4, "character": 4 }, "end": { - "line": 2, + "line": 4, "character": 7 } }, diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/config/type_cast_in_obj_field_config2.json b/language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/config/type_cast_in_obj_field_config2.json index 89128496e481..4d6bd3d7611b 100644 --- a/language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/config/type_cast_in_obj_field_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/config/type_cast_in_obj_field_config2.json @@ -1,6 +1,6 @@ { "position": { - "line": 7, + "line": 6, "character": 15 }, "source": "type_cast_in_obj_fields.bal", @@ -12,11 +12,11 @@ { "range": { "start": { - "line": 7, + "line": 6, "character": 20 }, "end": { - "line": 7, + "line": 6, "character": 20 } }, diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/source/type_cast_in_obj_fields.bal b/language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/source/type_cast_in_obj_fields.bal index c38af05d4278..73ae00110232 100644 --- a/language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/source/type_cast_in_obj_fields.bal +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/source/type_cast_in_obj_fields.bal @@ -1,10 +1,8 @@ +float f1 = 10.2; +decimal d1 = 10.2; + class TypeCastSuggestion { - int a = 10.1; - - float f1 = 10.2; - decimal d1 = 10.2; float f2 = f1 / d1; - } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/object/ObjectConstructorTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/object/ObjectConstructorTest.java index 42846a5be0cf..98f460f27f4e 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/object/ObjectConstructorTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/object/ObjectConstructorTest.java @@ -17,6 +17,7 @@ */ package org.ballerinalang.test.expressions.object; +import org.ballerinalang.test.BAssertUtil; import org.ballerinalang.test.BCompileUtil; import org.ballerinalang.test.BRunUtil; import org.ballerinalang.test.CompileResult; @@ -57,7 +58,9 @@ public Object[][] objectCtorTestFunctionList() { {"testObjectConstructorWithDistinctTypeReferenceVar"}, {"testObjectConstructorWithDefiniteTypeAndWithoutReference"}, {"testObjectConstructorExprWithReadOnlyCET"}, - {"testMultipleVarAssignments"} + {"testMultipleVarAssignments"}, + {"testLocalVariablesAsFieldDefaults"}, + {"testModuleLevelObjectCtrWithModuleLevelVariableAsFieldDefaults"} }; } @@ -236,6 +239,16 @@ public void testMultiLevelClosures(String funcName) { BRunUtil.invoke(multiLevelClosures, funcName); } + @Test + public void testInvalidFieldsInObjectCtr() { + CompileResult result = + BCompileUtil.compile("test-src/expressions/object/object_constructor_fields_negative.bal"); + int i = 0; + BAssertUtil.validateError(result, i++, "undefined symbol 'x'", 22, 17); + BAssertUtil.validateError(result, i++, "undefined symbol 'x'", 33, 13); + Assert.assertEquals(result.getErrorCount(), i); + } + @AfterClass public void tearDown() { compiledConstructedObjects = null; diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/klass/ClassTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/klass/ClassTest.java index ad3d899ec2ba..d85ab1ffab9c 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/klass/ClassTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/klass/ClassTest.java @@ -24,6 +24,7 @@ import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /** @@ -34,11 +35,13 @@ public class ClassTest { private CompileResult compileResult; private CompileResult distinctCompUnit; + private CompileResult classDefCompileResult; @BeforeClass public void setup() { compileResult = BCompileUtil.compile("test-src/klass/simple_class.bal"); distinctCompUnit = BCompileUtil.compile("test-src/klass/distinct-class-def.bal"); + classDefCompileResult = BCompileUtil.compile("test-src/klass/class_def_test.bal"); } @Test @@ -114,13 +117,14 @@ public void classDefNegativeSemanticErrors() { Assert.assertEquals(negative.getErrorCount(), i); } - @Test(description = "Negative tests to check fields that have initialized using another field") + @Test(description = "Negative tests to check fields that have been initialized using other fields") public void classDefFieldsInitializedUsingAnotherField() { CompileResult negative = BCompileUtil.compile("test-src/klass/class_def_field_negative.bal"); int i = 0; BAssertUtil.validateError(negative, i++, "undefined symbol 'a'", 19, 13); BAssertUtil.validateError(negative, i++, "undefined symbol 'a'", 27, 19); BAssertUtil.validateError(negative, i++, "undefined symbol 'name'", 36, 20); + BAssertUtil.validateError(negative, i++, "undefined symbol 'name'", 44, 20); Assert.assertEquals(negative.getErrorCount(), i); } @@ -136,12 +140,17 @@ public void classDefDataflowNegative() { Assert.assertEquals(negative.getErrorCount(), i); } - @Test(description = "A test case covering ballerina-platform/ballerina-lang#36172") - public void classDefTest() { - CompileResult result = BCompileUtil.compile("test-src/klass/class_def_test.bal"); - Assert.assertEquals(result.getErrorCount(), 0); - BRunUtil.invoke(result, "testFooClass"); - BRunUtil.invoke(result, "testGlobalVariablesAssignmentToFields"); + @Test(dataProvider = "classDefTestFunctions") + public void testClassDef(String functionName) { + BRunUtil.invoke(classDefCompileResult, functionName); + } + + @DataProvider(name = "classDefTestFunctions") + public Object[] classDefTestFunctions() { + return new String[]{ + "testUnionTypeInInitParameter", + "testModuleLevelVariableAsFieldDefault" + }; } @AfterClass diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/object/ObjectTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/object/ObjectTest.java index 51a79fe39323..840fe2869de6 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/object/ObjectTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/object/ObjectTest.java @@ -46,14 +46,11 @@ public class ObjectTest { private CompileResult checkInInitializerResult; private CompileResult checkFunctionReferencesResult; - private CompileResult objectCtrResult; @BeforeClass public void setUp() { checkInInitializerResult = BCompileUtil.compile("test-src/object/object_field_initializer_with_check.bal"); checkFunctionReferencesResult = BCompileUtil.compile("test-src/object/object_function_pointer.bal"); - objectCtrResult = BCompileUtil.compile("test-src/object/object_constructor.bal"); - } @AfterClass @@ -604,17 +601,13 @@ public void testStructPrint() { @Test public void testObjectInit() { - Object returns = BRunUtil.invoke(objectCtrResult, "testObjectInit"); + CompileResult compileResult = BCompileUtil.compile("test-src/object/object_constructor.bal"); + Object returns = BRunUtil.invoke(compileResult, "testObjectInit"); Assert.assertSame(returns.getClass(), Long.class); Assert.assertEquals(returns, 1L); } - @Test - public void testLocalVariablesAssignmentToFields() { - BRunUtil.invoke(objectCtrResult, "testLocalVariablesAssignmentToFields"); - } - @Test public void testObjectPrivateMethods() { CompileResult compileResult = BCompileUtil.compile("test-src/object/object_private_method.bal"); @@ -810,8 +803,7 @@ public void testObjectAttachFuncReturningTuple() { public void testDuplicateFields() { CompileResult result = BCompileUtil.compile("test-src/object/object_field_negative.bal"); BAssertUtil.validateError(result, 0, "redeclared symbol 'error'", 20, 18); - BAssertUtil.validateError(result, 1, "undefined symbol 'x'", 33, 17); - Assert.assertEquals(result.getErrorCount(), 2); + Assert.assertEquals(result.getErrorCount(), 1); } @Test(description = "Test lang lib object type inclusion") diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/expressions/object/object_constructor_expression.bal b/tests/jballerina-unit-test/src/test/resources/test-src/expressions/object/object_constructor_expression.bal index 423e18e2cb7f..9b9d0efa5056 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/expressions/object/object_constructor_expression.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/expressions/object/object_constructor_expression.bal @@ -374,6 +374,33 @@ function testMultipleVarAssignments() { assertTrue(obj3.foo()); } +function testLocalVariablesAsFieldDefaults() { + int a = 10; + + var obj = object { + int x = a; + + function init() { + } + }; + assertValueEquality(obj.x, 10); +} + +int b = 11; + +var moduleObj = object { + int x = b; + + function init() { + } +}; + +function testModuleLevelObjectCtrWithModuleLevelVariableAsFieldDefaults() { + assertValueEquality(moduleObj.x, 11); + b = 12; + assertValueEquality(moduleObj.x, 11); +} + // assertion helpers const ASSERTION_ERROR_REASON = "AssertionError"; diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/expressions/object/object_constructor_fields_negative.bal b/tests/jballerina-unit-test/src/test/resources/test-src/expressions/object/object_constructor_fields_negative.bal new file mode 100644 index 000000000000..3fcc920b5639 --- /dev/null +++ b/tests/jballerina-unit-test/src/test/resources/test-src/expressions/object/object_constructor_fields_negative.bal @@ -0,0 +1,37 @@ +// Copyright (c) 2022 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +// +// WSO2 Inc. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +function testFieldInitializationUsingAnotherField() { + int a = 10; + + var _ = object { + int x = a; + int y = x; // error + + function init() { + } + }; +} + +int b = 11; + +var _ = object { + int x = b; + int y = x; // error + + function init() { + } +}; diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/klass/class_def_field_negative.bal b/tests/jballerina-unit-test/src/test/resources/test-src/klass/class_def_field_negative.bal index 7202b039fc72..50cb2d423bcd 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/klass/class_def_field_negative.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/klass/class_def_field_negative.bal @@ -38,3 +38,12 @@ class ClassC { function init() { } } + +class ClassD { + int age = 25; + string lname = name; // error + string name = "John Doe"; + + function init() { + } +} diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/klass/class_def_test.bal b/tests/jballerina-unit-test/src/test/resources/test-src/klass/class_def_test.bal index 898b03020483..5b3cfd995523 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/klass/class_def_test.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/klass/class_def_test.bal @@ -26,7 +26,7 @@ public class Foo { } } -function testFooClass() { +function testUnionTypeInInitParameter() { Foo f = new; assertEquality(f.s, COMMA); } @@ -38,13 +38,15 @@ public class Bar { int b = a; function init() { - assertEquality(self.b, 3); } } -function testGlobalVariablesAssignmentToFields() { +function testModuleLevelVariableAsFieldDefault() { Bar b = new(); + a = 6; assertEquality(b.b, 3); + Bar b2 = new; + assertEquality(b2.b, 6); } const ASSERTION_ERROR_REASON = "AssertionError"; diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/object/object_constructor.bal b/tests/jballerina-unit-test/src/test/resources/test-src/object/object_constructor.bal index c8315ba46a4d..aa2fac76e393 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/object/object_constructor.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/object/object_constructor.bal @@ -12,24 +12,3 @@ public function testObjectInit() returns int { p = new; return a; } - -function testLocalVariablesAssignmentToFields() { - int a = 10; - - var obj = object { - int x = a; - - function init() { - assertEquality(self.x, 10); - } - }; - assertEquality(obj.x, 10); -} - -isolated function assertEquality(anydata expected, anydata actual) { - if expected == actual { - return; - } - - panic error(string `expected '${expected.toString()}', found '${actual.toString()}'`); -} diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/object/object_field_negative.bal b/tests/jballerina-unit-test/src/test/resources/test-src/object/object_field_negative.bal index f1a90b8ffb5a..64c5d455eef7 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/object/object_field_negative.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/object/object_field_negative.bal @@ -24,15 +24,3 @@ class Person { self.'error = er; } } - -function testFieldInitializationUsingAnotherField() { - int a = 10; - - var _ = object { - int x = a; - int y = x; // error - - function init() { - } - }; -} From 7485976f98839ea0755ac9e8809f67a8167daab5 Mon Sep 17 00:00:00 2001 From: Nadeeshan96 Date: Mon, 5 Dec 2022 13:23:23 +0530 Subject: [PATCH 170/450] Change frame class name --- .../ballerinalang/compiler/bir/codegen/JvmConstants.java | 1 + .../compiler/bir/codegen/methodgen/MethodGenUtils.java | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java index 8dcd8ada020a..579ce703386f 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java @@ -335,6 +335,7 @@ public class JvmConstants { public static final String FILE_NAME_PERIOD_SEPERATOR = "$$$"; public static final String VALUE_CLASS_PREFIX = "$value$"; public static final String TYPEDESC_CLASS_PREFIX = "$typedesc$"; + public static final String FRAME_CLASS_PREFIX = "$frame$"; public static final String BALLERINA = "ballerina"; public static final String ENCODED_DOT_CHARACTER = "$0046"; public static final PackageID DEFAULT = new PackageID(Names.ANON_ORG, new Name(ENCODED_DOT_CHARACTER), diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/MethodGenUtils.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/MethodGenUtils.java index a6a0458c38de..0d174cb74081 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/MethodGenUtils.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/MethodGenUtils.java @@ -33,6 +33,7 @@ import static org.objectweb.asm.Opcodes.GETSTATIC; import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.ENCODED_DOT_CHARACTER; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.FRAME_CLASS_PREFIX; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.SCHEDULER; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.SCHEDULE_FUNCTION_METHOD; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_STRAND_METADATA; @@ -114,12 +115,12 @@ private MethodGenUtils() { } static String getFrameClassName(String pkgName, String funcName, BType attachedType) { - String frameClassName = pkgName; + String frameClassName = pkgName + FRAME_CLASS_PREFIX; if (isValidType(attachedType)) { frameClassName += JvmCodeGenUtil.toNameString(attachedType) + "_"; } - return frameClassName + funcName + "Frame"; + return frameClassName + funcName; } private static boolean isValidType(BType attachedType) { From ddb08e07385a8e8d8fcc79a9e23ef14966c3930e Mon Sep 17 00:00:00 2001 From: Sasindu Alahakoon Date: Mon, 5 Dec 2022 14:53:09 +0530 Subject: [PATCH 171/450] Remv IDL & update constructor in CompilationOption --- .../java/io/ballerina/projects/CompilationOptions.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/CompilationOptions.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/CompilationOptions.java index e1060c94edca..766d36a29d28 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/CompilationOptions.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/CompilationOptions.java @@ -42,7 +42,7 @@ public class CompilationOptions { CompilationOptions(Boolean offlineBuild, Boolean observabilityIncluded, Boolean dumpBir, Boolean dumpBirFile, String cloud, Boolean listConflictedClasses, Boolean sticky, Boolean dumpGraph, Boolean dumpRawGraphs, Boolean withCodeGenerators, - Boolean configSchemaGen, Boolean exportOpenAPI, + Boolean withCodeModifiers, Boolean configSchemaGen, Boolean exportOpenAPI, Boolean exportComponentModel, Boolean enableCache) { this.offlineBuild = offlineBuild; this.observabilityIncluded = observabilityIncluded; @@ -324,11 +324,6 @@ CompilationOptionsBuilder setExportComponentModel(Boolean value) { return this; } - CompilationOptionsBuilder setExportComponentModel(Boolean value) { - exportComponentModel = value; - return this; - } - public CompilationOptionsBuilder setEnableCache(Boolean value) { enableCache = value; return this; From a73c78a2f2b94fbac6921c93839a17d06730ebe1 Mon Sep 17 00:00:00 2001 From: Nadeeshan96 Date: Mon, 5 Dec 2022 15:35:29 +0530 Subject: [PATCH 172/450] Remove unused classes --- .../toml/parser/LockFileProcessor.java | 86 ----- .../compiler/BinaryFileWriter.java | 297 ------------------ .../ByteArrayBasedCompiledPackageEntry.java | 56 ---- .../compiler/DependencyTree.java | 114 ------- .../compiler/InMemoryCompiledPackage.java | 103 ------ .../compiler/LockFileConstants.java | 38 --- .../compiler/LockFileWriter.java | 200 ------------ .../PathBasedCompiledPackageEntry.java | 58 ---- .../ballerinalang/compiler/TypeCreator.java | 46 --- .../compiler/TypeSignatureReader.java | 221 ------------- 10 files changed, 1219 deletions(-) delete mode 100644 compiler/ballerina-lang/src/main/java/org/ballerinalang/toml/parser/LockFileProcessor.java delete mode 100644 compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/BinaryFileWriter.java delete mode 100644 compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/ByteArrayBasedCompiledPackageEntry.java delete mode 100644 compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/DependencyTree.java delete mode 100644 compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/InMemoryCompiledPackage.java delete mode 100644 compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/LockFileConstants.java delete mode 100644 compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/LockFileWriter.java delete mode 100644 compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/PathBasedCompiledPackageEntry.java delete mode 100644 compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/TypeCreator.java delete mode 100644 compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/TypeSignatureReader.java diff --git a/compiler/ballerina-lang/src/main/java/org/ballerinalang/toml/parser/LockFileProcessor.java b/compiler/ballerina-lang/src/main/java/org/ballerinalang/toml/parser/LockFileProcessor.java deleted file mode 100644 index 234afecc8d8b..000000000000 --- a/compiler/ballerina-lang/src/main/java/org/ballerinalang/toml/parser/LockFileProcessor.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.ballerinalang.toml.parser; - -import com.moandjiezana.toml.Toml; -import org.ballerinalang.toml.model.LockFile; -import org.wso2.ballerinalang.compiler.SourceDirectory; -import org.wso2.ballerinalang.compiler.util.CompilerContext; - -import java.io.InputStream; -import java.io.PrintStream; - -/** - * LockFile Processor which processes the toml file parsed and populate a {@link LockFile}. - * - * @since 0.973.1 - */ -public class LockFileProcessor { - private static final PrintStream err = System.err; - private static final CompilerContext.Key LOCK_FILE_PROC_KEY = new CompilerContext.Key<>(); - private final LockFile lockFile; - - private LockFileProcessor(LockFile lockFile) { - this.lockFile = lockFile; - } - - /** - * Get an instance of the LockFileProcessor. - * - * @param context compiler context - * @param lockEnabled if lock is enabled or not - * @return instance of LockFileProcessor - */ - public static LockFileProcessor getInstance(CompilerContext context, boolean lockEnabled) { - if (!lockEnabled) { - return new LockFileProcessor(new LockFile()); - } - LockFileProcessor lockFileProcessor = context.get(LOCK_FILE_PROC_KEY); - if (lockFileProcessor == null) { - SourceDirectory sourceDirectory = context.get(SourceDirectory.class); - LockFile lockFile = LockFileProcessor.parseTomlContentAsStream(sourceDirectory.getLockFileContent()); - LockFileProcessor instance = new LockFileProcessor(lockFile); - context.put(LOCK_FILE_PROC_KEY, instance); - return instance; - } - return lockFileProcessor; - } - - /** - * Get the char stream from inputstream. - * - * @param inputStream inputstream of the toml file content - * @return lockFile object - */ - public static LockFile parseTomlContentAsStream(InputStream inputStream) { - try { - Toml lockToml = new Toml().read(inputStream); - return lockToml.to(LockFile.class); - } catch (Exception e) { - err.println("Ballerina.lock file is corrupted. this build will ignore using the lock file in resolving " + - "dependencies. a valid lock file will be generated if '--skip-lock' is set to false when " + - "using build command. '--skip-lock' flag is false by default."); - } - - return null; - } - - public LockFile getLockFile() { - return this.lockFile; - } -} diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/BinaryFileWriter.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/BinaryFileWriter.java deleted file mode 100644 index 9d6ffe1d201b..000000000000 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/BinaryFileWriter.java +++ /dev/null @@ -1,297 +0,0 @@ -/* - * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.wso2.ballerinalang.compiler; - -import org.apache.commons.lang3.StringUtils; -import org.ballerinalang.compiler.BLangCompilerException; -import org.ballerinalang.compiler.CompilerPhase; -import org.ballerinalang.model.elements.PackageID; -import org.ballerinalang.repository.CompiledPackage; -import org.ballerinalang.repository.CompilerOutputEntry; -import org.ballerinalang.repository.CompilerOutputEntry.Kind; -import org.wso2.ballerinalang.compiler.semantics.model.symbols.BPackageSymbol; -import org.wso2.ballerinalang.compiler.tree.BLangPackage; -import org.wso2.ballerinalang.compiler.util.CompilerContext; -import org.wso2.ballerinalang.compiler.util.CompilerOptions; -import org.wso2.ballerinalang.compiler.util.ProjectDirConstants; -import org.wso2.ballerinalang.programfile.CompiledBinaryFile; -import org.wso2.ballerinalang.programfile.CompiledBinaryFile.BIRPackageFile; -import org.wso2.ballerinalang.programfile.PackageFileWriter; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -import static org.wso2.ballerinalang.compiler.util.ProjectDirConstants.BLANG_COMPILED_JAR_EXT; -import static org.wso2.ballerinalang.compiler.util.ProjectDirConstants.BLANG_COMPILED_PKG_BIR_EXT; -import static org.wso2.ballerinalang.compiler.util.ProjectDirConstants.BLANG_COMPILED_PKG_EXT; -import static org.wso2.ballerinalang.compiler.util.ProjectDirConstants.BLANG_COMPILED_PROG_EXT; -import static org.wso2.ballerinalang.compiler.util.ProjectDirConstants.BLANG_SOURCE_EXT; -import static org.wso2.ballerinalang.compiler.util.ProjectDirConstants.DOT_BALLERINA_DIR_NAME; -import static org.wso2.ballerinalang.compiler.util.ProjectDirConstants.DOT_BALLERINA_REPO_DIR_NAME; - -/** - * Write a compiled executable program(.balx) or a compiled package(bala.) to a file. - * - * @since 0.965.0 - */ -public class BinaryFileWriter { - private static final CompilerContext.Key BINARY_FILE_WRITER_KEY = - new CompilerContext.Key<>(); - private static final String JAVA_IO_TMP_DIR = "java.io.tmpdir"; - private static PrintStream outStream = System.out; - - private final SourceDirectory sourceDirectory; - private final CompilerPhase compilerPhase; - - public static BinaryFileWriter getInstance(CompilerContext context) { - BinaryFileWriter binaryFileWriter = context.get(BINARY_FILE_WRITER_KEY); - if (binaryFileWriter == null) { - binaryFileWriter = new BinaryFileWriter(context); - } - return binaryFileWriter; - } - - private BinaryFileWriter(CompilerContext context) { - context.put(BINARY_FILE_WRITER_KEY, this); - this.sourceDirectory = context.get(SourceDirectory.class); - if (this.sourceDirectory == null) { - throw new IllegalArgumentException("source directory has not been initialized"); - } - this.compilerPhase = CompilerOptions.getInstance(context).getCompilerPhase(); - } - - public void write(BLangPackage packageNode) { - if (packageNode.symbol.entryPointExists) { - writeExecutableBinary(packageNode); - } - writeLibraryPackage(packageNode); - } - - public void write(BLangPackage packageNode, String fileName) { - if (this.compilerPhase == CompilerPhase.BIR_GEN) { - if (packageNode.packageID.isUnnamed) { - writeBIR(packageNode, fileName); - } else { - writePackageBIR(packageNode); - } - } - // TODO Reuse binary content in PackageFile when writing the program file.. - if (packageNode.symbol.entryPointExists) { - outStream.println("Generating executable"); - writeExecutableBinary(packageNode, fileName); - } - writeLibraryPackage(packageNode); - } - - private void writeBIR(BLangPackage packageNode, String fileName) { - if (packageNode.symbol.birPackageFile != null) { - String birFilename = cleanupExecFileName(fileName, BLANG_COMPILED_PKG_EXT); - Path destDirPath = createAndGetTempDir(packageNode); // bir will be written to a temp directory. - try { - addFileBirContent(cleanupExecFileName(fileName, BLANG_COMPILED_PKG_BIR_EXT), - packageNode.symbol.birPackageFile, packageNode.symbol.compiledPackage); - this.sourceDirectory.saveCompiledPackage(packageNode.symbol.compiledPackage, destDirPath, birFilename); - } catch (IOException e) { - String msg = "error writing the compiled module(bir) of '" + - packageNode.packageID + "' to '" + destDirPath + "': " + e.getMessage(); - throw new BLangCompilerException(msg, e); - } - } - } - - private void writePackageBIR(BLangPackage packageNode) { - if (packageNode.symbol.birPackageFile != null) { - String birFilename = cleanupExecFileName(packageNode.packageID.name.value, BLANG_COMPILED_PKG_EXT); - Path destDirPath = getPackageDirPathInProjectRepo(packageNode.packageID); - try { - addPackageBirContent(packageNode.packageID, - packageNode.symbol.birPackageFile, packageNode.symbol.compiledPackage); - this.sourceDirectory.saveCompiledPackage(packageNode.symbol.compiledPackage, destDirPath, birFilename); - } catch (IOException e) { - String msg = "error writing the compiled module(bir) of '" + - packageNode.packageID + "' to '" + destDirPath + "': " + e.getMessage(); - throw new BLangCompilerException(msg, e); - } - } - } - - private void writeExecutableBinary(BLangPackage packageNode) { - String fileName = getOutputFileName(packageNode, BLANG_COMPILED_PROG_EXT); - writeExecutableBinary(packageNode, fileName); - } - - private void writeExecutableBinary(BLangPackage packageNode, String fileName) { - - if (this.compilerPhase == CompilerPhase.BIR_GEN && packageNode.jarBinaryContent != null) { - String jarFilename = cleanupExecFileName(fileName, BLANG_COMPILED_JAR_EXT); - this.sourceDirectory.saveCompiledProgram(new ByteArrayInputStream(packageNode.jarBinaryContent), - jarFilename); - return; - } - String birFilename = cleanupExecFileName(fileName, BLANG_COMPILED_PKG_EXT); - Path destDirPath = createAndGetTempDir(packageNode); // bir will be written to a temp directory. - try { - addFileBirContent(cleanupExecFileName(fileName, BLANG_COMPILED_PKG_BIR_EXT), - packageNode.symbol.birPackageFile, packageNode.symbol.compiledPackage); - this.sourceDirectory.saveCompiledPackage(packageNode.symbol.compiledPackage, destDirPath, birFilename); - } catch (IOException e) { - String msg = "error writing the compiled module(bir) of '" + - packageNode.packageID + "' to '" + destDirPath + "': " + e.getMessage(); - throw new BLangCompilerException(msg, e); - } - } - - private void writeLibraryPackage(BLangPackage packageNode) { - String fileName = getOutputFileName(packageNode, BLANG_COMPILED_PKG_EXT); - writeLibraryPackage(packageNode.symbol, fileName); - } - - public void writeLibraryPackage(BPackageSymbol symbol, String compiledPackageFileName) { - PackageID packageID = symbol.pkgID; - - // Filter out packages which loaded from BALAs - CompiledPackage compiledPackage = symbol.compiledPackage; - if (compiledPackage.getKind() == CompiledPackage.Kind.FROM_BINARY) { - return; - } - - // Filter out unnamed packages - if (packageID.isUnnamed) { - return; - } - - if (compiledPackageFileName == null || compiledPackageFileName.isEmpty()) { - throw new IllegalArgumentException("invalid target file name"); - } - - if (!compiledPackageFileName.endsWith(BLANG_COMPILED_PKG_EXT)) { - compiledPackageFileName += BLANG_COMPILED_PKG_EXT; - } - - Path destDirPath = getPackageDirPathInProjectRepo(packageID); - try { - if (symbol.birPackageFile != null) { - addPackageBirContent(packageID, symbol.birPackageFile, compiledPackage); - } - if (symbol.packageFile != null) { - addPackageBinaryContent(packageID, symbol.packageFile, compiledPackage); - } - this.sourceDirectory.saveCompiledPackage(compiledPackage, destDirPath, compiledPackageFileName); - } catch (IOException e) { - String msg = "error writing the compiled module(bala) of '" + - packageID + "' to '" + destDirPath + "': " + e.getMessage(); - throw new BLangCompilerException(msg, e); - } - } - - // private methods - - private Path createAndGetTempDir(BLangPackage packageNode) { - Path tempDir = Paths.get(System.getProperty(JAVA_IO_TMP_DIR)) - .resolve(packageNode.packageID.orgName.value) - .resolve(packageNode.packageID.version.value) - .resolve(packageNode.packageID.name.value); - - if (!Files.exists(tempDir)) { - createDirectory(tempDir); - } - - return tempDir; - } - - private void createDirectory(Path tempDir) { - try { - Files.createDirectories(tempDir); - } catch (IOException e) { - throw new BLangCompilerException("failed to create directory '" + tempDir.toString() + "'", e); - } - } - - private String getOutputFileName(BLangPackage packageNode, String suffix) { - if (packageNode.packageID.isUnnamed) { - String sourceFileName = packageNode.packageID.sourceFileName.value; - if (sourceFileName.endsWith(BLANG_SOURCE_EXT)) { - sourceFileName = StringUtils.removeEnd(sourceFileName, - BLANG_SOURCE_EXT).concat(BLANG_COMPILED_PROG_EXT); - } - return sourceFileName; - } - - return packageNode.packageID.name.value + suffix; - } - - private Path getPackageDirPathInProjectRepo(PackageID pkgId) { - Path relativePkgPath = Paths.get(DOT_BALLERINA_DIR_NAME, DOT_BALLERINA_REPO_DIR_NAME, - pkgId.getOrgName().getValue(), pkgId.getName().getValue(), pkgId.getPackageVersion().getValue()); - return this.sourceDirectory.getPath().resolve(relativePkgPath); - } - - private void addPackageBinaryContent(PackageID pkgId, - CompiledBinaryFile.PackageFile packageFile, - CompiledPackage compiledPackage) throws IOException { - byte[] pkgBinaryContent = PackageFileWriter.writePackage(packageFile); - ByteArrayBasedCompiledPackageEntry pkgBinaryEntry = new ByteArrayBasedCompiledPackageEntry( - pkgBinaryContent, getPackageBinaryName(pkgId), CompilerOutputEntry.Kind.OBJ); - compiledPackage.setPackageBinaryEntry(pkgBinaryEntry); - } - - private void addPackageBirContent(PackageID pkgId, BIRPackageFile birPackageFile, - CompiledPackage compiledPackage) throws IOException { - byte[] pkgBirBinaryContent = PackageFileWriter.writePackage(birPackageFile); - ByteArrayBasedCompiledPackageEntry pkgBinaryEntry = new ByteArrayBasedCompiledPackageEntry( - pkgBirBinaryContent, getPackageBirName(pkgId), Kind.BIR); - compiledPackage.setPackageBirEntry(pkgBinaryEntry); - } - - private void addFileBirContent(String fileName, BIRPackageFile birPackageFile, - CompiledPackage compiledPackage) throws IOException { - byte[] pkgBirBinaryContent = PackageFileWriter.writePackage(birPackageFile); - ByteArrayBasedCompiledPackageEntry pkgBinaryEntry = new ByteArrayBasedCompiledPackageEntry( - pkgBirBinaryContent, fileName, Kind.BIR); - compiledPackage.setPackageBirEntry(pkgBinaryEntry); - } - - private String getPackageBinaryName(PackageID packageID) { - return packageID.getName().value + ProjectDirConstants.BLANG_COMPILED_PKG_BINARY_EXT; - } - - private String getPackageBirName(PackageID packageID) { - return packageID.getName().value + BLANG_COMPILED_PKG_BIR_EXT; - } - - private String cleanupExecFileName(String fileName, String extension) { - String updatedFileName = fileName; - if (updatedFileName == null || updatedFileName.isEmpty()) { - throw new IllegalArgumentException("invalid target file name"); - } - - if (updatedFileName.endsWith(BLANG_SOURCE_EXT)) { - updatedFileName = updatedFileName.substring(0, - updatedFileName.length() - BLANG_SOURCE_EXT.length()); - } - - if (!updatedFileName.endsWith(extension)) { - updatedFileName += extension; - } - return updatedFileName; - } -} diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/ByteArrayBasedCompiledPackageEntry.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/ByteArrayBasedCompiledPackageEntry.java deleted file mode 100644 index b95d5a69f54a..000000000000 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/ByteArrayBasedCompiledPackageEntry.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.wso2.ballerinalang.compiler; - -import org.ballerinalang.repository.CompilerOutputEntry; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; - -/** - * {@code PathBasedCompiledPackageEntry} represents compiled package entry. - * - * @since 0.970.0 - */ -public class ByteArrayBasedCompiledPackageEntry implements CompilerOutputEntry { - - private byte[] content; - private String entryName; - private Kind kind; - - public ByteArrayBasedCompiledPackageEntry(byte[] content, String entryName, Kind kind) { - this.content = content; - this.entryName = entryName; - this.kind = kind; - } - - @Override - public String getEntryName() { - return this.entryName; - } - - @Override - public Kind getEntryKind() { - return this.kind; - } - - @Override - public InputStream getInputStream() { - return new ByteArrayInputStream(content); - } -} diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/DependencyTree.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/DependencyTree.java deleted file mode 100644 index be2d08b7c69e..000000000000 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/DependencyTree.java +++ /dev/null @@ -1,114 +0,0 @@ -package org.wso2.ballerinalang.compiler; - -import org.wso2.ballerinalang.compiler.semantics.model.symbols.BPackageSymbol; -import org.wso2.ballerinalang.compiler.tree.BLangPackage; -import org.wso2.ballerinalang.compiler.util.CompilerContext; - -import java.io.PrintStream; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -/** - * Class to render the dependency tree. - */ -public class DependencyTree { - private static final CompilerContext.Key DEPENDENCY_TREE_KEY = - new CompilerContext.Key<>(); - private PrintStream outStream = System.out; - - private DependencyTree(CompilerContext context) { - context.put(DEPENDENCY_TREE_KEY, this); - } - - public static DependencyTree getInstance(CompilerContext context) { - DependencyTree binaryFileWriter = context.get(DEPENDENCY_TREE_KEY); - if (binaryFileWriter == null) { - binaryFileWriter = new DependencyTree(context); - } - return binaryFileWriter; - } - - /** - * Render dependency tree of package. - * - * @param packageSymbol package symbol - * @param depth depth - * @return dependency tree - */ - private static String renderDependencyTree(BPackageSymbol packageSymbol, int depth) { - List lines = renderDependencyTreeLines(packageSymbol, depth); - StringBuilder sb = new StringBuilder(lines.size() * 20); - for (StringBuilder line : lines) { - sb.append(line); - sb.append("\n"); - } - return sb.toString(); - } - - /** - * Render dependency tree lines. - * - * @param packageNode package - * @param depth depth - * @return list of strings with strings to render the dependency tree - */ - private static List renderDependencyTreeLines(BPackageSymbol packageNode, int depth) { - List result = new LinkedList<>(); - if (depth > 0) { - result.add(new StringBuilder().append(packageNode.pkgID.toString())); - } - Iterator iterator = packageNode.imports.iterator(); - while (iterator.hasNext()) { - List subtree = renderDependencyTreeLines(iterator.next(), 1); - if (iterator.hasNext()) { - addSubtree(result, subtree); - } else { - addLastSubtree(result, subtree); - } - } - return result; - } - - /** - * Render a subtree of the dependency tree. - * - * @param result list of strings with the result - * @param subtree list of strings of the subtree - */ - private static void addSubtree(List result, List subtree) { - Iterator iterator = subtree.iterator(); - result.add(iterator.next().insert(0, "├── ")); - while (iterator.hasNext()) { - result.add(iterator.next().insert(0, "│ ")); - } - } - - /** - * Renders the last subtree of the dependency tree. - * - * @param result list of strings with the result - * @param subtree list of strings of the subtree - */ - private static void addLastSubtree(List result, List subtree) { - Iterator iterator = subtree.iterator(); - result.add(iterator.next().insert(0, "└── ")); - while (iterator.hasNext()) { - result.add(iterator.next().insert(0, " ")); - } - } - - /** - * List dependency packages. - * - * @param packageNode package node - */ - void listDependencyPackages(BLangPackage packageNode) { - String pkgIdAsStr = packageNode.symbol.pkgID.toString(); - if (packageNode.symbol.pkgID.isUnnamed) { - pkgIdAsStr = packageNode.symbol.pkgID.sourceFileName.value; - } - outStream.println(pkgIdAsStr); - outStream.println(DependencyTree.renderDependencyTree(packageNode.symbol, 0)); - } -} diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/InMemoryCompiledPackage.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/InMemoryCompiledPackage.java deleted file mode 100644 index 3074788df9d8..000000000000 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/InMemoryCompiledPackage.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.wso2.ballerinalang.compiler; - -import org.ballerinalang.model.elements.PackageID; -import org.ballerinalang.repository.CompiledPackage; -import org.ballerinalang.repository.CompilerOutputEntry; - -import java.util.ArrayList; -import java.util.List; - -/** - * {@code InMemoryCompiledPackage} represents a in-memory version of a compiled Ballerina package. - * - * @since 0.970.0 - */ -public class InMemoryCompiledPackage implements CompiledPackage { - public PackageID pkgID; - public List srcEntries; - public CompilerOutputEntry pkgMDEntry; - public CompilerOutputEntry pkgBinaryEntry; - public CompilerOutputEntry pkgBirEntry; - - public InMemoryCompiledPackage(PackageID pkgID) { - this.pkgID = pkgID; - this.srcEntries = new ArrayList<>(); - } - - @Override - public PackageID getPackageID() { - return this.pkgID; - } - - @Override - public List getSourceEntries() { - return this.srcEntries; - } - - @Override - public void addSourceEntry(CompilerOutputEntry compiledPackageEntry) { - this.srcEntries.add(compiledPackageEntry); - } - - @Override - public CompilerOutputEntry getPackageMDEntry() { - return pkgMDEntry; - } - - @Override - public CompilerOutputEntry getPackageBirEntry() { - return pkgBirEntry; - } - - @Override - public void setPackageBirEntry(CompilerOutputEntry entry) { - this.pkgBirEntry = entry; - } - - @Override - public CompilerOutputEntry getPackageBinaryEntry() { - return pkgBinaryEntry; - } - - @Override - public void setPackageBinaryEntry(CompilerOutputEntry entry) { - this.pkgBinaryEntry = entry; - } - - @Override - public List getAllEntries() { - List allEntries = new ArrayList<>(srcEntries); - if (pkgBinaryEntry != null) { - allEntries.add(pkgBinaryEntry); - } - if (pkgBirEntry != null) { //TODO remove this check(ideally pkgBinaryEntry shouldn't be there, only the bir) - allEntries.add(pkgBirEntry); - } - if (pkgMDEntry != null) { - allEntries.add(pkgMDEntry); - } - return allEntries; - } - - @Override - public Kind getKind() { - return Kind.FROM_SOURCE; - } -} diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/LockFileConstants.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/LockFileConstants.java deleted file mode 100644 index 1665b6d90a76..000000000000 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/LockFileConstants.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.wso2.ballerinalang.compiler; - -/** - * Defines constants related to the Ballerina.lock file. - * - * @since 0.973.1 - */ -public class LockFileConstants { - - static final String LOCK_FILE_PACKAGE_VERSION = "version"; - static final String LOCK_FILE_PACKAGE_NAME = "name"; - static final String BALLERINA = "ballerina"; - static final String BALLERINAX = "ballerinax"; - static final String LOCK_FILE_PROJECT = "project"; - static final String LOCK_FILE_VERSION = "lockfileversion"; - static final String LOCK_FILE_PACKAGES = "modules"; - static final String LOCK_FILE_PACKAGE = "module"; - static final String LOCK_FILE_ORG_NAME = "org"; - static final String LOCK_FILE_IMPORTS = "imports"; - static final String BALLERINA_VERSION = "ballerinaversion"; -} diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/LockFileWriter.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/LockFileWriter.java deleted file mode 100644 index 5712221dab7e..000000000000 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/LockFileWriter.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.wso2.ballerinalang.compiler; - -import com.moandjiezana.toml.TomlWriter; -import org.ballerinalang.model.elements.PackageID; -import org.ballerinalang.toml.model.Dependency; -import org.ballerinalang.toml.model.LockFile; -import org.ballerinalang.toml.model.LockFileImport; -import org.ballerinalang.toml.model.Manifest; -import org.wso2.ballerinalang.compiler.semantics.model.symbols.BPackageSymbol; -import org.wso2.ballerinalang.compiler.tree.BLangPackage; -import org.wso2.ballerinalang.compiler.util.CompilerContext; -import org.wso2.ballerinalang.compiler.util.ProjectDirConstants; -import org.wso2.ballerinalang.util.RepoUtils; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -import static org.wso2.ballerinalang.compiler.util.ProjectDirConstants.USER_REPO_BIR_DIRNAME; - -/** - * Write Ballerina.lock to target after every build. - * - * @since 0.973.1 - */ -public class LockFileWriter { - private static final CompilerContext.Key LOCK_FILE_WRITER_KEY = new CompilerContext.Key<>(); - private final Manifest manifest; - private LockFile lockFile = new LockFile(); - - /** - * Constructor of LockFileWriter. - * - * @param context compiler context - * @param manifest The manifest of the project(Ballerina.toml - */ - private LockFileWriter(CompilerContext context, Manifest manifest) { - context.put(LOCK_FILE_WRITER_KEY, this); - this.manifest = manifest; - } - - /** - * Get an instance of the LockFileWriter. - * - * @param context compiler context - * @param manifest The manifest of the project(Ballerina.toml) - * @return instance of the LockFileWriter - */ - public static LockFileWriter getInstance(CompilerContext context, Manifest manifest) { - LockFileWriter lockFileWriter = context.get(LOCK_FILE_WRITER_KEY); - if (lockFileWriter == null) { - lockFileWriter = new LockFileWriter(context, manifest); - } - return lockFileWriter; - } - - /** - * Generate list of imports of dependencies. - * - * @param moduleSymbol Module symbol. - */ - private void addImportsToLockFileModel(BPackageSymbol moduleSymbol) { - if (moduleSymbol.pkgID.version.value.isEmpty() || "*".equals(moduleSymbol.pkgID.version.value)) { - return; - } - - Optional hasPathDependency = manifest.getDependencies().stream() - .filter(dep -> dep.getOrgName().equals(moduleSymbol.pkgID.orgName.value) && - dep.getModuleName().equals(moduleSymbol.pkgID.name.value) && - null != dep.getMetadata().getPath()) - .findFirst(); - - // skip path dependencies - if (!hasPathDependency.isPresent()) { - if (moduleSymbol.imports.size() > 0) { - List importsForLockFile = getImports(moduleSymbol.imports); - if (importsForLockFile.size() > 0) { - this.lockFile.getImports().put(moduleSymbol.pkgID.toString(), importsForLockFile); - } - - for (BPackageSymbol importSymbol : moduleSymbol.imports) { - addImportsToLockFileModel(importSymbol); - } - } - } - } - - /** - * Get import module list as {@link LockFileImport}. - * - * @param moduleSymbols list of module symbols of imported modules - * @return list of packages - */ - private List getImports(List moduleSymbols) { - return moduleSymbols.stream() - .filter(symbol -> !"".equals(symbol.pkgID.version.value)) - .filter(symbol -> isModuleShouldAddedToLockFile(symbol.pkgID)) - .map(symbol -> new LockFileImport(symbol.pkgID.orgName.value, symbol.pkgID.name.value, - symbol.pkgID.version.value)) - .distinct() - .collect(Collectors.toList()); - } - - /** - * Update the project of the lock file. - */ - private void updateProject() { - this.lockFile.setOrgName(this.manifest.getProject().getOrgName()); - this.lockFile.setVersion(this.manifest.getProject().getVersion()); - this.lockFile.setLockfileVersion("1.0.0"); - this.lockFile.setBallerinaVersion(RepoUtils.getBallerinaVersion()); - } - - /** - * Update module names of the lockfile model. - * - * @param modules Module objects. - */ - private void updateDependencies(List modules) { - // update this.ballerinaLockModules with dependencies. - for (BLangPackage module : modules) { - addImportsToLockFileModel(module.symbol); - } - } - - /** - * Write Ballerina.lock file overwriting existing Ballerina.lock file. - * - * @param modules Modules to lock dependencies. - * @param lockFilePath Path to the lock file. - */ - public void writeLockFile(List modules, Path lockFilePath) { - updateProject(); - updateDependencies(modules); - try { - TomlWriter tomlLockWriter = new TomlWriter(); - String tomlString = tomlLockWriter.write(this.lockFile); - Files.write(lockFilePath, tomlString.getBytes()); - } catch (IOException ignore) { - // ignore - } - } - - /** - * Check if this module should be added to lock file. - * `lang` modules and built-in modules not exists in `BAL_HOME/cache/bir` directory avoided in the lock file. - * - * @param packageID package ID. - * @return is module should be added to lock file. - */ - private boolean isModuleShouldAddedToLockFile(PackageID packageID) { - if (isBuiltInModule(packageID)) { - // `lang` modules should be avoided in lock file - if (packageID.getName().getValue().startsWith("lang.")) { - return false; - } - - // built in modules in `BAL_HOME/cache/bir` directory should be added to lock file - Path cachedModulePath = Paths - .get(System.getProperty(ProjectDirConstants.BALLERINA_HOME), "cache", USER_REPO_BIR_DIRNAME, - packageID.getOrgName().getValue(), packageID.getName().getValue()); - return cachedModulePath.toFile().exists(); - } else { - // Non built in modules should be added to lock file - return true; - } - } - - /** - * Check if module is a built in module. - * - * @param packageID package ID. - * @return if module org name equals to `ballerina` or `ballerinax`. - */ - private boolean isBuiltInModule(PackageID packageID) { - String packageOrgName = packageID.orgName.getValue().trim(); - return packageOrgName.equals("ballerina") || packageOrgName.equals("ballerinax"); - } -} diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/PathBasedCompiledPackageEntry.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/PathBasedCompiledPackageEntry.java deleted file mode 100644 index df4aa5437bc8..000000000000 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/PathBasedCompiledPackageEntry.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.wso2.ballerinalang.compiler; - -import org.ballerinalang.repository.CompilerOutputEntry; - -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.Path; - -/** - * {@code PathBasedCompiledPackageEntry} represents compiled package entry. - * - * @since 0.970.0 - */ -public class PathBasedCompiledPackageEntry implements CompilerOutputEntry { - - private Path root; - private Path path; - private Kind kind; - - public PathBasedCompiledPackageEntry(Path root, Path path, Kind kind) { - this.root = root; - this.path = path; - this.kind = kind; - } - - @Override - public String getEntryName() { - return this.path.toString(); - } - - @Override - public Kind getEntryKind() { - return this.kind; - } - - @Override - public InputStream getInputStream() throws IOException { - return Files.newInputStream(this.root.resolve(this.path)); - } -} diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/TypeCreator.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/TypeCreator.java deleted file mode 100644 index c5b20c4ed232..000000000000 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/TypeCreator.java +++ /dev/null @@ -1,46 +0,0 @@ -/* -* Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ -package org.wso2.ballerinalang.compiler; - -import java.util.List; - -/** - * Interface to implement by all type creators. - * - * @param Type of the types created by the type creator. - * - * @since 0.975.0 - */ -public interface TypeCreator { - - T getBasicType(char typeChar); - - T getBuiltinRefType(String typeName); - - T getRefType(char typeChar, String pkgPath, String typeName); - - T getConstrainedType(char typeChar, T constraint); - - T getArrayType(T elemType, int size); - - T getCollectionType(char typeChar, List memberTypes); - - T getFunctionType(List funcParamsStack, T retType); - - T getErrorType(T reasonType, T detailsType); -} diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/TypeSignatureReader.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/TypeSignatureReader.java deleted file mode 100644 index d25bed7293bf..000000000000 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/TypeSignatureReader.java +++ /dev/null @@ -1,221 +0,0 @@ -/* -* Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ -package org.wso2.ballerinalang.compiler; - -import org.wso2.ballerinalang.compiler.util.Names; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Stack; - -/** - * {@code TypeSignatureReader} reads the type signature and creates type. - * - * @param Type of the type to be created from the signature. - * - * @since 0.975.0 - */ -public class TypeSignatureReader { - - public int createBTypeFromSig(TypeCreator typeCreator, char[] chars, int index, Stack typeStack) { - int nameIndex; - char typeChar = chars[index]; - switch (typeChar) { - case 'I': - case 'W': - case 'F': - case 'L': - case 'S': - case 'B': - case 'Y': - case 'A': - case 'N': - case 'K': - typeStack.push(typeCreator.getBasicType(typeChar)); - return index + 1; - case 'R': - index++; - nameIndex = index; - while (chars[nameIndex] != ';') { - nameIndex++; - } - String typeName = new String(Arrays.copyOfRange(chars, index, nameIndex)); - typeStack.push(typeCreator.getBuiltinRefType(typeName)); - return nameIndex + 1; - case 'C': - case 'T': - case 'X': - case 'D': - case 'G': - case 'Z': - case 'E': - nameIndex = index; - while (chars[nameIndex] != ';') { - nameIndex++; - } - String name = new String(Arrays.copyOfRange(chars, index, nameIndex + 1)); - T type = getBTypeFromDescriptor(typeCreator, name); - typeStack.push(type); - return nameIndex + 1; - case '[': - int endIndex = index + 1; - int j = index + 1; - while (chars[j] != ';') { - endIndex++; - j++; - } - - int size = Integer.parseInt(String.valueOf(Arrays.copyOfRange(chars, index + 1, endIndex))); - index = createBTypeFromSig(typeCreator, chars, endIndex + 1, typeStack); - T elemType = typeStack.pop(); - typeStack.push(typeCreator.getArrayType(elemType, size)); - - return index; - case 'M': - case 'H': - case 'Q': - index = createBTypeFromSig(typeCreator, chars, index + 1, typeStack); - T constraintType = typeStack.pop(); - typeStack.push(typeCreator.getConstrainedType(typeChar, constraintType)); - return index; - case 'U': - index++; - index = createFunctionType(typeCreator, chars, index, typeStack); - return index + 1; - case 'O': - case 'P': - index++; - nameIndex = index; - while (chars[nameIndex] != ';') { - nameIndex++; - } - List memberTypes = new ArrayList<>(); - int memberCount = Integer.parseInt(new String(Arrays.copyOfRange(chars, index, nameIndex))); - index = nameIndex; - for (int i = 0; i < memberCount; i++) { - index = createBTypeFromSig(typeCreator, chars, index + 1, typeStack) - 1; - memberTypes.add(typeStack.pop()); - } - - typeStack.push(typeCreator.getCollectionType(typeChar, memberTypes)); - return index + 1; - default: - throw new IllegalArgumentException("unsupported base type char: " + typeChar); - } - } - - public T getBTypeFromDescriptor(TypeCreator typeCreator, String desc) { - char ch = desc.charAt(0); - switch (ch) { - case 'I': - case 'W': - case 'F': - case 'L': - case 'S': - case 'B': - case 'Y': - case 'A': - case 'N': - case 'K': - return typeCreator.getBasicType(ch); - case 'R': - String typeName = desc.substring(1, desc.length() - 1); - return typeCreator.getBuiltinRefType(typeName); - case 'M': - case 'H': - case 'Q': - T constraintType = getBTypeFromDescriptor(typeCreator, desc.substring(1)); - return typeCreator.getConstrainedType(ch, constraintType); - case 'C': - case 'T': - case 'X': - case 'Z': - case 'G': - case 'D': - case 'E': - typeName = desc.substring(1, desc.length() - 1); - String[] parts = typeName.split(":"); - - if (parts.length == 1) { - if (ch == 'D') { - return typeCreator.getConstrainedType(ch, null); - } - } - - String pkgPath; - String name; - if (parts.length == 2) { - pkgPath = parts[0]; - name = parts[1]; - } else { - pkgPath = String.join(Names.VERSION_SEPARATOR.value, parts[0], parts[1]); - name = parts[2]; - } - - constraintType = typeCreator.getRefType(ch, pkgPath, name); - return typeCreator.getConstrainedType(ch, constraintType); - case '[': - int index = 1; - char[] size = null; - if (desc.contains(";")) { - index = desc.indexOf(";"); - size = new char[index - 1]; - desc.getChars(1, index, size, 0); - index++; - } - T elemType = getBTypeFromDescriptor(typeCreator, desc.substring(index)); - return typeCreator.getArrayType(elemType, Integer.parseInt(String.valueOf(size))); - - case 'U': - case 'O': - case 'P': - Stack typeStack = new Stack<>(); - createBTypeFromSig(typeCreator, desc.toCharArray(), 0, typeStack); - return typeStack.pop(); - default: - throw new IllegalArgumentException("unsupported base type char: " + ch); - } - } - - public int createFunctionType(TypeCreator typeCreator, char[] chars, int index, Stack typeStack) { - // Skip the first parenthesis - index++; - - // Read function parameters - Stack funcParamsStack = new Stack<>(); - while (chars[index] != ')' || chars[index + 1] != '(') { - index = createBTypeFromSig(typeCreator, chars, index, funcParamsStack); - } - - // Read function return type. - // Skip the two parenthesis ')(', which separate params and return params - index += 2; - T retType; - if (chars[index] == ')') { - retType = null; - } else { - Stack returnParamsStack = new Stack<>(); - index = createBTypeFromSig(typeCreator, chars, index, returnParamsStack); - retType = returnParamsStack.pop(); - } - - typeStack.push(typeCreator.getFunctionType(funcParamsStack, retType)); - return index; - } -} From 0b73483998f73d4bb4e30494146b1b7c0106ecee Mon Sep 17 00:00:00 2001 From: Nadeeshan96 Date: Tue, 6 Dec 2022 00:00:03 +0530 Subject: [PATCH 173/450] Fix failing CodeCoverageReportTest.normalizedCoverageClassTest --- .../ballerinalang/testerina/test/CodeCoverageReportTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/CodeCoverageReportTest.java b/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/CodeCoverageReportTest.java index 4612223474cd..1b9aeba318ea 100644 --- a/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/CodeCoverageReportTest.java +++ b/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/CodeCoverageReportTest.java @@ -271,6 +271,9 @@ private void validateClassNames(HashMap> expectedClassMap) if ("class".equals(actualClassList.item(j).getNodeName())) { String className = actualClassList.item(j).getAttributes(). getNamedItem("name").getNodeValue(); + if (className.contains("$frame$")) { + continue; + } if (expectedClassMap.get(packageName).contains(className)) { Assert.assertTrue(true); } else { From d1a4d5a33113ae5d2de691f68f952e1fca6612c1 Mon Sep 17 00:00:00 2001 From: malinthar Date: Tue, 6 Dec 2022 12:14:31 +0530 Subject: [PATCH 174/450] Add missing resource access action completions --- ...ClientResourceAccessActionNodeContext.java | 74 +++++++++---- ...lient_resource_access_action_config18.json | 103 ++++++++++++++++++ ...lient_resource_access_action_config19.json | 39 +++++++ ...client_resource_access_action_source18.bal | 40 +++++++ ...client_resource_access_action_source19.bal | 40 +++++++ 5 files changed, 275 insertions(+), 21 deletions(-) create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_resource_access_action_config18.json create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_resource_access_action_config19.json create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/action_node_context/source/client_resource_access_action_source18.bal create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/action_node_context/source/client_resource_access_action_source19.bal diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ClientResourceAccessActionNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ClientResourceAccessActionNodeContext.java index f9b37eebb5f6..59c0b09bf6f6 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ClientResourceAccessActionNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ClientResourceAccessActionNodeContext.java @@ -18,6 +18,7 @@ import io.ballerina.compiler.api.SemanticModel; import io.ballerina.compiler.api.symbols.ArrayTypeSymbol; import io.ballerina.compiler.api.symbols.FunctionSymbol; +import io.ballerina.compiler.api.symbols.FunctionTypeSymbol; import io.ballerina.compiler.api.symbols.MethodSymbol; import io.ballerina.compiler.api.symbols.PathParameterSymbol; import io.ballerina.compiler.api.symbols.Qualifier; @@ -160,9 +161,11 @@ private List getPathSegmentCompletionItems(ClientResourceAcces } else if (completablePathSegments.getRight() && ResourcePathCompletionUtil .isInMethodCallContext(node, context)) { //suggest method call expressions - CompletionItem completionItem = - ResourcePathCompletionItemBuilder.buildMethodCallExpression(resourceMethod, context); - completionItems.add(new SymbolCompletionItem(context, resourceMethod, completionItem)); + if (!isGetMethodWithoutParams(resourceMethod)) { + CompletionItem completionItem = + ResourcePathCompletionItemBuilder.buildMethodCallExpression(resourceMethod, context); + completionItems.add(new SymbolCompletionItem(context, resourceMethod, completionItem)); + } } } return completionItems; @@ -183,7 +186,10 @@ private Pair, Boolean> completableSegmentList(ResourceMethodSy List currentSegments, BallerinaCompletionContext context, ClientResourceAccessActionNode accNode) { - if (segments.size() < currentSegments.size()) { + Optional pathRestParam = + segments.stream().filter(pathSegment -> + pathSegment.pathSegmentKind() == PathSegment.Kind.PATH_REST_PARAMETER).findFirst(); + if (segments.size() < currentSegments.size() && pathRestParam.isEmpty()) { return Pair.of(Collections.emptyList(), false); } @@ -197,7 +203,15 @@ private Pair, Boolean> completableSegmentList(ResourceMethodSy for (int i = 0; i < numOfProvidedSegments; i++) { completableSegmentStartIndex += 1; Node node = currentSegments.get(i); - PathSegment segment = segments.get(i); + PathSegment segment; + if (i > segments.size() - 1) { + if (pathRestParam.isEmpty()) { + return Pair.of(Collections.emptyList(), false); + } + segment = pathRestParam.get(); + } else { + segment = segments.get(i); + } if (node.kind() == SyntaxKind.IDENTIFIER_TOKEN && segment.pathSegmentKind() == PathSegment.Kind.NAMED_SEGMENT) { String currentPath = ((IdentifierToken) node).text().strip(); @@ -220,27 +234,34 @@ private Pair, Boolean> completableSegmentList(ResourceMethodSy } //Covers named segments that are not matching return Pair.of(Collections.emptyList(), false); - } else if (node.kind() == SyntaxKind.COMPUTED_RESOURCE_ACCESS_SEGMENT - && (segment.pathSegmentKind() == PathSegment.Kind.PATH_PARAMETER || - segment.pathSegmentKind() == PathSegment.Kind.PATH_REST_PARAMETER)) { - TypeSymbol typeSymbol = segment.pathSegmentKind() == PathSegment.Kind.PATH_REST_PARAMETER ? - ((ArrayTypeSymbol) (((PathParameterSymbol) segment).typeDescriptor())).memberTypeDescriptor() : - ((PathParameterSymbol) segment).typeDescriptor(); - Optional semanticModel = context.currentSemanticModel(); - if (semanticModel.isEmpty()) { - return Pair.of(Collections.emptyList(), false); - } - Optional exprType = - semanticModel.get().typeOf(((ComputedResourceAccessSegmentNode) node).expression()); + } else if (segment.pathSegmentKind() == PathSegment.Kind.PATH_PARAMETER || + segment.pathSegmentKind() == PathSegment.Kind.PATH_REST_PARAMETER) { + if (node.kind() == SyntaxKind.COMPUTED_RESOURCE_ACCESS_SEGMENT) { + TypeSymbol typeSymbol = segment.pathSegmentKind() == PathSegment.Kind.PATH_REST_PARAMETER ? + ((ArrayTypeSymbol) (((PathParameterSymbol) segment).typeDescriptor())) + .memberTypeDescriptor() : ((PathParameterSymbol) segment).typeDescriptor(); + Optional semanticModel = context.currentSemanticModel(); + if (semanticModel.isEmpty()) { + return Pair.of(Collections.emptyList(), false); + } + Optional exprType = + semanticModel.get().typeOf(((ComputedResourceAccessSegmentNode) node).expression()); - if (exprType.isEmpty() || !exprType.get().subtypeOf(typeSymbol)) { - return Pair.of(Collections.emptyList(), false); + if (exprType.isEmpty() || !exprType.get().subtypeOf(typeSymbol)) { + return Pair.of(Collections.emptyList(), false); + } + continue; + } else if (node.kind() == SyntaxKind.IDENTIFIER_TOKEN) { + continue; } - continue; } return Pair.of(Collections.emptyList(), false); } - return Pair.of(segments.subList(completableSegmentStartIndex, segments.size()), true); + + List completableSegments = + completableSegmentStartIndex <= segments.size() ? + segments.subList(completableSegmentStartIndex, segments.size()) : Collections.emptyList(); + return Pair.of(completableSegments, true); } private boolean isInResourceMethodParameterContext(ClientResourceAccessActionNode node, @@ -266,4 +287,15 @@ private List getNamedArgExpressionCompletionItems(BallerinaCom return getNamedArgCompletionItems(context, functionSymbol, node.arguments().get().arguments()); } + + private boolean isGetMethodWithoutParams(ResourceMethodSymbol resourceMethodSymbol) { + Optional name = resourceMethodSymbol.getName(); + FunctionTypeSymbol functionTypeSymbol = resourceMethodSymbol.typeDescriptor(); + if (name.isPresent() && !"get".equals(name.get())) { + return false; + } + return (functionTypeSymbol.params().isEmpty() + || functionTypeSymbol.params().get().size() == 0) + && functionTypeSymbol.restParam().isEmpty(); + } } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_resource_access_action_config18.json b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_resource_access_action_config18.json new file mode 100644 index 000000000000..5b6650ae1f5d --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_resource_access_action_config18.json @@ -0,0 +1,103 @@ +{ + "position": { + "line": 38, + "character": 22 + }, + "source": "action_node_context/source/client_resource_access_action_source18.bal", + "items": [ + { + "label": "(string id)", + "kind": "Function", + "detail": "()", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _._ \n \n \n**Params** \n- `string[]` params \n- `string` id" + } + }, + "sortText": "G", + "filterText": "get", + "insertText": "(${1})", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 38, + "character": 21 + }, + "end": { + "line": 38, + "character": 22 + } + }, + "newText": "" + } + ], + "command": { + "title": "editor.action.triggerParameterHints", + "command": "editor.action.triggerParameterHints" + } + }, + { + "label": ".post", + "kind": "Function", + "detail": "()", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _._ \n \n \n**Params** \n- `string[]` params" + } + }, + "sortText": "G", + "filterText": "post", + "insertText": ".post", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 38, + "character": 21 + }, + "end": { + "line": 38, + "character": 22 + } + }, + "newText": "" + } + ] + }, + { + "label": ".put", + "kind": "Function", + "detail": "()", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _._ \n \n \n**Params** \n- `string[]` params" + } + }, + "sortText": "G", + "filterText": "put", + "insertText": ".put", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 38, + "character": 21 + }, + "end": { + "line": 38, + "character": 22 + } + }, + "newText": "" + } + ] + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_resource_access_action_config19.json b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_resource_access_action_config19.json new file mode 100644 index 000000000000..90da066a6ffe --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_resource_access_action_config19.json @@ -0,0 +1,39 @@ +{ + "position": { + "line": 38, + "character": 40 + }, + "source": "action_node_context/source/client_resource_access_action_source19.bal", + "items": [ + { + "label": ".post", + "kind": "Function", + "detail": "()", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _._ \n \n \n**Params** \n- `int` id \n- `string[]` params" + } + }, + "sortText": "G", + "filterText": "post", + "insertText": ".post", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 38, + "character": 39 + }, + "end": { + "line": 38, + "character": 40 + } + }, + "newText": "" + } + ] + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/source/client_resource_access_action_source18.bal b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/source/client_resource_access_action_source18.bal new file mode 100644 index 000000000000..04b0dd0515cf --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/source/client_resource_access_action_source18.bal @@ -0,0 +1,40 @@ +client class MyClient { + + resource function get user/[int id]() returns json { + return {}; + } + + resource function post user/[int id](string referrer) { + + } + + resource function get user/[int id]/[string... params]() { + } + + resource function post user/[int id]/[string... params]() { + } + + resource function get [string... params](string id) { + } + + resource function post [string... params]() { + + } + + resource function post user/[string... params](string id, string age, string name) { + + } + + resource function put [string... params]() { + + } + + resource function patch user/[int... params]() { + + } +} + +public function testClient() returns error? { + MyClient cl = new (); + cl->/a/abc/["cd"].; +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/source/client_resource_access_action_source19.bal b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/source/client_resource_access_action_source19.bal new file mode 100644 index 000000000000..f6be3dcdff85 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/source/client_resource_access_action_source19.bal @@ -0,0 +1,40 @@ +client class MyClient { + + resource function get user/[int id]() returns json { + return {}; + } + + resource function post user/[int id](string referrer) { + + } + + resource function get user/[int id]/[string... params]() { + } + + resource function post user/[int id]/[string... params]() { + } + + resource function get [string... params](string id) { + } + + resource function post [string... params]() { + + } + + resource function post user/[string... params](string id, string age, string name) { + + } + + resource function put [string... params]() { + + } + + resource function patch [int... params]() { + + } +} + +public function testClient() returns error? { + MyClient cl = new (); + cl->/user/[1]/path1/path2/["path3"].; +} From a8eef892840127b5ebb9662c40be6ea0360f7151 Mon Sep 17 00:00:00 2001 From: HindujaB Date: Tue, 6 Dec 2022 16:55:12 +0530 Subject: [PATCH 175/450] Fix final constants failing with null --- .../bir/codegen/split/constants/JvmArrayTypeConstantsGen.java | 4 +--- .../bir/codegen/split/constants/JvmRefTypeConstantsGen.java | 4 +--- .../bir/codegen/split/constants/JvmTupleTypeConstantsGen.java | 4 +--- .../bir/codegen/split/constants/JvmUnionTypeConstantsGen.java | 4 +--- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmArrayTypeConstantsGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmArrayTypeConstantsGen.java index 005d88e87f67..e0bc22dd716f 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmArrayTypeConstantsGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmArrayTypeConstantsGen.java @@ -38,7 +38,6 @@ import java.util.TreeMap; import static org.objectweb.asm.ClassWriter.COMPUTE_FRAMES; -import static org.objectweb.asm.Opcodes.ACC_FINAL; import static org.objectweb.asm.Opcodes.ACC_PUBLIC; import static org.objectweb.asm.Opcodes.ACC_STATIC; import static org.objectweb.asm.Opcodes.GETSTATIC; @@ -109,8 +108,7 @@ private void genPopulateMethod(BArrayType arrayType, String varName) { } private void createBArrayType(MethodVisitor mv, BArrayType arrayType, String varName) { - FieldVisitor fv = cw.visitField(ACC_PUBLIC + ACC_FINAL + ACC_STATIC, varName, - GET_ARRAY_TYPE_IMPL, null, null); + FieldVisitor fv = cw.visitField(ACC_PUBLIC + ACC_STATIC, varName, GET_ARRAY_TYPE_IMPL, null, null); fv.visitEnd(); jvmArrayTypeGen.createArrayType(mv, arrayType, types); mv.visitFieldInsn(Opcodes.PUTSTATIC, arrayConstantsClass, varName, GET_ARRAY_TYPE_IMPL); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmRefTypeConstantsGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmRefTypeConstantsGen.java index f42db1b45736..1e8abf3a7122 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmRefTypeConstantsGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmRefTypeConstantsGen.java @@ -36,7 +36,6 @@ import java.util.TreeMap; import static org.objectweb.asm.ClassWriter.COMPUTE_FRAMES; -import static org.objectweb.asm.Opcodes.ACC_FINAL; import static org.objectweb.asm.Opcodes.ACC_PUBLIC; import static org.objectweb.asm.Opcodes.ACC_STATIC; import static org.objectweb.asm.Opcodes.GETSTATIC; @@ -110,8 +109,7 @@ private void createTypeRefType(MethodVisitor mv, BTypeReferenceType type, String } private void visitTypeRefField(String varName) { - FieldVisitor fv = cw.visitField(ACC_PUBLIC + ACC_FINAL + ACC_STATIC, varName, - GET_TYPE_REF_TYPE_IMPL, null, null); + FieldVisitor fv = cw.visitField(ACC_PUBLIC + ACC_STATIC, varName, GET_TYPE_REF_TYPE_IMPL, null, null); fv.visitEnd(); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmTupleTypeConstantsGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmTupleTypeConstantsGen.java index 1cd7e2db4e7d..b98d8527c2a2 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmTupleTypeConstantsGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmTupleTypeConstantsGen.java @@ -40,7 +40,6 @@ import java.util.TreeMap; import static org.objectweb.asm.ClassWriter.COMPUTE_FRAMES; -import static org.objectweb.asm.Opcodes.ACC_FINAL; import static org.objectweb.asm.Opcodes.ACC_PUBLIC; import static org.objectweb.asm.Opcodes.ACC_STATIC; import static org.objectweb.asm.Opcodes.GETSTATIC; @@ -129,8 +128,7 @@ private void createBTupleType(MethodVisitor mv, BTupleType tupleType, String var } private void visitBTupleField(String varName) { - FieldVisitor fv = cw.visitField(ACC_PUBLIC + ACC_FINAL + ACC_STATIC, varName, - GET_TUPLE_TYPE_IMPL, null, null); + FieldVisitor fv = cw.visitField(ACC_PUBLIC + ACC_STATIC, varName, GET_TUPLE_TYPE_IMPL, null, null); fv.visitEnd(); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmUnionTypeConstantsGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmUnionTypeConstantsGen.java index 94a50f41e494..be79bf4c49fb 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmUnionTypeConstantsGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmUnionTypeConstantsGen.java @@ -40,7 +40,6 @@ import java.util.TreeMap; import static org.objectweb.asm.ClassWriter.COMPUTE_FRAMES; -import static org.objectweb.asm.Opcodes.ACC_FINAL; import static org.objectweb.asm.Opcodes.ACC_PUBLIC; import static org.objectweb.asm.Opcodes.ACC_STATIC; import static org.objectweb.asm.Opcodes.GETSTATIC; @@ -129,8 +128,7 @@ private void createBunionType(MethodVisitor mv, BUnionType unionType, String var } private void visitBUnionField(String varName) { - FieldVisitor fv = cw.visitField(ACC_PUBLIC + ACC_FINAL + ACC_STATIC, varName, - GET_UNION_TYPE_IMPL, null, null); + FieldVisitor fv = cw.visitField(ACC_PUBLIC + ACC_STATIC, varName, GET_UNION_TYPE_IMPL, null, null); fv.visitEnd(); } From ac5d8c1fd14e0c987ef91d789fe698966e44bee5 Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Tue, 6 Dec 2022 17:00:55 +0530 Subject: [PATCH 176/450] Add interactions on dependencies --- .../generators/GeneratorUtils.java | 4 + .../ServiceDeclarationNodeVisitor.java | 5 +- .../ServiceMemberFunctionNodeVisitor.java | 55 +++++- .../nodevisitors/StatementNodeVisitor.java | 161 ------------------ .../model/service/Service.java | 4 +- 5 files changed, 61 insertions(+), 168 deletions(-) delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/StatementNodeVisitor.java diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/GeneratorUtils.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/GeneratorUtils.java index 115f17e8fcb0..d1d22254cfc2 100644 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/GeneratorUtils.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/GeneratorUtils.java @@ -144,4 +144,8 @@ public static String getClientModuleName(Node clientNode, SemanticModel semantic return clientModuleName; } + + public static String getClientModuleName(TypeSymbol typeSymbol) { + return typeSymbol.signature().trim().replace(CLIENT, ""); + } } diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java index 496d247e66ce..acf690641933 100644 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java @@ -109,8 +109,9 @@ public void visit(ServiceDeclarationNode serviceDeclarationNode) { serviceDeclarationNode.accept(serviceMemberFunctionNodeVisitor); services.add(new Service(serviceName.trim(), serviceAnnotation.getId(), getServiceType(serviceDeclarationNode), serviceMemberFunctionNodeVisitor.getResources(), - serviceMemberFunctionNodeVisitor.getRemoteFunctions(), serviceAnnotation, GeneratorUtils. - getElementLocation(filePath.toString(), serviceDeclarationNode.lineRange()))); + serviceMemberFunctionNodeVisitor.getRemoteFunctions(), serviceAnnotation, + serviceMemberFunctionNodeVisitor.getInteractionList(), + GeneratorUtils.getElementLocation(filePath.toString(), serviceDeclarationNode.lineRange()))); } private String getServiceType(ServiceDeclarationNode serviceDeclarationNode) { diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java index 208c43faf3d3..5686b58c7c68 100644 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java @@ -23,15 +23,19 @@ import io.ballerina.architecturemodelgenerator.generators.GeneratorUtils; import io.ballerina.architecturemodelgenerator.model.ElementLocation; import io.ballerina.architecturemodelgenerator.model.service.FunctionParameter; +import io.ballerina.architecturemodelgenerator.model.service.Interaction; import io.ballerina.architecturemodelgenerator.model.service.RemoteFunction; import io.ballerina.architecturemodelgenerator.model.service.Resource; import io.ballerina.architecturemodelgenerator.model.service.ResourceId; import io.ballerina.architecturemodelgenerator.model.service.ResourceParameter; import io.ballerina.compiler.api.SemanticModel; +import io.ballerina.compiler.api.symbols.Annotatable; import io.ballerina.compiler.api.symbols.ArrayTypeSymbol; +import io.ballerina.compiler.api.symbols.ClassSymbol; import io.ballerina.compiler.api.symbols.MethodSymbol; import io.ballerina.compiler.api.symbols.ParameterSymbol; import io.ballerina.compiler.api.symbols.PathParameterSymbol; +import io.ballerina.compiler.api.symbols.Qualifier; import io.ballerina.compiler.api.symbols.Symbol; import io.ballerina.compiler.api.symbols.SymbolKind; import io.ballerina.compiler.api.symbols.TypeDescKind; @@ -41,17 +45,23 @@ import io.ballerina.compiler.syntax.tree.AnnotationNode; import io.ballerina.compiler.syntax.tree.ConstantDeclarationNode; import io.ballerina.compiler.syntax.tree.DefaultableParameterNode; +import io.ballerina.compiler.syntax.tree.FieldAccessExpressionNode; import io.ballerina.compiler.syntax.tree.FunctionDefinitionNode; import io.ballerina.compiler.syntax.tree.FunctionSignatureNode; +import io.ballerina.compiler.syntax.tree.NameReferenceNode; import io.ballerina.compiler.syntax.tree.Node; import io.ballerina.compiler.syntax.tree.NodeList; import io.ballerina.compiler.syntax.tree.NodeVisitor; +import io.ballerina.compiler.syntax.tree.ObjectFieldNode; import io.ballerina.compiler.syntax.tree.ParameterNode; import io.ballerina.compiler.syntax.tree.RequiredParameterNode; import io.ballerina.compiler.syntax.tree.ResourcePathParameterNode; import io.ballerina.compiler.syntax.tree.ReturnTypeDescriptorNode; import io.ballerina.compiler.syntax.tree.SeparatedNodeList; +import io.ballerina.compiler.syntax.tree.SimpleNameReferenceNode; import io.ballerina.compiler.syntax.tree.SyntaxKind; +import io.ballerina.compiler.syntax.tree.Token; +import io.ballerina.compiler.syntax.tree.TypedBindingPatternNode; import io.ballerina.compiler.syntax.tree.VariableDeclarationNode; import io.ballerina.projects.Package; @@ -60,6 +70,10 @@ import java.util.List; import java.util.Optional; +import static io.ballerina.architecturemodelgenerator.generators.GeneratorUtils.getClientModuleName; +import static io.ballerina.architecturemodelgenerator.generators.GeneratorUtils.getElementLocation; +import static io.ballerina.architecturemodelgenerator.generators.GeneratorUtils.getServiceAnnotation; + /** * Visitor class for FunctionDefinition node. * @@ -72,6 +86,7 @@ public class ServiceMemberFunctionNodeVisitor extends NodeVisitor { private final Package currentPackage; private List resources = new LinkedList<>(); private List remoteFunctions = new LinkedList<>(); + private final List interactionList = new LinkedList<>(); private final ComponentModel.PackageId packageId; private final String filePath; @@ -93,9 +108,13 @@ public List getRemoteFunctions() { return remoteFunctions; } + public List getInteractionList() { + return interactionList; + } + @Override public void visit(FunctionDefinitionNode functionDefinitionNode) { - ElementLocation elementLocation = GeneratorUtils.getElementLocation(filePath, + ElementLocation elementLocation = getElementLocation(filePath, functionDefinitionNode.lineRange()); SyntaxKind kind = functionDefinitionNode.kind(); switch (kind) { @@ -159,7 +178,7 @@ public void visit(FunctionDefinitionNode functionDefinitionNode) { } private ResourceParameter getPathParameter(ResourcePathParameterNode resourcePathParameterNode) { - ElementLocation elementLocation = GeneratorUtils.getElementLocation(this.filePath, + ElementLocation elementLocation = getElementLocation(this.filePath, resourcePathParameterNode.lineRange()); String name = resourcePathParameterNode.paramName().get().text(); List paramTypes = new LinkedList<>(); @@ -176,7 +195,7 @@ private void getParameters(FunctionSignatureNode functionSignatureNode, boolean SeparatedNodeList parameterNodes = functionSignatureNode.parameters(); for (ParameterNode parameterNode : parameterNodes) { - ElementLocation elementLocation = GeneratorUtils.getElementLocation(this.filePath, + ElementLocation elementLocation = getElementLocation(this.filePath, parameterNode.lineRange()); Optional symbol = semanticModel.symbol(parameterNode); if (symbol.isPresent() && symbol.get().kind().equals(SymbolKind.PARAMETER)) { @@ -304,8 +323,36 @@ private List getReturnTypes(FunctionDefinitionNode functionDefinitionNod } @Override - public void visit(VariableDeclarationNode variableDeclarationNode) { + public void visit(ObjectFieldNode objectFieldNode) { + Node fieldTypeName = objectFieldNode.typeName(); + Optional fieldTypeNameSymbol = semanticModel.symbol(fieldTypeName); + if (fieldTypeNameSymbol.isPresent()) { + TypeDescKind fieldTypeNameTypeDescKind = ((TypeSymbol) fieldTypeNameSymbol.get()).typeKind(); + if (fieldTypeNameTypeDescKind.equals(TypeDescKind.TYPE_REFERENCE)) { + TypeReferenceTypeSymbol fieldTypeNameTypeRefSymbol = + (TypeReferenceTypeSymbol) fieldTypeNameSymbol.get(); + SymbolKind fieldTypeNameSymbolKind = fieldTypeNameTypeRefSymbol.definition().kind(); + if (fieldTypeNameSymbolKind.equals(SymbolKind.CLASS)) { + ClassSymbol fieldRefClassSymbol = (ClassSymbol) fieldTypeNameTypeRefSymbol.typeDescriptor(); + boolean isClientClass = fieldRefClassSymbol.qualifiers().stream() + .anyMatch(qualifier -> qualifier.equals(Qualifier.CLIENT)); + if (isClientClass && objectFieldNode.metadata().isPresent()) { + String serviceId = + getServiceAnnotation(objectFieldNode.metadata().get().annotations(), filePath).getId(); + Interaction interaction = new Interaction(new ResourceId(serviceId, + null, null), getClientModuleName((TypeSymbol) fieldTypeNameSymbol.get()), + getElementLocation(filePath, objectFieldNode.lineRange())); + interactionList.add(interaction); + } + } + } + } + } + @Override + public void visit(VariableDeclarationNode variableDeclarationNode) { + TypedBindingPatternNode typedBindingPatternNode = variableDeclarationNode.typedBindingPattern(); + typedBindingPatternNode.modify(); } @Override diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/StatementNodeVisitor.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/StatementNodeVisitor.java deleted file mode 100644 index b92ed08d2640..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/StatementNodeVisitor.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator.generators.service.nodevisitors; - -import io.ballerina.architecturemodelgenerator.generators.GeneratorUtils; -import io.ballerina.compiler.api.SemanticModel; -import io.ballerina.compiler.api.symbols.Symbol; -import io.ballerina.compiler.api.symbols.TypeReferenceTypeSymbol; -import io.ballerina.compiler.syntax.tree.AnnotationNode; -import io.ballerina.compiler.syntax.tree.ClassDefinitionNode; -import io.ballerina.compiler.syntax.tree.EnumDeclarationNode; -import io.ballerina.compiler.syntax.tree.FunctionDefinitionNode; -import io.ballerina.compiler.syntax.tree.ImportDeclarationNode; -import io.ballerina.compiler.syntax.tree.MetadataNode; -import io.ballerina.compiler.syntax.tree.ModuleVariableDeclarationNode; -import io.ballerina.compiler.syntax.tree.NodeList; -import io.ballerina.compiler.syntax.tree.NodeVisitor; -import io.ballerina.compiler.syntax.tree.ObjectFieldNode; -import io.ballerina.compiler.syntax.tree.QualifiedNameReferenceNode; -import io.ballerina.compiler.syntax.tree.SimpleNameReferenceNode; -import io.ballerina.compiler.syntax.tree.TypeDefinitionNode; -import io.ballerina.compiler.syntax.tree.TypeDescriptorNode; -import io.ballerina.compiler.syntax.tree.VariableDeclarationNode; - -import java.util.Optional; - -import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.CLIENT; - -/** - * Visitor class to identify client declaration nodes inside a Ballerina service. - * - * @since 2201.2.2 - */ -public class StatementNodeVisitor extends NodeVisitor { - - private String serviceId = null; - private String connectorType = null; - private final SemanticModel semanticModel; - private final String clientName; - private final String filePath; - - public StatementNodeVisitor(String clientName, SemanticModel semanticModel, String filePath) { - - this.clientName = clientName; - this.semanticModel = semanticModel; - this.filePath = filePath; - } - - public String getServiceId() { - return serviceId; - } - - public String getConnectorType() { - return connectorType; - } - - @Override - public void visit(VariableDeclarationNode variableDeclarationNode) { - - if (variableDeclarationNode.typedBindingPattern().bindingPattern().toString().trim().equals(clientName)) { - TypeDescriptorNode typeDescriptorNode = variableDeclarationNode.typedBindingPattern().typeDescriptor(); - connectorType = getClientModuleName(typeDescriptorNode); - NodeList annotations = variableDeclarationNode.annotations(); - this.serviceId = GeneratorUtils.getServiceAnnotation(annotations, this.filePath).getId(); - } - } - - @Override - public void visit(ObjectFieldNode objectFieldNode) { - - if (objectFieldNode.fieldName().text().trim().equals(clientName)) { - TypeDescriptorNode typeDescriptorNode = (TypeDescriptorNode) objectFieldNode.typeName(); - connectorType = getClientModuleName(typeDescriptorNode); - Optional metadataNode = objectFieldNode.metadata(); - if (metadataNode.isPresent()) { - NodeList annotationNodes = metadataNode.get().annotations(); - serviceId = GeneratorUtils.getServiceAnnotation(annotationNodes, this.filePath).getId(); - } - } - } - - @Override - public void visit(ModuleVariableDeclarationNode moduleVariableDeclarationNode) { - - if (moduleVariableDeclarationNode.typedBindingPattern().bindingPattern().toString().trim().equals(clientName)) { - TypeDescriptorNode typeDescriptorNode = - moduleVariableDeclarationNode.typedBindingPattern().typeDescriptor(); - connectorType = getClientModuleName(typeDescriptorNode); - Optional metadataNode = moduleVariableDeclarationNode.metadata(); - if (metadataNode.isPresent()) { - NodeList annotationNodes = metadataNode.get().annotations(); - serviceId = GeneratorUtils.getServiceAnnotation(annotationNodes, this.filePath).getId(); - } - } - } - - private String getClientModuleName(TypeDescriptorNode typeDescriptorNode) { - - String clientModuleName = null; - if (typeDescriptorNode instanceof QualifiedNameReferenceNode) { - QualifiedNameReferenceNode clientNode = (QualifiedNameReferenceNode) typeDescriptorNode; - Optional listenerSymbol = semanticModel.symbol(clientNode); - if (listenerSymbol.isPresent() && (listenerSymbol.get() instanceof TypeReferenceTypeSymbol)) { - clientModuleName = ((TypeReferenceTypeSymbol) - listenerSymbol.get()).signature().trim().replace(CLIENT, ""); - } else { - clientModuleName = clientNode.modulePrefix().text().trim(); - } - } else if (typeDescriptorNode instanceof SimpleNameReferenceNode) { - Optional optionalSymbol = semanticModel.symbol(typeDescriptorNode); - if (optionalSymbol.isPresent() && optionalSymbol.get() instanceof TypeReferenceTypeSymbol) { - TypeReferenceTypeSymbol typeReferenceTypeSymbol = (TypeReferenceTypeSymbol) optionalSymbol.get(); - clientModuleName = typeReferenceTypeSymbol.signature().trim(); - } - } - return clientModuleName; - } - - @Override - public void visit(TypeDefinitionNode typeDefinitionNode) { - - // no-op overloaded method to avoid unnecessary syntax tree visits - } - - @Override - public void visit(ImportDeclarationNode importDeclarationNode) { - - } - - @Override - public void visit(EnumDeclarationNode enumDeclarationNode) { - - } - - @Override - public void visit(FunctionDefinitionNode functionDefinitionNode) { - - } - - @Override - public void visit(ClassDefinitionNode classDefinitionNode) { - - } - -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Service.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Service.java index e5a8814bdc45..2aec41592ae9 100644 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Service.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Service.java @@ -36,9 +36,10 @@ public class Service extends ModelElement { private final List resources; private final ServiceAnnotation annotation; private final List remoteFunctions; + private final List interactions; public Service(String path, String serviceId, String serviceType, List resources, - List remoteFunctions, ServiceAnnotation annotation, + List remoteFunctions, ServiceAnnotation annotation, List interactions, ElementLocation elementLocation) { super(elementLocation); this.annotation = annotation; @@ -47,6 +48,7 @@ public Service(String path, String serviceId, String serviceType, List this.serviceType = serviceType; this.resources = resources; this.remoteFunctions = remoteFunctions; + this.interactions = interactions; } public String getPath() { From 1471fab08699d792707a791e7fbe97e92c0233a9 Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Tue, 6 Dec 2022 17:08:03 +0530 Subject: [PATCH 177/450] Fix spotbug errors --- .../service/nodevisitors/ActionNodeVisitor.java | 6 +++--- .../ServiceDeclarationNodeVisitor.java | 2 +- .../ServiceMemberFunctionNodeVisitor.java | 6 ------ .../model/service/Service.java | 17 ++++++++++------- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ActionNodeVisitor.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ActionNodeVisitor.java index a98ce1531cbf..c18952d88261 100644 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ActionNodeVisitor.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ActionNodeVisitor.java @@ -18,7 +18,6 @@ package io.ballerina.architecturemodelgenerator.generators.service.nodevisitors; -import io.ballerina.architecturemodelgenerator.generators.GeneratorUtils; import io.ballerina.architecturemodelgenerator.model.service.Interaction; import io.ballerina.architecturemodelgenerator.model.service.ResourceId; import io.ballerina.compiler.api.ModuleID; @@ -59,6 +58,7 @@ import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.FORWARD_SLASH; import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.TYPE_MAP; import static io.ballerina.architecturemodelgenerator.generators.GeneratorUtils.getClientModuleName; +import static io.ballerina.architecturemodelgenerator.generators.GeneratorUtils.getElementLocation; import static io.ballerina.architecturemodelgenerator.generators.GeneratorUtils.getServiceAnnotation; /** @@ -99,7 +99,7 @@ public void visit(ClientResourceAccessActionNode clientResourceAccessActionNode) Interaction interaction = new Interaction( new ResourceId(serviceId, resourceMethod, resourcePath), - getClientModuleName(clientNode, semanticModel), GeneratorUtils.getElementLocation(filePath, + getClientModuleName(clientNode, semanticModel), getElementLocation(filePath, clientResourceAccessActionNode.lineRange())); interactionList.add(interaction); } @@ -131,7 +131,7 @@ public void visit(RemoteMethodCallActionNode remoteMethodCallActionNode) { Interaction interaction = new Interaction(new ResourceId(serviceId, resourceMethod, null), getClientModuleName(clientNode, semanticModel), - GeneratorUtils.getElementLocation(filePath, remoteMethodCallActionNode.lineRange())); + getElementLocation(filePath, remoteMethodCallActionNode.lineRange())); interactionList.add(interaction); } } diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java index acf690641933..345e392f07d7 100644 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java @@ -109,7 +109,7 @@ public void visit(ServiceDeclarationNode serviceDeclarationNode) { serviceDeclarationNode.accept(serviceMemberFunctionNodeVisitor); services.add(new Service(serviceName.trim(), serviceAnnotation.getId(), getServiceType(serviceDeclarationNode), serviceMemberFunctionNodeVisitor.getResources(), - serviceMemberFunctionNodeVisitor.getRemoteFunctions(), serviceAnnotation, + serviceAnnotation, serviceMemberFunctionNodeVisitor.getRemoteFunctions(), serviceMemberFunctionNodeVisitor.getInteractionList(), GeneratorUtils.getElementLocation(filePath.toString(), serviceDeclarationNode.lineRange()))); } diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java index 5686b58c7c68..bdb52deeaae2 100644 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java @@ -20,7 +20,6 @@ import io.ballerina.architecturemodelgenerator.ComponentModel; import io.ballerina.architecturemodelgenerator.ProjectDesignConstants.ParameterIn; -import io.ballerina.architecturemodelgenerator.generators.GeneratorUtils; import io.ballerina.architecturemodelgenerator.model.ElementLocation; import io.ballerina.architecturemodelgenerator.model.service.FunctionParameter; import io.ballerina.architecturemodelgenerator.model.service.Interaction; @@ -29,7 +28,6 @@ import io.ballerina.architecturemodelgenerator.model.service.ResourceId; import io.ballerina.architecturemodelgenerator.model.service.ResourceParameter; import io.ballerina.compiler.api.SemanticModel; -import io.ballerina.compiler.api.symbols.Annotatable; import io.ballerina.compiler.api.symbols.ArrayTypeSymbol; import io.ballerina.compiler.api.symbols.ClassSymbol; import io.ballerina.compiler.api.symbols.MethodSymbol; @@ -45,10 +43,8 @@ import io.ballerina.compiler.syntax.tree.AnnotationNode; import io.ballerina.compiler.syntax.tree.ConstantDeclarationNode; import io.ballerina.compiler.syntax.tree.DefaultableParameterNode; -import io.ballerina.compiler.syntax.tree.FieldAccessExpressionNode; import io.ballerina.compiler.syntax.tree.FunctionDefinitionNode; import io.ballerina.compiler.syntax.tree.FunctionSignatureNode; -import io.ballerina.compiler.syntax.tree.NameReferenceNode; import io.ballerina.compiler.syntax.tree.Node; import io.ballerina.compiler.syntax.tree.NodeList; import io.ballerina.compiler.syntax.tree.NodeVisitor; @@ -58,9 +54,7 @@ import io.ballerina.compiler.syntax.tree.ResourcePathParameterNode; import io.ballerina.compiler.syntax.tree.ReturnTypeDescriptorNode; import io.ballerina.compiler.syntax.tree.SeparatedNodeList; -import io.ballerina.compiler.syntax.tree.SimpleNameReferenceNode; import io.ballerina.compiler.syntax.tree.SyntaxKind; -import io.ballerina.compiler.syntax.tree.Token; import io.ballerina.compiler.syntax.tree.TypedBindingPatternNode; import io.ballerina.compiler.syntax.tree.VariableDeclarationNode; import io.ballerina.projects.Package; diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Service.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Service.java index 2aec41592ae9..add5cce304a0 100644 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Service.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Service.java @@ -39,14 +39,14 @@ public class Service extends ModelElement { private final List interactions; public Service(String path, String serviceId, String serviceType, List resources, - List remoteFunctions, ServiceAnnotation annotation, List interactions, + ServiceAnnotation annotation, List remoteFunctions, List interactions, ElementLocation elementLocation) { super(elementLocation); - this.annotation = annotation; this.path = path; this.serviceId = serviceId; this.serviceType = serviceType; this.resources = resources; + this.annotation = annotation; this.remoteFunctions = remoteFunctions; this.interactions = interactions; } @@ -59,20 +59,23 @@ public String getServiceId() { return serviceId; } + public String getServiceType() { + return serviceType; + } + public List getResources() { return resources; } - public String getServiceType() { - return serviceType; + public ServiceAnnotation getAnnotation() { + return annotation; } public List getRemoteFunctions() { return remoteFunctions; } - public ServiceAnnotation getAnnotation() { - return annotation; + public List getInteractions() { + return interactions; } - } From f0466421aecf47c36fe679ab5ecc5a95b86a7eca Mon Sep 17 00:00:00 2001 From: HindujaB Date: Thu, 8 Dec 2022 10:51:34 +0530 Subject: [PATCH 178/450] Address review comments --- .../jvm/runtime/api/tests/TypeReference.java | 133 ++++++------------ 1 file changed, 46 insertions(+), 87 deletions(-) diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java index ab735a47281d..1f403c39c7da 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java @@ -84,17 +84,11 @@ public static Boolean validateFunctionType(BTypedesc typedesc) { throw error; } } - - if (functionType.getReturnType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { - throw error; - } - - if (functionType.getReturnParameterType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { - throw error; - } - Type restType = functionType.getRestType(); - if (((BArrayType) restType).getElementType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + + if (functionType.getReturnType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG || + functionType.getReturnParameterType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG || + (((BArrayType) restType).getElementType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG)) { throw error; } return true; @@ -105,13 +99,10 @@ public static Boolean validateIntersectionType(BTypedesc typedesc) { intersectionType = (BIntersectionType) ((ReferenceType) typedesc.getDescribingType()).getReferredType(); BError error = ErrorCreator.createError( StringUtils.fromString("intersection type API provided a non type reference type.")); - - if (intersectionType.getEffectiveType().getTag() != TypeTags.RECORD_TYPE_TAG) { - throw error; - } - List constituentTypes = intersectionType.getConstituentTypes(); - if (constituentTypes.get(0).getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + + if (intersectionType.getEffectiveType().getTag() != TypeTags.RECORD_TYPE_TAG || + (constituentTypes.get(0).getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG)) { throw error; } return true; @@ -119,11 +110,10 @@ public static Boolean validateIntersectionType(BTypedesc typedesc) { public static Boolean validateMapType(BTypedesc typedesc) { BMapType mapType = (BMapType) ((ReferenceType) typedesc.getDescribingType()).getReferredType(); - BError error = ErrorCreator.createError(StringUtils.fromString("map type API provided a non type reference " + - "type.")); if (mapType.getConstrainedType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { - throw error; + throw ErrorCreator.createError(StringUtils.fromString("map type API provided a non type reference " + + "type.")); } return true; } @@ -131,45 +121,32 @@ public static Boolean validateMapType(BTypedesc typedesc) { public static Boolean validateRecordType(BTypedesc typedesc) { BRecordType recordType = (BRecordType) (TypeUtils.getReferredType(typedesc.getDescribingType())); - BError error = ErrorCreator.createError(StringUtils.fromString("record type API provided a non type reference" + - " type.")); if (recordType.getRestFieldType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { - throw error; + throw ErrorCreator.createError(StringUtils.fromString("record type API provided a non type reference" + + " type.")); } return true; } public static Boolean validateStreamType(BTypedesc value1, BStream value2) { BStreamType streamType = (BStreamType) ((ReferenceType) value1.getDescribingType()).getReferredType(); - BError error = ErrorCreator.createError(StringUtils.fromString("stream API provided a non type reference" + - " type.")); - if (streamType.getConstrainedType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { - throw error; - } - if (streamType.getCompletionType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { - throw error; - } - if (value2.getConstraintType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { - throw error; - } - if (value2.getCompletionType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { - throw error; + if (streamType.getConstrainedType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG || + streamType.getCompletionType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG || + value2.getConstraintType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG || + value2.getCompletionType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw ErrorCreator.createError(StringUtils.fromString("stream API provided a non type reference" + + " type.")); } return true; } public static Boolean validateTableType(BTypedesc typedesc, TableValue tableValue) { BTableType tableType = (BTableType) ((ReferenceType) typedesc.getDescribingType()).getReferredType(); - BError error = ErrorCreator.createError(StringUtils.fromString("table type API provided a non type reference" + - " type.")); - if (tableType.getConstrainedType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { - throw error; - } - if (tableValue.getKeyType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { - throw error; - } - if (tableValue.getType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { - throw error; + if (tableType.getConstrainedType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG || + tableValue.getKeyType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG || + tableValue.getType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw ErrorCreator.createError(StringUtils.fromString("table type API provided a non type reference" + + " type.")); } return true; } @@ -193,10 +170,9 @@ public static Boolean validateTupleType(BTypedesc typedesc) { public static Boolean validateTypedescType(BTypedesc typedesc) { BTypedescType typedescType = (BTypedescType) ((ReferenceType) typedesc.getDescribingType()).getReferredType(); - BError error = ErrorCreator.createError(StringUtils.fromString("typdesc type API provided a non type " + - "reference type.")); if (typedescType.getConstraint().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { - throw error; + throw ErrorCreator.createError(StringUtils.fromString("typdesc type API provided a non type " + + "reference type.")); } return true; } @@ -241,10 +217,9 @@ public static Boolean validateParameterizedType(ObjectValue objectValue) { public static Boolean validateTypeUtilsAPI(BTypedesc typedesc) { Type type = typedesc.getDescribingType(); - BError error = ErrorCreator.createError(StringUtils.fromString("TypeUtils API provided a non type " + - "reference type.")); if (!TypeUtils.isValueType(type)) { - throw error; + throw ErrorCreator.createError(StringUtils.fromString("TypeUtils API provided a non type " + + "reference type.")); } return true; } @@ -254,80 +229,64 @@ public static Object getInt(ObjectValue objectValue, BTypedesc td) { } public static Boolean validateBArray(BArray value1, BArray value2) { - BError error = ErrorCreator.createError(StringUtils.fromString("BArray getType API provided a non type " + - "reference type.")); if (value1.getType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG || - value2.getType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { - throw error; - } - if (value1.getElementType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { - throw error; + value2.getType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG || + value1.getElementType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { + throw ErrorCreator.createError(StringUtils.fromString("BArray getType API provided a non type " + + "reference type.")); } return true; } public static Boolean validateBMap(BMap value1, BMap value2) { - BError error = ErrorCreator.createError(StringUtils.fromString("BMap getType API provided a non type " + - "reference type.")); if (value1.getType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG || value2.getType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { - throw error; + throw ErrorCreator.createError(StringUtils.fromString("BMap getType API provided a non type " + + "reference type.")); } return true; } public static Boolean validateBError(BError value) { - BError error = ErrorCreator.createError(StringUtils.fromString("BError getType API provided a non type " + - "reference type.")); if (value.getType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { - throw error; + throw ErrorCreator.createError(StringUtils.fromString("BError getType API provided a non type " + + "reference type.")); } return true; } public static Boolean validateBFunctionPointer(BFunctionPointer value) { - BError error = ErrorCreator.createError(StringUtils.fromString("Function Pointer getType API provided a non " + - "type reference type.")); if (value.getType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { - throw error; + throw ErrorCreator.createError(StringUtils.fromString("Function Pointer getType API provided a non " + + "type reference type.")); } return true; } public static Boolean validateBObject(BObject value) { - BError error = ErrorCreator.createError(StringUtils.fromString("BObject getType API provided a non type " + - "reference type.")); if (value.getType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { - throw error; + throw ErrorCreator.createError(StringUtils.fromString("BObject getType API provided a non type " + + "reference type.")); } return true; } public static boolean validateUnionTypeNarrowing(Object value, BTypedesc typedesc) { Type describingType = typedesc.getDescribingType(); - BError error = ErrorCreator.createError(StringUtils.fromString("RefValue getType API provided a wrong type " + - "reference type.")); Type type = TypeChecker.getType(value); - if (type.getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { - throw error; - } - if (type.getTag() != describingType.getTag() || !type.toString().equals(describingType.toString())) { - throw error; + if (type.getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG || + type.getTag() != describingType.getTag() || !type.toString().equals(describingType.toString())) { + throw ErrorCreator.createError(StringUtils.fromString("RefValue getType API provided a wrong type " + + "reference type.")); } return true; } public static boolean validateTableKeys(BTable table) { - BError error = ErrorCreator.createError(StringUtils.fromString("Table keys does not provide type-reference " + - "type.")); - if (table.getType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG) { - throw error; - } - if (table.size() != 1) { - throw error; - } - if (table.getKeyType().getTag() != TypeTags.TUPLE_TAG) { - throw error; + if (table.getType().getTag() != TypeTags.TYPE_REFERENCED_TYPE_TAG || table.size() != 1 || + table.getKeyType().getTag() != TypeTags.TUPLE_TAG) { + throw ErrorCreator.createError(StringUtils.fromString("Table keys does not provide type-reference " + + "type.")); } return true; } From c0683c1b831146523f4f44584750f54569b968c9 Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Thu, 8 Dec 2022 13:40:56 +0530 Subject: [PATCH 179/450] Add dependency model to track dependencies --- .../ServiceDeclarationNodeVisitor.java | 2 +- .../ServiceMemberFunctionNodeVisitor.java | 79 ++++++++++++++----- .../model/service/Dependency.java | 46 +++++++++++ .../model/service/Service.java | 10 +-- 4 files changed, 110 insertions(+), 27 deletions(-) create mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Dependency.java diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java index 345e392f07d7..9eccf8ccc0e4 100644 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java @@ -110,7 +110,7 @@ public void visit(ServiceDeclarationNode serviceDeclarationNode) { services.add(new Service(serviceName.trim(), serviceAnnotation.getId(), getServiceType(serviceDeclarationNode), serviceMemberFunctionNodeVisitor.getResources(), serviceAnnotation, serviceMemberFunctionNodeVisitor.getRemoteFunctions(), - serviceMemberFunctionNodeVisitor.getInteractionList(), + serviceMemberFunctionNodeVisitor.getDependencyList(), GeneratorUtils.getElementLocation(filePath.toString(), serviceDeclarationNode.lineRange()))); } diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java index bdb52deeaae2..e9b8f9f2faf3 100644 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java @@ -21,8 +21,8 @@ import io.ballerina.architecturemodelgenerator.ComponentModel; import io.ballerina.architecturemodelgenerator.ProjectDesignConstants.ParameterIn; import io.ballerina.architecturemodelgenerator.model.ElementLocation; +import io.ballerina.architecturemodelgenerator.model.service.Dependency; import io.ballerina.architecturemodelgenerator.model.service.FunctionParameter; -import io.ballerina.architecturemodelgenerator.model.service.Interaction; import io.ballerina.architecturemodelgenerator.model.service.RemoteFunction; import io.ballerina.architecturemodelgenerator.model.service.Resource; import io.ballerina.architecturemodelgenerator.model.service.ResourceId; @@ -50,12 +50,14 @@ import io.ballerina.compiler.syntax.tree.NodeVisitor; import io.ballerina.compiler.syntax.tree.ObjectFieldNode; import io.ballerina.compiler.syntax.tree.ParameterNode; +import io.ballerina.compiler.syntax.tree.ParenthesisedTypeDescriptorNode; import io.ballerina.compiler.syntax.tree.RequiredParameterNode; import io.ballerina.compiler.syntax.tree.ResourcePathParameterNode; import io.ballerina.compiler.syntax.tree.ReturnTypeDescriptorNode; import io.ballerina.compiler.syntax.tree.SeparatedNodeList; import io.ballerina.compiler.syntax.tree.SyntaxKind; import io.ballerina.compiler.syntax.tree.TypedBindingPatternNode; +import io.ballerina.compiler.syntax.tree.UnionTypeDescriptorNode; import io.ballerina.compiler.syntax.tree.VariableDeclarationNode; import io.ballerina.projects.Package; @@ -80,7 +82,7 @@ public class ServiceMemberFunctionNodeVisitor extends NodeVisitor { private final Package currentPackage; private List resources = new LinkedList<>(); private List remoteFunctions = new LinkedList<>(); - private final List interactionList = new LinkedList<>(); + private final List dependencyList = new LinkedList<>(); private final ComponentModel.PackageId packageId; private final String filePath; @@ -102,8 +104,8 @@ public List getRemoteFunctions() { return remoteFunctions; } - public List getInteractionList() { - return interactionList; + public List getDependencyList() { + return dependencyList; } @Override @@ -318,25 +320,22 @@ private List getReturnTypes(FunctionDefinitionNode functionDefinitionNod @Override public void visit(ObjectFieldNode objectFieldNode) { - Node fieldTypeName = objectFieldNode.typeName(); - Optional fieldTypeNameSymbol = semanticModel.symbol(fieldTypeName); - if (fieldTypeNameSymbol.isPresent()) { - TypeDescKind fieldTypeNameTypeDescKind = ((TypeSymbol) fieldTypeNameSymbol.get()).typeKind(); - if (fieldTypeNameTypeDescKind.equals(TypeDescKind.TYPE_REFERENCE)) { - TypeReferenceTypeSymbol fieldTypeNameTypeRefSymbol = - (TypeReferenceTypeSymbol) fieldTypeNameSymbol.get(); - SymbolKind fieldTypeNameSymbolKind = fieldTypeNameTypeRefSymbol.definition().kind(); - if (fieldTypeNameSymbolKind.equals(SymbolKind.CLASS)) { - ClassSymbol fieldRefClassSymbol = (ClassSymbol) fieldTypeNameTypeRefSymbol.typeDescriptor(); - boolean isClientClass = fieldRefClassSymbol.qualifiers().stream() + Node fieldTypeName = getReferredNode(objectFieldNode.typeName()); + if (fieldTypeName != null) { + Optional fieldTypeNameSymbol = semanticModel.symbol(fieldTypeName); + if (fieldTypeNameSymbol.isPresent()) { + ClassSymbol referredClassSymbol = getReferredClassSymbol((TypeSymbol) fieldTypeNameSymbol.get()); + if (referredClassSymbol != null) { + boolean isClientClass = referredClassSymbol.qualifiers().stream() .anyMatch(qualifier -> qualifier.equals(Qualifier.CLIENT)); - if (isClientClass && objectFieldNode.metadata().isPresent()) { - String serviceId = - getServiceAnnotation(objectFieldNode.metadata().get().annotations(), filePath).getId(); - Interaction interaction = new Interaction(new ResourceId(serviceId, - null, null), getClientModuleName((TypeSymbol) fieldTypeNameSymbol.get()), + if (isClientClass) { + String serviceId = objectFieldNode.metadata().isPresent() ? + getServiceAnnotation(objectFieldNode.metadata().get().annotations(), filePath).getId() : + null; + Dependency dependency = new Dependency(serviceId, + getClientModuleName((TypeSymbol) fieldTypeNameSymbol.get()), getElementLocation(filePath, objectFieldNode.lineRange())); - interactionList.add(interaction); + dependencyList.add(dependency); } } } @@ -353,4 +352,42 @@ public void visit(VariableDeclarationNode variableDeclarationNode) { public void visit(ConstantDeclarationNode constantDeclarationNode) { } + + private Node getReferredNode(Node typeName) { + Node qualifiedNameRefNode = null; + if (typeName.kind().equals(SyntaxKind.QUALIFIED_NAME_REFERENCE) || + typeName.kind().equals(SyntaxKind.SIMPLE_NAME_REFERENCE)) { + qualifiedNameRefNode = typeName; + } else if (typeName.kind().equals(SyntaxKind.UNION_TYPE_DESC)) { + Node leftTypeDescNode = getReferredNode(((UnionTypeDescriptorNode) typeName).leftTypeDesc()); + Node rightTypeDescNode = getReferredNode(((UnionTypeDescriptorNode) typeName).rightTypeDesc()); + if (leftTypeDescNode != null && (leftTypeDescNode.kind().equals(SyntaxKind.QUALIFIED_NAME_REFERENCE) || + leftTypeDescNode.kind().equals(SyntaxKind.SIMPLE_NAME_REFERENCE))) { + qualifiedNameRefNode = leftTypeDescNode; + } + if (rightTypeDescNode != null && (rightTypeDescNode.kind().equals(SyntaxKind.QUALIFIED_NAME_REFERENCE) || + rightTypeDescNode.kind().equals(SyntaxKind.SIMPLE_NAME_REFERENCE))) { + qualifiedNameRefNode = rightTypeDescNode; + } + } else if (typeName.kind().equals(SyntaxKind.PARENTHESISED_TYPE_DESC)) { + Node typeDescNode = getReferredNode(((ParenthesisedTypeDescriptorNode) typeName).typedesc()); + if (typeDescNode != null && (typeDescNode.kind().equals(SyntaxKind.QUALIFIED_NAME_REFERENCE) || + typeDescNode.kind().equals(SyntaxKind.SIMPLE_NAME_REFERENCE))) { + qualifiedNameRefNode = typeDescNode; + } + } + return qualifiedNameRefNode; + } + + private ClassSymbol getReferredClassSymbol(TypeSymbol symbol) { + ClassSymbol classSymbol = null; + if (symbol.kind().equals(SymbolKind.CLASS)) { + classSymbol = (ClassSymbol) symbol; + } else if (symbol.typeKind().equals(TypeDescKind.TYPE_REFERENCE)) { + TypeReferenceTypeSymbol typeRefTypeSymbol = (TypeReferenceTypeSymbol) symbol; + TypeSymbol typeDescTypeSymbol = typeRefTypeSymbol.typeDescriptor(); + classSymbol = getReferredClassSymbol(typeDescTypeSymbol); + } + return classSymbol; + } } diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Dependency.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Dependency.java new file mode 100644 index 000000000000..07a2f1203a38 --- /dev/null +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Dependency.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.ballerina.architecturemodelgenerator.model.service; + +import io.ballerina.architecturemodelgenerator.model.ElementLocation; +import io.ballerina.architecturemodelgenerator.model.ModelElement; + +/** + * Represent the dependency of another service. + * + * @since 2201.2.2 + */ +public class Dependency extends ModelElement { + private final String serviceId; + private final String connectorType; + + public Dependency(String serviceId, String connectorType, ElementLocation elementLocation) { + super(elementLocation); + this.serviceId = serviceId; + this.connectorType = connectorType; + } + + public String getServiceId() { + return serviceId; + } + + public String getConnectorType() { + return connectorType; + } +} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Service.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Service.java index add5cce304a0..6415903d382f 100644 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Service.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Service.java @@ -36,10 +36,10 @@ public class Service extends ModelElement { private final List resources; private final ServiceAnnotation annotation; private final List remoteFunctions; - private final List interactions; + private final List dependencies; public Service(String path, String serviceId, String serviceType, List resources, - ServiceAnnotation annotation, List remoteFunctions, List interactions, + ServiceAnnotation annotation, List remoteFunctions, List dependencies, ElementLocation elementLocation) { super(elementLocation); this.path = path; @@ -48,7 +48,7 @@ public Service(String path, String serviceId, String serviceType, List this.resources = resources; this.annotation = annotation; this.remoteFunctions = remoteFunctions; - this.interactions = interactions; + this.dependencies = dependencies; } public String getPath() { @@ -75,7 +75,7 @@ public List getRemoteFunctions() { return remoteFunctions; } - public List getInteractions() { - return interactions; + public List getDependencies() { + return dependencies; } } From b8f6b0c10f4db76f00becd600de2b3591b78dc43 Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Thu, 8 Dec 2022 14:05:20 +0530 Subject: [PATCH 180/450] Update connector type of Client declaration Update client declaration nodes referred type to be used as Dependency models connector type --- .../generators/GeneratorUtils.java | 6 +++++- .../nodevisitors/ServiceMemberFunctionNodeVisitor.java | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/GeneratorUtils.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/GeneratorUtils.java index d1d22254cfc2..b157798bcd22 100644 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/GeneratorUtils.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/GeneratorUtils.java @@ -146,6 +146,10 @@ public static String getClientModuleName(Node clientNode, SemanticModel semantic } public static String getClientModuleName(TypeSymbol typeSymbol) { - return typeSymbol.signature().trim().replace(CLIENT, ""); + String clientModuleName = typeSymbol.signature().trim().replace(CLIENT, ""); + if (typeSymbol.getModule().isPresent()) { + clientModuleName = typeSymbol.getModule().get().id().toString();; + } + return clientModuleName; } } diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java index e9b8f9f2faf3..d7ef3336e562 100644 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java @@ -333,7 +333,7 @@ public void visit(ObjectFieldNode objectFieldNode) { getServiceAnnotation(objectFieldNode.metadata().get().annotations(), filePath).getId() : null; Dependency dependency = new Dependency(serviceId, - getClientModuleName((TypeSymbol) fieldTypeNameSymbol.get()), + getClientModuleName(referredClassSymbol), getElementLocation(filePath, objectFieldNode.lineRange())); dependencyList.add(dependency); } From 79cce29122bc5a6978de39b24c40139ce9e754d5 Mon Sep 17 00:00:00 2001 From: Nadeeshan96 Date: Thu, 8 Dec 2022 16:46:48 +0530 Subject: [PATCH 181/450] Change code coverage isRequiredFile method --- .../test/runtime/util/CodeCoverageUtils.java | 16 ++++------------ .../testerina/test/CodeCoverageReportTest.java | 5 +---- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/CodeCoverageUtils.java b/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/CodeCoverageUtils.java index 312f3b2ac106..e133815dd613 100644 --- a/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/CodeCoverageUtils.java +++ b/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/CodeCoverageUtils.java @@ -130,18 +130,10 @@ public static void unzipCompiledSource(Path source, Path destination, String org private static boolean isRequiredFile(String path, String orgName, boolean enableIncludesFilter, String includesInCoverage) { - if (path.contains("$_init") || path.contains("META-INF") || path.contains("/tests/")) { - return false; - } else if (path.contains("Frame") && path.contains("module")) { - return false; - } else if (path.contains("Frame") && path.contains(orgName)) { - return false; - } else if (path.contains("module-info.class")) { - return false; - } else if (enableIncludesFilter && !isIncluded(path, includesInCoverage)) { - return false; - } - return true; + return !(path.contains("$_init") || path.contains("META-INF") || path.contains("/tests/") + || (path.contains("$frame$") && path.contains("module")) + || (path.contains("$frame$") && path.contains(orgName)) || path.contains("module-info.class") + || (enableIncludesFilter && !isIncluded(path, includesInCoverage))); } private static String normalizeRegexPattern(String pattern) { diff --git a/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/CodeCoverageReportTest.java b/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/CodeCoverageReportTest.java index 1b9aeba318ea..21f7fe63e952 100644 --- a/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/CodeCoverageReportTest.java +++ b/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/CodeCoverageReportTest.java @@ -174,7 +174,7 @@ public void normalizedCoverageClassTest() throws BallerinaTestException { } /** - * Get the expected class elements per each package element in covergae XML. + * Get the expected class elements per each package element in coverage XML. * * @return HashMap> */ @@ -271,9 +271,6 @@ private void validateClassNames(HashMap> expectedClassMap) if ("class".equals(actualClassList.item(j).getNodeName())) { String className = actualClassList.item(j).getAttributes(). getNamedItem("name").getNodeValue(); - if (className.contains("$frame$")) { - continue; - } if (expectedClassMap.get(packageName).contains(className)) { Assert.assertTrue(true); } else { From 2921db63454db70e8f8dce6c62bfbdc259ac6a7c Mon Sep 17 00:00:00 2001 From: Nadeeshan96 Date: Thu, 8 Dec 2022 17:30:09 +0530 Subject: [PATCH 182/450] Move frames into a separate folder --- .../wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java index 579ce703386f..458c4d39861a 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java @@ -335,7 +335,7 @@ public class JvmConstants { public static final String FILE_NAME_PERIOD_SEPERATOR = "$$$"; public static final String VALUE_CLASS_PREFIX = "$value$"; public static final String TYPEDESC_CLASS_PREFIX = "$typedesc$"; - public static final String FRAME_CLASS_PREFIX = "$frame$"; + public static final String FRAME_CLASS_PREFIX = "frames/$frame$"; public static final String BALLERINA = "ballerina"; public static final String ENCODED_DOT_CHARACTER = "$0046"; public static final PackageID DEFAULT = new PackageID(Names.ANON_ORG, new Name(ENCODED_DOT_CHARACTER), From 5ba3e7663faa945461cd2fd3580e35a137c34d70 Mon Sep 17 00:00:00 2001 From: Nipuna Ranasinghe Date: Wed, 26 Oct 2022 10:24:01 +0530 Subject: [PATCH 183/450] Fix inferred typedesc parameter handling for function invocation evaluations --- .../evaluation/EvaluationExceptionKind.java | 3 +++ .../engine/InvocationArgProcessor.java | 23 ++++++++++++------- .../engine/NodeBasedArgProcessor.java | 10 ++++---- .../MethodCallExpressionEvaluator.java | 3 +-- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/EvaluationExceptionKind.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/EvaluationExceptionKind.java index 97d1b22418fa..07cba82639ff 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/EvaluationExceptionKind.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/EvaluationExceptionKind.java @@ -48,6 +48,9 @@ public enum EvaluationExceptionKind { MISSING_MESSAGE_IN_ERROR("Missing error message in error constructor"), REST_ARG_IN_ERROR("Rest args are not allowed in error constructor"), ADDITIONAL_ARG_IN_ERROR("Additional positional arg in error constructor"), + + CANNOT_INFER_PARAM_TYPE("Can not infer type for parameter '%s' in function '%s'. Consider passing" + + "the parameter value explicitly as an argument"), VARIABLE_EXECUTION_ERROR("Internal error occurred when processing variable: '%s'"), NON_PUBLIC_OR_UNDEFINED_ACCESS("Attempt to refer to undefined/non-accessible symbol '%s:%s'"), BLOCK_EVALUATION("Block expressions/statements are not supported"), diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/InvocationArgProcessor.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/InvocationArgProcessor.java index 401facd34c34..9456794817ff 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/InvocationArgProcessor.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/InvocationArgProcessor.java @@ -30,6 +30,7 @@ import io.ballerina.compiler.syntax.tree.Node; import io.ballerina.compiler.syntax.tree.NonTerminalNode; import io.ballerina.compiler.syntax.tree.ParameterNode; +import io.ballerina.compiler.syntax.tree.SyntaxKind; import io.ballerina.tools.text.TextRange; import org.ballerinalang.debugadapter.EvaluationContext; import org.ballerinalang.debugadapter.SuspendedContext; @@ -47,6 +48,7 @@ import java.util.stream.Collectors; import static org.ballerinalang.debugadapter.evaluation.EvaluationException.createEvaluationException; +import static org.ballerinalang.debugadapter.evaluation.EvaluationExceptionKind.CANNOT_INFER_PARAM_TYPE; import static org.ballerinalang.debugadapter.evaluation.EvaluationExceptionKind.FUNCTION_EXECUTION_ERROR; import static org.ballerinalang.debugadapter.evaluation.EvaluationExceptionKind.OBJECT_METHOD_NOT_FOUND; import static org.ballerinalang.debugadapter.evaluation.engine.NodeBasedArgProcessor.getParameterName; @@ -90,7 +92,7 @@ protected InvocationArgProcessor(SuspendedContext context, String functionName, public abstract List process(List> argEvaluators) throws EvaluationException; protected List getOrderedArgList(Map namedArgValues, FunctionSymbol definitionSymbol, - FunctionSignatureNode definitionNode) throws EvaluationException { + FunctionDefinitionNode definitionNode) throws EvaluationException { try { List argValueList = new ArrayList<>(); List args = jdiMethodReference.arguments(); @@ -109,10 +111,10 @@ protected List getOrderedArgList(Map namedArgValues, Funct continue; } // If this is a defaultable parameter - if (namedArgValues.get(argName) == null && - namedArgValues.get(argName + DEFAULTABLE_PARAM_SUFFIX) != null) { + String defaultableArgName = argName + DEFAULTABLE_PARAM_SUFFIX; + if (namedArgValues.get(argName) == null && namedArgValues.get(defaultableArgName) != null) { if (definitionNode == null && definitionSymbol != null) { - definitionNode = getSyntaxTreeNodeFrom(argName.replace(DEFAULTABLE_PARAM_SUFFIX, ""), + definitionNode = getDefinitionNodeFrom(argName.replace(DEFAULTABLE_PARAM_SUFFIX, ""), definitionSymbol); } if (definitionNode != null) { @@ -172,12 +174,12 @@ protected static Value resolveType(SuspendedContext context, String arrayTypeNam return resolvedTypes.size() > 1 ? bTypeResolver.getUnionTypeFrom(resolvedTypes) : resolvedTypes.get(0); } - private FunctionSignatureNode getSyntaxTreeNodeFrom(String argName, FunctionSymbol definitionSymbol) + private FunctionDefinitionNode getDefinitionNodeFrom(String argName, FunctionSymbol definitionSymbol) throws EvaluationException { try { TextRange textRange = definitionSymbol.getLocation().get().textRange(); NonTerminalNode node = ((ModulePartNode) context.getDocument().syntaxTree().rootNode()).findNode(textRange); - return ((FunctionDefinitionNode) node).functionSignature(); + return (FunctionDefinitionNode) node; } catch (Exception e) { throw createEvaluationException(String.format("failed to evaluate the default value expression of the " + "parameter '%s' in function '%s'.", argName, functionName)); @@ -197,14 +199,19 @@ private static boolean isRestArg(Map.Entry arg) { } private static Value getDefaultValue(SuspendedContext context, LocalVariable localVariable, - FunctionSignatureNode functionDefinition) throws EvaluationException { + FunctionDefinitionNode functionDefinition) throws EvaluationException { String name = localVariable.name(); - Optional paramNode = functionDefinition.parameters().stream() + Optional paramNode = functionDefinition.functionSignature().parameters().stream() .filter(parameterNode -> getParameterName(parameterNode).equals(name)) .findFirst(); Node expression = ((DefaultableParameterNode) paramNode.get()).expression(); + if (expression.kind().equals(SyntaxKind.INFERRED_TYPEDESC_DEFAULT)) { + throw createEvaluationException(CANNOT_INFER_PARAM_TYPE, getParameterName(paramNode.get()), + functionDefinition.functionName().text()); + } + DebugExpressionEvaluator defaultValueEvaluator = new DebugExpressionEvaluator(new EvaluationContext(context)); defaultValueEvaluator.setExpression(expression.toSourceCode()); return defaultValueEvaluator.evaluate().getJdiValue(); diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/NodeBasedArgProcessor.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/NodeBasedArgProcessor.java index 5fa8d7567a50..60211cf10f96 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/NodeBasedArgProcessor.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/NodeBasedArgProcessor.java @@ -19,7 +19,7 @@ import com.sun.jdi.Method; import com.sun.jdi.Value; import io.ballerina.compiler.syntax.tree.DefaultableParameterNode; -import io.ballerina.compiler.syntax.tree.FunctionSignatureNode; +import io.ballerina.compiler.syntax.tree.FunctionDefinitionNode; import io.ballerina.compiler.syntax.tree.ParameterNode; import io.ballerina.compiler.syntax.tree.RequiredParameterNode; import io.ballerina.compiler.syntax.tree.RestParameterNode; @@ -50,10 +50,10 @@ */ public class NodeBasedArgProcessor extends InvocationArgProcessor { - private final FunctionSignatureNode definitionNode; + private final FunctionDefinitionNode definitionNode; public NodeBasedArgProcessor(SuspendedContext context, String functionName, Method jdiMethodReference, - FunctionSignatureNode definitionNode) { + FunctionDefinitionNode definitionNode) { super(context, functionName, jdiMethodReference); this.definitionNode = definitionNode; } @@ -72,8 +72,8 @@ public List process(List> argEvaluators) List params = new ArrayList<>(); Map remainingParams = new HashMap<>(); - if (!definitionNode.parameters().isEmpty()) { - for (ParameterNode paramNode : definitionNode.parameters()) { + if (!definitionNode.functionSignature().parameters().isEmpty()) { + for (ParameterNode paramNode : definitionNode.functionSignature().parameters()) { params.add(paramNode); remainingParams.put(getParameterName(paramNode), paramNode); } diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/MethodCallExpressionEvaluator.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/MethodCallExpressionEvaluator.java index 7270522fad2d..80bb089d5795 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/MethodCallExpressionEvaluator.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/MethodCallExpressionEvaluator.java @@ -233,9 +233,8 @@ private Value invokeLangLibMethod(BExpressionValue resultVar) throws EvaluationE } argEvaluators.add(0, new AbstractMap.SimpleEntry<>("", objectExpressionEvaluator)); - FunctionSignatureNode functionSignature = langLibFunctionDef.functionSignature(); NodeBasedArgProcessor argProcessor = new NodeBasedArgProcessor(context, methodName, langLibMethod - .getJDIMethodRef(), functionSignature); + .getJDIMethodRef(), langLibFunctionDef); List orderedArgsList = argProcessor.process(argEvaluators); langLibMethod.setArgValues(orderedArgsList); return langLibMethod.invokeSafely(); From 03a676092e3db99204450150a322a3f4cd8f3c3d Mon Sep 17 00:00:00 2001 From: Nipuna Ranasinghe Date: Mon, 28 Nov 2022 10:30:01 +0530 Subject: [PATCH 184/450] Add support for builtin simple name reference evaluations --- .../evaluation/EvaluatorBuilder.java | 44 +++++++++++++++++ .../engine/InvocationArgProcessor.java | 1 - .../BuiltinSimpleNameReferenceEvaluator.java | 49 +++++++++++++++++++ .../MethodCallExpressionEvaluator.java | 1 - 4 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/BuiltinSimpleNameReferenceEvaluator.java diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/EvaluatorBuilder.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/EvaluatorBuilder.java index f2e707e4b34f..e663af1a915f 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/EvaluatorBuilder.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/EvaluatorBuilder.java @@ -20,6 +20,7 @@ import io.ballerina.compiler.syntax.tree.BasicLiteralNode; import io.ballerina.compiler.syntax.tree.BinaryExpressionNode; import io.ballerina.compiler.syntax.tree.BracedExpressionNode; +import io.ballerina.compiler.syntax.tree.BuiltinSimpleNameReferenceNode; import io.ballerina.compiler.syntax.tree.ConditionalExpressionNode; import io.ballerina.compiler.syntax.tree.ErrorConstructorExpressionNode; import io.ballerina.compiler.syntax.tree.ExplicitAnonymousFunctionExpressionNode; @@ -63,6 +64,7 @@ import org.ballerinalang.debugadapter.evaluation.engine.expression.AnonFunctionExpressionEvaluator; import org.ballerinalang.debugadapter.evaluation.engine.expression.BasicLiteralEvaluator; import org.ballerinalang.debugadapter.evaluation.engine.expression.BinaryExpressionEvaluator; +import org.ballerinalang.debugadapter.evaluation.engine.expression.BuiltinSimpleNameReferenceEvaluator; import org.ballerinalang.debugadapter.evaluation.engine.expression.ConditionalExpressionEvaluator; import org.ballerinalang.debugadapter.evaluation.engine.expression.ErrorConstructorExpressionEvaluator; import org.ballerinalang.debugadapter.evaluation.engine.expression.FieldAccessExpressionEvaluator; @@ -481,6 +483,12 @@ public void visit(SimpleNameReferenceNode simpleNameReferenceNode) { result = new SimpleNameReferenceEvaluator(context, simpleNameReferenceNode); } + @Override + public void visit(BuiltinSimpleNameReferenceNode builtinSimpleNameReferenceNode) { + visitSyntaxNode(builtinSimpleNameReferenceNode); + result = new BuiltinSimpleNameReferenceEvaluator(context, builtinSimpleNameReferenceNode); + } + @Override public void visit(BasicLiteralNode basicLiteralNode) { visitSyntaxNode(basicLiteralNode); @@ -727,6 +735,42 @@ private void addRemoteMethodCallActionSyntax() { } private void addMiscellaneousSyntax() { + // typedesc expressions + supportedSyntax.add(SyntaxKind.RECORD_TYPE_DESC); + supportedSyntax.add(SyntaxKind.OBJECT_TYPE_DESC); + supportedSyntax.add(SyntaxKind.NIL_TYPE_DESC); + supportedSyntax.add(SyntaxKind.OPTIONAL_TYPE_DESC); + supportedSyntax.add(SyntaxKind.ARRAY_TYPE_DESC); + supportedSyntax.add(SyntaxKind.INT_TYPE_DESC); + supportedSyntax.add(SyntaxKind.BYTE_TYPE_DESC); + supportedSyntax.add(SyntaxKind.FLOAT_TYPE_DESC); + supportedSyntax.add(SyntaxKind.DECIMAL_TYPE_DESC); + supportedSyntax.add(SyntaxKind.STRING_TYPE_DESC); + supportedSyntax.add(SyntaxKind.BOOLEAN_TYPE_DESC); + supportedSyntax.add(SyntaxKind.XML_TYPE_DESC); + supportedSyntax.add(SyntaxKind.JSON_TYPE_DESC); + supportedSyntax.add(SyntaxKind.HANDLE_TYPE_DESC); + supportedSyntax.add(SyntaxKind.ANY_TYPE_DESC); + supportedSyntax.add(SyntaxKind.ANYDATA_TYPE_DESC); + supportedSyntax.add(SyntaxKind.NEVER_TYPE_DESC); + supportedSyntax.add(SyntaxKind.VAR_TYPE_DESC); + supportedSyntax.add(SyntaxKind.SERVICE_TYPE_DESC); + supportedSyntax.add(SyntaxKind.MAP_TYPE_DESC); + supportedSyntax.add(SyntaxKind.UNION_TYPE_DESC); + supportedSyntax.add(SyntaxKind.ERROR_TYPE_DESC); + supportedSyntax.add(SyntaxKind.STREAM_TYPE_DESC); + supportedSyntax.add(SyntaxKind.TABLE_TYPE_DESC); + supportedSyntax.add(SyntaxKind.FUNCTION_TYPE_DESC); + supportedSyntax.add(SyntaxKind.TUPLE_TYPE_DESC); + supportedSyntax.add(SyntaxKind.PARENTHESISED_TYPE_DESC); + supportedSyntax.add(SyntaxKind.READONLY_TYPE_DESC); + supportedSyntax.add(SyntaxKind.DISTINCT_TYPE_DESC); + supportedSyntax.add(SyntaxKind.INTERSECTION_TYPE_DESC); + supportedSyntax.add(SyntaxKind.SINGLETON_TYPE_DESC); + supportedSyntax.add(SyntaxKind.TYPE_REFERENCE_TYPE_DESC); + supportedSyntax.add(SyntaxKind.TYPEDESC_TYPE_DESC); + supportedSyntax.add(SyntaxKind.FUTURE_TYPE_DESC); + // braced expression supportedSyntax.add(SyntaxKind.BRACED_EXPRESSION); supportedSyntax.add(SyntaxKind.OPEN_PAREN_TOKEN); diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/InvocationArgProcessor.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/InvocationArgProcessor.java index 9456794817ff..3f752ad6dbba 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/InvocationArgProcessor.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/InvocationArgProcessor.java @@ -25,7 +25,6 @@ import io.ballerina.compiler.api.symbols.FunctionSymbol; import io.ballerina.compiler.syntax.tree.DefaultableParameterNode; import io.ballerina.compiler.syntax.tree.FunctionDefinitionNode; -import io.ballerina.compiler.syntax.tree.FunctionSignatureNode; import io.ballerina.compiler.syntax.tree.ModulePartNode; import io.ballerina.compiler.syntax.tree.Node; import io.ballerina.compiler.syntax.tree.NonTerminalNode; diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/BuiltinSimpleNameReferenceEvaluator.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/BuiltinSimpleNameReferenceEvaluator.java new file mode 100644 index 000000000000..069485a001c1 --- /dev/null +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/BuiltinSimpleNameReferenceEvaluator.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (http://wso2.com) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.ballerinalang.debugadapter.evaluation.engine.expression; + +import com.sun.jdi.Value; +import io.ballerina.compiler.syntax.tree.BuiltinSimpleNameReferenceNode; +import org.ballerinalang.debugadapter.EvaluationContext; +import org.ballerinalang.debugadapter.evaluation.BExpressionValue; +import org.ballerinalang.debugadapter.evaluation.EvaluationException; +import org.ballerinalang.debugadapter.evaluation.engine.Evaluator; +import org.ballerinalang.debugadapter.evaluation.engine.NameBasedTypeResolver; + +import java.util.List; + +/** + * Builtin simple name reference evaluator implementation. + * + * @since 2201.3.1 + */ +public class BuiltinSimpleNameReferenceEvaluator extends Evaluator { + + private final BuiltinSimpleNameReferenceNode syntaxNode; + + public BuiltinSimpleNameReferenceEvaluator(EvaluationContext context, BuiltinSimpleNameReferenceNode node) { + super(context); + this.syntaxNode = node; + } + + @Override + public BExpressionValue evaluate() throws EvaluationException { + NameBasedTypeResolver builtInTypeResolver = new NameBasedTypeResolver(evaluationContext); + List resolve = builtInTypeResolver.resolve(syntaxNode.name().text().trim()); + return new BExpressionValue(context, resolve.get(0)); + } +} diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/MethodCallExpressionEvaluator.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/MethodCallExpressionEvaluator.java index 80bb089d5795..49b7ed58d23e 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/MethodCallExpressionEvaluator.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/MethodCallExpressionEvaluator.java @@ -27,7 +27,6 @@ import io.ballerina.compiler.api.symbols.MethodSymbol; import io.ballerina.compiler.syntax.tree.ExpressionNode; import io.ballerina.compiler.syntax.tree.FunctionDefinitionNode; -import io.ballerina.compiler.syntax.tree.FunctionSignatureNode; import io.ballerina.compiler.syntax.tree.MethodCallExpressionNode; import io.ballerina.compiler.syntax.tree.RemoteMethodCallActionNode; import io.ballerina.projects.Package; From 24cb406e471463358c5fdf2312d8253a02f2b8bc Mon Sep 17 00:00:00 2001 From: Nipuna Ranasinghe Date: Wed, 23 Nov 2022 16:07:30 +0530 Subject: [PATCH 185/450] Add integration tests for builtin type evaluation --- .../ExpressionEvaluationBaseTest.java | 58 +++++++------------ .../ExpressionEvaluationNegativeTest.java | 6 ++ .../evaluation/ExpressionEvaluationTest.java | 19 ++++++ 3 files changed, 46 insertions(+), 37 deletions(-) diff --git a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationBaseTest.java b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationBaseTest.java index a96c8f47e11f..967c1178a199 100644 --- a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationBaseTest.java +++ b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationBaseTest.java @@ -32,6 +32,7 @@ public abstract class ExpressionEvaluationBaseTest extends BaseTestCase { protected StoppedEventArguments context; + // local variable names defined in test sources protected static final String NIL_VAR = "varVariable"; protected static final String BOOLEAN_VAR = "booleanVar"; protected static final String INT_VAR = "intVar"; @@ -41,7 +42,6 @@ public abstract class ExpressionEvaluationBaseTest extends BaseTestCase { protected static final String SIGNED8INT_VAR = "signed8IntVar"; protected static final String SIGNED16INT_VAR = "signed16IntVar"; protected static final String SIGNED32INT_VAR = "signed32IntVar"; - protected static final String FLOAT_VAR = "floatVar"; protected static final String DECIMAL_VAR = "decimalVar"; protected static final String STRING_VAR = "stringVar"; @@ -69,6 +69,7 @@ public abstract class ExpressionEvaluationBaseTest extends BaseTestCase { protected static final String NEVER_VAR = "neverVar"; protected static final String SERVICE_VAR = "serviceVar"; + // global variable names defined in test sources protected static final String GLOBAL_VAR_01 = "nameWithoutType"; protected static final String GLOBAL_VAR_02 = "nameWithType"; protected static final String GLOBAL_VAR_03 = "nameMap"; @@ -81,6 +82,23 @@ public abstract class ExpressionEvaluationBaseTest extends BaseTestCase { protected static final String GLOBAL_VAR_10 = "jsonVar"; protected static final String GLOBAL_VAR_11 = "'\\ \\/\\:\\@\\[\\`\\{\\~\\u{03C0}_IL"; + // basic, simple types + protected static final String INT_TYPE_DESC = "int"; + protected static final String FLOAT_TYPE_DESC = "float"; + protected static final String DECIMAL_TYPE_DESC = "decimal"; + protected static final String BOOLEAN_TYPE_DESC = "boolean"; + + // basic, sequence types + protected static final String STRING_TYPE_DESC = "string"; + + // other types + protected static final String BYTE_TYPE_DESC = "byte"; + protected static final String JSON_TYPE_DESC = "json"; + protected static final String ANY_TYPE_DESC = "any"; + protected static final String ANYDATA_TYPE_DESC = "anydata"; + protected static final String NEVER_TYPE_DESC = "never"; + protected static final String PARENTHESISED_TYPE_DESC = "(int)"; + protected DebugTestRunner debugTestRunner; @BeforeMethod(alwaysRun = true) @@ -99,107 +117,73 @@ protected void endSoftAssertions() { protected abstract void prepareForEvaluation() throws BallerinaTestException; - // 1. literal expressions public abstract void literalEvaluationTest() throws BallerinaTestException; - // 2. list constructor expressions public abstract void listConstructorEvaluationTest() throws BallerinaTestException; - // 3. mapping constructor expressions public abstract void mappingConstructorEvaluationTest() throws BallerinaTestException; - // Todo - table constructor[preview] and service constructor - - // 4. string template expressions public abstract void stringTemplateEvaluationTest() throws BallerinaTestException; - // 5. xml template expressions public abstract void xmlTemplateEvaluationTest() throws BallerinaTestException; - // 6. new constructor expressions public abstract void newConstructorEvaluationTest() throws BallerinaTestException; - // 7. variable reference expressions public abstract void variableReferenceEvaluationTest() throws BallerinaTestException; - // 8. field access expressions + public abstract void builtInNameReferenceEvaluationTest() throws BallerinaTestException; + public abstract void fieldAccessEvaluationTest() throws BallerinaTestException; - // 9. XML attribute access expressions public abstract void xmlAttributeAccessEvaluationTest() throws BallerinaTestException; - // 10. Annotation access expressions public abstract void annotationAccessEvaluationTest() throws BallerinaTestException; - // 11. Member access expressions public abstract void memberAccessEvaluationTest() throws BallerinaTestException; - // 12. Function call expressions public abstract void functionCallEvaluationTest() throws BallerinaTestException; - // 13. Method call expressions public abstract void methodCallEvaluationTest() throws BallerinaTestException; - // 14. Error constructor expressions public abstract void errorConstructorEvaluationTest() throws BallerinaTestException; - // 15. Anonymous function expressions public abstract void anonymousFunctionEvaluationTest() throws BallerinaTestException; - // 16. Anonymous function expressions public abstract void letExpressionEvaluationTest() throws BallerinaTestException; - // 17. Type cast expressions public abstract void typeCastEvaluationTest() throws BallerinaTestException; - // 18. Typeof expressions public abstract void typeOfExpressionEvaluationTest() throws BallerinaTestException; - // 19. Unary expressions public abstract void unaryExpressionEvaluationTest() throws BallerinaTestException; - // 20. Multiplicative expressions public abstract void multiplicativeExpressionEvaluationTest() throws BallerinaTestException; - // 21. Additive expressions public abstract void additiveExpressionEvaluationTest() throws BallerinaTestException; - // 22. Shift expressions public abstract void shiftExpressionEvaluationTest() throws BallerinaTestException; - // 23. Range expressions public abstract void rangeExpressionEvaluationTest() throws BallerinaTestException; - // 24. Numerical comparison expressions public abstract void comparisonEvaluationTest() throws BallerinaTestException; - // 25. Type test expressions public abstract void typeTestEvaluationTest() throws BallerinaTestException; - // 26. Equality expressions public abstract void equalityEvaluationTest() throws BallerinaTestException; - // 27. Binary bitwise expressions public abstract void binaryBitwiseEvaluationTest() throws BallerinaTestException; - // 28. Logical expressions public abstract void logicalEvaluationTest() throws BallerinaTestException; - // 29. Conditional expressions public abstract void conditionalExpressionEvaluationTest() throws BallerinaTestException; - // 30. Checking expressions public abstract void checkingExpressionEvaluationTest() throws BallerinaTestException; - // 31. Trap expressions public abstract void trapExpressionEvaluationTest() throws BallerinaTestException; - // 32. Query expressions public abstract void queryExpressionEvaluationTest() throws BallerinaTestException; - // 33. XML navigation expressions public abstract void xmlNavigationEvaluationTest() throws BallerinaTestException; - // 34. Remote method call actions public abstract void remoteCallActionEvaluationTest() throws BallerinaTestException; } diff --git a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationNegativeTest.java b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationNegativeTest.java index 03718956b627..c234595199d7 100644 --- a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationNegativeTest.java +++ b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationNegativeTest.java @@ -104,6 +104,12 @@ public void variableReferenceEvaluationTest() throws BallerinaTestException { "foo")); } + @Override + @Test(enabled = false) + public void builtInNameReferenceEvaluationTest() throws BallerinaTestException { + // Todo + } + @Override @Test(enabled = false) public void fieldAccessEvaluationTest() throws BallerinaTestException { diff --git a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationTest.java b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationTest.java index f1aa8d8b8d1a..965ec03e86f3 100644 --- a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationTest.java +++ b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationTest.java @@ -105,6 +105,25 @@ public void newConstructorEvaluationTest() throws BallerinaTestException { debugTestRunner.assertExpression(context, "new Location(\"New York\",\"USA\")", "Location", "object"); } + @Override + @Test + public void builtInNameReferenceEvaluationTest() throws BallerinaTestException { + // basic, simple types + debugTestRunner.assertExpression(context, INT_TYPE_DESC, "int", "typedesc"); + debugTestRunner.assertExpression(context, FLOAT_TYPE_DESC, "float", "typedesc"); + debugTestRunner.assertExpression(context, DECIMAL_TYPE_DESC, "decimal", "typedesc"); + debugTestRunner.assertExpression(context, BOOLEAN_TYPE_DESC, "boolean", "typedesc"); + // basic, sequence types + debugTestRunner.assertExpression(context, STRING_TYPE_DESC, "string", "typedesc"); + // other types + debugTestRunner.assertExpression(context, BYTE_TYPE_DESC, "byte", "typedesc"); + debugTestRunner.assertExpression(context, JSON_TYPE_DESC, "json", "typedesc"); + debugTestRunner.assertExpression(context, ANY_TYPE_DESC, "any", "typedesc"); + debugTestRunner.assertExpression(context, ANYDATA_TYPE_DESC, "anydata", "typedesc"); + debugTestRunner.assertExpression(context, NEVER_TYPE_DESC, "never", "typedesc"); + debugTestRunner.assertExpression(context, PARENTHESISED_TYPE_DESC, "int", "typedesc"); + } + @Override @Test public void variableReferenceEvaluationTest() throws BallerinaTestException { From 9c07c0b6fad758289830d87ee026f710a5726481 Mon Sep 17 00:00:00 2001 From: Nipuna Ranasinghe Date: Mon, 28 Nov 2022 10:37:12 +0530 Subject: [PATCH 186/450] Add support for named type reference evaluations --- .../evaluation/EvaluationExceptionKind.java | 1 + .../BuiltinSimpleNameReferenceEvaluator.java | 29 ++++++++++++--- .../SimpleNameReferenceEvaluator.java | 36 ++++++++++++++++++- .../evaluation/utils/EvaluationUtils.java | 1 + 4 files changed, 62 insertions(+), 5 deletions(-) diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/EvaluationExceptionKind.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/EvaluationExceptionKind.java index 07cba82639ff..0ddc924c08bc 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/EvaluationExceptionKind.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/EvaluationExceptionKind.java @@ -39,6 +39,7 @@ public enum EvaluationExceptionKind { INDEX_OUT_OF_RANGE_ERROR("%s index out of range: index=%d, size=%d"), INVALID_KEY_TYPE_ERROR("expected key type '%s'; found '%s' in '%s'"), TYPE_RESOLVING_ERROR("Failed to resolve type: '%s'"), + NAME_REF_RESOLVING_ERROR("Failed to resolve reference: '%s'"), IMPORT_RESOLVING_ERROR("Failed to resolve the import: '%s'"), STRAND_NOT_FOUND("Error occurred when trying to get the strand instance for the current stack frame"), CLASS_LOADING_FAILED("Failed to load the required classes to execute method: '%s'"), diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/BuiltinSimpleNameReferenceEvaluator.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/BuiltinSimpleNameReferenceEvaluator.java index 069485a001c1..2578f7f365a3 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/BuiltinSimpleNameReferenceEvaluator.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/BuiltinSimpleNameReferenceEvaluator.java @@ -23,9 +23,18 @@ import org.ballerinalang.debugadapter.evaluation.EvaluationException; import org.ballerinalang.debugadapter.evaluation.engine.Evaluator; import org.ballerinalang.debugadapter.evaluation.engine.NameBasedTypeResolver; +import org.ballerinalang.debugadapter.evaluation.engine.invokable.RuntimeStaticMethod; +import java.util.LinkedList; import java.util.List; +import static org.ballerinalang.debugadapter.evaluation.EvaluationException.createEvaluationException; +import static org.ballerinalang.debugadapter.evaluation.EvaluationExceptionKind.NAME_REF_RESOLVING_ERROR; +import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.B_TYPE_CLASS; +import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.B_VALUE_CREATOR_CLASS; +import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.CREATE_TYPEDESC_VALUE_METHOD; +import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.getRuntimeMethod; + /** * Builtin simple name reference evaluator implementation. * @@ -33,17 +42,29 @@ */ public class BuiltinSimpleNameReferenceEvaluator extends Evaluator { - private final BuiltinSimpleNameReferenceNode syntaxNode; + private final String typeName; public BuiltinSimpleNameReferenceEvaluator(EvaluationContext context, BuiltinSimpleNameReferenceNode node) { super(context); - this.syntaxNode = node; + this.typeName = node.name().text().trim(); } @Override public BExpressionValue evaluate() throws EvaluationException { NameBasedTypeResolver builtInTypeResolver = new NameBasedTypeResolver(evaluationContext); - List resolve = builtInTypeResolver.resolve(syntaxNode.name().text().trim()); - return new BExpressionValue(context, resolve.get(0)); + List resolvedTypes = builtInTypeResolver.resolve(typeName); + if (resolvedTypes.size() != 1) { + throw createEvaluationException(NAME_REF_RESOLVING_ERROR, typeName); + } + + Value type = resolvedTypes.get(0); + List argTypeNames = new LinkedList<>(); + argTypeNames.add(B_TYPE_CLASS); + RuntimeStaticMethod createTypedescMethod = getRuntimeMethod(context, B_VALUE_CREATOR_CLASS, + CREATE_TYPEDESC_VALUE_METHOD, argTypeNames); + List argValues = new LinkedList<>(); + argValues.add(type); + createTypedescMethod.setArgValues(argValues); + return new BExpressionValue(context, createTypedescMethod.invokeSafely()); } } diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/SimpleNameReferenceEvaluator.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/SimpleNameReferenceEvaluator.java index 196258c03b49..e00018f27c75 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/SimpleNameReferenceEvaluator.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/SimpleNameReferenceEvaluator.java @@ -16,15 +16,26 @@ package org.ballerinalang.debugadapter.evaluation.engine.expression; +import com.sun.jdi.Value; import io.ballerina.compiler.syntax.tree.SimpleNameReferenceNode; import org.ballerinalang.debugadapter.EvaluationContext; import org.ballerinalang.debugadapter.evaluation.BExpressionValue; import org.ballerinalang.debugadapter.evaluation.EvaluationException; import org.ballerinalang.debugadapter.evaluation.engine.Evaluator; +import org.ballerinalang.debugadapter.evaluation.engine.NameBasedTypeResolver; +import org.ballerinalang.debugadapter.evaluation.engine.invokable.RuntimeStaticMethod; import org.ballerinalang.debugadapter.evaluation.utils.VariableUtils; +import java.util.LinkedList; +import java.util.List; + import static org.ballerinalang.debugadapter.evaluation.EvaluationException.createEvaluationException; +import static org.ballerinalang.debugadapter.evaluation.EvaluationExceptionKind.NAME_REF_RESOLVING_ERROR; import static org.ballerinalang.debugadapter.evaluation.EvaluationExceptionKind.VARIABLE_EXECUTION_ERROR; +import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.B_TYPE_CLASS; +import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.B_VALUE_CREATOR_CLASS; +import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.CREATE_TYPEDESC_VALUE_METHOD; +import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.getRuntimeMethod; /** * Simple name reference evaluator implementation. @@ -43,7 +54,30 @@ public SimpleNameReferenceEvaluator(EvaluationContext context, SimpleNameReferen @Override public BExpressionValue evaluate() throws EvaluationException { try { - return new BExpressionValue(context, VariableUtils.fetchVariableValue(context, nameReference)); + Value value = null; + try { + value = VariableUtils.fetchVariableValue(context, nameReference); + } catch (EvaluationException ignored) { + } + + if (value == null) { + NameBasedTypeResolver typeResolver = new NameBasedTypeResolver(evaluationContext); + List resolvedTypes = typeResolver.resolve(nameReference); + if (resolvedTypes.size() != 1) { + throw createEvaluationException(NAME_REF_RESOLVING_ERROR, nameReference); + } + value = resolvedTypes.get(0); + List argTypeNames = new LinkedList<>(); + argTypeNames.add(B_TYPE_CLASS); + RuntimeStaticMethod createTypedescMethod = getRuntimeMethod(context, B_VALUE_CREATOR_CLASS, + CREATE_TYPEDESC_VALUE_METHOD, argTypeNames); + List argValues = new LinkedList<>(); + argValues.add(value); + createTypedescMethod.setArgValues(argValues); + return new BExpressionValue(context, createTypedescMethod.invokeSafely()); + } + + return new BExpressionValue(context, value); } catch (EvaluationException e) { throw e; } catch (Exception e) { diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/utils/EvaluationUtils.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/utils/EvaluationUtils.java index 426b6107cf18..50dc3b9d12cb 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/utils/EvaluationUtils.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/utils/EvaluationUtils.java @@ -147,6 +147,7 @@ public class EvaluationUtils { public static final String CREATE_XML_VALUE_METHOD = "createXmlValue"; public static final String CREATE_OBJECT_VALUE_METHOD = "createObjectValue"; public static final String CREATE_ERROR_VALUE_METHOD = "createErrorValue"; + public static final String CREATE_TYPEDESC_VALUE_METHOD = "createTypedescValue"; public static final String VALUE_OF_METHOD = "valueOf"; public static final String VALUE_FROM_STRING_METHOD = "fromString"; public static final String REF_EQUAL_METHOD = "isReferenceEqual"; From ba82d672e9aad3f39148e9407080a587103e766c Mon Sep 17 00:00:00 2001 From: Nipuna Ranasinghe Date: Mon, 28 Nov 2022 15:47:50 +0530 Subject: [PATCH 187/450] Fix runtime API to support never typedesc --- .../main/java/io/ballerina/runtime/api/utils/TypeUtils.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/TypeUtils.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/TypeUtils.java index 307c42af5529..1178d9268b66 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/TypeUtils.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/api/utils/TypeUtils.java @@ -37,6 +37,7 @@ import static io.ballerina.runtime.api.PredefinedTypes.TYPE_INT; import static io.ballerina.runtime.api.PredefinedTypes.TYPE_JSON; import static io.ballerina.runtime.api.PredefinedTypes.TYPE_MAP; +import static io.ballerina.runtime.api.PredefinedTypes.TYPE_NEVER; import static io.ballerina.runtime.api.PredefinedTypes.TYPE_NULL; import static io.ballerina.runtime.api.PredefinedTypes.TYPE_STREAM; import static io.ballerina.runtime.api.PredefinedTypes.TYPE_STRING; @@ -110,6 +111,8 @@ public static Type getTypeFromName(String typeName) { return TYPE_ERROR; case TypeConstants.ANYDATA_TNAME: return TYPE_ANYDATA; + case TypeConstants.NEVER_TNAME: + return TYPE_NEVER; default: throw new IllegalStateException("Unknown type name"); } From b8881b72f9d9dde4f1144626848da823cf835b63 Mon Sep 17 00:00:00 2001 From: Nipuna Ranasinghe Date: Mon, 28 Nov 2022 15:48:20 +0530 Subject: [PATCH 188/450] Add more tests --- .../evaluation/EvaluationExceptionKind.java | 2 +- .../ExpressionAsProgramEvaluator.java | 2 +- .../SimpleNameReferenceEvaluator.java | 26 +--------- .../evaluation/utils/VariableUtils.java | 48 +++++++++++++++---- .../ExpressionEvaluationBaseTest.java | 2 +- .../ExpressionEvaluationNegativeTest.java | 2 +- .../evaluation/ExpressionEvaluationTest.java | 12 ++++- .../PackageEvaluationNegativeTest.java | 4 +- .../evaluation/PackageEvaluationTest.java | 4 +- .../SingleFileEvaluationNegativeTest.java | 4 +- .../evaluation/SingleFileEvaluationTest.java | 4 +- .../evaluation-tests-1/utils.bal | 6 ++- 12 files changed, 67 insertions(+), 49 deletions(-) diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/EvaluationExceptionKind.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/EvaluationExceptionKind.java index 0ddc924c08bc..25009a699924 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/EvaluationExceptionKind.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/EvaluationExceptionKind.java @@ -39,7 +39,7 @@ public enum EvaluationExceptionKind { INDEX_OUT_OF_RANGE_ERROR("%s index out of range: index=%d, size=%d"), INVALID_KEY_TYPE_ERROR("expected key type '%s'; found '%s' in '%s'"), TYPE_RESOLVING_ERROR("Failed to resolve type: '%s'"), - NAME_REF_RESOLVING_ERROR("Failed to resolve reference: '%s'"), + NAME_REF_RESOLVING_ERROR("Failed to resolve the name reference: '%s'"), IMPORT_RESOLVING_ERROR("Failed to resolve the import: '%s'"), STRAND_NOT_FOUND("Error occurred when trying to get the strand instance for the current stack frame"), CLASS_LOADING_FAILED("Failed to load the required classes to execute method: '%s'"), diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/ExpressionAsProgramEvaluator.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/ExpressionAsProgramEvaluator.java index a4b4cab2402c..f79c72fcb218 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/ExpressionAsProgramEvaluator.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/ExpressionAsProgramEvaluator.java @@ -517,7 +517,7 @@ private void processSnippetFunctionParameters() throws EvaluationException { .getCapturedVariables()); List capturedTypes = new ArrayList<>(); for (String name : capturedVarNames) { - Value jdiValue = VariableUtils.fetchVariableValue(context, name); + Value jdiValue = VariableUtils.fetchNameReferenceValue(evaluationContext, name); BVariable bVar = VariableFactory.getVariable(context, jdiValue); capturedTypes.add(getTypeNameString(bVar)); externalVariableValues.add(getValueAsObject(context, jdiValue)); diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/SimpleNameReferenceEvaluator.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/SimpleNameReferenceEvaluator.java index e00018f27c75..2503149cbb70 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/SimpleNameReferenceEvaluator.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/SimpleNameReferenceEvaluator.java @@ -54,30 +54,8 @@ public SimpleNameReferenceEvaluator(EvaluationContext context, SimpleNameReferen @Override public BExpressionValue evaluate() throws EvaluationException { try { - Value value = null; - try { - value = VariableUtils.fetchVariableValue(context, nameReference); - } catch (EvaluationException ignored) { - } - - if (value == null) { - NameBasedTypeResolver typeResolver = new NameBasedTypeResolver(evaluationContext); - List resolvedTypes = typeResolver.resolve(nameReference); - if (resolvedTypes.size() != 1) { - throw createEvaluationException(NAME_REF_RESOLVING_ERROR, nameReference); - } - value = resolvedTypes.get(0); - List argTypeNames = new LinkedList<>(); - argTypeNames.add(B_TYPE_CLASS); - RuntimeStaticMethod createTypedescMethod = getRuntimeMethod(context, B_VALUE_CREATOR_CLASS, - CREATE_TYPEDESC_VALUE_METHOD, argTypeNames); - List argValues = new LinkedList<>(); - argValues.add(value); - createTypedescMethod.setArgValues(argValues); - return new BExpressionValue(context, createTypedescMethod.invokeSafely()); - } - - return new BExpressionValue(context, value); + return new BExpressionValue(context, VariableUtils.fetchNameReferenceValue(evaluationContext, + nameReference)); } catch (EvaluationException e) { throw e; } catch (Exception e) { diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/utils/VariableUtils.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/utils/VariableUtils.java index 96c75745e82c..9d9fde034ca4 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/utils/VariableUtils.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/utils/VariableUtils.java @@ -20,9 +20,11 @@ import com.sun.jdi.ReferenceType; import com.sun.jdi.Value; import io.ballerina.compiler.api.symbols.ModuleSymbol; +import org.ballerinalang.debugadapter.EvaluationContext; import org.ballerinalang.debugadapter.SuspendedContext; import org.ballerinalang.debugadapter.evaluation.BExpressionValue; import org.ballerinalang.debugadapter.evaluation.EvaluationException; +import org.ballerinalang.debugadapter.evaluation.engine.NameBasedTypeResolver; import org.ballerinalang.debugadapter.evaluation.engine.invokable.RuntimeStaticMethod; import org.ballerinalang.debugadapter.jdi.JdiProxyException; import org.ballerinalang.debugadapter.jdi.LocalVariableProxyImpl; @@ -34,6 +36,7 @@ import org.ballerinalang.debugadapter.variable.VariableFactory; import java.util.Collections; +import java.util.LinkedList; import java.util.List; import java.util.Objects; import java.util.Optional; @@ -41,11 +44,15 @@ import java.util.stream.Collectors; import static org.ballerinalang.debugadapter.evaluation.EvaluationException.createEvaluationException; -import static org.ballerinalang.debugadapter.evaluation.EvaluationExceptionKind.VARIABLE_NOT_FOUND; +import static org.ballerinalang.debugadapter.evaluation.EvaluationExceptionKind.NAME_REF_RESOLVING_ERROR; import static org.ballerinalang.debugadapter.evaluation.IdentifierModifier.encodeModuleName; import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.B_DEBUGGER_RUNTIME_UTILS_CLASS; +import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.B_TYPE_CLASS; +import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.B_VALUE_CREATOR_CLASS; +import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.CREATE_TYPEDESC_VALUE_METHOD; import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.GET_BMAP_TYPE_METHOD; import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.MODULE_VERSION_SEPARATOR_REGEX; +import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.getRuntimeMethod; import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.loadClass; import static org.ballerinalang.debugadapter.utils.PackageUtils.INIT_CLASS_NAME; import static org.ballerinalang.debugadapter.variable.VariableUtils.UNKNOWN_VALUE; @@ -58,22 +65,43 @@ public class VariableUtils { /** - * Returns runtime value of the matching variable, for the given name. This method searches for a matching - * variable in both local and global variable scopes. + * Returns runtime value of the Balerina value reference for the given name. For that, this method searches for a + * match according to the below order. + * + *

    + *
  • variables defined both local and global scopes + *
  • types defined int both local and global scopes + *
* * @param context suspended context * @param name name of the variable to be retrieved * @return the JDI value instance of the Ballerina variable */ - public static Value fetchVariableValue(SuspendedContext context, String name) throws EvaluationException { - Optional bExpressionValue = searchLocalVariables(context, name); - if (bExpressionValue.isEmpty()) { - bExpressionValue = searchGlobalVariables(context, name); + public static Value fetchNameReferenceValue(EvaluationContext context, String name) throws EvaluationException { + Optional bExpressionValue = searchLocalVariables(context.getSuspendedContext(), name); + if (bExpressionValue.isPresent()) { + return bExpressionValue.get().getJdiValue(); + } + + bExpressionValue = searchGlobalVariables(context.getSuspendedContext(), name); + if (bExpressionValue.isPresent()) { + return bExpressionValue.get().getJdiValue(); } - if (bExpressionValue.isEmpty()) { - throw createEvaluationException(VARIABLE_NOT_FOUND, name); + + NameBasedTypeResolver typeResolver = new NameBasedTypeResolver(context); + List resolvedTypes = typeResolver.resolve(name); + if (resolvedTypes.size() != 1) { + throw createEvaluationException(NAME_REF_RESOLVING_ERROR, name); } - return bExpressionValue.get().getJdiValue(); + Value type = resolvedTypes.get(0); + List argTypeNames = new LinkedList<>(); + argTypeNames.add(B_TYPE_CLASS); + RuntimeStaticMethod createTypeDescMethod = getRuntimeMethod(context.getSuspendedContext(), + B_VALUE_CREATOR_CLASS, CREATE_TYPEDESC_VALUE_METHOD, argTypeNames); + List argValues = new LinkedList<>(); + argValues.add(type); + createTypeDescMethod.setArgValues(argValues); + return createTypeDescMethod.invokeSafely(); } /** diff --git a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationBaseTest.java b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationBaseTest.java index 967c1178a199..1d4c6d998870 100644 --- a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationBaseTest.java +++ b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationBaseTest.java @@ -129,7 +129,7 @@ protected void endSoftAssertions() { public abstract void newConstructorEvaluationTest() throws BallerinaTestException; - public abstract void variableReferenceEvaluationTest() throws BallerinaTestException; + public abstract void simpleNameReferenceEvaluationTest() throws BallerinaTestException; public abstract void builtInNameReferenceEvaluationTest() throws BallerinaTestException; diff --git a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationNegativeTest.java b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationNegativeTest.java index c234595199d7..ded0341fbfe7 100644 --- a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationNegativeTest.java +++ b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationNegativeTest.java @@ -94,7 +94,7 @@ public void newConstructorEvaluationTest() throws BallerinaTestException { @Override @Test - public void variableReferenceEvaluationTest() throws BallerinaTestException { + public void simpleNameReferenceEvaluationTest() throws BallerinaTestException { // undefined constant evaluation debugTestRunner.assertEvaluationError(context, "int:MAX", String.format(NON_PUBLIC_OR_UNDEFINED_ACCESS .getString(), "int", "MAX")); diff --git a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationTest.java b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationTest.java index 965ec03e86f3..efa266f6bd7a 100644 --- a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationTest.java +++ b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationTest.java @@ -126,7 +126,7 @@ public void builtInNameReferenceEvaluationTest() throws BallerinaTestException { @Override @Test - public void variableReferenceEvaluationTest() throws BallerinaTestException { + public void simpleNameReferenceEvaluationTest() throws BallerinaTestException { // var variable test debugTestRunner.assertExpression(context, NIL_VAR, "()", "nil"); // boolean variable test @@ -203,6 +203,10 @@ public void variableReferenceEvaluationTest() throws BallerinaTestException { // qualified name references with import alias debugTestRunner.assertExpression(context, "langFloat:PI", "3.141592653589793", "float"); + + // named types + debugTestRunner.assertExpression(context, "Student", "evaluation_tests:Student", "typedesc"); + debugTestRunner.assertExpression(context, "AnonPerson", "evaluation_tests:AnonPerson", "typedesc"); } @Override @@ -361,6 +365,10 @@ public void functionCallEvaluationTest() throws BallerinaTestException { // with qualified literals (i.e. imported modules) debugTestRunner.assertExpression(context, "int:abs(-6)", "6", "int"); + + // with typedesc values as arguments + debugTestRunner.assertExpression(context, "processTypeDesc(int)", "int", "typedesc"); + debugTestRunner.assertExpression(context, "processTypeDesc(Student)", "evaluation_tests:Student", "typedesc"); } @Override @@ -567,7 +575,7 @@ public void additiveExpressionEvaluationTest() throws BallerinaTestException { // string template concatenation String bStringTemplateExpr = String.format("string `name: ${%s}, age: ${%s}`", STRING_VAR, INT_VAR); debugTestRunner.assertExpression(context, String.format("%s + %s + %s", bStringTemplateExpr, - bStringTemplateExpr, bStringTemplateExpr), + bStringTemplateExpr, bStringTemplateExpr), "\"name: foo, age: 20name: foo, age: 20name: foo, age: 20\"", "string"); // xml + xml diff --git a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/PackageEvaluationNegativeTest.java b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/PackageEvaluationNegativeTest.java index 69a786cf28fe..b092d80032bc 100644 --- a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/PackageEvaluationNegativeTest.java +++ b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/PackageEvaluationNegativeTest.java @@ -110,8 +110,8 @@ public void unaryExpressionEvaluationTest() throws BallerinaTestException { @Override @Test - public void variableReferenceEvaluationTest() throws BallerinaTestException { - super.variableReferenceEvaluationTest(); + public void simpleNameReferenceEvaluationTest() throws BallerinaTestException { + super.simpleNameReferenceEvaluationTest(); // package-private constant evaluation debugTestRunner.assertEvaluationError(context, "other:constant", String.format(NON_PUBLIC_OR_UNDEFINED_ACCESS diff --git a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/PackageEvaluationTest.java b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/PackageEvaluationTest.java index 17a4c9aaf68b..f5cfd19cefaa 100644 --- a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/PackageEvaluationTest.java +++ b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/PackageEvaluationTest.java @@ -106,8 +106,8 @@ public void unaryExpressionEvaluationTest() throws BallerinaTestException { @Override @Test - public void variableReferenceEvaluationTest() throws BallerinaTestException { - super.variableReferenceEvaluationTest(); + public void simpleNameReferenceEvaluationTest() throws BallerinaTestException { + super.simpleNameReferenceEvaluationTest(); // Todo - move to common evaluation test suite after fixing the value string debugTestRunner.assertExpression(context, GLOBAL_VAR_03, diff --git a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/SingleFileEvaluationNegativeTest.java b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/SingleFileEvaluationNegativeTest.java index a12a845bc707..09b0804530e7 100644 --- a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/SingleFileEvaluationNegativeTest.java +++ b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/SingleFileEvaluationNegativeTest.java @@ -91,8 +91,8 @@ public void unaryExpressionEvaluationTest() throws BallerinaTestException { } @Override - public void variableReferenceEvaluationTest() throws BallerinaTestException { - super.variableReferenceEvaluationTest(); + public void simpleNameReferenceEvaluationTest() throws BallerinaTestException { + super.simpleNameReferenceEvaluationTest(); // access constants in undefined modules debugTestRunner.assertEvaluationError(context, "other:constant", diff --git a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/SingleFileEvaluationTest.java b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/SingleFileEvaluationTest.java index c6f4bcac0338..b7aee7ee968a 100644 --- a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/SingleFileEvaluationTest.java +++ b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/SingleFileEvaluationTest.java @@ -48,8 +48,8 @@ protected void prepareForEvaluation() throws BallerinaTestException { @Override @Test - public void variableReferenceEvaluationTest() throws BallerinaTestException { - super.variableReferenceEvaluationTest(); + public void simpleNameReferenceEvaluationTest() throws BallerinaTestException { + super.simpleNameReferenceEvaluationTest(); // Todo - move to common evaluation test suite after fixing the value string debugTestRunner.assertExpression(context, GLOBAL_VAR_03, "record {| readonly \"John\" name; |} & readonly", diff --git a/tests/jballerina-debugger-integration-test/src/test/resources/project-based-tests/evaluation-tests-1/utils.bal b/tests/jballerina-debugger-integration-test/src/test/resources/project-based-tests/evaluation-tests-1/utils.bal index f3140593e2d0..3e46891f0fb8 100644 --- a/tests/jballerina-debugger-integration-test/src/test/resources/project-based-tests/evaluation-tests-1/utils.bal +++ b/tests/jballerina-debugger-integration-test/src/test/resources/project-based-tests/evaluation-tests-1/utils.bal @@ -48,7 +48,7 @@ public type T1 record { string name; }; -T1 a = { name: "John" }; +T1 a = {name: "John"}; function sum(int a, int b) returns int { return a + b; @@ -67,3 +67,7 @@ public function getSum(int a, int b) returns int { return -1; } } + +function processTypeDesc(typedesc t) returns typedesc { + return t; +} From 15ef5b050996684d4f7ccb1ca7a91e5a062a6bb2 Mon Sep 17 00:00:00 2001 From: Nipuna Ranasinghe Date: Tue, 29 Nov 2022 07:35:35 +0530 Subject: [PATCH 189/450] Add minor fixes --- .../ExpressionAsProgramEvaluator.java | 12 +++- .../SimpleNameReferenceEvaluator.java | 11 ---- .../evaluation/utils/VariableUtils.java | 57 +++++++++++------- .../evaluation/EvaluationExceptionKind.java | 5 +- .../ExpressionEvaluationNegativeTest.java | 5 ++ .../evaluation-tests-1/Dependencies.toml | 50 ++++++++++++++++ .../src/test/resources/testng.xml | 58 +++++++++---------- 7 files changed, 134 insertions(+), 64 deletions(-) create mode 100644 tests/jballerina-debugger-integration-test/src/test/resources/project-based-tests/evaluation-tests-1/Dependencies.toml diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/ExpressionAsProgramEvaluator.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/ExpressionAsProgramEvaluator.java index f79c72fcb218..ff427086027d 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/ExpressionAsProgramEvaluator.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/ExpressionAsProgramEvaluator.java @@ -71,6 +71,7 @@ import static org.ballerinalang.debugadapter.evaluation.EvaluationException.createEvaluationException; import static org.ballerinalang.debugadapter.evaluation.EvaluationExceptionKind.INTERNAL_ERROR; +import static org.ballerinalang.debugadapter.evaluation.EvaluationExceptionKind.VARIABLE_NOT_FOUND; import static org.ballerinalang.debugadapter.evaluation.IdentifierModifier.QUOTED_IDENTIFIER_PREFIX; import static org.ballerinalang.debugadapter.evaluation.IdentifierModifier.decodeAndEscapeIdentifier; import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.B_DEBUGGER_RUNTIME_CLASS; @@ -517,10 +518,15 @@ private void processSnippetFunctionParameters() throws EvaluationException { .getCapturedVariables()); List capturedTypes = new ArrayList<>(); for (String name : capturedVarNames) { - Value jdiValue = VariableUtils.fetchNameReferenceValue(evaluationContext, name); - BVariable bVar = VariableFactory.getVariable(context, jdiValue); + Optional variableValue = VariableUtils.fetchVariableReferenceValue(evaluationContext, + name); + if (variableValue.isEmpty()) { + throw createEvaluationException(VARIABLE_NOT_FOUND, name); + } + + BVariable bVar = VariableFactory.getVariable(context, variableValue.get().getJdiValue()); capturedTypes.add(getTypeNameString(bVar)); - externalVariableValues.add(getValueAsObject(context, jdiValue)); + externalVariableValues.add(getValueAsObject(context, variableValue.get().getJdiValue())); } for (int index = 0; index < capturedVarNames.size(); index++) { diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/SimpleNameReferenceEvaluator.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/SimpleNameReferenceEvaluator.java index 2503149cbb70..7f008f2fca62 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/SimpleNameReferenceEvaluator.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/SimpleNameReferenceEvaluator.java @@ -16,26 +16,15 @@ package org.ballerinalang.debugadapter.evaluation.engine.expression; -import com.sun.jdi.Value; import io.ballerina.compiler.syntax.tree.SimpleNameReferenceNode; import org.ballerinalang.debugadapter.EvaluationContext; import org.ballerinalang.debugadapter.evaluation.BExpressionValue; import org.ballerinalang.debugadapter.evaluation.EvaluationException; import org.ballerinalang.debugadapter.evaluation.engine.Evaluator; -import org.ballerinalang.debugadapter.evaluation.engine.NameBasedTypeResolver; -import org.ballerinalang.debugadapter.evaluation.engine.invokable.RuntimeStaticMethod; import org.ballerinalang.debugadapter.evaluation.utils.VariableUtils; -import java.util.LinkedList; -import java.util.List; - import static org.ballerinalang.debugadapter.evaluation.EvaluationException.createEvaluationException; -import static org.ballerinalang.debugadapter.evaluation.EvaluationExceptionKind.NAME_REF_RESOLVING_ERROR; import static org.ballerinalang.debugadapter.evaluation.EvaluationExceptionKind.VARIABLE_EXECUTION_ERROR; -import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.B_TYPE_CLASS; -import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.B_VALUE_CREATOR_CLASS; -import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.CREATE_TYPEDESC_VALUE_METHOD; -import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.getRuntimeMethod; /** * Simple name reference evaluator implementation. diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/utils/VariableUtils.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/utils/VariableUtils.java index 9d9fde034ca4..c191a37a8ccd 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/utils/VariableUtils.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/utils/VariableUtils.java @@ -65,7 +65,7 @@ public class VariableUtils { /** - * Returns runtime value of the Balerina value reference for the given name. For that, this method searches for a + * Returns runtime value of the Ballerina value reference for the given name. For that, this method searches for a * match according to the below order. * *
    @@ -78,30 +78,47 @@ public class VariableUtils { * @return the JDI value instance of the Ballerina variable */ public static Value fetchNameReferenceValue(EvaluationContext context, String name) throws EvaluationException { - Optional bExpressionValue = searchLocalVariables(context.getSuspendedContext(), name); - if (bExpressionValue.isPresent()) { - return bExpressionValue.get().getJdiValue(); - } - - bExpressionValue = searchGlobalVariables(context.getSuspendedContext(), name); - if (bExpressionValue.isPresent()) { - return bExpressionValue.get().getJdiValue(); + Optional variableReferenceValue = fetchVariableReferenceValue(context, name); + if (variableReferenceValue.isPresent()) { + return variableReferenceValue.get().getJdiValue(); } NameBasedTypeResolver typeResolver = new NameBasedTypeResolver(context); - List resolvedTypes = typeResolver.resolve(name); - if (resolvedTypes.size() != 1) { + try { + List resolvedTypes = typeResolver.resolve(name); + if (resolvedTypes.size() != 1) { + throw createEvaluationException(NAME_REF_RESOLVING_ERROR, name); + } + Value type = resolvedTypes.get(0); + List argTypeNames = new LinkedList<>(); + argTypeNames.add(B_TYPE_CLASS); + RuntimeStaticMethod createTypeDescMethod = getRuntimeMethod(context.getSuspendedContext(), + B_VALUE_CREATOR_CLASS, CREATE_TYPEDESC_VALUE_METHOD, argTypeNames); + List argValues = new LinkedList<>(); + argValues.add(type); + createTypeDescMethod.setArgValues(argValues); + return createTypeDescMethod.invokeSafely(); + } catch (EvaluationException e) { throw createEvaluationException(NAME_REF_RESOLVING_ERROR, name); } - Value type = resolvedTypes.get(0); - List argTypeNames = new LinkedList<>(); - argTypeNames.add(B_TYPE_CLASS); - RuntimeStaticMethod createTypeDescMethod = getRuntimeMethod(context.getSuspendedContext(), - B_VALUE_CREATOR_CLASS, CREATE_TYPEDESC_VALUE_METHOD, argTypeNames); - List argValues = new LinkedList<>(); - argValues.add(type); - createTypeDescMethod.setArgValues(argValues); - return createTypeDescMethod.invokeSafely(); + } + + /** + * Returns runtime value of the Ballerina variable value reference for the given name. + * + * @param context suspended context + * @param name name of the variable to be retrieved + * @return the JDI value instance of the Ballerina variable + */ + public static Optional fetchVariableReferenceValue(EvaluationContext context, String name) + throws EvaluationException { + Optional bExpressionValue = searchLocalVariables(context.getSuspendedContext(), name); + if (bExpressionValue.isPresent()) { + return bExpressionValue; + } + + bExpressionValue = searchGlobalVariables(context.getSuspendedContext(), name); + return bExpressionValue; } /** diff --git a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/EvaluationExceptionKind.java b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/EvaluationExceptionKind.java index ecfaf51b9783..0b49ae9ac9ba 100644 --- a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/EvaluationExceptionKind.java +++ b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/EvaluationExceptionKind.java @@ -39,8 +39,9 @@ public enum EvaluationExceptionKind { INDEX_OUT_OF_RANGE_ERROR("%s index out of range: index=%d, size=%d"), INVALID_KEY_TYPE_ERROR("expected key type '%s'; found '%s' in '%s'"), TYPE_RESOLVING_ERROR("Failed to resolve type: '%s'"), + NAME_REF_RESOLVING_ERROR("Failed to resolve the name reference: '%s'"), IMPORT_RESOLVING_ERROR("Failed to resolve the import: '%s'"), - STRAND_NOT_FOUND("Error occurred when trying to get the current strand instance for executing the method: %s"), + STRAND_NOT_FOUND("Error occurred when trying to get the strand instance for the current stack frame"), CLASS_LOADING_FAILED("Failed to load the required classes to execute method: '%s'"), INVALID_ARGUMENT("Unsupported/invalid argument found: %s"), INVALID_XML_ATTRIBUTE("Invalid xml attribute access on %s"), @@ -48,6 +49,8 @@ public enum EvaluationExceptionKind { MISSING_MESSAGE_IN_ERROR("Missing error message in error constructor"), REST_ARG_IN_ERROR("Rest args are not allowed in error constructor"), ADDITIONAL_ARG_IN_ERROR("Additional positional arg in error constructor"), + CANNOT_INFER_PARAM_TYPE("Can not infer type for parameter '%s' in function '%s'. Consider passing" + + "the parameter value explicitly as an argument"), VARIABLE_EXECUTION_ERROR("Internal error occurred when processing variable: '%s'"), NON_PUBLIC_OR_UNDEFINED_ACCESS("Attempt to refer to undefined/non-accessible symbol '%s:%s'"), BLOCK_EVALUATION("Block expressions/statements are not supported"), diff --git a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationNegativeTest.java b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationNegativeTest.java index ded0341fbfe7..00ae8ce81a29 100644 --- a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationNegativeTest.java +++ b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationNegativeTest.java @@ -25,6 +25,7 @@ import static org.ballerinalang.debugger.test.adapter.evaluation.EvaluationExceptionKind.CUSTOM_ERROR; import static org.ballerinalang.debugger.test.adapter.evaluation.EvaluationExceptionKind.IMPORT_RESOLVING_ERROR; +import static org.ballerinalang.debugger.test.adapter.evaluation.EvaluationExceptionKind.NAME_REF_RESOLVING_ERROR; import static org.ballerinalang.debugger.test.adapter.evaluation.EvaluationExceptionKind.NON_PUBLIC_OR_UNDEFINED_ACCESS; import static org.ballerinalang.debugger.test.adapter.evaluation.EvaluationExceptionKind.REMOTE_METHOD_NOT_FOUND; import static org.ballerinalang.debugger.test.adapter.evaluation.EvaluationExceptionKind.UNSUPPORTED_EXPRESSION; @@ -95,6 +96,10 @@ public void newConstructorEvaluationTest() throws BallerinaTestException { @Override @Test public void simpleNameReferenceEvaluationTest() throws BallerinaTestException { + // undefined name reference evaluation + debugTestRunner.assertEvaluationError(context, "unknown", String.format(NAME_REF_RESOLVING_ERROR.getString(), + "unknown")); + // undefined constant evaluation debugTestRunner.assertEvaluationError(context, "int:MAX", String.format(NON_PUBLIC_OR_UNDEFINED_ACCESS .getString(), "int", "MAX")); diff --git a/tests/jballerina-debugger-integration-test/src/test/resources/project-based-tests/evaluation-tests-1/Dependencies.toml b/tests/jballerina-debugger-integration-test/src/test/resources/project-based-tests/evaluation-tests-1/Dependencies.toml new file mode 100644 index 000000000000..36adf3d9d14b --- /dev/null +++ b/tests/jballerina-debugger-integration-test/src/test/resources/project-based-tests/evaluation-tests-1/Dependencies.toml @@ -0,0 +1,50 @@ +# AUTO-GENERATED FILE. DO NOT MODIFY. + +# This file is auto-generated by Ballerina for managing dependency versions. +# It should not be modified by hand. + +[ballerina] +dependencies-toml-version = "2" + +[[package]] +org = "ballerina" +name = "jballerina.java" +version = "0.0.0" + +[[package]] +org = "ballerina" +name = "lang.float" +version = "0.0.0" +dependencies = [ + {org = "ballerina", name = "jballerina.java"} +] +modules = [ + {org = "ballerina", packageName = "lang.float", moduleName = "lang.float"} +] + +[[package]] +org = "ballerina" +name = "lang.int" +version = "0.0.0" +dependencies = [ + {org = "ballerina", name = "jballerina.java"} +] +modules = [ + {org = "ballerina", packageName = "lang.int", moduleName = "lang.int"} +] + +[[package]] +org = "debug_test_resources" +name = "evaluation_tests" +version = "0.1.0" +dependencies = [ + {org = "ballerina", name = "lang.float"}, + {org = "ballerina", name = "lang.int"} +] +modules = [ + {org = "debug_test_resources", packageName = "evaluation_tests", moduleName = "evaluation_tests"}, + {org = "debug_test_resources", packageName = "evaluation_tests", moduleName = "evaluation_tests.other"}, + {org = "debug_test_resources", packageName = "evaluation_tests", moduleName = "evaluation_tests.other2"} +] + + diff --git a/tests/jballerina-debugger-integration-test/src/test/resources/testng.xml b/tests/jballerina-debugger-integration-test/src/test/resources/testng.xml index 7e7c6aec2b47..02c9346cfb76 100644 --- a/tests/jballerina-debugger-integration-test/src/test/resources/testng.xml +++ b/tests/jballerina-debugger-integration-test/src/test/resources/testng.xml @@ -31,44 +31,44 @@ under the License. - - + + - - - - - + + + + + - - - + + + - - - + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - + + + From d535ab031b7635646fa5dfd5fedb49a4ef36438c Mon Sep 17 00:00:00 2001 From: Nipuna Ranasinghe Date: Tue, 29 Nov 2022 11:42:54 +0530 Subject: [PATCH 190/450] Improve negative tests --- .../evaluation/DebugExpressionEvaluator.java | 2 +- .../evaluation/EvaluationExceptionKind.java | 1 + .../engine/NameBasedTypeResolver.java | 4 +- .../ExpressionAsProgramEvaluator.java | 3 +- .../QualifiedNameReferenceEvaluator.java | 38 ++++- .../SimpleNameReferenceEvaluator.java | 4 +- .../evaluation/utils/EvaluationUtils.java | 150 ++++++++++++++++++ .../evaluation/utils/VariableUtils.java | 134 ---------------- .../evaluation/EvaluationExceptionKind.java | 2 + .../ExpressionEvaluationBaseTest.java | 2 +- .../ExpressionEvaluationNegativeTest.java | 10 +- .../evaluation/ExpressionEvaluationTest.java | 2 +- .../PackageEvaluationNegativeTest.java | 19 ++- .../evaluation/PackageEvaluationTest.java | 9 +- .../SingleFileEvaluationNegativeTest.java | 4 +- .../evaluation/SingleFileEvaluationTest.java | 4 +- .../evaluation-tests-1/Dependencies.toml | 50 ------ .../src/test/resources/testng.xml | 58 +++---- 18 files changed, 250 insertions(+), 246 deletions(-) delete mode 100644 tests/jballerina-debugger-integration-test/src/test/resources/project-based-tests/evaluation-tests-1/Dependencies.toml diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/DebugExpressionEvaluator.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/DebugExpressionEvaluator.java index 244da3656fab..5211aa4b4f9c 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/DebugExpressionEvaluator.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/DebugExpressionEvaluator.java @@ -66,7 +66,7 @@ public BExpressionValue evaluate() throws EvaluationException { EvaluatorBuilder evaluatorBuilder = new EvaluatorBuilder(evaluationContext); Evaluator evaluator = evaluatorBuilder.build(parsedExpression); - return new BExpressionValue(context, evaluator.evaluate().getJdiValue()); + return evaluator.evaluate(); } catch (EvaluationException e) { throw e; } catch (Exception e) { diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/EvaluationExceptionKind.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/EvaluationExceptionKind.java index 25009a699924..1e806827be04 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/EvaluationExceptionKind.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/EvaluationExceptionKind.java @@ -34,6 +34,7 @@ public enum EvaluationExceptionKind { FIELD_NOT_FOUND("Undefined field '%s' in `%s`"), VARIABLE_NOT_FOUND("Undefined variable '%s'"), QUALIFIED_VARIABLE_RESOLVING_FAILED("Failed to resolve qualified variable: '%s:%s'"), + QUALIFIED_REFERENCE_NOT_FOUND("Failed to resolve qualified name reference: '%s:%s'"), HELPER_UTIL_NOT_FOUND("Failed to load the evaluation helper util method: '%s'"), FUNCTION_EXECUTION_ERROR("Error occurred when executing method: '%s'"), INDEX_OUT_OF_RANGE_ERROR("%s index out of range: index=%d, size=%d"), diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/NameBasedTypeResolver.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/NameBasedTypeResolver.java index 6c0b6d54f2f3..6aadc210e1c3 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/NameBasedTypeResolver.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/NameBasedTypeResolver.java @@ -24,7 +24,7 @@ import org.ballerinalang.debugadapter.evaluation.EvaluationException; import org.ballerinalang.debugadapter.utils.PackageUtils; -import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import java.util.Optional; @@ -59,7 +59,7 @@ public NameBasedTypeResolver(EvaluationContext context) { */ @Override public List resolve(String typeDescriptor) throws EvaluationException { - List resolvedTypes = new ArrayList<>(); + List resolvedTypes = new LinkedList<>(); // If the type is a union, resolves each sub type iteratively. if (typeDescriptor.contains(UNION_TYPE_SEPARATOR_REGEX)) { String[] unionTypes = typeDescriptor.split(UNION_TYPE_SEPARATOR_REGEX); diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/ExpressionAsProgramEvaluator.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/ExpressionAsProgramEvaluator.java index ff427086027d..ef52b608ec90 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/ExpressionAsProgramEvaluator.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/ExpressionAsProgramEvaluator.java @@ -52,6 +52,7 @@ import org.ballerinalang.debugadapter.evaluation.engine.ExternalVariableReferenceFinder; import org.ballerinalang.debugadapter.evaluation.engine.ModuleLevelDefinitionFinder; import org.ballerinalang.debugadapter.evaluation.engine.invokable.RuntimeStaticMethod; +import org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils; import org.ballerinalang.debugadapter.evaluation.utils.FileUtils; import org.ballerinalang.debugadapter.evaluation.utils.VariableUtils; import org.ballerinalang.debugadapter.variable.BVariable; @@ -518,7 +519,7 @@ private void processSnippetFunctionParameters() throws EvaluationException { .getCapturedVariables()); List capturedTypes = new ArrayList<>(); for (String name : capturedVarNames) { - Optional variableValue = VariableUtils.fetchVariableReferenceValue(evaluationContext, + Optional variableValue = EvaluationUtils.fetchVariableReferenceValue(evaluationContext, name); if (variableValue.isEmpty()) { throw createEvaluationException(VARIABLE_NOT_FOUND, name); diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/QualifiedNameReferenceEvaluator.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/QualifiedNameReferenceEvaluator.java index 48988a712380..541979cc2ef3 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/QualifiedNameReferenceEvaluator.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/QualifiedNameReferenceEvaluator.java @@ -16,6 +16,7 @@ package org.ballerinalang.debugadapter.evaluation.engine.expression; +import com.sun.jdi.Value; import io.ballerina.compiler.api.symbols.ConstantSymbol; import io.ballerina.compiler.api.symbols.ModuleSymbol; import io.ballerina.compiler.api.symbols.SymbolKind; @@ -25,8 +26,12 @@ import org.ballerinalang.debugadapter.evaluation.BExpressionValue; import org.ballerinalang.debugadapter.evaluation.EvaluationException; import org.ballerinalang.debugadapter.evaluation.engine.Evaluator; +import org.ballerinalang.debugadapter.evaluation.engine.NameBasedTypeResolver; +import org.ballerinalang.debugadapter.evaluation.engine.invokable.RuntimeStaticMethod; import org.ballerinalang.debugadapter.evaluation.utils.VariableUtils; +import java.util.LinkedList; +import java.util.List; import java.util.Optional; import static org.ballerinalang.debugadapter.evaluation.EvaluationException.createEvaluationException; @@ -35,6 +40,10 @@ import static org.ballerinalang.debugadapter.evaluation.EvaluationExceptionKind.NON_PUBLIC_OR_UNDEFINED_ACCESS; import static org.ballerinalang.debugadapter.evaluation.EvaluationExceptionKind.QUALIFIED_VARIABLE_RESOLVING_FAILED; import static org.ballerinalang.debugadapter.evaluation.engine.EvaluationTypeResolver.isPublicSymbol; +import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.B_TYPE_CLASS; +import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.B_VALUE_CREATOR_CLASS; +import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.CREATE_TYPEDESC_VALUE_METHOD; +import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.getRuntimeMethod; /** * Ballerina qualified name reference evaluator implementation. @@ -69,10 +78,28 @@ public BExpressionValue evaluate() throws EvaluationException { // Validates whether the given module has a public variable, using semantic API. Optional moduleVariable = searchForModuleVariable(moduleSymbol, modulePrefix); - if (moduleVariable.isEmpty()) { + if (moduleVariable.isPresent()) { + return moduleVariable.get(); + } + + NameBasedTypeResolver qualifiedTypeResolver = new NameBasedTypeResolver(evaluationContext); + try { + List resolvedTypes = qualifiedTypeResolver.resolve(modulePrefix + ":" + nameReference); + if (resolvedTypes.size() != 1) { + throw createEvaluationException(QUALIFIED_VARIABLE_RESOLVING_FAILED, modulePrefix, nameReference); + } + Value type = resolvedTypes.get(0); + List argTypeNames = new LinkedList<>(); + argTypeNames.add(B_TYPE_CLASS); + RuntimeStaticMethod createTypeDescMethod = getRuntimeMethod(context, + B_VALUE_CREATOR_CLASS, CREATE_TYPEDESC_VALUE_METHOD, argTypeNames); + List argValues = new LinkedList<>(); + argValues.add(type); + createTypeDescMethod.setArgValues(argValues); + return new BExpressionValue(context, createTypeDescMethod.invokeSafely()); + } catch (EvaluationException e) { throw createEvaluationException(QUALIFIED_VARIABLE_RESOLVING_FAILED, modulePrefix, nameReference); } - return moduleVariable.get(); } catch (EvaluationException e) { throw e; } catch (Exception e) { @@ -111,10 +138,9 @@ private Optional searchForModuleVariable(ModuleSymbol moduleSy .map(symbol -> (VariableSymbol) symbol) .findAny(); - if (variableSymbol.isEmpty() || variableSymbol.get().getModule().isEmpty()) { - throw createEvaluationException(NON_PUBLIC_OR_UNDEFINED_ACCESS, modulePrefix, nameReference); - } else if (!isPublicSymbol(variableSymbol.get())) { - throw createEvaluationException(NON_PUBLIC_OR_UNDEFINED_ACCESS, modulePrefix, nameReference); + if (variableSymbol.isEmpty() || variableSymbol.get().getModule().isEmpty() + || !isPublicSymbol(variableSymbol.get())) { + return Optional.empty(); } return VariableUtils.getModuleVariable(context, variableSymbol.get().getModule().get(), nameReference); diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/SimpleNameReferenceEvaluator.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/SimpleNameReferenceEvaluator.java index 7f008f2fca62..d52477819a79 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/SimpleNameReferenceEvaluator.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/engine/expression/SimpleNameReferenceEvaluator.java @@ -21,7 +21,7 @@ import org.ballerinalang.debugadapter.evaluation.BExpressionValue; import org.ballerinalang.debugadapter.evaluation.EvaluationException; import org.ballerinalang.debugadapter.evaluation.engine.Evaluator; -import org.ballerinalang.debugadapter.evaluation.utils.VariableUtils; +import org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils; import static org.ballerinalang.debugadapter.evaluation.EvaluationException.createEvaluationException; import static org.ballerinalang.debugadapter.evaluation.EvaluationExceptionKind.VARIABLE_EXECUTION_ERROR; @@ -43,7 +43,7 @@ public SimpleNameReferenceEvaluator(EvaluationContext context, SimpleNameReferen @Override public BExpressionValue evaluate() throws EvaluationException { try { - return new BExpressionValue(context, VariableUtils.fetchNameReferenceValue(evaluationContext, + return new BExpressionValue(context, EvaluationUtils.fetchNameReferenceValue(evaluationContext, nameReference)); } catch (EvaluationException e) { throw e; diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/utils/EvaluationUtils.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/utils/EvaluationUtils.java index 50dc3b9d12cb..1cc4e51bd3b1 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/utils/EvaluationUtils.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/utils/EvaluationUtils.java @@ -20,6 +20,7 @@ import com.sun.jdi.ClassObjectReference; import com.sun.jdi.ClassType; import com.sun.jdi.DoubleValue; +import com.sun.jdi.Field; import com.sun.jdi.FloatValue; import com.sun.jdi.IntegerValue; import com.sun.jdi.InvocationException; @@ -32,20 +33,30 @@ import io.ballerina.compiler.api.ModuleID; import io.ballerina.compiler.api.symbols.Symbol; import io.ballerina.identifier.Utils; +import org.ballerinalang.debugadapter.EvaluationContext; import org.ballerinalang.debugadapter.SuspendedContext; import org.ballerinalang.debugadapter.evaluation.BExpressionValue; import org.ballerinalang.debugadapter.evaluation.EvaluationException; import org.ballerinalang.debugadapter.evaluation.IdentifierModifier; +import org.ballerinalang.debugadapter.evaluation.engine.NameBasedTypeResolver; import org.ballerinalang.debugadapter.evaluation.engine.invokable.GeneratedStaticMethod; import org.ballerinalang.debugadapter.evaluation.engine.invokable.RuntimeInstanceMethod; import org.ballerinalang.debugadapter.evaluation.engine.invokable.RuntimeStaticMethod; +import org.ballerinalang.debugadapter.jdi.JdiProxyException; +import org.ballerinalang.debugadapter.jdi.LocalVariableProxyImpl; +import org.ballerinalang.debugadapter.utils.PackageUtils; import org.ballerinalang.debugadapter.variable.BVariable; +import org.ballerinalang.debugadapter.variable.BVariableType; +import org.ballerinalang.debugadapter.variable.DebugVariableException; +import org.ballerinalang.debugadapter.variable.IndexedCompoundVariable; import org.ballerinalang.debugadapter.variable.JVMValueType; import org.ballerinalang.debugadapter.variable.VariableFactory; import java.util.ArrayList; import java.util.Collections; +import java.util.LinkedList; import java.util.List; +import java.util.Objects; import java.util.Optional; import java.util.StringJoiner; import java.util.stream.Collectors; @@ -54,8 +65,10 @@ import static org.ballerinalang.debugadapter.evaluation.EvaluationException.createEvaluationException; import static org.ballerinalang.debugadapter.evaluation.EvaluationExceptionKind.CLASS_LOADING_FAILED; import static org.ballerinalang.debugadapter.evaluation.EvaluationExceptionKind.HELPER_UTIL_NOT_FOUND; +import static org.ballerinalang.debugadapter.evaluation.EvaluationExceptionKind.NAME_REF_RESOLVING_ERROR; import static org.ballerinalang.debugadapter.evaluation.IdentifierModifier.encodeModuleName; import static org.ballerinalang.debugadapter.utils.PackageUtils.BAL_FILE_EXT; +import static org.ballerinalang.debugadapter.utils.PackageUtils.INIT_CLASS_NAME; /** * Debug expression evaluation utils. @@ -544,4 +557,141 @@ public static String modifyName(String identifier) { return Utils.decodeIdentifier(IdentifierModifier.encodeIdentifier(identifier, IdentifierModifier.IdentifierType.OTHER)); } + + /** + * Returns runtime value of the Ballerina value reference for the given name. For that, this method searches for a + * match according to the below order. + * + *
      + *
    • variables defined both local and global scopes + *
    • types defined int both local and global scopes + *
    + * + * @param context suspended context + * @param name name of the variable to be retrieved + * @return the JDI value instance of the Ballerina variable + */ + public static Value fetchNameReferenceValue(EvaluationContext context, String name) throws EvaluationException { + Optional variableReferenceValue = fetchVariableReferenceValue(context, name); + if (variableReferenceValue.isPresent()) { + return variableReferenceValue.get().getJdiValue(); + } + + NameBasedTypeResolver typeResolver = new NameBasedTypeResolver(context); + try { + List resolvedTypes = typeResolver.resolve(name); + if (resolvedTypes.size() != 1) { + throw createEvaluationException(NAME_REF_RESOLVING_ERROR, name); + } + Value type = resolvedTypes.get(0); + List argTypeNames = new LinkedList<>(); + argTypeNames.add(B_TYPE_CLASS); + RuntimeStaticMethod createTypeDescMethod = getRuntimeMethod(context.getSuspendedContext(), + B_VALUE_CREATOR_CLASS, CREATE_TYPEDESC_VALUE_METHOD, argTypeNames); + List argValues = new LinkedList<>(); + argValues.add(type); + createTypeDescMethod.setArgValues(argValues); + return createTypeDescMethod.invokeSafely(); + } catch (EvaluationException e) { + throw createEvaluationException(NAME_REF_RESOLVING_ERROR, name); + } + } + + /** + * Returns runtime value of the Ballerina variable value reference for the given name. + * + * @param context suspended context + * @param name name of the variable to be retrieved + * @return the JDI value instance of the Ballerina variable + */ + public static Optional fetchVariableReferenceValue(EvaluationContext context, String name) + throws EvaluationException { + Optional bExpressionValue = searchLocalVariables(context.getSuspendedContext(), name); + if (bExpressionValue.isPresent()) { + return bExpressionValue; + } + + bExpressionValue = searchGlobalVariables(context.getSuspendedContext(), name); + return bExpressionValue; + } + + /** + * Returns runtime value of the matching local variable, for the given name. + * + * @param context suspended context + * @param nameReference name of the variable to be retrieved + * @return the JDI value instance of the local variable + */ + private static Optional searchLocalVariables(SuspendedContext context, String nameReference) { + try { + LocalVariableProxyImpl jvmVar = context.getFrame().visibleVariableByName(nameReference); + if (jvmVar != null) { + return Optional.of(new BExpressionValue(context, context.getFrame().getValue(jvmVar))); + } + + // As all the ballerina variables which are being used inside lambda functions are converted into maps + // during the runtime code generation, such local variables should be accessed in a different manner. + List lambdaParamMaps = context.getFrame().visibleVariables().stream() + .filter(org.ballerinalang.debugadapter.variable.VariableUtils::isLambdaParamMap) + .collect(Collectors.toList()); + + Optional localVariableMatch = lambdaParamMaps.stream() + .map(localVariableProxy -> { + try { + Value varValue = context.getFrame().getValue(localVariableProxy); + BVariable mapVar = VariableFactory.getVariable(context, varValue); + if (mapVar == null || mapVar.getBType() != BVariableType.MAP + || !(mapVar instanceof IndexedCompoundVariable)) { + return null; + } + return ((IndexedCompoundVariable) mapVar).getChildByName(nameReference); + } catch (JdiProxyException | DebugVariableException e) { + return null; + } + }) + .filter(Objects::nonNull) + .findAny(); + + if (localVariableMatch.isEmpty()) { + return Optional.empty(); + } + return Optional.of(new BExpressionValue(context, localVariableMatch.get())); + } catch (JdiProxyException e) { + return Optional.empty(); + } + } + + /** + * Returns runtime value of the matching global variable, for the given name. + * + * @param context suspended context + * @param nameReference name of the variable to be retrieved + * @return the JDI value instance of the global variable + */ + private static Optional searchGlobalVariables(SuspendedContext context, String nameReference) { + String classQName = PackageUtils.getQualifiedClassName(context, INIT_CLASS_NAME); + return getFieldValue(context, classQName, nameReference); + } + + private static Optional getFieldValue(SuspendedContext context, String qualifiedClassName, + String fieldName) { + List classesRef = context.getAttachedVm().classesByName(qualifiedClassName); + // Tries to load the required class instance using "java.lang.Class.forName()" method. + if (classesRef == null || classesRef.isEmpty()) { + try { + classesRef = Collections.singletonList(loadClass(context, qualifiedClassName, "")); + } catch (EvaluationException e) { + return Optional.empty(); + } + } + if (classesRef.size() != 1) { + return Optional.empty(); + } + + Field field = classesRef.get(0).fieldByName(fieldName); + if (field == null) { + return Optional.empty(); + } + return Optional.of(new BExpressionValue(context, classesRef.get(0).getValue(field))); + } } diff --git a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/utils/VariableUtils.java b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/utils/VariableUtils.java index c191a37a8ccd..d55a8ec2cd86 100644 --- a/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/utils/VariableUtils.java +++ b/misc/debug-adapter/modules/debug-adapter-core/src/main/java/org/ballerinalang/debugadapter/evaluation/utils/VariableUtils.java @@ -20,39 +20,20 @@ import com.sun.jdi.ReferenceType; import com.sun.jdi.Value; import io.ballerina.compiler.api.symbols.ModuleSymbol; -import org.ballerinalang.debugadapter.EvaluationContext; import org.ballerinalang.debugadapter.SuspendedContext; import org.ballerinalang.debugadapter.evaluation.BExpressionValue; import org.ballerinalang.debugadapter.evaluation.EvaluationException; -import org.ballerinalang.debugadapter.evaluation.engine.NameBasedTypeResolver; import org.ballerinalang.debugadapter.evaluation.engine.invokable.RuntimeStaticMethod; -import org.ballerinalang.debugadapter.jdi.JdiProxyException; -import org.ballerinalang.debugadapter.jdi.LocalVariableProxyImpl; -import org.ballerinalang.debugadapter.utils.PackageUtils; -import org.ballerinalang.debugadapter.variable.BVariable; -import org.ballerinalang.debugadapter.variable.BVariableType; -import org.ballerinalang.debugadapter.variable.DebugVariableException; -import org.ballerinalang.debugadapter.variable.IndexedCompoundVariable; -import org.ballerinalang.debugadapter.variable.VariableFactory; import java.util.Collections; -import java.util.LinkedList; import java.util.List; -import java.util.Objects; import java.util.Optional; import java.util.StringJoiner; -import java.util.stream.Collectors; -import static org.ballerinalang.debugadapter.evaluation.EvaluationException.createEvaluationException; -import static org.ballerinalang.debugadapter.evaluation.EvaluationExceptionKind.NAME_REF_RESOLVING_ERROR; import static org.ballerinalang.debugadapter.evaluation.IdentifierModifier.encodeModuleName; import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.B_DEBUGGER_RUNTIME_UTILS_CLASS; -import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.B_TYPE_CLASS; -import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.B_VALUE_CREATOR_CLASS; -import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.CREATE_TYPEDESC_VALUE_METHOD; import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.GET_BMAP_TYPE_METHOD; import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.MODULE_VERSION_SEPARATOR_REGEX; -import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.getRuntimeMethod; import static org.ballerinalang.debugadapter.evaluation.utils.EvaluationUtils.loadClass; import static org.ballerinalang.debugadapter.utils.PackageUtils.INIT_CLASS_NAME; import static org.ballerinalang.debugadapter.variable.VariableUtils.UNKNOWN_VALUE; @@ -64,121 +45,6 @@ */ public class VariableUtils { - /** - * Returns runtime value of the Ballerina value reference for the given name. For that, this method searches for a - * match according to the below order. - * - *
      - *
    • variables defined both local and global scopes - *
    • types defined int both local and global scopes - *
    - * - * @param context suspended context - * @param name name of the variable to be retrieved - * @return the JDI value instance of the Ballerina variable - */ - public static Value fetchNameReferenceValue(EvaluationContext context, String name) throws EvaluationException { - Optional variableReferenceValue = fetchVariableReferenceValue(context, name); - if (variableReferenceValue.isPresent()) { - return variableReferenceValue.get().getJdiValue(); - } - - NameBasedTypeResolver typeResolver = new NameBasedTypeResolver(context); - try { - List resolvedTypes = typeResolver.resolve(name); - if (resolvedTypes.size() != 1) { - throw createEvaluationException(NAME_REF_RESOLVING_ERROR, name); - } - Value type = resolvedTypes.get(0); - List argTypeNames = new LinkedList<>(); - argTypeNames.add(B_TYPE_CLASS); - RuntimeStaticMethod createTypeDescMethod = getRuntimeMethod(context.getSuspendedContext(), - B_VALUE_CREATOR_CLASS, CREATE_TYPEDESC_VALUE_METHOD, argTypeNames); - List argValues = new LinkedList<>(); - argValues.add(type); - createTypeDescMethod.setArgValues(argValues); - return createTypeDescMethod.invokeSafely(); - } catch (EvaluationException e) { - throw createEvaluationException(NAME_REF_RESOLVING_ERROR, name); - } - } - - /** - * Returns runtime value of the Ballerina variable value reference for the given name. - * - * @param context suspended context - * @param name name of the variable to be retrieved - * @return the JDI value instance of the Ballerina variable - */ - public static Optional fetchVariableReferenceValue(EvaluationContext context, String name) - throws EvaluationException { - Optional bExpressionValue = searchLocalVariables(context.getSuspendedContext(), name); - if (bExpressionValue.isPresent()) { - return bExpressionValue; - } - - bExpressionValue = searchGlobalVariables(context.getSuspendedContext(), name); - return bExpressionValue; - } - - /** - * Returns runtime value of the matching local variable, for the given name. - * - * @param context suspended context - * @param nameReference name of the variable to be retrieved - * @return the JDI value instance of the local variable - */ - private static Optional searchLocalVariables(SuspendedContext context, String nameReference) { - try { - LocalVariableProxyImpl jvmVar = context.getFrame().visibleVariableByName(nameReference); - if (jvmVar != null) { - return Optional.of(new BExpressionValue(context, context.getFrame().getValue(jvmVar))); - } - - // As all the ballerina variables which are being used inside lambda functions are converted into maps - // during the runtime code generation, such local variables should be accessed in a different manner. - List lambdaParamMaps = context.getFrame().visibleVariables().stream() - .filter(org.ballerinalang.debugadapter.variable.VariableUtils::isLambdaParamMap) - .collect(Collectors.toList()); - - Optional localVariableMatch = lambdaParamMaps.stream() - .map(localVariableProxy -> { - try { - Value varValue = context.getFrame().getValue(localVariableProxy); - BVariable mapVar = VariableFactory.getVariable(context, varValue); - if (mapVar == null || mapVar.getBType() != BVariableType.MAP - || !(mapVar instanceof IndexedCompoundVariable)) { - return null; - } - return ((IndexedCompoundVariable) mapVar).getChildByName(nameReference); - } catch (JdiProxyException | DebugVariableException e) { - return null; - } - }) - .filter(Objects::nonNull) - .findAny(); - - if (localVariableMatch.isEmpty()) { - return Optional.empty(); - } - return Optional.of(new BExpressionValue(context, localVariableMatch.get())); - } catch (JdiProxyException e) { - return Optional.empty(); - } - } - - /** - * Returns runtime value of the matching global variable, for the given name. - * - * @param context suspended context - * @param nameReference name of the variable to be retrieved - * @return the JDI value instance of the global variable - */ - private static Optional searchGlobalVariables(SuspendedContext context, String nameReference) { - String classQName = PackageUtils.getQualifiedClassName(context, INIT_CLASS_NAME); - return getFieldValue(context, classQName, nameReference); - } - /** * Returns runtime value of the matching constant variable, for the given name. * diff --git a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/EvaluationExceptionKind.java b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/EvaluationExceptionKind.java index 0b49ae9ac9ba..7cdfac38c513 100644 --- a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/EvaluationExceptionKind.java +++ b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/EvaluationExceptionKind.java @@ -34,6 +34,7 @@ public enum EvaluationExceptionKind { FIELD_NOT_FOUND("Undefined field '%s' in `%s`"), VARIABLE_NOT_FOUND("Undefined variable '%s'"), QUALIFIED_VARIABLE_RESOLVING_FAILED("Failed to resolve qualified variable: '%s:%s'"), + QUALIFIED_REFERENCE_NOT_FOUND("Failed to resolve qualified name reference: '%s:%s'"), HELPER_UTIL_NOT_FOUND("Failed to load the evaluation helper util method: '%s'"), FUNCTION_EXECUTION_ERROR("Error occurred when executing method: '%s'"), INDEX_OUT_OF_RANGE_ERROR("%s index out of range: index=%d, size=%d"), @@ -49,6 +50,7 @@ public enum EvaluationExceptionKind { MISSING_MESSAGE_IN_ERROR("Missing error message in error constructor"), REST_ARG_IN_ERROR("Rest args are not allowed in error constructor"), ADDITIONAL_ARG_IN_ERROR("Additional positional arg in error constructor"), + CANNOT_INFER_PARAM_TYPE("Can not infer type for parameter '%s' in function '%s'. Consider passing" + "the parameter value explicitly as an argument"), VARIABLE_EXECUTION_ERROR("Internal error occurred when processing variable: '%s'"), diff --git a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationBaseTest.java b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationBaseTest.java index 1d4c6d998870..5da6099b21d2 100644 --- a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationBaseTest.java +++ b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationBaseTest.java @@ -129,7 +129,7 @@ protected void endSoftAssertions() { public abstract void newConstructorEvaluationTest() throws BallerinaTestException; - public abstract void simpleNameReferenceEvaluationTest() throws BallerinaTestException; + public abstract void nameReferenceEvaluationTest() throws BallerinaTestException; public abstract void builtInNameReferenceEvaluationTest() throws BallerinaTestException; diff --git a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationNegativeTest.java b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationNegativeTest.java index 00ae8ce81a29..bfa2f857d45d 100644 --- a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationNegativeTest.java +++ b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationNegativeTest.java @@ -26,7 +26,7 @@ import static org.ballerinalang.debugger.test.adapter.evaluation.EvaluationExceptionKind.CUSTOM_ERROR; import static org.ballerinalang.debugger.test.adapter.evaluation.EvaluationExceptionKind.IMPORT_RESOLVING_ERROR; import static org.ballerinalang.debugger.test.adapter.evaluation.EvaluationExceptionKind.NAME_REF_RESOLVING_ERROR; -import static org.ballerinalang.debugger.test.adapter.evaluation.EvaluationExceptionKind.NON_PUBLIC_OR_UNDEFINED_ACCESS; +import static org.ballerinalang.debugger.test.adapter.evaluation.EvaluationExceptionKind.QUALIFIED_VARIABLE_RESOLVING_FAILED; import static org.ballerinalang.debugger.test.adapter.evaluation.EvaluationExceptionKind.REMOTE_METHOD_NOT_FOUND; import static org.ballerinalang.debugger.test.adapter.evaluation.EvaluationExceptionKind.UNSUPPORTED_EXPRESSION; @@ -95,13 +95,13 @@ public void newConstructorEvaluationTest() throws BallerinaTestException { @Override @Test - public void simpleNameReferenceEvaluationTest() throws BallerinaTestException { + public void nameReferenceEvaluationTest() throws BallerinaTestException { // undefined name reference evaluation debugTestRunner.assertEvaluationError(context, "unknown", String.format(NAME_REF_RESOLVING_ERROR.getString(), "unknown")); // undefined constant evaluation - debugTestRunner.assertEvaluationError(context, "int:MAX", String.format(NON_PUBLIC_OR_UNDEFINED_ACCESS + debugTestRunner.assertEvaluationError(context, "int:MAX", String.format(QUALIFIED_VARIABLE_RESOLVING_FAILED .getString(), "int", "MAX")); // undefined module evaluation @@ -448,10 +448,10 @@ public void queryExpressionEvaluationTest() throws BallerinaTestException { "Reason: compilation error(s) found while creating executables for evaluation: " + System.lineSeparator() + "field name 'id' used in key specifier is not found in table constraint type" + - " 'map<(any|error)>'" + + " 'map<(any|error)>'" + System.lineSeparator() + "field name 'name' used in key specifier is not found in table constraint type" + - " 'map<(any|error)>'"); + " 'map<(any|error)>'"); // on conflict clauses usages with non-table returns debugTestRunner.assertEvaluationError(context, "from var customer in conflictedCustomerList" + diff --git a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationTest.java b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationTest.java index efa266f6bd7a..5d6c54edc35c 100644 --- a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationTest.java +++ b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationTest.java @@ -126,7 +126,7 @@ public void builtInNameReferenceEvaluationTest() throws BallerinaTestException { @Override @Test - public void simpleNameReferenceEvaluationTest() throws BallerinaTestException { + public void nameReferenceEvaluationTest() throws BallerinaTestException { // var variable test debugTestRunner.assertExpression(context, NIL_VAR, "()", "nil"); // boolean variable test diff --git a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/PackageEvaluationNegativeTest.java b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/PackageEvaluationNegativeTest.java index b092d80032bc..6ec15d7ba5cb 100644 --- a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/PackageEvaluationNegativeTest.java +++ b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/PackageEvaluationNegativeTest.java @@ -31,6 +31,7 @@ import static org.ballerinalang.debugger.test.adapter.evaluation.EvaluationExceptionKind.NON_PUBLIC_OR_UNDEFINED_ACCESS; import static org.ballerinalang.debugger.test.adapter.evaluation.EvaluationExceptionKind.NON_PUBLIC_OR_UNDEFINED_CLASS; import static org.ballerinalang.debugger.test.adapter.evaluation.EvaluationExceptionKind.NON_PUBLIC_OR_UNDEFINED_FUNCTION; +import static org.ballerinalang.debugger.test.adapter.evaluation.EvaluationExceptionKind.QUALIFIED_VARIABLE_RESOLVING_FAILED; /** * Test implementation for debug expression evaluation negative scenarios on Ballerina packages. @@ -104,21 +105,25 @@ public void unaryExpressionEvaluationTest() throws BallerinaTestException { super.unaryExpressionEvaluationTest(); // with qualified literals (i.e. imported modules) - debugTestRunner.assertEvaluationError(context, "-other:constant", String.format(NON_PUBLIC_OR_UNDEFINED_ACCESS - .getString(), "other", "constant")); + debugTestRunner.assertEvaluationError(context, "-other:constant", + String.format(QUALIFIED_VARIABLE_RESOLVING_FAILED.getString(), "other", "constant")); } @Override @Test - public void simpleNameReferenceEvaluationTest() throws BallerinaTestException { - super.simpleNameReferenceEvaluationTest(); + public void nameReferenceEvaluationTest() throws BallerinaTestException { + super.nameReferenceEvaluationTest(); // package-private constant evaluation - debugTestRunner.assertEvaluationError(context, "other:constant", String.format(NON_PUBLIC_OR_UNDEFINED_ACCESS - .getString(), "other", "constant")); + debugTestRunner.assertEvaluationError(context, "other:constant", + String.format(QUALIFIED_VARIABLE_RESOLVING_FAILED.getString(), "other", "constant")); // package-private module variable evaluation debugTestRunner.assertEvaluationError(context, "other:privateModuleVariable", - String.format(NON_PUBLIC_OR_UNDEFINED_ACCESS.getString(), "other", "privateModuleVariable")); + String.format(QUALIFIED_VARIABLE_RESOLVING_FAILED.getString(), "other", "privateModuleVariable")); + + // other qualified references (i.e. types) + debugTestRunner.assertEvaluationError(context, "other:UndefinedType", + String.format(QUALIFIED_VARIABLE_RESOLVING_FAILED.getString(), "other", "UndefinedType")); } } diff --git a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/PackageEvaluationTest.java b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/PackageEvaluationTest.java index f5cfd19cefaa..35f3be3f3c0e 100644 --- a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/PackageEvaluationTest.java +++ b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/PackageEvaluationTest.java @@ -106,19 +106,22 @@ public void unaryExpressionEvaluationTest() throws BallerinaTestException { @Override @Test - public void simpleNameReferenceEvaluationTest() throws BallerinaTestException { - super.simpleNameReferenceEvaluationTest(); + public void nameReferenceEvaluationTest() throws BallerinaTestException { + super.nameReferenceEvaluationTest(); // Todo - move to common evaluation test suite after fixing the value string debugTestRunner.assertExpression(context, GLOBAL_VAR_03, "(debug_test_resources/evaluation_tests:0:$anonType$nameMap$_0 & readonly)", "record"); - // with qualified variable references (i.e. imported modules) + // qualified variable references (i.e. imported modules) debugTestRunner.assertExpression(context, "other:publicConstant", "\"Ballerina\"", "string"); debugTestRunner.assertExpression(context, "other:publicModuleVariable", "\"public\"", "string"); debugTestRunner.assertExpression(context, "other:constMap", "(debug_test_resources/evaluation_tests.other:0:$anonType$constMap$_0 & readonly)", "record"); + + // other qualified references (i.e. types) + debugTestRunner.assertExpression(context, "other:Kid", "evaluation_tests.other:Kid", "typedesc"); } } diff --git a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/SingleFileEvaluationNegativeTest.java b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/SingleFileEvaluationNegativeTest.java index 09b0804530e7..76f602d3b364 100644 --- a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/SingleFileEvaluationNegativeTest.java +++ b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/SingleFileEvaluationNegativeTest.java @@ -91,8 +91,8 @@ public void unaryExpressionEvaluationTest() throws BallerinaTestException { } @Override - public void simpleNameReferenceEvaluationTest() throws BallerinaTestException { - super.simpleNameReferenceEvaluationTest(); + public void nameReferenceEvaluationTest() throws BallerinaTestException { + super.nameReferenceEvaluationTest(); // access constants in undefined modules debugTestRunner.assertEvaluationError(context, "other:constant", diff --git a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/SingleFileEvaluationTest.java b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/SingleFileEvaluationTest.java index b7aee7ee968a..12c6b50bb52e 100644 --- a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/SingleFileEvaluationTest.java +++ b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/SingleFileEvaluationTest.java @@ -48,8 +48,8 @@ protected void prepareForEvaluation() throws BallerinaTestException { @Override @Test - public void simpleNameReferenceEvaluationTest() throws BallerinaTestException { - super.simpleNameReferenceEvaluationTest(); + public void nameReferenceEvaluationTest() throws BallerinaTestException { + super.nameReferenceEvaluationTest(); // Todo - move to common evaluation test suite after fixing the value string debugTestRunner.assertExpression(context, GLOBAL_VAR_03, "record {| readonly \"John\" name; |} & readonly", diff --git a/tests/jballerina-debugger-integration-test/src/test/resources/project-based-tests/evaluation-tests-1/Dependencies.toml b/tests/jballerina-debugger-integration-test/src/test/resources/project-based-tests/evaluation-tests-1/Dependencies.toml deleted file mode 100644 index 36adf3d9d14b..000000000000 --- a/tests/jballerina-debugger-integration-test/src/test/resources/project-based-tests/evaluation-tests-1/Dependencies.toml +++ /dev/null @@ -1,50 +0,0 @@ -# AUTO-GENERATED FILE. DO NOT MODIFY. - -# This file is auto-generated by Ballerina for managing dependency versions. -# It should not be modified by hand. - -[ballerina] -dependencies-toml-version = "2" - -[[package]] -org = "ballerina" -name = "jballerina.java" -version = "0.0.0" - -[[package]] -org = "ballerina" -name = "lang.float" -version = "0.0.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] -modules = [ - {org = "ballerina", packageName = "lang.float", moduleName = "lang.float"} -] - -[[package]] -org = "ballerina" -name = "lang.int" -version = "0.0.0" -dependencies = [ - {org = "ballerina", name = "jballerina.java"} -] -modules = [ - {org = "ballerina", packageName = "lang.int", moduleName = "lang.int"} -] - -[[package]] -org = "debug_test_resources" -name = "evaluation_tests" -version = "0.1.0" -dependencies = [ - {org = "ballerina", name = "lang.float"}, - {org = "ballerina", name = "lang.int"} -] -modules = [ - {org = "debug_test_resources", packageName = "evaluation_tests", moduleName = "evaluation_tests"}, - {org = "debug_test_resources", packageName = "evaluation_tests", moduleName = "evaluation_tests.other"}, - {org = "debug_test_resources", packageName = "evaluation_tests", moduleName = "evaluation_tests.other2"} -] - - diff --git a/tests/jballerina-debugger-integration-test/src/test/resources/testng.xml b/tests/jballerina-debugger-integration-test/src/test/resources/testng.xml index 02c9346cfb76..28074f2c1421 100644 --- a/tests/jballerina-debugger-integration-test/src/test/resources/testng.xml +++ b/tests/jballerina-debugger-integration-test/src/test/resources/testng.xml @@ -31,44 +31,44 @@ under the License. - - + + - - - - - + + + + + - - - + + + - - - + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - + + + From 0014be1b8da3f5258058ea6fdad38fce3ce889c1 Mon Sep 17 00:00:00 2001 From: Nipuna Ranasinghe Date: Tue, 29 Nov 2022 11:48:03 +0530 Subject: [PATCH 191/450] Add minor fix --- .../src/test/resources/testng.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/jballerina-debugger-integration-test/src/test/resources/testng.xml b/tests/jballerina-debugger-integration-test/src/test/resources/testng.xml index 28074f2c1421..7e7c6aec2b47 100644 --- a/tests/jballerina-debugger-integration-test/src/test/resources/testng.xml +++ b/tests/jballerina-debugger-integration-test/src/test/resources/testng.xml @@ -47,9 +47,9 @@ under the License. - - - + + + From 55d02caddeb6951d706cf5e7cf9e6aebbfa3a1d0 Mon Sep 17 00:00:00 2001 From: Nipuna Ranasinghe Date: Tue, 6 Dec 2022 13:47:51 +0530 Subject: [PATCH 192/450] Fix single file evaluation failures --- .../adapter/evaluation/ExpressionEvaluationTest.java | 5 ----- .../adapter/evaluation/PackageEvaluationTest.java | 8 +++++++- .../adapter/evaluation/SingleFileEvaluationTest.java | 12 ++++++++++++ .../resources/single-file-tests/evaluation_main.bal | 4 ++++ 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationTest.java b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationTest.java index 5d6c54edc35c..2aa01ec907ad 100644 --- a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationTest.java +++ b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/ExpressionEvaluationTest.java @@ -203,10 +203,6 @@ public void nameReferenceEvaluationTest() throws BallerinaTestException { // qualified name references with import alias debugTestRunner.assertExpression(context, "langFloat:PI", "3.141592653589793", "float"); - - // named types - debugTestRunner.assertExpression(context, "Student", "evaluation_tests:Student", "typedesc"); - debugTestRunner.assertExpression(context, "AnonPerson", "evaluation_tests:AnonPerson", "typedesc"); } @Override @@ -368,7 +364,6 @@ public void functionCallEvaluationTest() throws BallerinaTestException { // with typedesc values as arguments debugTestRunner.assertExpression(context, "processTypeDesc(int)", "int", "typedesc"); - debugTestRunner.assertExpression(context, "processTypeDesc(Student)", "evaluation_tests:Student", "typedesc"); } @Override diff --git a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/PackageEvaluationTest.java b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/PackageEvaluationTest.java index 35f3be3f3c0e..526461f8e711 100644 --- a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/PackageEvaluationTest.java +++ b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/PackageEvaluationTest.java @@ -53,6 +53,8 @@ public void functionCallEvaluationTest() throws BallerinaTestException { // with qualified literals (i.e. imported modules from the same package) debugTestRunner.assertExpression(context, "other:sum(2,6)", "8", "int"); + // with typedesc values as arguments + debugTestRunner.assertExpression(context, "processTypeDesc(Student)", "evaluation_tests:Student", "typedesc"); } @Override @@ -121,7 +123,11 @@ public void nameReferenceEvaluationTest() throws BallerinaTestException { "(debug_test_resources/evaluation_tests.other:0:$anonType$constMap$_0 & readonly)", "record"); - // other qualified references (i.e. types) + // other simple name references (i.e. types) + debugTestRunner.assertExpression(context, "Student", "evaluation_tests:Student", "typedesc"); + debugTestRunner.assertExpression(context, "AnonPerson", "evaluation_tests:AnonPerson", "typedesc"); + + // other qualified name references (i.e. types) debugTestRunner.assertExpression(context, "other:Kid", "evaluation_tests.other:Kid", "typedesc"); } } diff --git a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/SingleFileEvaluationTest.java b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/SingleFileEvaluationTest.java index 12c6b50bb52e..b47c9f65a3e0 100644 --- a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/SingleFileEvaluationTest.java +++ b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/evaluation/SingleFileEvaluationTest.java @@ -51,8 +51,20 @@ protected void prepareForEvaluation() throws BallerinaTestException { public void nameReferenceEvaluationTest() throws BallerinaTestException { super.nameReferenceEvaluationTest(); + // other simple name references (i.e. types) + debugTestRunner.assertExpression(context, "Student", "Student", "typedesc"); + debugTestRunner.assertExpression(context, "AnonPerson", "AnonPerson", "typedesc"); + // Todo - move to common evaluation test suite after fixing the value string debugTestRunner.assertExpression(context, GLOBAL_VAR_03, "record {| readonly \"John\" name; |} & readonly", "record"); } + + @Override + public void functionCallEvaluationTest() throws BallerinaTestException { + super.functionCallEvaluationTest(); + + // with typedesc values as arguments + debugTestRunner.assertExpression(context, "processTypeDesc(Student)", "Student", "typedesc"); + } } diff --git a/tests/jballerina-debugger-integration-test/src/test/resources/single-file-tests/evaluation_main.bal b/tests/jballerina-debugger-integration-test/src/test/resources/single-file-tests/evaluation_main.bal index 0d3baeafc7a5..143fa37e27bd 100644 --- a/tests/jballerina-debugger-integration-test/src/test/resources/single-file-tests/evaluation_main.bal +++ b/tests/jballerina-debugger-integration-test/src/test/resources/single-file-tests/evaluation_main.bal @@ -449,3 +449,7 @@ function getRecordConstrainedError() returns FooError { FooError e = error FooError("Some Error", detailMsg = "Failed Message", isFatal = true); return e; } + +function processTypeDesc(typedesc t) returns typedesc { + return t; +} \ No newline at end of file From 72213cf47ba7ec49647b07bee321d0d1b181ad6c Mon Sep 17 00:00:00 2001 From: Nipuna Ranasinghe Date: Thu, 8 Dec 2022 09:46:20 +0530 Subject: [PATCH 193/450] Address review suggestions --- .../src/test/resources/single-file-tests/evaluation_main.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/jballerina-debugger-integration-test/src/test/resources/single-file-tests/evaluation_main.bal b/tests/jballerina-debugger-integration-test/src/test/resources/single-file-tests/evaluation_main.bal index 143fa37e27bd..bed227ac51c6 100644 --- a/tests/jballerina-debugger-integration-test/src/test/resources/single-file-tests/evaluation_main.bal +++ b/tests/jballerina-debugger-integration-test/src/test/resources/single-file-tests/evaluation_main.bal @@ -452,4 +452,4 @@ function getRecordConstrainedError() returns FooError { function processTypeDesc(typedesc t) returns typedesc { return t; -} \ No newline at end of file +} From c03910f649eb98245ffc9c2aacea236a2d8c055d Mon Sep 17 00:00:00 2001 From: Nadeeshan96 Date: Fri, 9 Dec 2022 14:29:07 +0530 Subject: [PATCH 194/450] Add original name to BFiniteType BTypeSymbol --- .../compiler/parser/BLangNodeBuilder.java | 12 ++++++++++++ .../semantics/analyzer/SymbolEnter.java | 19 ++++++++----------- .../model/symbols/BTypeDefinitionSymbol.java | 7 ++++++- .../semantics/model/symbols/Symbols.java | 11 +++++++++++ 4 files changed, 37 insertions(+), 12 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java index 7315a7fe4d44..44a1d1aef0b9 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java @@ -1051,6 +1051,17 @@ private BLangUserDefinedType deSugarTypeAsUserDefType(BLangType toIndirect) { return createUserDefinedType(pos, (BLangIdentifier) TreeBuilder.createIdentifierNode(), bLTypeDef.name); } + private void setOriginalNameForAnonTypeGenName(IdentifierNode anonTypeGenName) { + if (!this.anonTypeNameSuffixes.isEmpty()) { + StringBuilder originalName = new StringBuilder( + this.anonTypeNameSuffixes.elementAt(this.anonTypeNameSuffixes.size() - 1)); + for (int i = this.anonTypeNameSuffixes.size() - 2; i >= 0; i--) { + originalName.append(DOLLAR).append(this.anonTypeNameSuffixes.elementAt(i)); + } + anonTypeGenName.setOriginalValue(originalName.toString()); + } + } + private BLangTypeDefinition createTypeDefinitionWithTypeNode(BLangType toIndirect) { Location pos = toIndirect.pos; BLangTypeDefinition bLTypeDef = (BLangTypeDefinition) TreeBuilder.createTypeDefinition(); @@ -1058,6 +1069,7 @@ private BLangTypeDefinition createTypeDefinitionWithTypeNode(BLangType toIndirec // Generate a name for the anonymous object String genName = anonymousModelHelper.getNextAnonymousTypeKey(packageID, this.anonTypeNameSuffixes); IdentifierNode anonTypeGenName = createIdentifier(symTable.builtinPos, genName); + setOriginalNameForAnonTypeGenName(anonTypeGenName); bLTypeDef.setName(anonTypeGenName); bLTypeDef.flagSet.add(Flag.PUBLIC); bLTypeDef.flagSet.add(Flag.ANONYMOUS); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolEnter.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolEnter.java index a45ffab5305d..84819080a5cc 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolEnter.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolEnter.java @@ -1635,11 +1635,13 @@ public void visit(BLangTypeDefinition typeDefinition) { typeDefinition.setPrecedence(this.typePrecedence++); BSymbol typeDefSymbol = Symbols.createTypeDefinitionSymbol(Flags.asMask(typeDefinition.flagSet), - names.fromIdNode(typeDefinition.name), env.enclPkg.packageID, definedType, env.scope.owner, - typeDefinition.name.pos, getOrigin(typeDefinition.name.value)); + names.fromIdNode(typeDefinition.name), names.originalNameFromIdNode(typeDefinition.name), + env.enclPkg.packageID, definedType, env.scope.owner, typeDefinition.name.pos, + getOrigin(typeDefinition.name.value)); typeDefSymbol.markdownDocumentation = getMarkdownDocAttachment(typeDefinition.markdownDocumentationAttachment); BTypeSymbol typeSymbol = new BTypeSymbol(SymTag.TYPE_REF, typeDefSymbol.flags, typeDefSymbol.name, - typeDefSymbol.pkgID, typeDefSymbol.type, typeDefSymbol.owner, typeDefSymbol.pos, typeDefSymbol.origin); + typeDefSymbol.originalName, typeDefSymbol.pkgID, typeDefSymbol.type, typeDefSymbol.owner, + typeDefSymbol.pos, typeDefSymbol.origin); typeSymbol.markdownDocumentation = typeDefSymbol.markdownDocumentation; ((BTypeDefinitionSymbol) typeDefSymbol).referenceType = new BTypeReferenceType(definedType, typeSymbol, typeDefSymbol.type.flags); @@ -1649,7 +1651,7 @@ public void visit(BLangTypeDefinition typeDefinition) { if (definedType.tsymbol.name == Names.EMPTY) { isLabel = false; definedType.tsymbol.name = names.fromIdNode(typeDefinition.name); - definedType.tsymbol.originalName = names.fromIdNode(typeDefinition.name); + definedType.tsymbol.originalName = names.originalNameFromIdNode(typeDefinition.name); definedType.tsymbol.flags |= typeDefSymbol.flags; definedType.tsymbol.markdownDocumentation = typeDefSymbol.markdownDocumentation; @@ -1908,16 +1910,11 @@ private BEnumSymbol createEnumSymbol(BLangTypeDefinition typeDefinition, BType d } BEnumSymbol enumSymbol = new BEnumSymbol(enumMembers, Flags.asMask(typeDefinition.flagSet), - names.fromIdNode(typeDefinition.name), names.fromIdNode(typeDefinition.name), - env.enclPkg.symbol.pkgID, definedType, env.scope.owner, + names.fromIdNode(typeDefinition.name), names.originalNameFromIdNode(typeDefinition.name), + env.enclPkg.packageID, definedType, env.scope.owner, typeDefinition.pos, SOURCE); - enumSymbol.name = names.fromIdNode(typeDefinition.name); - enumSymbol.originalName = names.fromIdNode(typeDefinition.name); - enumSymbol.flags |= Flags.asMask(typeDefinition.flagSet); - enumSymbol.markdownDocumentation = getMarkdownDocAttachment(typeDefinition.markdownDocumentationAttachment); - enumSymbol.pkgID = env.enclPkg.packageID; return enumSymbol; } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/BTypeDefinitionSymbol.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/BTypeDefinitionSymbol.java index 001dc4a6368e..7b60aa0ef6e3 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/BTypeDefinitionSymbol.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/BTypeDefinitionSymbol.java @@ -41,7 +41,12 @@ public class BTypeDefinitionSymbol extends BSymbol implements Annotatable { public BTypeDefinitionSymbol(long flags, Name name, PackageID pkgID, BType type, BSymbol owner, Location pos, SymbolOrigin origin) { - super(SymTag.TYPE_DEF, flags, name, pkgID, type, owner, pos, origin); + this(flags, name, name, pkgID, type, owner, pos, origin); + } + + public BTypeDefinitionSymbol(long flags, Name name, Name originalName, PackageID pkgID, BType type, BSymbol owner, + Location pos, SymbolOrigin origin) { + super(SymTag.TYPE_DEF, flags, name, originalName, pkgID, type, owner, pos, origin); this.kind = SymbolKind.TYPE_DEF; this.annAttachments = new ArrayList<>(); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/Symbols.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/Symbols.java index c2ed153c4acf..66f7da7be03e 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/Symbols.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/Symbols.java @@ -190,6 +190,17 @@ public static BTypeDefinitionSymbol createTypeDefinitionSymbol(long flags, return new BTypeDefinitionSymbol(flags, name, pkgID, type, owner, pos, origin); } + public static BTypeDefinitionSymbol createTypeDefinitionSymbol(long flags, + Name name, + Name originalName, + PackageID pkgID, + BType type, + BSymbol owner, + Location pos, + SymbolOrigin origin) { + return new BTypeDefinitionSymbol(flags, name, originalName, pkgID, type, owner, pos, origin); + } + public static BInvokableTypeSymbol createInvokableTypeSymbol(int symTag, long flags, From f2a04d1a32f14ff6d6208dfc0df87eb48e87bf81 Mon Sep 17 00:00:00 2001 From: Nadeeshan96 Date: Fri, 9 Dec 2022 15:38:21 +0530 Subject: [PATCH 195/450] Add original name to the runtime BFiniteType --- .../runtime/internal/types/BFiniteType.java | 14 ++++++++++++-- .../compiler/bir/codegen/JvmSignatures.java | 2 +- .../compiler/bir/codegen/JvmTypeGen.java | 7 ++++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/types/BFiniteType.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/types/BFiniteType.java index c861afc51bf5..936f904164d8 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/types/BFiniteType.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/types/BFiniteType.java @@ -40,16 +40,21 @@ public class BFiniteType extends BType implements FiniteType { public Set valueSpace; private int typeFlags; + private String originalName; public BFiniteType(String typeName) { - super(typeName, null, RefValue.class); - this.valueSpace = new LinkedHashSet<>(); + this(typeName, new LinkedHashSet<>(), 0); } public BFiniteType(String typeName, Set values, int typeFlags) { + this(typeName, typeName, values, typeFlags); + } + + public BFiniteType(String typeName, String originalName, Set values, int typeFlags) { super(typeName, null, RefValue.class); this.valueSpace = values; this.typeFlags = typeFlags; + this.originalName = originalName; } @Override @@ -80,6 +85,11 @@ public V getZeroValue() { return null; } + @Override + public String getName() { + return this.originalName; + } + @Override public V getEmptyValue() { if (valueSpace.stream().anyMatch(val -> val == null || TypeChecker.getType(val).isNilable())) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java index 8675ebe0548c..2c3de4ec975a 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmSignatures.java @@ -288,7 +288,7 @@ public class JvmSignatures { public static final String INIT_ERROR = "(L" + B_STRING_VALUE + ";)V"; public static final String INIT_ERROR_TYPE_IMPL = "(L" + STRING_VALUE + ";L" + MODULE + ";)V"; public static final String INIT_FIELD_IMPL = "(L" + TYPE + ";L" + STRING_VALUE + ";J)V"; - public static final String INIT_FINITE_TYPE_IMPL = "(L" + STRING_VALUE + ";L" + SET + ";I)V"; + public static final String INIT_FINITE_TYPE_IMPL = "(L" + STRING_VALUE + ";L" + STRING_VALUE + ";L" + SET + ";I)V"; public static final String INIT_FUNCTION_PARAM = "(L" + STRING_VALUE + ";ZL" + STRING_VALUE + ";L" + TYPE + ";)V"; public static final String INIT_FUNCTION_TYPE_IMPL = "(L" + MODULE + ";J)V"; public static final String INIT_FUNCTION_TYPE_IMPL_WITH_PARAMS = "(L" + MODULE + ";[L" + FUNCTION_PARAMETER + ";" + diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeGen.java index 7a3164312cd6..87eeec637164 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeGen.java @@ -1083,9 +1083,11 @@ private void loadFiniteType(MethodVisitor mv, BFiniteType finiteType) { mv.visitTypeInsn(NEW, FINITE_TYPE_IMPL); mv.visitInsn(DUP); - // Load type name + // load type name String name = Utils.decodeIdentifier(toNameString(finiteType)); mv.visitLdcInsn(name); + // load original type name + mv.visitLdcInsn(finiteType.tsymbol.originalName.value); mv.visitTypeInsn(NEW, LINKED_HASH_SET); mv.visitInsn(DUP); @@ -1114,8 +1116,7 @@ private void loadFiniteType(MethodVisitor mv, BFiniteType finiteType) { mv.visitLdcInsn(typeFlag(finiteType)); // initialize the finite type using the value space - mv.visitMethodInsn(INVOKESPECIAL, FINITE_TYPE_IMPL, JVM_INIT_METHOD, - INIT_FINITE_TYPE_IMPL, false); + mv.visitMethodInsn(INVOKESPECIAL, FINITE_TYPE_IMPL, JVM_INIT_METHOD, INIT_FINITE_TYPE_IMPL, false); } private void loadValueType(MethodVisitor mv, BType valueType) { From be0009c858111a029127225f5d3377c40a074f2e Mon Sep 17 00:00:00 2001 From: Nadeeshan96 Date: Fri, 9 Dec 2022 16:33:29 +0530 Subject: [PATCH 196/450] Set original name in constants --- .../wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java index 44a1d1aef0b9..f9c983aa9169 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java @@ -883,8 +883,9 @@ private void createAnonymousTypeDefForConstantDeclaration(BLangConstant constant BLangTypeDefinition typeDef = (BLangTypeDefinition) TreeBuilder.createTypeDefinition(); this.anonTypeNameSuffixes.push(constantNode.name.value); String genName = anonymousModelHelper.getNextAnonymousTypeKey(packageID, anonTypeNameSuffixes); - this.anonTypeNameSuffixes.pop(); IdentifierNode anonTypeGenName = createIdentifier(symTable.builtinPos, genName); + setOriginalNameForAnonTypeGenName(anonTypeGenName); + this.anonTypeNameSuffixes.pop(); typeDef.setName(anonTypeGenName); typeDef.flagSet.add(Flag.PUBLIC); typeDef.flagSet.add(Flag.ANONYMOUS); From 736db5a2f349a4570cd646a12d0e673c9c9378ee Mon Sep 17 00:00:00 2001 From: Nadeeshan96 Date: Fri, 9 Dec 2022 17:40:53 +0530 Subject: [PATCH 197/450] Add tests for type names of finite types --- .../jvm/runtime/api/tests/Enums.java | 38 +++++++++++++++++++ .../api/values/modules/enums/enums.bal | 33 ++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Enums.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Enums.java index 4ac1a6c7f457..43120530089d 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Enums.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/Enums.java @@ -19,6 +19,8 @@ package org.ballerinalang.nativeimpl.jvm.runtime.api.tests; import io.ballerina.runtime.api.Module; +import io.ballerina.runtime.api.TypeTags; +import io.ballerina.runtime.api.creators.ErrorCreator; import io.ballerina.runtime.api.creators.TypeCreator; import io.ballerina.runtime.api.creators.ValueCreator; import io.ballerina.runtime.api.flags.SymbolFlags; @@ -27,10 +29,15 @@ import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.types.UnionType; import io.ballerina.runtime.api.utils.StringUtils; +import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; +import io.ballerina.runtime.api.values.BError; import io.ballerina.runtime.api.values.BString; +import io.ballerina.runtime.api.values.BTypedesc; import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -58,6 +65,37 @@ public static BArray createEnumArray(BString enumName) { return ValueCreator.createArrayValue(arrayType); } + public static void testFiniteTypeUnionElements(BTypedesc t, BArray elements) { + Set members = new HashSet<>(); + members.addAll(Arrays.asList(elements.getStringArray())); + BError notFiniteTypeError = ErrorCreator.createError( + StringUtils.fromString("union member type is not a finite type")); + BError matchError = ErrorCreator.createError( + StringUtils.fromString("type name does not match given names")); + + Type describingType = TypeUtils.getReferredType(t.getDescribingType()); + if (describingType.getTag() == TypeTags.UNION_TAG) { + UnionType unionType = (UnionType) describingType; + for (Type memberType : unionType.getMemberTypes()) { + if (memberType.getTag() == TypeTags.FINITE_TYPE_TAG) { + String typeName = memberType.getName(); + if (members.contains(typeName)) { + members.remove(typeName); + } else { + throw matchError; + } + } else { + throw notFiniteTypeError; + } + } + if (!members.isEmpty()) { + throw ErrorCreator.createError(StringUtils.fromString("all union member type names are not provided")); + } + } else { + throw ErrorCreator.createError(StringUtils.fromString("given type is not a union type")); + } + } + public static void addToEnumArray(BArray array, BString value) { array.append(value); } diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/values/modules/enums/enums.bal b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/values/modules/enums/enums.bal index a4433f4bc577..717ff05559e7 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/values/modules/enums/enums.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/runtime/api/values/modules/enums/enums.bal @@ -22,7 +22,40 @@ enum Status { CLOSE } +enum Language { + ENG = "English", + TL = "Tamil", + SI = "Sinhala" +} + +enum Race { + ENG = "English", + TL = "Tamil", + SI = "Sinhala" +} + +const R = "RED"; +const G = "GREEN"; +const B = "BLUE"; + +type Color R|G|B; + public function validateAPI() { + testEnumArray(); + testFiniteTypeGetName(); +} + +function testFiniteTypeGetName() { + testFiniteTypeUnionElements(Language, ["ENG", "TL", "SI"]); + testFiniteTypeUnionElements(Race, ["ENG", "TL", "SI"]); + testFiniteTypeUnionElements(Color, ["R", "G", "B"]); +} + +function testFiniteTypeUnionElements(typedesc t, string[] elements) = @java:Method { + 'class: "org.ballerinalang.nativeimpl.jvm.runtime.api.tests.Enums" +} external; + +function testEnumArray() { Status[] enumArray = createEnumArray("Status"); addToEnumArray(enumArray, "OPEN"); test:assertEquals(enumArray.pop(), OPEN); From 1369c3f27b6bb0e6a2f34a048741ee1cf9355d7d Mon Sep 17 00:00:00 2001 From: Fathima Dilhasha Date: Thu, 24 Nov 2022 10:44:26 +0530 Subject: [PATCH 198/450] Load generated sources --- .../projects/directory/BuildProject.java | 30 +++- .../projects/directory/ProjectLoader.java | 7 + .../projects/internal/ModuleData.java | 4 + .../projects/internal/PackageDiagnostic.java | 24 +++- .../projects/internal/ProjectFiles.java | 59 +++++++- .../projects/util/ProjectConstants.java | 1 + .../ballerina/projects/util/ProjectPaths.java | 50 +++++-- .../ballerina/projects/ProjectPathsTest.java | 37 ++++- .../langserver/BallerinaLanguageServer.java | 2 + .../langserver/common/utils/PathUtil.java | 18 ++- .../workspace/BallerinaWorkspaceManager.java | 17 ++- .../projects/test/TestBalaProject.java | 8 -- .../TestBuildProjectWithGeneratedSources.java | 133 ++++++++++++++++++ .../my_generated_project/Ballerina.toml | 4 + .../my_generated_project/Cloud.toml | 2 + .../my_generated_project/CompilerPlugin.toml | 5 + .../my_generated_project/Dependencies.toml | 32 +++++ .../my_generated_project/Module.md | 1 + .../my_generated_project/Package.md | 1 + .../my_generated_project/generated/gen.bal | 6 + .../my_generated_project/generated/gen1.bal | 6 + .../generated/newmod/mewmod_gen.bal | 10 ++ .../generated/services/services_gen.bal | 10 ++ .../generated/storage/storage_gen.bal | 10 ++ .../libs/platform-io-1.3.0-java.txt | 1 + .../my_generated_project/main.bal | 7 + .../modules/services/Module.md | 1 + .../modules/services/resources/config.json | 1 + .../resources/invalidProject/Ballerina.toml | 4 + .../resources/invalidProject/main.bal | 5 + .../invalidProject/tests/main_tests.bal | 2 + .../modules/services/svc.bal | 6 + .../modules/services/tests/svc_tests.bal | 2 + .../modules/storage/db.bal | 2 + .../modules/storage/resources/db.json | 1 + .../modules/storage/tests/db_tests.bal | 2 + .../my_generated_project/tests/main_tests.bal | 2 + .../my_generated_project/util/file-util.bal | 2 + .../my_generated_project/utils.bal | 5 + .../project_no_permission/Ballerina.toml | 4 + .../project_no_permission/generated/gen1.bal | 1 + .../generated/services/svc1.bal | 1 + .../project_no_permission/main.bal | 3 + 43 files changed, 487 insertions(+), 42 deletions(-) create mode 100644 project-api/project-api-test/src/test/java/io/ballerina/projects/test/TestBuildProjectWithGeneratedSources.java create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/Ballerina.toml create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/Cloud.toml create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/CompilerPlugin.toml create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/Dependencies.toml create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/Module.md create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/Package.md create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/generated/gen.bal create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/generated/gen1.bal create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/generated/newmod/mewmod_gen.bal create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/generated/services/services_gen.bal create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/generated/storage/storage_gen.bal create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/libs/platform-io-1.3.0-java.txt create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/main.bal create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/services/Module.md create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/services/resources/config.json create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/services/resources/invalidProject/Ballerina.toml create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/services/resources/invalidProject/main.bal create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/services/resources/invalidProject/tests/main_tests.bal create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/services/svc.bal create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/services/tests/svc_tests.bal create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/storage/db.bal create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/storage/resources/db.json create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/storage/tests/db_tests.bal create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/tests/main_tests.bal create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/util/file-util.bal create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/utils.bal create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/project_no_permission/Ballerina.toml create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/project_no_permission/generated/gen1.bal create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/project_no_permission/generated/services/svc1.bal create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/project_no_permission/main.bal diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/directory/BuildProject.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/directory/BuildProject.java index 6e59aa527cd0..d11206d7dec5 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/directory/BuildProject.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/directory/BuildProject.java @@ -138,12 +138,34 @@ private Optional modulePath(ModuleId moduleId) { return Optional.empty(); } + private Optional generatedModulePath(ModuleId moduleId) { + if (currentPackage().moduleIds().contains(moduleId)) { + Optional generatedModulePath = Optional.of(sourceRoot. + resolve(ProjectConstants.GENERATED_MODULES_ROOT)); + if (currentPackage().getDefaultModule().moduleId() == moduleId && + Files.isDirectory(generatedModulePath.get())) { + return generatedModulePath; + } + String moduleName = currentPackage().module(moduleId).moduleName().moduleNamePart(); + if (Files.isDirectory(Optional.of(generatedModulePath.get().resolve(moduleName)).get())) { + return Optional.of(generatedModulePath.get().resolve(moduleName)); + } + } + return Optional.empty(); + } + @Override public Optional documentPath(DocumentId documentId) { for (ModuleId moduleId : currentPackage().moduleIds()) { Module module = currentPackage().module(moduleId); Optional modulePath = modulePath(moduleId); if (module.documentIds().contains(documentId)) { + Optional generatedModulePath = generatedModulePath(moduleId); + if (generatedModulePath.isPresent()) { + if (Files.exists(generatedModulePath.get().resolve(module.document(documentId).name()))) { + return Optional.of(generatedModulePath.get().resolve(module.document(documentId).name())); + } + } if (modulePath.isPresent()) { return Optional.of(modulePath.get().resolve(module.document(documentId).name())); } @@ -176,6 +198,8 @@ public Project duplicate() { public DocumentId documentId(Path file) { if (isFilePathInProject(file)) { Path parent = Optional.of(file.toAbsolutePath().getParent()).get(); + String parentFileName = Optional.of(parent.getFileName()).get().toString(); + boolean isDefaultModule = false; for (ModuleId moduleId : this.currentPackage().moduleIds()) { String moduleDirName; // Check for the module name contains a dot and not being the default module @@ -184,10 +208,12 @@ public DocumentId documentId(Path file) { .split(this.currentPackage().packageName().toString() + "\\.")[1]; } else { moduleDirName = Optional.of(this.sourceRoot.getFileName()).get().toString(); + isDefaultModule = true; } Module module = this.currentPackage().module(moduleId); - if (Optional.of(parent.getFileName()).get().toString().equals(moduleDirName)) { + if (parentFileName.equals(moduleDirName) || + (isDefaultModule && ProjectConstants.GENERATED_MODULES_ROOT.equals(parentFileName))) { // this is a source file for (DocumentId documentId : module.documentIds()) { if (module.document(documentId).name().equals( @@ -195,7 +221,7 @@ public DocumentId documentId(Path file) { return documentId; } } - } else if (Optional.of(parent.getFileName()).get().toString().equals(ProjectConstants.TEST_DIR_NAME)) { + } else if (ProjectConstants.TEST_DIR_NAME.equals(parentFileName)) { // this is a test file if (Optional.of(Optional.of(parent.getParent()).get().getFileName()).get().toString() .equals(moduleDirName)) { diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/directory/ProjectLoader.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/directory/ProjectLoader.java index 32c99b09cd6d..034428f2ebc3 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/directory/ProjectLoader.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/directory/ProjectLoader.java @@ -67,6 +67,13 @@ public static Project loadProject(Path path, ProjectEnvironmentBuilder projectEn if (ProjectConstants.MODULES_ROOT.equals( Optional.of(absFilePath.getParent()).get().toFile().getName())) { projectRoot = Optional.of(Optional.of(absFilePath.getParent()).get().getParent()).get(); + } else if (ProjectConstants.GENERATED_MODULES_ROOT.equals(absFilePath.toFile().getName())) { + // Generated default module + projectRoot = Optional.of(absFilePath.getParent()).get(); + } else if (ProjectConstants.GENERATED_MODULES_ROOT. + equals(Optional.of(absFilePath.getParent()).get().toFile().getName())) { + // Generated non default module + projectRoot = Optional.of(Optional.of(absFilePath.getParent()).get().getParent()).get(); } else { projectRoot = absFilePath; } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ModuleData.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ModuleData.java index 213dbd4d4e1e..e5c406c5be11 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ModuleData.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ModuleData.java @@ -76,6 +76,10 @@ public List sourceDocs() { return srcDocs; } + public void addSourceDocs(List docs) { + srcDocs.addAll(docs); + } + public List testSourceDocs() { return testSrcDocs; } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageDiagnostic.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageDiagnostic.java index dc451abd0448..c19da957456a 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageDiagnostic.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageDiagnostic.java @@ -32,6 +32,7 @@ import io.ballerina.tools.text.TextRange; import java.io.File; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; @@ -58,16 +59,29 @@ protected PackageDiagnostic(DiagnosticInfo diagnosticInfo, Location location) { public PackageDiagnostic(Diagnostic diagnostic, ModuleDescriptor moduleDescriptor, Project project) { String filePath; ModuleName moduleName = moduleDescriptor.name(); + String diagnosticPath = diagnostic.location().lineRange().filePath(); + Path modulesRoot = Paths.get(ProjectConstants.MODULES_ROOT); if (project.kind().equals(ProjectKind.BALA_PROJECT)) { - Path modulePath = Paths.get(ProjectConstants.MODULES_ROOT).resolve(moduleName.toString()); + Path modulePath = modulesRoot.resolve(moduleName.toString()); filePath = project.sourceRoot().resolve(modulePath).resolve( - diagnostic.location().lineRange().filePath()).toString(); + diagnosticPath).toString(); } else { + Path generatedRoot = Paths.get(ProjectConstants.GENERATED_MODULES_ROOT); if (!moduleName.isDefaultModuleName()) { - Path modulePath = Paths.get(ProjectConstants.MODULES_ROOT).resolve(moduleName.moduleNamePart()); - filePath = modulePath.resolve(diagnostic.location().lineRange().filePath()).toString(); + Path generatedPath = generatedRoot. + resolve(moduleName.moduleNamePart()); + if (Files.exists(project.sourceRoot().resolve(generatedPath). + resolve(diagnosticPath).toAbsolutePath())) { + filePath = generatedPath.resolve(diagnosticPath).toString(); + } else { + filePath = modulesRoot.resolve(moduleName.moduleNamePart()). + resolve(diagnosticPath).toString(); + } } else { - filePath = diagnostic.location().lineRange().filePath(); + filePath = Files.exists(project.sourceRoot().resolve(generatedRoot). + resolve(diagnosticPath).toAbsolutePath()) ? + generatedRoot.resolve(diagnosticPath).toString() : diagnosticPath; + } } this.diagnostic = diagnostic; diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ProjectFiles.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ProjectFiles.java index cd7861b86e74..94e608c9d761 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ProjectFiles.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ProjectFiles.java @@ -32,6 +32,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.PathMatcher; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Optional; @@ -67,7 +68,7 @@ public static PackageData loadSingleFileProjectPackageData(Path filePath) { public static PackageData loadBuildProjectPackageData(Path packageDirPath) { ModuleData defaultModule = loadModule(packageDirPath); List otherModules = loadOtherModules(packageDirPath); - + otherModules.addAll(loadNewGeneratedModules(packageDirPath)); DocumentData ballerinaToml = loadDocument(packageDirPath.resolve(ProjectConstants.BALLERINA_TOML)); DocumentData dependenciesToml = loadDocument(packageDirPath.resolve(ProjectConstants.DEPENDENCIES_TOML)); DocumentData cloudToml = loadDocument(packageDirPath.resolve(ProjectConstants.CLOUD_TOML)); @@ -78,6 +79,40 @@ public static PackageData loadBuildProjectPackageData(Path packageDirPath) { ballerinaToml, dependenciesToml, cloudToml, compilerPluginToml, packageMd); } + private static Collection loadNewGeneratedModules(Path packageDirPath) { + Path generatedSourceRoot = packageDirPath.resolve(ProjectConstants.GENERATED_MODULES_ROOT); + if (Files.isDirectory(generatedSourceRoot)) { + try (Stream pathStream = Files.walk(generatedSourceRoot, 1)) { + return pathStream + .filter(path -> !ProjectConstants.GENERATED_MODULES_ROOT.equals(path.toFile().getName())) + .filter(Files::isDirectory) + .filter(path -> isNewModule(packageDirPath, path)) + .filter(path -> { + // validate moduleName + if (!ProjectUtils.validateModuleName(path.toFile().getName())) { + throw new ProjectException("Invalid module name : '" + path.getFileName() + "' :\n" + + "Module name can only contain alphanumerics, underscores and periods"); + } + if (!ProjectUtils.validateNameLength(path.toFile().getName())) { + throw new ProjectException("Invalid module name : '" + path.getFileName() + "' :\n" + + "Maximum length of module name is 256 characters"); + } + return true; + }) + .map(ProjectFiles::loadModule) + .collect(Collectors.toList()); + } catch (IOException e) { + throw new ProjectException(e); + } + } + return Collections.emptyList(); + } + + private static boolean isNewModule(Path packageDirPath, Path path) { + Path modulePath = packageDirPath.resolve(ProjectConstants.MODULES_ROOT).resolve(path.toFile().getName()); + return !Files.exists(modulePath); + } + private static List loadOtherModules(Path packageDirPath) { Path modulesDirPath = packageDirPath.resolve("modules"); if (!Files.isDirectory(modulesDirPath)) { @@ -111,12 +146,24 @@ private static ModuleData loadModule(Path moduleDirPath) { List srcDocs = loadDocuments(moduleDirPath); List testSrcDocs; Path testDirPath = moduleDirPath.resolve("tests"); - if (Files.isDirectory(testDirPath)) { - testSrcDocs = loadTestDocuments(testDirPath); - } else { - testSrcDocs = Collections.emptyList(); + testSrcDocs = Files.isDirectory(testDirPath) ? loadTestDocuments(testDirPath) : Collections.emptyList(); + + // If the module is not a newly generated module, explicitly load generated sources + if (!ProjectConstants.GENERATED_MODULES_ROOT.equals(Optional.of( + moduleDirPath.getParent()).get().toFile().getName())) { + // Generated sources root for default module + Path generatedSourcesRoot = moduleDirPath.resolve(ProjectConstants.GENERATED_MODULES_ROOT); + if (ProjectConstants.MODULES_ROOT.equals(Optional.of(moduleDirPath.getParent()).get().toFile().getName())) { + // generated sources root for non-default modules + generatedSourcesRoot = Optional.of(Optional.of(Optional.of(moduleDirPath.getParent()). + get().getParent()).get(). + resolve(ProjectConstants.GENERATED_MODULES_ROOT)).get(). + resolve(Optional.of(moduleDirPath.toFile()).get().getName()); + } + if (Files.isDirectory(generatedSourcesRoot)) { + srcDocs.addAll(loadDocuments(generatedSourcesRoot)); + } } - DocumentData moduleMd = loadDocument(moduleDirPath.resolve(ProjectConstants.MODULE_MD_FILE_NAME)); List resources = loadResources(moduleDirPath); List testResources = loadResources(moduleDirPath.resolve(ProjectConstants.TEST_DIR_NAME)); diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectConstants.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectConstants.java index 8c17fb092720..252378957925 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectConstants.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectConstants.java @@ -63,6 +63,7 @@ public class ProjectConstants { // Bala specific constants public static final String MODULES_ROOT = "modules"; + public static final String GENERATED_MODULES_ROOT = "generated"; public static final String LIB_DIR = "lib"; public static final String COMPILER_PLUGIN_DIR = "compiler-plugin"; diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectPaths.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectPaths.java index 1a09958faa1f..23d47b411578 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectPaths.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectPaths.java @@ -52,13 +52,8 @@ public static Path packageRoot(Path filepath) throws ProjectException { if (hasBallerinaToml(filepath) || hasPackageJson(filepath)) { return filepath; } - if (isModulesRoot(filepath)) { - return findProjectRoot(filepath).orElseThrow(); - } - if (isAModuleRoot(filepath)) { - return findProjectRoot(filepath).orElseThrow(); - } - if (isAModuleTestsRoot(filepath)) { + if (isModulesRoot(filepath) || isGeneratedModulesRoot(filepath) || isAModuleRoot(filepath) || + isAGeneratedModuleRoot(filepath) || isAModuleTestsRoot(filepath)) { return findProjectRoot(filepath).orElseThrow(); } throw new ProjectException("provided directory does not belong to a Ballerina package: " + filepath); @@ -88,7 +83,11 @@ public static Path packageRoot(Path filepath) throws ProjectException { // check if the file is a source file in the default module if (isDefaultModuleSrcFile(absFilePath)) { - return absFilePath.getParent(); + Path parentPath = absFilePath.getParent(); + if (ProjectConstants.GENERATED_MODULES_ROOT.equals(Optional.of(parentPath).get().toFile().getName())) { + parentPath = parentPath.getParent(); + } + return parentPath; } // check if the file is a test file in the default module if (isDefaultModuleTestFile(absFilePath)) { @@ -117,6 +116,20 @@ public static Path packageRoot(Path filepath) throws ProjectException { throw new ProjectException("provided file path does not belong to a Ballerina package: " + filepath); } + private static boolean isAGeneratedModuleRoot(Path filepath) { + Path absFilePath = filepath.toAbsolutePath().normalize(); + Optional projectRoot = findProjectRoot(absFilePath); + if (projectRoot.isPresent()) { + Path fileName = absFilePath.getFileName(); + if (fileName != null) { + Path generatedModuleRoot = projectRoot.get().resolve(ProjectConstants.GENERATED_MODULES_ROOT). + resolve(fileName); + return generatedModuleRoot.toAbsolutePath().normalize().toString().equals(absFilePath.toString()); + } + } + return false; + } + private static boolean isModulesRoot(Path filepath) { Path absFilePath = filepath.toAbsolutePath().normalize(); Optional projectRoot = findProjectRoot(absFilePath); @@ -127,6 +140,16 @@ private static boolean isModulesRoot(Path filepath) { return false; } + private static boolean isGeneratedModulesRoot(Path filepath) { + Path absFilePath = filepath.toAbsolutePath().normalize(); + Optional projectRoot = findProjectRoot(absFilePath); + if (projectRoot.isPresent()) { + Path generatedModulesRoot = projectRoot.get().resolve(ProjectConstants.GENERATED_MODULES_ROOT); + return generatedModulesRoot.toAbsolutePath().normalize().toString().equals(absFilePath.toString()); + } + return false; + } + private static boolean isAModuleTestsRoot(Path filepath) { Path absFilePath = filepath.toAbsolutePath().normalize(); Optional projectRoot = findProjectRoot(filepath); @@ -238,8 +261,11 @@ public static boolean isStandaloneBalFile(Path filepath) { } static boolean isDefaultModuleSrcFile(Path filePath) { - Path absFilePath = filePath.toAbsolutePath().normalize(); - return hasBallerinaToml(Optional.of(absFilePath.getParent()).get()); + Path parentPath = filePath.toAbsolutePath().normalize().getParent(); + if (ProjectConstants.GENERATED_MODULES_ROOT.equals(Optional.of(parentPath).get().toFile().getName())) { + parentPath = parentPath.getParent(); + } + return hasBallerinaToml(Optional.of(parentPath).get()); } static boolean isDefaultModuleTestFile(Path filePath) { @@ -255,9 +281,11 @@ static boolean isDefaultModuleTestFile(Path filePath) { static boolean isNonDefaultModuleSrcFile(Path filePath) { Path absFilePath = filePath.toAbsolutePath().normalize(); + // modulesRoot is equivalent to generatedSourcesRoot in file structure Path modulesRoot = Optional.of(Optional.of(absFilePath.getParent()).get().getParent()).get(); Path projectRoot = modulesRoot.getParent(); - return ProjectConstants.MODULES_ROOT.equals(modulesRoot.toFile().getName()) + return (ProjectConstants.MODULES_ROOT.equals(modulesRoot.toFile().getName()) || + ProjectConstants.GENERATED_MODULES_ROOT.equals(modulesRoot.toFile().getName())) && hasBallerinaToml(projectRoot); } diff --git a/compiler/ballerina-lang/src/test/java/io/ballerina/projects/ProjectPathsTest.java b/compiler/ballerina-lang/src/test/java/io/ballerina/projects/ProjectPathsTest.java index 681c6facbc9b..3bbe24e7335f 100644 --- a/compiler/ballerina-lang/src/test/java/io/ballerina/projects/ProjectPathsTest.java +++ b/compiler/ballerina-lang/src/test/java/io/ballerina/projects/ProjectPathsTest.java @@ -66,6 +66,22 @@ public void setUp() throws IOException { Files.createFile(buildProjectPath.resolve("test-utils") .resolve("utils.bal")); // path - /tmp/testProj/test-utils/utils.bal + // Create generated files + // Generated file for default module + Files.createDirectories(buildProjectPath.resolve("generated")); + Files.createFile( + buildProjectPath.resolve("generated").resolve("gen.bal")); + + // Generated file for module 01 + Files.createDirectories(buildProjectPath.resolve("generated").resolve("module1")); + Files.createFile( + buildProjectPath.resolve("generated").resolve("module1").resolve("gen_mod1.bal")); + + // Generated file for module 02 (A new generated module) + Files.createDirectories(buildProjectPath.resolve("generated").resolve("module2")); + Files.createFile( + buildProjectPath.resolve("generated").resolve("module2").resolve("gen_mod2.bal")); + // Create a bala project balaProjectPath = tempDir.resolve("testBalaProj"); Files.createDirectories(balaProjectPath.resolve("modules").resolve("mod1")); @@ -88,6 +104,17 @@ public void testPackageRoot() { Assert.assertEquals(ProjectPaths.packageRoot(buildProjectPath .resolve("modules").resolve("module1").resolve("tests").resolve("main_test.bal")), buildProjectPath); + // test package root of generated files + Assert.assertEquals(ProjectPaths.packageRoot(buildProjectPath + .resolve("generated").resolve("module1").resolve("gen_mod1.bal")), buildProjectPath); + Assert.assertEquals(ProjectPaths.packageRoot(buildProjectPath + .resolve("generated").resolve("module2").resolve("gen_mod2.bal")), buildProjectPath); + Assert.assertEquals(ProjectPaths.packageRoot(buildProjectPath.resolve("generated").resolve("gen.bal")), + buildProjectPath); + + Assert.assertEquals(ProjectPaths.packageRoot(buildProjectPath + .resolve("modules").resolve("module1").resolve("tests") + .resolve("main_test.bal")), buildProjectPath); // test package root of bala project Assert.assertEquals(ProjectPaths.packageRoot(balaProjectPath .resolve("modules").resolve("mod1").resolve("mod1.bal")), balaProjectPath); @@ -105,7 +132,12 @@ public void testPackageRootWithDirectory() { .resolve("modules").resolve("module1").resolve("tests")), buildProjectPath); Assert.assertEquals(ProjectPaths.packageRoot(buildProjectPath .resolve("modules")), buildProjectPath); - + Assert.assertEquals(ProjectPaths.packageRoot(buildProjectPath + .resolve("generated")), buildProjectPath); + Assert.assertEquals(ProjectPaths.packageRoot(buildProjectPath + .resolve("generated").resolve("module1")), buildProjectPath); + Assert.assertEquals(ProjectPaths.packageRoot(buildProjectPath + .resolve("generated").resolve("module2")), buildProjectPath); // test package root of bala project Assert.assertEquals(ProjectPaths.packageRoot(balaProjectPath), balaProjectPath); Assert.assertEquals(ProjectPaths.packageRoot(balaProjectPath @@ -173,6 +205,9 @@ public void testIsBallerinaStandaloneFile() { Assert.assertFalse(ProjectPaths.isStandaloneBalFile( balaProjectPath.resolve("modules").resolve("mod1").resolve("mod1.bal"))); + + Assert.assertFalse(ProjectPaths.isStandaloneBalFile( + balaProjectPath.resolve("generated").resolve("module1").resolve("gen_mod1.bal"))); } @Test diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/BallerinaLanguageServer.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/BallerinaLanguageServer.java index efd0ba5b45a9..8876ab46e895 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/BallerinaLanguageServer.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/BallerinaLanguageServer.java @@ -404,6 +404,8 @@ private void startListeningFileChanges() { watchers.add(new FileSystemWatcher("/**/*.bal", WatchKind.Create + WatchKind.Delete + WatchKind.Change)); watchers.add(new FileSystemWatcher("/**/modules/*", WatchKind.Create + WatchKind.Delete)); watchers.add(new FileSystemWatcher("/**/modules", WatchKind.Delete)); + watchers.add(new FileSystemWatcher("/**/generated/*", WatchKind.Create + WatchKind.Delete)); + watchers.add(new FileSystemWatcher("/**/generated", WatchKind.Delete)); watchers.add(new FileSystemWatcher("/**/" + ProjectConstants.BALLERINA_TOML, WatchKind.Create + WatchKind.Delete)); watchers.add(new FileSystemWatcher("/**/" + ProjectConstants.CLOUD_TOML, diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/PathUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/PathUtil.java index 1bf8a60b9fa0..137e7b9f035d 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/PathUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/PathUtil.java @@ -26,6 +26,7 @@ import io.ballerina.projects.ProjectKind; import io.ballerina.projects.ResolvedPackageDependency; import io.ballerina.projects.environment.PackageCache; +import io.ballerina.projects.util.ProjectConstants; import io.ballerina.tools.diagnostics.Location; import org.ballerinalang.langserver.commons.DocumentServiceContext; import org.ballerinalang.langserver.commons.LanguageServerContext; @@ -37,6 +38,7 @@ import java.net.URI; import java.net.URISyntaxException; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Collection; @@ -260,12 +262,20 @@ public static Path getPathFromLocation(Module module, Location location) { .resolve(module.moduleName().toString()) .resolve(filePath); } - + Path sourceRoot = module.project().sourceRoot(); if (module.isDefaultModule()) { - return module.project().sourceRoot().resolve(filePath); + if (Files.exists(sourceRoot.resolve(ProjectConstants.GENERATED_MODULES_ROOT).resolve(filePath))) { + return sourceRoot.resolve(ProjectConstants.GENERATED_MODULES_ROOT).resolve(filePath); + } + return sourceRoot.resolve(filePath); } else { - return module.project().sourceRoot() - .resolve("modules") + if (Files.exists(sourceRoot.resolve(ProjectConstants.GENERATED_MODULES_ROOT). + resolve(module.moduleName().moduleNamePart()).resolve(filePath))) { + return sourceRoot.resolve(ProjectConstants.GENERATED_MODULES_ROOT). + resolve(module.moduleName().moduleNamePart()).resolve(filePath); + } + return sourceRoot + .resolve(ProjectConstants.MODULES_ROOT) .resolve(module.moduleName().moduleNamePart()) .resolve(filePath); } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/workspace/BallerinaWorkspaceManager.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/workspace/BallerinaWorkspaceManager.java index 67e21b300f61..9b4bb328cda9 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/workspace/BallerinaWorkspaceManager.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/workspace/BallerinaWorkspaceManager.java @@ -564,10 +564,15 @@ private Optional projectOfWatchedFileChange(Path filePath, FileEven // If inside a tests folder, get parent parent = parent.getParent(); } - if (ProjectConstants.MODULES_ROOT.equals(parent.getParent().getFileName().toString())) { - // If inside a module folder, get parent + if (ProjectConstants.MODULES_ROOT.equals(parent.getParent().getFileName().toString()) || + ProjectConstants.GENERATED_MODULES_ROOT.equals(parent.getParent().getFileName().toString())) { + // If inside a modules or generated folder, get parent of parent parent = parent.getParent().getParent(); } + if (ProjectConstants.GENERATED_MODULES_ROOT.equals(parent.getFileName().toString())) { + // If a generated source for a non-default module, get parent of parent + parent = parent.getParent(); + } return projectPair(parent); } } else if (isBallerinaTomlChange) { @@ -595,11 +600,12 @@ private Optional projectOfWatchedFileChange(Path filePath, FileEven return projectPair(filePath.getParent()); } else if (isModuleChange) { Path projectRoot; - if (ProjectConstants.MODULES_ROOT.equals(filePath.getFileName().toString())) { - // If it is **/projectRoot/modules + if (ProjectConstants.MODULES_ROOT.equals(filePath.getFileName().toString()) || + ProjectConstants.GENERATED_MODULES_ROOT.equals(filePath.getFileName().toString())) { + // If it is **/projectRoot/modules OR **/projectRoot/generated projectRoot = filePath.getParent(); } else { - // If it is **/projectRoot/modules/mod2 + // If it is **/projectRoot/modules/mod2 OR **/projectRoot/generated/mod2 projectRoot = filePath.getParent().getParent(); } return projectPair(projectRoot); @@ -1282,6 +1288,7 @@ private Optional getProjectOfWatchedFileChange(Path filePath, FileE // fails when physical file is deleted from the disk boolean isModuleChange = filePath.toFile().isDirectory() && filePath.getParent().endsWith(ProjectConstants.MODULES_ROOT) || + filePath.getParent().endsWith(ProjectConstants.GENERATED_MODULES_ROOT) || (fileEvent.getType() == FileChangeType.Deleted && !isBallerinaSourceChange && !isBallerinaTomlChange && !isCloudTomlChange && !isDependenciesTomlChange && !isCompilerPluginTomlChange); diff --git a/project-api/project-api-test/src/test/java/io/ballerina/projects/test/TestBalaProject.java b/project-api/project-api-test/src/test/java/io/ballerina/projects/test/TestBalaProject.java index 179dbaee8baa..597cf3d126f9 100644 --- a/project-api/project-api-test/src/test/java/io/ballerina/projects/test/TestBalaProject.java +++ b/project-api/project-api-test/src/test/java/io/ballerina/projects/test/TestBalaProject.java @@ -242,14 +242,6 @@ public void testGetDocumentIdFromPathInExtractedBala() { } catch (ProjectException e) { // ignore } - - // try to get id of a non-bal file from the project - try { - balaProject.documentId(null); - Assert.fail("expected a ProjectException"); - } catch (ProjectException e) { - // ignore - } } @Test diff --git a/project-api/project-api-test/src/test/java/io/ballerina/projects/test/TestBuildProjectWithGeneratedSources.java b/project-api/project-api-test/src/test/java/io/ballerina/projects/test/TestBuildProjectWithGeneratedSources.java new file mode 100644 index 000000000000..56e9406f5d16 --- /dev/null +++ b/project-api/project-api-test/src/test/java/io/ballerina/projects/test/TestBuildProjectWithGeneratedSources.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package io.ballerina.projects.test; + +import io.ballerina.projects.BallerinaToml; +import io.ballerina.projects.BuildOptions; +import io.ballerina.projects.DocumentId; +import io.ballerina.projects.Module; +import io.ballerina.projects.ModuleId; +import io.ballerina.projects.Package; + +import io.ballerina.projects.directory.BuildProject; + +import io.ballerina.projects.util.ProjectConstants; +import org.testng.Assert; +import org.testng.SkipException; +import org.testng.annotations.AfterClass; +import org.testng.annotations.Test; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Collection; +import java.util.Optional; + +import static io.ballerina.projects.test.TestUtils.isWindows; +import static io.ballerina.projects.test.TestUtils.resetPermissions; + +/** + * Contains cases to test the basic package structure when the project includes generated directory. + * + * @since 2201.4.0 + */ +public class TestBuildProjectWithGeneratedSources extends BaseTest { + private static final Path RESOURCE_DIRECTORY = Paths.get("src/test/resources/generated-sources-tests/"); + + @Test (description = "tests loading a valid build project with generated sources") + public void testBuildProjectAPI() { + Path projectPath = RESOURCE_DIRECTORY.resolve("my_generated_project"); + + // 1) Initialize the project instance + BuildProject project = loadBuildProject(projectPath); + // 2) Load the package + Package currentPackage = project.currentPackage(); + // 3) Load the default module + Module defaultModule = currentPackage.getDefaultModule(); + Assert.assertEquals(defaultModule.documentIds().size(), 4); + + // 4) Get Ballerina.toml file + Optional ballerinaTomlOptional = currentPackage.ballerinaToml(); + Assert.assertTrue(ballerinaTomlOptional.isPresent()); + + int noOfSrcDocuments = 0; + int noOfTestDocuments = 0; + final Collection moduleIds = currentPackage.moduleIds(); + Assert.assertEquals(moduleIds.size(), 4); + for (ModuleId moduleId : moduleIds) { + Module module = currentPackage.module(moduleId); + noOfSrcDocuments += module.documentIds().size(); + noOfTestDocuments += module.testDocumentIds().size(); + for (DocumentId docId : module.documentIds()) { + Assert.assertNotNull(module.document(docId).syntaxTree()); + } + } + + Assert.assertEquals(noOfSrcDocuments, 9); + Assert.assertEquals(noOfTestDocuments, 3); + + } + + @Test (description = "tests loading a build project with generated sources with no read permission") + public void testBuildProjectWithNoReadPermission() { + // Skip test in windows due to file permission setting issue + if (isWindows()) { + throw new SkipException("Skipping tests on Windows"); + } + Path projectPath = RESOURCE_DIRECTORY.resolve("project_no_permission"); + Path generatedDirPath = projectPath.resolve(ProjectConstants.GENERATED_MODULES_ROOT); + // 1) Remove read permission + boolean readable = generatedDirPath.toFile().setReadable(false, true); + if (!readable) { + Assert.fail("could not remove read permission"); + } + + // 2) Initialize the project instance + BuildProject project = null; + try { + project = TestUtils.loadBuildProject(projectPath); + } catch (Exception e) { + Assert.assertTrue(e.getMessage().contains("does not have read permissions")); + } + + resetPermissions(generatedDirPath); + } + + @AfterClass (alwaysRun = true) + public void reset() { + Path projectPath = RESOURCE_DIRECTORY.resolve("project_no_permission"); + TestUtils.resetPermissions(projectPath); + } + + private static BuildProject loadBuildProject(Path projectPath) { + return loadBuildProject(projectPath, null); + } + + private static BuildProject loadBuildProject(Path projectPath, BuildOptions buildOptions) { + BuildProject buildProject = null; + try { + if (buildOptions == null) { + buildProject = TestUtils.loadBuildProject(projectPath); + } else { + buildProject = TestUtils.loadBuildProject(projectPath, buildOptions); + } + } catch (Exception e) { + Assert.fail(e.getMessage()); + } + return buildProject; + } +} diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/Ballerina.toml b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/Ballerina.toml new file mode 100644 index 000000000000..ddd92c145ec2 --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/Ballerina.toml @@ -0,0 +1,4 @@ +[package] +org = "sameera" +name = "myproject" +version = "0.1.0" diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/Cloud.toml b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/Cloud.toml new file mode 100644 index 000000000000..feb693a718e8 --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/Cloud.toml @@ -0,0 +1,2 @@ +[test] +attribute="value" diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/CompilerPlugin.toml b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/CompilerPlugin.toml new file mode 100644 index 000000000000..67ce5826001e --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/CompilerPlugin.toml @@ -0,0 +1,5 @@ +[plugin] +class = "io.ballerina.openapi.Validator" + +[[dependency]] +path = "./libs/platform-io-1.3.0-java.txt" diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/Dependencies.toml b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/Dependencies.toml new file mode 100644 index 000000000000..c4ed02bae887 --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/Dependencies.toml @@ -0,0 +1,32 @@ +# AUTO-GENERATED FILE. DO NOT MODIFY. + +# This file is auto-generated by Ballerina for managing dependency versions. +# It should not be modified by hand. + +[ballerina] +dependencies-toml-version = "2" + +[[package]] +org = "sameera" +name = "myproject" +version = "0.1.0" +dependencies = [ + {org = "samjs", name = "package_k"} +] +modules = [ + {org = "sameera", packageName = "myproject", moduleName = "myproject"}, + {org = "sameera", packageName = "myproject", moduleName = "myproject.services"}, + {org = "sameera", packageName = "myproject", moduleName = "myproject.storage"} +] + +[[package]] +org = "samjs" +name = "package_k" +version = "1.0.0" +modules = [ + {org = "samjs", packageName = "package_k", moduleName = "package_k"}, + {org = "samjs", packageName = "package_k", moduleName = "package_k.mod_k1"}, + {org = "samjs", packageName = "package_k", moduleName = "package_k.mod_k2"} +] + + diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/Module.md b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/Module.md new file mode 100644 index 000000000000..e6368012fa1c --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/Module.md @@ -0,0 +1 @@ +# Default Module Md \ No newline at end of file diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/Package.md b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/Package.md new file mode 100644 index 000000000000..f34e41b1a6d5 --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/Package.md @@ -0,0 +1 @@ +# Package Md \ No newline at end of file diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/generated/gen.bal b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/generated/gen.bal new file mode 100644 index 000000000000..5f6099473298 --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/generated/gen.bal @@ -0,0 +1,6 @@ +public function helloGen(string name) returns string { + if !(name is "") { + return "Hello, " + name; + } + return "Hello, World!"; +} diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/generated/gen1.bal b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/generated/gen1.bal new file mode 100644 index 000000000000..52f9c3938edc --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/generated/gen1.bal @@ -0,0 +1,6 @@ +public function helloGen1(string name) returns string { + if !(name is "") { + return "Hello, " + name; + } + return "Hello, World!"; +} diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/generated/newmod/mewmod_gen.bal b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/generated/newmod/mewmod_gen.bal new file mode 100644 index 000000000000..23c3b2cef225 --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/generated/newmod/mewmod_gen.bal @@ -0,0 +1,10 @@ +# Description +# +# + name - Parameter Description +# + return - Return Value Description +public function helloNewMod(string name) returns string { + if !(name is "") { + return "Hello, " + name; + } + return "Hello, World!"; +} diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/generated/services/services_gen.bal b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/generated/services/services_gen.bal new file mode 100644 index 000000000000..efcb11be2cbf --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/generated/services/services_gen.bal @@ -0,0 +1,10 @@ +# Description +# +# + name - Parameter Description +# + return - Return Value Description +public function helloServices(string name) returns string { + if !(name is "") { + return "Hello, " + name; + } + return "Hello, World!"; +} diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/generated/storage/storage_gen.bal b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/generated/storage/storage_gen.bal new file mode 100644 index 000000000000..ac735b170427 --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/generated/storage/storage_gen.bal @@ -0,0 +1,10 @@ +# Description +# +# + name - Parameter Description +# + return - Return Value Description +public function helloStorage(string name) returns string { + if !(name is "") { + return "Hello, " + name; + } + return "Hello, World!"; +} diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/libs/platform-io-1.3.0-java.txt b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/libs/platform-io-1.3.0-java.txt new file mode 100644 index 000000000000..9840276fe9a5 --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/libs/platform-io-1.3.0-java.txt @@ -0,0 +1 @@ +// Added this file for a JAR file diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/main.bal b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/main.bal new file mode 100644 index 000000000000..a95ec5b5055b --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/main.bal @@ -0,0 +1,7 @@ +import myproject.services; +import sameera/myproject.storage; + +public function main() { +services:runServices(); +storage:initDatabase(); +} \ No newline at end of file diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/services/Module.md b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/services/Module.md new file mode 100644 index 000000000000..29b88dc5c60f --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/services/Module.md @@ -0,0 +1 @@ +# Service Module Md \ No newline at end of file diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/services/resources/config.json b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/services/resources/config.json new file mode 100644 index 000000000000..9e26dfeeb6e6 --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/services/resources/config.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/services/resources/invalidProject/Ballerina.toml b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/services/resources/invalidProject/Ballerina.toml new file mode 100644 index 000000000000..35fbd629fdc8 --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/services/resources/invalidProject/Ballerina.toml @@ -0,0 +1,4 @@ +[package] +org = "sameera" +name = "winery" +version = "0.1.0" diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/services/resources/invalidProject/main.bal b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/services/resources/invalidProject/main.bal new file mode 100644 index 000000000000..69d22f754f81 --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/services/resources/invalidProject/main.bal @@ -0,0 +1,5 @@ +import ballerina/io; + +public function main() { + io:println("Sameera Jayasoma"); +} diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/services/resources/invalidProject/tests/main_tests.bal b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/services/resources/invalidProject/tests/main_tests.bal new file mode 100644 index 000000000000..764b65dd22c9 --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/services/resources/invalidProject/tests/main_tests.bal @@ -0,0 +1,2 @@ +public function testRunMain() { +} diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/services/svc.bal b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/services/svc.bal new file mode 100644 index 000000000000..228ec53bf552 --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/services/svc.bal @@ -0,0 +1,6 @@ +import sameera/myproject.storage; + + +public function runServices() { + storage:initDatabase(); +} diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/services/tests/svc_tests.bal b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/services/tests/svc_tests.bal new file mode 100644 index 000000000000..9d08bb944a5d --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/services/tests/svc_tests.bal @@ -0,0 +1,2 @@ +public function testServices() { +} diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/storage/db.bal b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/storage/db.bal new file mode 100644 index 000000000000..c6f7268d109a --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/storage/db.bal @@ -0,0 +1,2 @@ +public function initDatabase() { +} \ No newline at end of file diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/storage/resources/db.json b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/storage/resources/db.json new file mode 100644 index 000000000000..9e26dfeeb6e6 --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/storage/resources/db.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/storage/tests/db_tests.bal b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/storage/tests/db_tests.bal new file mode 100644 index 000000000000..81594782cc8e --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/modules/storage/tests/db_tests.bal @@ -0,0 +1,2 @@ +public function testInitDatabase() { +} \ No newline at end of file diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/tests/main_tests.bal b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/tests/main_tests.bal new file mode 100644 index 000000000000..764b65dd22c9 --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/tests/main_tests.bal @@ -0,0 +1,2 @@ +public function testRunMain() { +} diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/util/file-util.bal b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/util/file-util.bal new file mode 100644 index 000000000000..c50943d7f157 --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/util/file-util.bal @@ -0,0 +1,2 @@ +public function foo() { +} diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/utils.bal b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/utils.bal new file mode 100644 index 000000000000..c68b39704c42 --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/my_generated_project/utils.bal @@ -0,0 +1,5 @@ +import samjs/package_k.mod_k1; + +public function foo() { + mod_k1:func1(); +} diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/project_no_permission/Ballerina.toml b/project-api/project-api-test/src/test/resources/generated-sources-tests/project_no_permission/Ballerina.toml new file mode 100644 index 000000000000..d61062624986 --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/project_no_permission/Ballerina.toml @@ -0,0 +1,4 @@ +[package] +org = "bar" +name = "winery" +version = "0.1.0" diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/project_no_permission/generated/gen1.bal b/project-api/project-api-test/src/test/resources/generated-sources-tests/project_no_permission/generated/gen1.bal new file mode 100644 index 000000000000..5aae5114ad3a --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/project_no_permission/generated/gen1.bal @@ -0,0 +1 @@ +int myVal = 5; \ No newline at end of file diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/project_no_permission/generated/services/svc1.bal b/project-api/project-api-test/src/test/resources/generated-sources-tests/project_no_permission/generated/services/svc1.bal new file mode 100644 index 000000000000..bda0e3a9cb65 --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/project_no_permission/generated/services/svc1.bal @@ -0,0 +1 @@ +int myVal2 = 5; \ No newline at end of file diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/project_no_permission/main.bal b/project-api/project-api-test/src/test/resources/generated-sources-tests/project_no_permission/main.bal new file mode 100644 index 000000000000..6d0ccb5ba65d --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/project_no_permission/main.bal @@ -0,0 +1,3 @@ + +public function main() { +} From 67ba31b5aa71664df31547fd19df45a4cf754b36 Mon Sep 17 00:00:00 2001 From: Fathima Dilhasha Date: Fri, 9 Dec 2022 18:54:06 +0530 Subject: [PATCH 199/450] Add verification for duplicate source file names --- .../projects/internal/ProjectFiles.java | 17 ++++++++++++++++- .../TestBuildProjectWithGeneratedSources.java | 2 -- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ProjectFiles.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ProjectFiles.java index 94e608c9d761..09716ce6157a 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ProjectFiles.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ProjectFiles.java @@ -161,7 +161,9 @@ private static ModuleData loadModule(Path moduleDirPath) { resolve(Optional.of(moduleDirPath.toFile()).get().getName()); } if (Files.isDirectory(generatedSourcesRoot)) { - srcDocs.addAll(loadDocuments(generatedSourcesRoot)); + List generatedDocs = loadDocuments(generatedSourcesRoot); + verifyDuplicateNames(srcDocs, generatedDocs, moduleDirPath.toFile().getName(), moduleDirPath); + srcDocs.addAll(generatedDocs); } } DocumentData moduleMd = loadDocument(moduleDirPath.resolve(ProjectConstants.MODULE_MD_FILE_NAME)); @@ -172,6 +174,19 @@ private static ModuleData loadModule(Path moduleDirPath) { resources, testResources); } + private static void verifyDuplicateNames(List srcDocs, List generatedDocs, + String moduleName, Path modulesDirPath) { + for (DocumentData doc : srcDocs) { + generatedDocs.forEach(generatedDoc -> { + if (doc.name().equals(generatedDoc.name())) { + throw new ProjectException("Source file with a duplicate name '" + doc.name() + "' detected in " + + "both generated and module sources for the module '" + moduleName + "'. Please provide a " + + "unique name for '" + modulesDirPath.resolve(doc.name()) + "'"); + } + }); + } + } + public static List loadResources(Path modulePath) { Path resourcesPath = modulePath.resolve(ProjectConstants.RESOURCE_DIR_NAME); if (Files.notExists(resourcesPath)) { diff --git a/project-api/project-api-test/src/test/java/io/ballerina/projects/test/TestBuildProjectWithGeneratedSources.java b/project-api/project-api-test/src/test/java/io/ballerina/projects/test/TestBuildProjectWithGeneratedSources.java index 56e9406f5d16..3227a52703a7 100644 --- a/project-api/project-api-test/src/test/java/io/ballerina/projects/test/TestBuildProjectWithGeneratedSources.java +++ b/project-api/project-api-test/src/test/java/io/ballerina/projects/test/TestBuildProjectWithGeneratedSources.java @@ -23,9 +23,7 @@ import io.ballerina.projects.Module; import io.ballerina.projects.ModuleId; import io.ballerina.projects.Package; - import io.ballerina.projects.directory.BuildProject; - import io.ballerina.projects.util.ProjectConstants; import org.testng.Assert; import org.testng.SkipException; From 02b2a3ab35f18430102d5624759a70bba10c0999 Mon Sep 17 00:00:00 2001 From: malinthar Date: Mon, 12 Dec 2022 09:54:35 +0530 Subject: [PATCH 200/450] Fix faling tests after merging --- .../util/ModulePartNodeContextUtil.java | 6 +- .../annotation_decl/config/config21.json | 402 ++++++++--------- .../completion/class_def/config/config22.json | 406 ++++++++--------- .../completion/class_def/config/config24.json | 289 ++++++------ .../config/comment_config3.json | 289 ++++++------ .../config/comment_config4.json | 289 ++++++------ .../enum_decl_ctx/config/config5.json | 399 ++++++++-------- .../config/anon_func_expr_ctx_config10.json | 289 ++++++------ .../function_call_expression_ctx_config7.json | 289 ++++++------ .../function_call_expression_ctx_config8.json | 289 ++++++------ .../config/module_ctx_config1.json | 289 ++++++------ .../config/module_ctx_config3.json | 289 ++++++------ .../config/field_access_ctx_config21.json | 289 ++++++------ .../config/foreach_stmt_ctx_config7.json | 289 ++++++------ .../config/foreach_stmt_ctx_config8.json | 289 ++++++------ .../function_body/config/config1.json | 289 ++++++------ .../function_body/config/config10.json | 289 ++++++------ .../function_body/config/config12.json | 289 ++++++------ .../function_body/config/config14.json | 289 ++++++------ .../function_body/config/config2.json | 289 ++++++------ .../function_body/config/config3.json | 289 ++++++------ .../function_body/config/config4.json | 289 ++++++------ .../function_body/config/config5.json | 289 ++++++------ .../function_body/config/config6.json | 289 ++++++------ .../import_decl/config/config11.json | 289 ++++++------ .../import_decl/config/config12.json | 289 ++++++------ .../import_decl/config/config21.json | 289 ++++++------ .../import_decl/config/config26.json | 289 ++++++------ .../module_part_context/config/config1.json | 395 ++++++++-------- .../module_part_context/config/config14.json | 427 +++++++++--------- .../module_part_context/config/config15.json | 415 ++++++++--------- .../module_part_context/config/config16.json | 417 ++++++++--------- .../module_part_context/config/config2.json | 395 ++++++++-------- .../module_part_context/config/config3.json | 395 ++++++++-------- .../module_part_context/config/config6.json | 402 ++++++++--------- ...le_level_after_annotation_decl_config.json | 414 +++++++++-------- .../module_level_after_class_defn_config.json | 414 +++++++++-------- .../module_level_after_const_decl_config.json | 414 +++++++++-------- .../module_level_after_enum_decl_config.json | 414 +++++++++-------- ...dule_level_after_funciton_defn_config.json | 414 +++++++++-------- ...module_level_after_import_decl_config.json | 407 ++++++++--------- ...dule_level_after_listener_decl_config.json | 414 +++++++++-------- ...odule_level_after_service_decl_config.json | 414 +++++++++-------- .../module_level_after_type_defn_config.json | 414 +++++++++-------- .../module_level_after_var_decl_config.json | 414 +++++++++-------- .../module_level_after_xmlns_decl_config.json | 414 +++++++++-------- ...e_level_before_annotation_decl_config.json | 414 +++++++++-------- ...module_level_before_class_defn_config.json | 414 +++++++++-------- ...module_level_before_const_decl_config.json | 414 +++++++++-------- .../module_level_before_enum_decl_config.json | 414 +++++++++-------- ...ule_level_before_function_defn_config.json | 414 +++++++++-------- ...odule_level_before_import_decl_config.json | 407 ++++++++--------- ...ule_level_before_listener_decl_config.json | 407 ++++++++--------- ...dule_level_before_service_decl_config.json | 414 +++++++++-------- .../module_level_before_type_defn_config.json | 414 +++++++++-------- .../module_level_before_var_decl_config.json | 414 +++++++++-------- ...module_level_before_xmlns_decl_config.json | 414 +++++++++-------- .../service_body/config/config4.json | 289 ++++++------ .../service_decl/config/config16.json | 289 ++++++------ .../service_decl/config/config17.json | 404 ++++++++--------- .../service_decl/config/config18.json | 404 ++++++++--------- .../service_decl/config/config7.json | 404 ++++++++--------- .../continue_break_stmt_ctx_config1.json | 289 ++++++------ .../continue_break_stmt_ctx_config2.json | 289 ++++++------ .../config/do_stmt_ctx_config1.json | 289 ++++++------ .../config/else_stmt_ctx_config1.json | 289 ++++++------ .../config/else_stmt_ctx_config2.json | 289 ++++++------ .../config/elseif_stmt_ctx_config1.json | 289 ++++++------ .../config/elseif_stmt_ctx_config2.json | 289 ++++++------ .../function_call_stmt_ctx_config1.json | 289 ++++++------ .../function_call_stmt_ctx_config2.json | 289 ++++++------ .../config/if_stmt_ctx_config1.json | 289 ++++++------ .../config/if_stmt_ctx_config2.json | 289 ++++++------ .../config/if_stmt_ctx_config7.json | 289 ++++++------ .../config/if_stmt_ctx_config8.json | 289 ++++++------ .../local_var_decl_stmt_ctx_config1.json | 289 ++++++------ .../config/lock_stmt_ctx_config1.json | 289 ++++++------ .../config/lock_stmt_ctx_config3.json | 289 ++++++------ .../config/onfail_clause_ctx_config1.json | 289 ++++++------ .../config/onfail_clause_ctx_config1a.json | 289 ++++++------ .../config/onfail_clause_ctx_config2.json | 289 ++++++------ .../config/onfail_clause_ctx_config2a.json | 289 ++++++------ .../config/onfail_clause_ctx_config3.json | 289 ++++++------ .../config/onfail_clause_ctx_config4.json | 289 ++++++------ .../config/onfail_clause_ctx_config5.json | 289 ++++++------ .../config/onfail_clause_ctx_config5a.json | 289 ++++++------ .../config/onfail_clause_ctx_config6.json | 289 ++++++------ .../config/onfail_clause_ctx_config6a.json | 289 ++++++------ .../config/return_stmt_ctx_config1.json | 289 ++++++------ .../config/return_stmt_ctx_config10.json | 289 ++++++------ .../config/return_stmt_ctx_config11.json | 289 ++++++------ .../config/return_stmt_ctx_config12.json | 289 ++++++------ .../config/return_stmt_ctx_config13.json | 289 ++++++------ .../config/return_stmt_ctx_config14.json | 289 ++++++------ .../config/return_stmt_ctx_config15.json | 289 ++++++------ .../config/return_stmt_ctx_config2.json | 289 ++++++------ .../config/return_stmt_ctx_config3.json | 289 ++++++------ .../config/return_stmt_ctx_config4.json | 289 ++++++------ .../config/return_stmt_ctx_config5.json | 289 ++++++------ .../config/return_stmt_ctx_config6.json | 289 ++++++------ .../config/return_stmt_ctx_config7.json | 289 ++++++------ .../config/return_stmt_ctx_config8.json | 289 ++++++------ .../config/return_stmt_ctx_config9.json | 289 ++++++------ .../config/transaction_config1.json | 289 ++++++------ .../config/while_stmt_ctx_config1.json | 289 ++++++------ .../config/while_stmt_ctx_config2.json | 289 ++++++------ .../worker_declaration_ctx_config1.json | 289 ++++++------ .../worker_declaration_ctx_config2.json | 289 ++++++------ 108 files changed, 17495 insertions(+), 17671 deletions(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ModulePartNodeContextUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ModulePartNodeContextUtil.java index a15d209b1b2d..6d3fb3b17b0f 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ModulePartNodeContextUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/util/ModulePartNodeContextUtil.java @@ -73,11 +73,7 @@ public static List getTopLevelItems(BallerinaCompletionContext Snippet.DEF_ANNOTATION, Snippet.DEF_RECORD, Snippet.STMT_NAMESPACE_DECLARATION, Snippet.DEF_OBJECT_SNIPPET, Snippet.DEF_CLASS, Snippet.DEF_ENUM, Snippet.DEF_CLOSED_RECORD, Snippet.DEF_ERROR_TYPE, Snippet.DEF_TABLE_TYPE_DESC, Snippet.DEF_TABLE_WITH_KEY_TYPE_DESC, - Snippet.DEF_STREAM, Snippet.DEF_SERVICE_COMMON - ); - - Snippet.DEF_STREAM, Snippet.DEF_SERVICE_COMMON, Snippet.DEF_CLIENT_DECLARATION - )); + Snippet.DEF_STREAM, Snippet.DEF_SERVICE_COMMON)); //Add import keyword conditionally if (isInImportStatementsContext(context)) { snippets.add(Snippet.KW_IMPORT); diff --git a/language-server/modules/langserver-core/src/test/resources/completion/annotation_decl/config/config21.json b/language-server/modules/langserver-core/src/test/resources/completion/annotation_decl/config/config21.json index 2fade15f3dd7..e40966d34b62 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/annotation_decl/config/config21.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/annotation_decl/config/config21.json @@ -9,7 +9,7 @@ "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -18,7 +18,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -27,7 +27,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -36,25 +36,16 @@ "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" }, - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -261,7 +252,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -270,7 +261,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -282,7 +273,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -290,79 +281,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -425,7 +352,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -449,7 +376,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -473,7 +400,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -497,7 +424,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -705,7 +560,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -729,7 +584,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -753,7 +608,7 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" @@ -762,7 +617,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -772,7 +627,7 @@ "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -792,19 +647,11 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -828,10 +675,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config22.json b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config22.json index 7b1c067a2496..5ba0ba305e71 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config22.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config22.json @@ -5,20 +5,11 @@ }, "source": "class_def/source/source22.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,7 +263,7 @@ "label": "UniqueGreetingsStore", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "UniqueGreetingsStore", "insertTextFormat": "Snippet" }, @@ -280,7 +271,7 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, @@ -288,79 +279,15 @@ "label": "BALLERINA", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "BALLERINA", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -369,7 +296,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -378,7 +305,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -387,7 +314,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -396,7 +323,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -405,7 +332,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -414,7 +341,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -423,7 +350,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -432,7 +359,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -456,7 +383,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -480,7 +407,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -504,7 +431,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -528,7 +455,7 @@ "label": "ballerina/module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet", @@ -552,7 +479,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -572,54 +499,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -644,14 +523,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -668,27 +539,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -712,7 +567,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -736,7 +591,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -760,7 +615,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -784,7 +639,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -808,7 +663,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -832,24 +687,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -873,10 +720,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config24.json b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config24.json index 2b453aac58bb..d464b88beeb2 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config24.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/class_def/config/config24.json @@ -266,70 +266,6 @@ "insertText": "Person", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -546,54 +482,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -618,14 +506,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -642,22 +522,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "name", "kind": "Variable", @@ -892,14 +756,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -923,6 +779,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/comment_context/config/comment_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/comment_context/config/comment_config3.json index 02e7d04b764d..2281a7d59a5b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/comment_context/config/comment_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/comment_context/config/comment_config3.json @@ -267,70 +267,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "getGreeting()", "kind": "Function", @@ -869,14 +733,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -900,6 +756,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "O", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "O", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "O", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "O", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "O", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "O", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "O", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "R", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "O", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "M", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "O", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "O", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "O", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "O", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "O", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "O", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "O", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "O", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/comment_context/config/comment_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/comment_context/config/comment_config4.json index f40b152f20d3..7b65ebcdfa8c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/comment_context/config/comment_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/comment_context/config/comment_config4.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "getGreeting()", "kind": "Function", @@ -869,14 +733,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -900,6 +756,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "O", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "O", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "O", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "O", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "O", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "O", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "O", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "R", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "O", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "M", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "O", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "O", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "O", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "O", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "O", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "O", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "O", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "O", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/enum_decl_ctx/config/config5.json b/language-server/modules/langserver-core/src/test/resources/completion/enum_decl_ctx/config/config5.json index 5be0eba3a784..793ea8627991 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/enum_decl_ctx/config/config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/enum_decl_ctx/config/config5.json @@ -9,7 +9,7 @@ "label": "import", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "import", "insertText": "import ", "insertTextFormat": "Snippet" @@ -18,7 +18,7 @@ "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +27,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +36,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +45,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +54,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +63,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +72,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +81,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +90,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +99,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +108,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +117,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +126,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +135,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +144,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +153,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +162,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +171,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +180,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +189,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +198,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +207,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +216,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +225,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +234,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +243,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +252,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +264,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,7 +272,7 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, @@ -280,7 +280,7 @@ "label": "Colour", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "Colour", "insertTextFormat": "Snippet" }, @@ -288,79 +288,15 @@ "label": "R", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "R", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -369,7 +305,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -378,7 +314,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -387,7 +323,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -396,7 +332,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -405,7 +341,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -414,7 +350,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -423,7 +359,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -432,7 +368,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -441,7 +377,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -465,7 +401,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -489,7 +425,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -513,7 +449,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -537,7 +473,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -557,54 +493,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -629,14 +517,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -653,27 +533,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -683,7 +547,7 @@ "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -707,7 +571,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -731,7 +595,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -755,7 +619,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -779,7 +643,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -803,24 +667,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -844,10 +700,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config10.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config10.json index 2f978722a351..bfa524a1d476 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config10.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/anon_func_expr_ctx_config10.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -508,54 +444,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -580,14 +468,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -604,22 +484,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "value4", "kind": "Variable", @@ -913,14 +777,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -944,6 +800,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config7.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config7.json index 1ed14d471544..c23e3544d1a1 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config7.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -532,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -604,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -628,22 +508,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunctionWithParams1(int a, int b)", "kind": "Function", @@ -908,14 +772,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -939,6 +795,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config8.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config8.json index 87100a9ecd48..75af16db3921 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/function_call_expression_ctx_config8.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -532,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -604,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -628,22 +508,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunctionWithParams1(int a, int b)", "kind": "Function", @@ -920,14 +784,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -951,6 +807,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config1.json index 216f4bce2934..0390ba2f5140 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config1.json @@ -440,70 +440,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -681,54 +617,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -753,14 +641,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -777,22 +657,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "worker", "kind": "Snippet", @@ -946,14 +810,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -977,6 +833,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config3.json index b302e2d9a682..d78da17e285d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/module_ctx_config3.json @@ -440,70 +440,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -810,54 +746,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -882,14 +770,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -906,22 +786,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test()", "kind": "Function", @@ -946,14 +810,6 @@ "insertText": "worker ${1:name} {\n\t${2}\n}", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -977,6 +833,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config21.json b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config21.json index 042ed9204897..28d78f8da352 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config21.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config21.json @@ -283,70 +283,6 @@ "insertText": "TestRec", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -548,54 +484,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -620,14 +508,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -644,22 +524,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "main(TestRec rec)", "kind": "Function", @@ -882,14 +746,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -913,6 +769,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config7.json b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config7.json index bd7ff5da28f0..3fe742289f8d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config7.json @@ -285,70 +285,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -565,54 +501,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -637,14 +525,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -661,22 +541,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "doSomeTask()", "kind": "Function", @@ -909,14 +773,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -940,6 +796,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config8.json b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config8.json index fad1e2571c60..d7659eb1de89 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/foreach_stmt_ctx_config8.json @@ -285,70 +285,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -565,54 +501,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -637,14 +525,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -661,22 +541,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "doSomeTask()", "kind": "Function", @@ -909,14 +773,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -940,6 +796,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config1.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config1.json index f624025b5ac7..eae29afa94bd 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config1.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -532,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -604,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -628,22 +508,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -854,14 +718,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -885,6 +741,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config10.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config10.json index e8de124f7500..a6b5183a85eb 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config10.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config10.json @@ -176,54 +176,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -248,14 +200,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -272,30 +216,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "isolated", "kind": "Keyword", @@ -396,62 +316,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "xmlns", "kind": "Snippet", @@ -888,14 +752,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -919,6 +775,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config12.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config12.json index dd6ca40d3e66..73350b9f2e98 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config12.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config12.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -532,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -604,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -628,22 +508,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "v", "kind": "Variable", @@ -889,14 +753,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -920,6 +776,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "O", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "O", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "O", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "O", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "O", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "O", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "O", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "R", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "O", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "M", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "O", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "O", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "O", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "O", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "O", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "O", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "O", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "O", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config14.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config14.json index 256f708a1eaa..eea229d01b7e 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config14.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config14.json @@ -492,70 +492,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -628,54 +564,6 @@ "insertText": "false", "insertTextFormat": "Snippet" }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -700,14 +588,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -724,22 +604,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "foo()", "kind": "Function", @@ -877,14 +741,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -908,6 +764,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config2.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config2.json index a476b8bd13f2..fbc43e6c7aa6 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config2.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -532,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -604,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -628,22 +508,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -854,14 +718,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -885,6 +741,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config3.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config3.json index c9078f768d16..aafd803ef785 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config3.json @@ -258,70 +258,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -523,54 +459,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -595,14 +483,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -619,22 +499,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -845,14 +709,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -876,6 +732,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config4.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config4.json index 2f705e7996f4..144fda7df98c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config4.json @@ -258,70 +258,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -523,54 +459,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -595,14 +483,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -619,22 +499,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "validator2", "kind": "Variable", @@ -856,14 +720,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -887,6 +743,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config5.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config5.json index 846f1f367cbc..7b266a129127 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config5.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -508,54 +444,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -580,14 +468,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -604,22 +484,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "validator1", "kind": "Variable", @@ -874,14 +738,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -905,6 +761,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config6.json b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config6.json index 4cd303f08ada..6598153a60e7 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/function_body/config/config6.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -508,54 +444,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -580,14 +468,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -604,22 +484,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "validator2", "kind": "Variable", @@ -874,14 +738,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -905,6 +761,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config11.json b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config11.json index ab068e7d502a..d6f704e8997c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config11.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config11.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -412,54 +348,6 @@ "insertText": "module1", "insertTextFormat": "Snippet" }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -484,14 +372,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -508,22 +388,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "lsproject.hierarchy.module4", "kind": "Module", @@ -956,14 +820,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -987,6 +843,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config12.json b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config12.json index cb5f540ca574..a8e4185f1e85 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config12.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config12.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -412,54 +348,6 @@ "insertText": "module1", "insertTextFormat": "Snippet" }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -484,14 +372,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -508,22 +388,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "lsproject.hierarchy.module4", "kind": "Module", @@ -956,14 +820,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -987,6 +843,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config21.json b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config21.json index a8713b8104dc..583e5de4d52f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config21.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config21.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -412,54 +348,6 @@ "insertText": "module1", "insertTextFormat": "Snippet" }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -484,14 +372,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -508,22 +388,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "lsproject.hierarchy.module4", "kind": "Module", @@ -956,14 +820,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -987,6 +843,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config26.json b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config26.json index d252c6ed7bab..d3b81ad78c36 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config26.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/config26.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -403,54 +339,6 @@ "insertText": "false", "insertTextFormat": "Snippet" }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -475,14 +363,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -499,22 +379,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "'service.'transaction.'join", "kind": "Module", @@ -932,14 +796,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -963,6 +819,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config1.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config1.json index 0ddf18126c80..83d4108828d8 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config1.json @@ -9,7 +9,7 @@ "label": "import", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "import", "insertText": "import ", "insertTextFormat": "Snippet" @@ -18,7 +18,7 @@ "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +27,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +36,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +45,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +54,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +63,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +72,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +81,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +90,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +99,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +108,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +117,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +126,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +135,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +144,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +153,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +162,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +171,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +180,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +189,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +198,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +207,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +216,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +225,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +234,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +243,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +252,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +264,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +272,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +289,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +298,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +307,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +316,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +325,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +334,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +343,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +352,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +376,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +400,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +424,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +448,7 @@ "label": "ballerina/module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet", @@ -536,7 +472,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -556,54 +492,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -628,14 +516,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -652,27 +532,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -696,7 +560,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -720,7 +584,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -744,7 +608,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -768,7 +632,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -792,7 +656,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -816,24 +680,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -857,10 +713,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config14.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config14.json index 4d5195301626..c265c5c0c8bd 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config14.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config14.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/lsproject/main.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,25 +117,16 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" }, - { - "label": "public main function", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "public_function_main", - "insertText": "public function main() {\n\t${1}\n}", - "insertTextFormat": "Snippet" - }, { "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +135,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +144,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +153,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +162,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +171,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +180,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +189,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +198,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +207,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +216,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +225,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +234,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -261,7 +243,7 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, @@ -272,79 +254,15 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +271,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +280,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +289,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +298,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +307,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +316,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +325,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +334,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -425,7 +343,7 @@ "label": "mod1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "mod1", "insertText": "mod1", "insertTextFormat": "Snippet" @@ -434,7 +352,7 @@ "label": "module2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module2", "insertText": "module2", "insertTextFormat": "Snippet" @@ -443,7 +361,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -467,7 +385,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -491,7 +409,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -515,7 +433,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -539,7 +457,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -559,54 +477,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -631,14 +501,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -655,27 +517,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "lsproject.module3", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module3", "insertText": "module3", "insertTextFormat": "Snippet", @@ -699,7 +545,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -709,7 +555,7 @@ "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -733,7 +579,7 @@ "label": "Service", "kind": "Interface", "detail": "Object", - "sortText": "D", + "sortText": "CA", "insertText": "Service", "insertTextFormat": "Snippet" }, @@ -741,7 +587,7 @@ "label": "Listener", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "Listener", "insertTextFormat": "Snippet" }, @@ -749,7 +595,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -773,7 +619,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -797,7 +643,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -821,7 +667,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -845,7 +691,7 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" @@ -854,7 +700,7 @@ "label": "mod1:Service", "kind": "Interface", "detail": "Object", - "sortText": "D", + "sortText": "CA", "insertText": "mod1:Service", "insertTextFormat": "Snippet" }, @@ -862,7 +708,7 @@ "label": "service on mod1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lsproject_module1_mod1_Listener", "insertText": "service ${1} on new mod1:Listener() {\n\n remote function method1() {\n return;\n }\n\n function method2() returns string|error {\n return ${3:\"\"};\n }\n\n function method3(mod1:MyType|int arg1) returns mod1:MyType {\n return ${4:{a: \"\"\\}};\n }\n\n}\n", "insertTextFormat": "Snippet", @@ -872,7 +718,7 @@ "label": "service on lsproject.module3:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lsproject_module3_Listener", "insertText": "service ${1} on new module3:Listener() {\n\n remote function method1() {\n return;\n }\n\n function method2() returns string|error {\n return ${3:\"\"};\n }\n\n function method3($CompilationError$|int arg1) returns $CompilationError$ {\n ${4}\n }\n\n}\n", "insertTextFormat": "Snippet", @@ -896,25 +742,17 @@ "label": "service on Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_Listener", "insertText": "service ${1} on new Listener() {\n\n remote function method1() {\n return;\n }\n\n function method2() returns string|error {\n return ${3:\"\"};\n }\n\n function method3($CompilationError$|int arg1) returns $CompilationError$ {\n ${4}\n }\n\n}\n", "insertTextFormat": "Snippet", "additionalTextEdits": [] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -938,10 +776,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config15.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config15.json index cb55bb582d88..b36752a75f13 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config15.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config15.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/source14.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,25 +117,16 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" }, - { - "label": "public main function", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "public_function_main", - "insertText": "public function main() {\n\t${1}\n}", - "insertTextFormat": "Snippet" - }, { "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +135,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +144,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +153,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +162,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +171,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +180,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +189,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +198,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +207,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +216,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +225,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +234,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -261,7 +243,7 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, @@ -269,7 +251,7 @@ "label": "Service", "kind": "Interface", "detail": "Object", - "sortText": "D", + "sortText": "CA", "insertText": "Service", "insertTextFormat": "Snippet" }, @@ -280,7 +262,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -288,79 +270,15 @@ "label": "Listener", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "Listener", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -369,7 +287,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -378,7 +296,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -387,7 +305,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -396,7 +314,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -405,7 +323,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -414,7 +332,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -423,7 +341,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -432,7 +350,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -441,7 +359,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -465,7 +383,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -489,7 +407,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -513,7 +431,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -537,7 +455,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -557,54 +475,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -629,14 +499,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -653,27 +515,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -683,7 +529,7 @@ "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -707,7 +553,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -731,7 +577,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -755,7 +601,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -779,7 +625,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -803,7 +649,7 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" @@ -812,25 +658,17 @@ "label": "service on Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_Listener", "insertText": "service ${1} on new Listener() {\n\n remote function method1() {\n return;\n }\n\n}\n", "insertTextFormat": "Snippet", "additionalTextEdits": [] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -854,10 +692,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config16.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config16.json index 077f97a8364b..e3f9f0dea280 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config16.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config16.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/lsproject/modules/module2/module2.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,25 +117,16 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" }, - { - "label": "public main function", - "kind": "Snippet", - "detail": "Snippet", - "sortText": "A", - "filterText": "public_function_main", - "insertText": "public function main() {\n\t${1}\n}", - "insertTextFormat": "Snippet" - }, { "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +135,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +144,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +153,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +162,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +171,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +180,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +189,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +198,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +207,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +216,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +225,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +234,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -261,7 +243,7 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, @@ -272,79 +254,15 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +271,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +280,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +289,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +298,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +307,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +316,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +325,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +334,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -425,7 +343,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -449,7 +367,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -473,7 +391,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -497,7 +415,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -521,7 +439,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -541,54 +459,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +483,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +499,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "lsproject.module3", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module3", "insertText": "module3", "insertTextFormat": "Snippet", @@ -681,7 +527,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +537,7 @@ "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -715,7 +561,7 @@ "label": "lsproject.module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module11", "insertTextFormat": "Snippet", @@ -739,7 +585,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -763,7 +609,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -787,7 +633,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -811,7 +657,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -835,7 +681,7 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" @@ -844,7 +690,7 @@ "label": "service on lsproject.module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lsproject_module1_Listener", "insertText": "service ${1} on new module11:Listener() {\n\n remote function method1() {\n return;\n }\n\n function method2() returns string|error {\n return ${3:\"\"};\n }\n\n function method3(module11:MyType|int arg1) returns module11:MyType {\n return ${4:{a: \"\"\\}};\n }\n\n}\n", "insertTextFormat": "Snippet", @@ -868,7 +714,7 @@ "label": "service on lsproject.module3:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lsproject_module3_Listener", "insertText": "service ${1} on new module3:Listener() {\n\n remote function method1() {\n return;\n }\n\n function method2() returns string|error {\n return ${3:\"\"};\n }\n\n function method3($CompilationError$|int arg1) returns $CompilationError$ {\n ${4}\n }\n\n}\n", "insertTextFormat": "Snippet", @@ -888,19 +734,11 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -924,10 +762,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config2.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config2.json index 0cccae6a28ad..b65bd64544b5 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config2.json @@ -9,7 +9,7 @@ "label": "import", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "import", "insertText": "import ", "insertTextFormat": "Snippet" @@ -18,7 +18,7 @@ "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +27,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +36,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +45,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +54,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +63,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +72,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +81,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +90,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +99,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +108,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +117,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +126,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +135,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +144,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +153,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +162,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +171,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +180,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +189,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +198,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +207,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +216,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +225,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +234,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +243,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +252,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +264,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +272,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +289,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +298,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +307,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +316,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +325,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +334,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +343,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +352,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +376,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +400,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +424,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +448,7 @@ "label": "ballerina/module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet", @@ -536,7 +472,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -556,54 +492,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -628,14 +516,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -652,27 +532,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -696,7 +560,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -720,7 +584,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -744,7 +608,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -768,7 +632,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -792,7 +656,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -816,24 +680,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -857,10 +713,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config3.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config3.json index 8ca1fce994d4..25587ec645ae 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config3.json @@ -9,7 +9,7 @@ "label": "import", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "import", "insertText": "import ", "insertTextFormat": "Snippet" @@ -18,7 +18,7 @@ "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +27,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +36,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +45,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +54,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +63,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +72,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +81,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +90,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +99,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +108,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +117,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +126,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +135,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +144,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +153,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +162,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +171,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +180,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +189,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +198,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +207,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +216,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +225,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +234,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +243,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +252,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +264,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +272,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +289,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +298,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +307,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +316,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +325,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +334,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +343,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +352,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +376,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +400,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +424,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +448,7 @@ "label": "ballerina/module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet", @@ -536,7 +472,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -556,54 +492,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -628,14 +516,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -652,27 +532,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -696,7 +560,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -720,7 +584,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -744,7 +608,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -768,7 +632,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -792,7 +656,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -816,24 +680,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -857,10 +713,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config6.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config6.json index 3bd9a5b7f925..488f69e0b3fc 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/config6.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/source6.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -425,7 +352,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -449,7 +376,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -473,7 +400,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -497,7 +424,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -667,7 +522,7 @@ "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -828,10 +675,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_annotation_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_annotation_decl_config.json index 2675a3b3caf9..62b381c319d0 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_annotation_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_annotation_decl_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -876,10 +723,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_class_defn_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_class_defn_config.json index 045b4c184ab4..74cf2fcde08e 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_class_defn_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_class_defn_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -876,10 +723,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_const_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_const_decl_config.json index 86e218c6805b..3d9cb2101f9a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_const_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_const_decl_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -876,10 +723,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_enum_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_enum_decl_config.json index e95931a10b53..8a5a3e60a4c4 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_enum_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_enum_decl_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -876,10 +723,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_funciton_defn_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_funciton_defn_config.json index d0d0fc393edf..87440bf56d76 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_funciton_defn_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_funciton_defn_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -876,10 +723,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_import_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_import_decl_config.json index 9b83f184c28e..b08f82f7136f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_import_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_import_decl_config.json @@ -9,7 +9,7 @@ "label": "import", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "import", "insertText": "import ", "insertTextFormat": "Snippet" @@ -18,7 +18,7 @@ "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +27,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +36,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +45,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +54,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +63,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +72,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +81,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +90,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +99,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +108,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +117,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +126,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +135,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +144,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +153,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +162,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +171,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +180,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +189,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +198,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +207,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +216,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +225,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +234,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +243,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +252,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +264,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +272,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +289,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +298,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +307,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +316,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +325,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +334,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +343,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +352,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +376,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +400,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +424,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +448,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +457,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +477,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +501,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +517,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +545,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +555,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +579,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +603,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +627,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +651,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +668,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +676,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +684,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +692,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +700,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +708,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -876,10 +732,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_listener_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_listener_decl_config.json index 1b5a19b74923..89690798d3dc 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_listener_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_listener_decl_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -876,10 +723,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_service_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_service_decl_config.json index 60e95f6ce6aa..0b681d05c20b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_service_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_service_decl_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -876,10 +723,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_type_defn_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_type_defn_config.json index d379d1503deb..b9be95cdc1e4 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_type_defn_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_type_defn_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -876,10 +723,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_var_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_var_decl_config.json index 4a1e952b9eac..a84924aac19f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_var_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_var_decl_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -876,10 +723,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_xmlns_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_xmlns_decl_config.json index e2742a304e8d..3b04ee33dd70 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_xmlns_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_after_xmlns_decl_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -876,10 +723,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_annotation_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_annotation_decl_config.json index 35e56bfc98f3..72702371a20c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_annotation_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_annotation_decl_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -876,10 +723,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_class_defn_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_class_defn_config.json index ab678f59a17e..3dca99e2aa51 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_class_defn_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_class_defn_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -876,10 +723,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_const_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_const_decl_config.json index 1bafa4125241..37f4f7aabd2d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_const_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_const_decl_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -876,10 +723,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_enum_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_enum_decl_config.json index 9a287433ace1..2bd21271590b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_enum_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_enum_decl_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -876,10 +723,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_function_defn_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_function_defn_config.json index fe30b2dd0f16..8dd3d9ed2d13 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_function_defn_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_function_defn_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -876,10 +723,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_import_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_import_decl_config.json index 93efa15d3dfb..09ed36e6ee95 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_import_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_import_decl_config.json @@ -9,7 +9,7 @@ "label": "import", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "import", "insertText": "import ", "insertTextFormat": "Snippet" @@ -18,7 +18,7 @@ "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +27,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +36,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +45,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +54,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +63,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +72,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +81,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +90,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +99,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +108,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +117,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +126,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +135,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +144,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +153,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +162,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +171,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +180,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +189,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +198,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +207,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +216,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +225,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +234,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +243,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +252,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +264,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +272,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +289,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +298,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +307,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +316,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +325,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +334,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +343,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +352,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +376,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +400,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +424,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +448,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +457,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +477,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +501,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +517,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +545,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +555,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +579,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +603,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +627,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +651,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +668,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +676,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +684,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +692,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +700,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +708,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -876,10 +732,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_listener_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_listener_decl_config.json index 6b527709efcd..e0dfc5cd0f0d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_listener_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_listener_decl_config.json @@ -9,7 +9,7 @@ "label": "import", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "import", "insertText": "import ", "insertTextFormat": "Snippet" @@ -18,7 +18,7 @@ "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +27,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +36,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +45,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +54,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +63,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +72,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +81,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +90,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +99,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +108,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +117,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +126,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +135,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +144,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +153,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +162,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +171,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +180,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +189,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +198,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +207,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +216,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +225,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +234,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +243,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +252,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +264,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +272,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +289,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +298,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +307,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +316,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +325,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +334,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +343,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +352,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +376,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +400,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +424,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +448,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +457,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +477,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +501,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +517,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +545,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +555,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +579,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +603,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +627,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +651,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +668,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +676,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +684,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +692,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +700,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +708,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -876,10 +732,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_service_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_service_decl_config.json index c89a63f47ed8..9f354124369a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_service_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_service_decl_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -876,10 +723,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_type_defn_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_type_defn_config.json index 860955c3c3e1..750889ed0b33 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_type_defn_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_type_defn_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -876,10 +723,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_var_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_var_decl_config.json index 9e1bafe08c4e..cebaa8d90d95 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_var_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_var_decl_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -876,10 +723,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_xmlns_decl_config.json b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_xmlns_decl_config.json index ee3111cf2a77..ce9578057df1 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_xmlns_decl_config.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/module_part_context/config/module_level_before_xmlns_decl_config.json @@ -5,20 +5,11 @@ }, "source": "module_part_context/source/module_part_start_and_end_of_decls_and_defns.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,79 +263,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -353,7 +280,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -362,7 +289,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -371,7 +298,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -380,7 +307,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -389,7 +316,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -398,7 +325,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -407,7 +334,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -416,7 +343,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -440,7 +367,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -464,7 +391,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -488,7 +415,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -512,7 +439,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -521,7 +448,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -541,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,27 +508,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -681,7 +536,7 @@ "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -691,7 +546,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -715,7 +570,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -739,7 +594,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -763,7 +618,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -787,24 +642,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ONE", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "ONE", "insertTextFormat": "Snippet" }, @@ -812,7 +659,7 @@ "label": "testConst", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "CA", "insertText": "testConst", "insertTextFormat": "Snippet" }, @@ -820,7 +667,7 @@ "label": "TWO", "kind": "TypeParameter", "detail": "Singleton", - "sortText": "D", + "sortText": "G", "insertText": "TWO", "insertTextFormat": "Snippet" }, @@ -828,7 +675,7 @@ "label": "testEnum", "kind": "Enum", "detail": "enum", - "sortText": "D", + "sortText": "G", "insertText": "testEnum", "insertTextFormat": "Snippet" }, @@ -836,7 +683,7 @@ "label": "TestClass", "kind": "Interface", "detail": "Class", - "sortText": "D", + "sortText": "CA", "insertText": "TestClass", "insertTextFormat": "Snippet" }, @@ -844,7 +691,7 @@ "label": "TestType", "kind": "TypeParameter", "detail": "Int", - "sortText": "D", + "sortText": "CA", "insertText": "TestType", "insertTextFormat": "Snippet" }, @@ -852,7 +699,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -876,10 +723,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_body/config/config4.json b/language-server/modules/langserver-core/src/test/resources/completion/service_body/config/config4.json index 46c255fe8ee8..876a1717d278 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_body/config/config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_body/config/config4.json @@ -258,70 +258,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -523,54 +459,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -595,14 +483,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -619,22 +499,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "s", "kind": "Variable", @@ -869,14 +733,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -900,6 +756,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config16.json b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config16.json index 064e0ca2f289..e25c84aa83a0 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config16.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config16.json @@ -266,70 +266,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -531,54 +467,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -603,14 +491,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -627,22 +507,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "lst", "kind": "Variable", @@ -869,14 +733,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -900,6 +756,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config17.json b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config17.json index b88910127181..b0a1e5e02185 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config17.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config17.json @@ -5,20 +5,11 @@ }, "source": "service_decl/source/source17.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,7 +263,7 @@ "label": "TestObject", "kind": "Interface", "detail": "Object", - "sortText": "D", + "sortText": "CA", "insertText": "TestObject", "insertTextFormat": "Snippet" }, @@ -280,79 +271,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -361,7 +288,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -370,7 +297,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -379,7 +306,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -388,7 +315,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -397,7 +324,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -406,7 +333,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -415,7 +342,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -424,7 +351,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -433,7 +360,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -457,7 +384,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -481,7 +408,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -505,7 +432,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -529,7 +456,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -549,54 +476,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -621,14 +500,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -645,27 +516,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -675,7 +530,7 @@ "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -699,7 +554,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -723,7 +578,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -747,7 +602,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -771,7 +626,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -795,24 +650,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -836,10 +683,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config18.json b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config18.json index e09ed2d3883d..79a2f355fbfc 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config18.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config18.json @@ -5,20 +5,11 @@ }, "source": "service_decl/source/source18.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,7 +263,7 @@ "label": "TestObject", "kind": "Interface", "detail": "Object", - "sortText": "D", + "sortText": "CA", "insertText": "TestObject", "insertTextFormat": "Snippet" }, @@ -280,79 +271,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -361,7 +288,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -370,7 +297,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -379,7 +306,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -388,7 +315,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -397,7 +324,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -406,7 +333,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -415,7 +342,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -424,7 +351,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -433,7 +360,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -457,7 +384,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -481,7 +408,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -505,7 +432,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -529,7 +456,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -549,54 +476,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -621,14 +500,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -645,27 +516,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -675,7 +530,7 @@ "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -699,7 +554,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -723,7 +578,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -747,7 +602,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -771,7 +626,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -795,24 +650,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -836,10 +683,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config7.json b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config7.json index 06a097ebdc14..6157d4226130 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/service_decl/config/config7.json @@ -5,20 +5,11 @@ }, "source": "service_decl/source/source7.bal", "items": [ - { - "label": "import", - "kind": "Keyword", - "detail": "Keyword", - "sortText": "B", - "filterText": "import", - "insertText": "import ", - "insertTextFormat": "Snippet" - }, { "label": "type", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "type", "insertText": "type ", "insertTextFormat": "Snippet" @@ -27,7 +18,7 @@ "label": "public", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "public", "insertText": "public ", "insertTextFormat": "Snippet" @@ -36,7 +27,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -45,7 +36,7 @@ "label": "final", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "final", "insertText": "final ", "insertTextFormat": "Snippet" @@ -54,7 +45,7 @@ "label": "const", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "const", "insertText": "const ", "insertTextFormat": "Snippet" @@ -63,7 +54,7 @@ "label": "listener", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "listener", "insertText": "listener ", "insertTextFormat": "Snippet" @@ -72,7 +63,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -81,7 +72,7 @@ "label": "var", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "var", "insertText": "var ", "insertTextFormat": "Snippet" @@ -90,7 +81,7 @@ "label": "enum", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "enum", "insertText": "enum ", "insertTextFormat": "Snippet" @@ -99,7 +90,7 @@ "label": "xmlns", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "xmlns", "insertText": "xmlns ", "insertTextFormat": "Snippet" @@ -108,7 +99,7 @@ "label": "class", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "class", "insertText": "class ", "insertTextFormat": "Snippet" @@ -117,7 +108,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -126,7 +117,7 @@ "label": "function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AE", "filterText": "function", "insertText": "function ${1:name}(${2})${3} {\n\t${4}\n}", "insertTextFormat": "Snippet" @@ -135,7 +126,7 @@ "label": "public main function", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AA", "filterText": "public_function_main", "insertText": "public function main() {\n\t${1}\n}", "insertTextFormat": "Snippet" @@ -144,7 +135,7 @@ "label": "configurable", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "configurable", "insertText": "configurable", "insertTextFormat": "Snippet" @@ -153,7 +144,7 @@ "label": "annotation", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "annotation", "insertText": "annotation ${1:typeName} ${2:name} on ${3:attachmentPoint};", "insertTextFormat": "Snippet" @@ -162,7 +153,7 @@ "label": "type record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AG", "filterText": "type_record", "insertText": "type ${1:RecordName} record {\n\t${2}\n};", "insertTextFormat": "Snippet" @@ -171,7 +162,7 @@ "label": "xmlns", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "xmlns", "insertText": "xmlns \"${1}\" as ${2:ns};", "insertTextFormat": "Snippet" @@ -180,7 +171,7 @@ "label": "type object", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_object", "insertText": "type ${1:ObjectName} object {${2}};", "insertTextFormat": "Snippet" @@ -189,7 +180,7 @@ "label": "class", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "class", "insertText": "class ${1:className} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -198,7 +189,7 @@ "label": "enum", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "enum", "insertText": "enum ${1:enumName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -207,7 +198,7 @@ "label": "type record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AF", "filterText": "type_record", "insertText": "type ${1:RecordName} record {|\n\t${2}\n|};", "insertTextFormat": "Snippet" @@ -216,7 +207,7 @@ "label": "type error", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_error", "insertText": "type ${1:ErrorName} error<${2:map}>;", "insertTextFormat": "Snippet" @@ -225,7 +216,7 @@ "label": "type TypeName table<>;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table", "insertText": "type ${1:TypeName} table<${2}>;", "insertTextFormat": "Snippet" @@ -234,7 +225,7 @@ "label": "type TypeName table<> key", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "type_table_key", "insertText": "type ${1:TypeName} table<${2}> key${3}", "insertTextFormat": "Snippet" @@ -243,7 +234,7 @@ "label": "stream<> streamName = new;", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "stream", "insertText": "stream<${1}> ${2:streamName} = new;", "insertTextFormat": "Snippet" @@ -252,7 +243,7 @@ "label": "service", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "AB", "filterText": "service", "insertText": "service on ${1:listenerName} {\n\t${2}\n}", "insertTextFormat": "Snippet" @@ -264,7 +255,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "D", + "sortText": "CA", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -272,7 +263,7 @@ "label": "TestObject", "kind": "Interface", "detail": "Object", - "sortText": "D", + "sortText": "CA", "insertText": "TestObject", "insertTextFormat": "Snippet" }, @@ -280,79 +271,15 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "D", + "sortText": "CA", "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "record", "insertText": "record ", "insertTextFormat": "Snippet" @@ -361,7 +288,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "AD", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -370,7 +297,7 @@ "label": "record {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {${1}}", "insertTextFormat": "Snippet" @@ -379,7 +306,7 @@ "label": "record {||}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "record", "insertText": "record {|${1}|}", "insertTextFormat": "Snippet" @@ -388,7 +315,7 @@ "label": "distinct", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "distinct", "insertText": "distinct", "insertTextFormat": "Snippet" @@ -397,7 +324,7 @@ "label": "object {}", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -406,7 +333,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -415,7 +342,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -424,7 +351,7 @@ "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet" @@ -433,7 +360,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -457,7 +384,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -481,7 +408,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -505,7 +432,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -529,7 +456,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -549,54 +476,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -621,14 +500,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -645,27 +516,11 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service on module1:Listener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_module1_Listener", "insertText": "service ${1} on new module1:Listener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -675,7 +530,7 @@ "label": "service on lang.test:MockListener", "kind": "Snippet", "detail": "Snippet", - "sortText": "E", + "sortText": "AC", "filterText": "service_lang_test_MockListener", "insertText": "service ${1} on new test:MockListener(${2:0}) {\n ${3}\n}\n", "insertTextFormat": "Snippet", @@ -699,7 +554,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -723,7 +578,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -747,7 +602,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -771,7 +626,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -795,24 +650,16 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "B", + "sortText": "D", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "E", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "C", + "sortText": "F", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -836,10 +683,155 @@ "label": "function (..) => ", "kind": "Snippet", "detail": "Snippet", - "sortText": "A", + "sortText": "B", "filterText": "function", "insertText": "function ${1:name}(${2})${3} => (${4});", "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "CA", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "CA", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "CA", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "CA", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "CA", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "CA", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "CA", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "AD", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "CA", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "CA", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "CA", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "CA", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "CA", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "CA", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "CA", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "CA", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "CA", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "CA", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/continue_break_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/continue_break_stmt_ctx_config1.json index bbf587d09773..c226ddd5d874 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/continue_break_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/continue_break_stmt_ctx_config1.json @@ -285,70 +285,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -565,54 +501,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -637,14 +525,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -661,22 +541,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "numberList", "kind": "Variable", @@ -902,14 +766,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -933,6 +789,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/continue_break_stmt_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/continue_break_stmt_ctx_config2.json index bdd76c83166d..092d33754906 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/continue_break_stmt_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/continue_break_stmt_ctx_config2.json @@ -285,70 +285,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -565,54 +501,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -637,14 +525,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -661,22 +541,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "numberList", "kind": "Variable", @@ -910,14 +774,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -941,6 +797,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/do_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/do_stmt_ctx_config1.json index 683d7407611a..1fedaf566fdf 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/do_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/do_stmt_ctx_config1.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -508,54 +444,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -580,14 +468,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -604,22 +484,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "value1", "kind": "Variable", @@ -876,14 +740,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -907,6 +763,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/else_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/else_stmt_ctx_config1.json index 0deee0d96e15..37d594b595cb 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/else_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/else_stmt_ctx_config1.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "doSomeTask()", "kind": "Function", @@ -883,14 +747,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -914,6 +770,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/else_stmt_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/else_stmt_ctx_config2.json index e38cdd14144f..9e3944d497bd 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/else_stmt_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/else_stmt_ctx_config2.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "doSomeTask()", "kind": "Function", @@ -883,14 +747,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -914,6 +770,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config1.json index 330ad24a0683..ddcef50a323f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config1.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "doSomeTask()", "kind": "Function", @@ -883,14 +747,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -914,6 +770,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config2.json index ede89b6b7dd4..38a4778453c8 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/elseif_stmt_ctx_config2.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "doSomeTask()", "kind": "Function", @@ -883,14 +747,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -914,6 +770,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/function_call_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/function_call_stmt_ctx_config1.json index 84219253ace1..efa88bab011b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/function_call_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/function_call_stmt_ctx_config1.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "doSomeTask()", "kind": "Function", @@ -884,14 +748,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -915,6 +771,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/function_call_stmt_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/function_call_stmt_ctx_config2.json index 8d5ccb397d79..df8bc813005c 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/function_call_stmt_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/function_call_stmt_ctx_config2.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "doSomeTask()", "kind": "Function", @@ -884,14 +748,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -915,6 +771,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config1.json index bc370de04738..cd40179e1d7a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config1.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "doSomeTask()", "kind": "Function", @@ -875,14 +739,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -906,6 +762,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config2.json index 5843951dbeed..9d159624d701 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config2.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "doSomeTask()", "kind": "Function", @@ -875,14 +739,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -906,6 +762,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config7.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config7.json index 52ffadb7f711..72b2f97dc20a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config7.json @@ -285,70 +285,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -565,54 +501,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -637,14 +525,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -661,22 +541,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "doSomeTask()", "kind": "Function", @@ -910,14 +774,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -941,6 +797,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config8.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config8.json index bdf0b71f0700..45b423223be4 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/if_stmt_ctx_config8.json @@ -285,70 +285,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -565,54 +501,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -637,14 +525,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -661,22 +541,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "doSomeTask()", "kind": "Function", @@ -910,14 +774,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -941,6 +797,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/local_var_decl_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/local_var_decl_stmt_ctx_config1.json index 02501b364761..70345055e038 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/local_var_decl_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/local_var_decl_stmt_ctx_config1.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "sendMail()", "kind": "Function", @@ -869,14 +733,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -900,6 +756,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/lock_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/lock_stmt_ctx_config1.json index b35382e29efc..2d01bd36adf3 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/lock_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/lock_stmt_ctx_config1.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "numberList", "kind": "Variable", @@ -884,14 +748,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -915,6 +771,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/lock_stmt_ctx_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/lock_stmt_ctx_config3.json index a5293959208a..3969dea797e9 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/lock_stmt_ctx_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/lock_stmt_ctx_config3.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "myInt", "kind": "Variable", @@ -868,14 +732,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -899,6 +755,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config1.json index 766b5b300b6b..8354acd3d9b9 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config1.json @@ -276,70 +276,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -541,54 +477,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +501,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,22 +517,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -871,14 +735,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -902,6 +758,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config1a.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config1a.json index 7e6a8b3f33fe..03d529593d51 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config1a.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config1a.json @@ -276,70 +276,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -541,54 +477,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +501,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,22 +517,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -871,14 +735,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -902,6 +758,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config2.json index 971a9f605259..f43f2fd795a4 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config2.json @@ -276,70 +276,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -541,54 +477,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +501,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,22 +517,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -871,14 +735,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -902,6 +758,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config2a.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config2a.json index 06180a1f2d7f..62e1dcacc1af 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config2a.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config2a.json @@ -276,70 +276,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -541,54 +477,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +501,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,22 +517,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -871,14 +735,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -902,6 +758,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config3.json index 8a1eeef1bb4b..ecdb89c7b3c7 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config3.json @@ -294,70 +294,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -559,54 +495,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -631,14 +519,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -655,22 +535,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "animals", "kind": "Variable", @@ -888,14 +752,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -919,6 +775,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config4.json index 73fd3c0dc7d0..9a747c7a57d6 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config4.json @@ -276,70 +276,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -541,54 +477,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +501,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,22 +517,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "animals", "kind": "Variable", @@ -871,14 +735,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -902,6 +758,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config5.json index 815ae54ce3d1..b8828f6e6eca 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config5.json @@ -276,70 +276,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -541,54 +477,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +501,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,22 +517,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "animals", "kind": "Variable", @@ -871,14 +735,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -902,6 +758,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config5a.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config5a.json index 0b10a0fad991..8419376c453d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config5a.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config5a.json @@ -276,70 +276,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -541,54 +477,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +501,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,22 +517,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "animals", "kind": "Variable", @@ -871,14 +735,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -902,6 +758,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config6.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config6.json index 274a75fe47af..97f979c5bbdd 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config6.json @@ -276,70 +276,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -541,54 +477,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +501,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,22 +517,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "animals", "kind": "Variable", @@ -875,14 +739,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -906,6 +762,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config6a.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config6a.json index 6bc6e35521a8..418af73ddee4 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config6a.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/onfail_clause_ctx_config6a.json @@ -276,70 +276,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -541,54 +477,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -613,14 +501,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -637,22 +517,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "animals", "kind": "Variable", @@ -875,14 +739,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -906,6 +762,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config1.json index 57c09ea473cb..b19f24b189bf 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config1.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -532,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -604,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -628,22 +508,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -854,14 +718,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -885,6 +741,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "O", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "O", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "O", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "O", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "O", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "O", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "O", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "R", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "O", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "M", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "O", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "O", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "O", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "O", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "O", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "O", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "O", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "O", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config10.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config10.json index cb0037fd05e6..8dfc6c1f37c9 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config10.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config10.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -523,54 +459,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -595,14 +483,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -619,22 +499,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.test", "kind": "Module", @@ -869,14 +733,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -900,6 +756,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config11.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config11.json index 817f4b52543d..99dd8010eb14 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config11.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config11.json @@ -266,70 +266,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -546,54 +482,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -618,14 +506,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -642,22 +522,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "self", "kind": "Variable", @@ -876,14 +740,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -907,6 +763,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config12.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config12.json index 96e576f1dba4..66ae48d1301b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config12.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config12.json @@ -258,70 +258,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -523,54 +459,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -595,14 +483,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -619,22 +499,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "l1", "kind": "Variable", @@ -879,14 +743,6 @@ "insertText": "module1:Response", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -910,6 +766,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config13.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config13.json index 9f5b34338121..923fa42d0681 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config13.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config13.json @@ -258,70 +258,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -523,54 +459,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -595,14 +483,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -619,22 +499,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "l1", "kind": "Variable", @@ -879,14 +743,6 @@ "insertText": "module1:Response", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -910,6 +766,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config14.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config14.json index 4de5609ea2cb..9a85eb2c3814 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config14.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config14.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -860,14 +724,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -891,6 +747,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config15.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config15.json index 2a6bb1855f88..6de1a9619470 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config15.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config15.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -523,54 +459,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -595,14 +483,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -619,22 +499,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.test", "kind": "Module", @@ -869,14 +733,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -900,6 +756,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config2.json index 146f1a9c826a..c2bf3d6f11fa 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config2.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -532,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -604,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -628,22 +508,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -887,14 +751,6 @@ "insertText": "module1:Response", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -918,6 +774,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "O", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "O", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "O", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "O", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "O", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "O", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "O", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "R", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "O", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "M", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "O", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "O", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "O", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "O", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "O", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "O", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "O", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "O", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config3.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config3.json index 692de60fb5dd..f46d0d7c6282 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config3.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -532,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -604,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -628,22 +508,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -853,14 +717,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -884,6 +740,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "O", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "O", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "O", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "O", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "O", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "O", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "O", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "R", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "O", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "M", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "O", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "O", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "O", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "O", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "O", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "O", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "O", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "O", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config4.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config4.json index 32d5b74950e6..505ec5bbf89b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config4.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -532,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -604,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -628,22 +508,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -845,14 +709,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -876,6 +732,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "O", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "O", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "O", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "O", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "O", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "O", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "O", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "R", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "O", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "M", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "O", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "O", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "O", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "O", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "O", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "O", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "O", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "O", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config5.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config5.json index 926f8e38a163..a6af548c1819 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config5.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config5.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -532,54 +468,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -604,14 +492,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -628,22 +508,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -878,14 +742,6 @@ "insertText": "module1:Response", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -909,6 +765,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "O", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "O", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "O", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "O", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "O", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "O", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "O", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "R", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "O", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "M", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "O", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "O", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "O", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "O", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "O", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "O", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "O", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "O", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config6.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config6.json index ae26576fca83..e3a08d667827 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config6.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config6.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -860,14 +724,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -891,6 +747,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config7.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config7.json index 20fad3cb125d..b93193d473cc 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config7.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config7.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "testFunction()", "kind": "Function", @@ -869,14 +733,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -900,6 +756,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "O", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "O", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "O", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "O", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "O", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "O", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "O", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "R", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "O", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "M", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "O", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "O", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "O", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "O", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "O", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "O", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "O", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "O", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config8.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config8.json index 1982bbc21dfc..bec057fe7b4f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config8.json @@ -258,70 +258,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -538,54 +474,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -610,14 +498,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -634,22 +514,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "worker", "kind": "Snippet", @@ -853,14 +717,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -884,6 +740,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config9.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config9.json index f841e2d81384..eb98afe24168 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config9.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/return_stmt_ctx_config9.json @@ -258,70 +258,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -538,54 +474,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -610,14 +498,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -634,22 +514,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "test", "kind": "Variable", @@ -853,14 +717,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -884,6 +740,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/transaction_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/transaction_config1.json index f0a99bbf9515..97200ddace8b 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/transaction_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/transaction_config1.json @@ -285,70 +285,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -550,54 +486,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -622,14 +510,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -646,22 +526,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "res", "kind": "Variable", @@ -886,14 +750,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -917,6 +773,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config1.json index 1cfb8b3d41c7..4cc928708bb3 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config1.json @@ -285,70 +285,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -565,54 +501,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -637,14 +525,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -661,22 +541,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "doSomeTask()", "kind": "Function", @@ -893,14 +757,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -924,6 +780,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config2.json index 56451a48bd55..040a590845b1 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/while_stmt_ctx_config2.json @@ -285,70 +285,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -565,54 +501,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -637,14 +525,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -661,22 +541,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "doSomeTask()", "kind": "Function", @@ -893,14 +757,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -924,6 +780,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/worker_declaration_ctx_config1.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/worker_declaration_ctx_config1.json index 3ec1b702f704..86a7ba6c2cd3 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/worker_declaration_ctx_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/worker_declaration_ctx_config1.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "getMessage()", "kind": "Function", @@ -875,14 +739,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -906,6 +762,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/worker_declaration_ctx_config2.json b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/worker_declaration_ctx_config2.json index fad1ac63827a..b5c16c856121 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/worker_declaration_ctx_config2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/statement_context/config/worker_declaration_ctx_config2.json @@ -267,70 +267,6 @@ "insertText": "Thread", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, - { - "label": "service", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "service", - "insertTextFormat": "Snippet" - }, { "label": "record", "kind": "Keyword", @@ -547,54 +483,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -619,14 +507,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -643,22 +523,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "getMessage()", "kind": "Function", @@ -875,14 +739,6 @@ "insertText": "null", "insertTextFormat": "Snippet" }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -906,6 +762,151 @@ "newText": "import ballerina/lang.regexp;\n" } ] + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "N", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "N", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "N", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "N", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "N", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "N", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "N", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "N", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "L", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "N", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "N", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "N", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "N", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "N", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "N", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "N", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "N", + "insertText": "typedesc", + "insertTextFormat": "Snippet" } ] } From 0d70d8c312ac5d6451909f8cff7faa0e4624a311 Mon Sep 17 00:00:00 2001 From: malinthar Date: Mon, 12 Dec 2022 10:23:03 +0530 Subject: [PATCH 201/450] Fix faling test --- .../config/new_expr_ctx_config24.json | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config24.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config24.json index a067e8130460..04ee7bfd3d2f 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config24.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config24.json @@ -265,7 +265,7 @@ "label": "service", "kind": "Keyword", "detail": "Keyword", - "sortText": "Q", + "sortText": "U", "filterText": "service", "insertText": "service", "insertTextFormat": "Snippet" @@ -274,7 +274,7 @@ "label": "new", "kind": "Keyword", "detail": "Keyword", - "sortText": "Q", + "sortText": "U", "filterText": "new", "insertText": "new ", "insertTextFormat": "Snippet" @@ -283,7 +283,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "Q", + "sortText": "U", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -292,7 +292,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "Q", + "sortText": "U", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -301,7 +301,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "Q", + "sortText": "U", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -310,7 +310,7 @@ "label": "let", "kind": "Keyword", "detail": "Keyword", - "sortText": "Q", + "sortText": "U", "filterText": "let", "insertText": "let", "insertTextFormat": "Snippet" @@ -319,7 +319,7 @@ "label": "typeof", "kind": "Keyword", "detail": "Keyword", - "sortText": "Q", + "sortText": "U", "filterText": "typeof", "insertText": "typeof ", "insertTextFormat": "Snippet" @@ -328,7 +328,7 @@ "label": "trap", "kind": "Keyword", "detail": "Keyword", - "sortText": "Q", + "sortText": "U", "filterText": "trap", "insertText": "trap", "insertTextFormat": "Snippet" @@ -337,7 +337,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "Q", + "sortText": "U", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -346,7 +346,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "Q", + "sortText": "U", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -355,7 +355,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "Q", + "sortText": "U", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -364,7 +364,7 @@ "label": "check", "kind": "Keyword", "detail": "Keyword", - "sortText": "Q", + "sortText": "U", "filterText": "check", "insertText": "check ", "insertTextFormat": "Snippet" @@ -373,7 +373,7 @@ "label": "checkpanic", "kind": "Keyword", "detail": "Keyword", - "sortText": "Q", + "sortText": "U", "filterText": "checkpanic", "insertText": "checkpanic ", "insertTextFormat": "Snippet" @@ -382,7 +382,7 @@ "label": "is", "kind": "Keyword", "detail": "Keyword", - "sortText": "Q", + "sortText": "U", "filterText": "is", "insertText": "is", "insertTextFormat": "Snippet" @@ -391,7 +391,7 @@ "label": "error constructor", "kind": "Snippet", "detail": "Snippet", - "sortText": "P", + "sortText": "T", "filterText": "error", "insertText": "error(\"${1}\")", "insertTextFormat": "Snippet" @@ -400,7 +400,7 @@ "label": "object constructor", "kind": "Snippet", "detail": "Snippet", - "sortText": "P", + "sortText": "T", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -409,7 +409,7 @@ "label": "base16", "kind": "Snippet", "detail": "Snippet", - "sortText": "P", + "sortText": "T", "filterText": "base16", "insertText": "base16 `${1}`", "insertTextFormat": "Snippet" @@ -418,7 +418,7 @@ "label": "base64", "kind": "Snippet", "detail": "Snippet", - "sortText": "P", + "sortText": "T", "filterText": "base64", "insertText": "base64 `${1}`", "insertTextFormat": "Snippet" @@ -427,7 +427,7 @@ "label": "from", "kind": "Keyword", "detail": "Keyword", - "sortText": "Q", + "sortText": "U", "filterText": "from", "insertText": "from ", "insertTextFormat": "Snippet" @@ -439,7 +439,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "M", + "sortText": "Q", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -447,7 +447,7 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "N", + "sortText": "R", "insertText": "Thread", "insertTextFormat": "Snippet" }, @@ -455,7 +455,7 @@ "label": "c1", "kind": "Variable", "detail": "MyClass", - "sortText": "B", + "sortText": "F", "insertText": "c1", "insertTextFormat": "Snippet" }, @@ -463,7 +463,7 @@ "label": "MyClass", "kind": "Interface", "detail": "Class", - "sortText": "K", + "sortText": "O", "insertText": "MyClass", "insertTextFormat": "Snippet" }, @@ -477,7 +477,7 @@ "value": "**Package:** _._ \n \n \n" } }, - "sortText": "C", + "sortText": "G", "filterText": "myFunc", "insertText": "myFunc()", "insertTextFormat": "Snippet" @@ -486,7 +486,7 @@ "label": "MyType", "kind": "Struct", "detail": "Record", - "sortText": "M", + "sortText": "Q", "insertText": "MyType", "insertTextFormat": "Snippet" }, @@ -550,7 +550,7 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "Q", + "sortText": "U", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" @@ -687,7 +687,7 @@ "label": "re ``", "kind": "Snippet", "detail": "Snippet", - "sortText": "P", + "sortText": "T", "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" From 5cb46b44a61eb7f8f7ea3db369c3f312bcfec4f5 Mon Sep 17 00:00:00 2001 From: DimuthuMadushan Date: Fri, 9 Dec 2022 16:04:31 +0530 Subject: [PATCH 202/450] Update the GraphQL help text with schema generation command --- .../resources/cli-help/ballerina-graphql.help | 42 +++++++++++++------ .../resources/cli-help/ballerina-help.help | 4 +- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/cli/ballerina-cli/src/main/resources/cli-help/ballerina-graphql.help b/cli/ballerina-cli/src/main/resources/cli-help/ballerina-graphql.help index 5f03c71a4742..e6833739c181 100644 --- a/cli/ballerina-cli/src/main/resources/cli-help/ballerina-graphql.help +++ b/cli/ballerina-cli/src/main/resources/cli-help/ballerina-graphql.help @@ -1,27 +1,40 @@ NAME - ballerina-graphql - Generate Ballerina client sources from a GraphQL config file - configured with GraphQL schemas(SDL) and GraphQL queries. + ballerina-graphql - Generate Ballerina client sources for a GraphQL config file + and generate GraphQL schema for a Ballerina GraphQL service. SYNOPSIS - bal graphql [-i | --input] [-o | --output] + bal graphql [-i | --input] + [-o | --output] + bal graphql [-i | --input] + [-o | --output] + [-s | --service] DESCRIPTION - Generate the Ballerina GraphQL client sources for a given GraphQL config file - configured with GraphQL schemas(SDL) and GraphQL queries. + Generate the Ballerina GraphQL client sources for a given GraphQL config file configured + with GraphQL schemas specified by GraphQL Schema Definition Language(SDL) and GraphQL + queries or export a GraphQL schema(SDL) for a given Ballerina GraphQL service. - The generated Ballerina sources will be written into the provided output location. + The generated Ballerina sources or GraphQL schema files will be written into the provided + output location. OPTIONS - -i, --input - Path to a GraphQL config file configured with GraphQL schemas(SDL) and GraphQL queries. - - -o, --output - Location of the generated Ballerina source code. If this path is not specified, - the output will be written to the same directory from which the command is run. - + -i, --input + This is mandatory input. The given GraphQL config file input configured with GraphQL + schemas(SDL) and queries will generate the Ballerina GraphQL client sources. The given + Ballerina GraphQL service file input will generate the GraphQL schema(SDL) file + relevant to the service. + -o, --output + Location of the generated Ballerina source code or GraphQL schema. If this path is not + specified, the output will be written to the same directory from which the command is + run. + -s, --service + This service base path is used to identify the service that needs to generate the + GraphQL schema. This option is used with the command of GraphQL schema generation. + If this base path is not specified, schemas will be generated for each of the GraphQL + services in the input file. EXAMPLES Generate Ballerina Graphql clients using a GraphQL config file (`graphql.config.yaml`). @@ -30,3 +43,6 @@ EXAMPLES Generate Ballerina Graphql clients using a GraphQL config file (`graphql.config.yaml`) and write the output to the given directory. $ bal graphql -i graphql.config.yaml -o ./output_path + + Generate a GraphQL schema for a selected GraphQL service from the given input file. + $ bal graphql -i graphql_service.bal -o ./output_path -s /service_base_path diff --git a/cli/ballerina-cli/src/main/resources/cli-help/ballerina-help.help b/cli/ballerina-cli/src/main/resources/cli-help/ballerina-help.help index 0341f7270cf8..4d4fbaa97736 100755 --- a/cli/ballerina-cli/src/main/resources/cli-help/ballerina-help.help +++ b/cli/ballerina-cli/src/main/resources/cli-help/ballerina-help.help @@ -40,8 +40,8 @@ COMMANDS format Format Ballerina source files grpc Generate the Ballerina sources for a given Protocol Buffer definition - graphql Generate Ballerina client sources - for a given GraphQL schema(SDL) and GraphQL queries + graphql Generate Ballerina client sources for a GraphQL config file + and generate GraphQL schema for a Ballerina GraphQL service. openapi Generate the Ballerina sources for a given OpenAPI definition and vice versa asyncapi Generate the Ballerina sources for a given AsyncAPI definition From ac2b63a5ec99153c6ea0f6afdf5e61b6c9cde409 Mon Sep 17 00:00:00 2001 From: Thevakumar-Luheerathan Date: Mon, 12 Dec 2022 11:20:18 +0530 Subject: [PATCH 203/450] Add hint for native build --- .../java/io/ballerina/cli/task/RunNativeImageTestTask.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java index df245085c315..de4543bf4b7e 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java @@ -244,7 +244,8 @@ private int runTestSuiteWithNativeImage(Package currentPackage, JBallerinaBacken try { if (nativeImageCommand == null) { throw new ProjectException("GraalVM installation directory not found. Set GRAALVM_HOME as an " + - "environment variable"); + "environment variable\nHINT: to install GraalVM follow the below link\n" + + "https://ballerina.io/learn/build-a-native-executable/#configure-graalvm"); } nativeImageCommand += File.separator + BIN_DIR_NAME + File.separator + (OS.contains("win") ? "native-image.cmd" : "native-image"); From c43e1729f8c86d1650679181a01742e333e8497f Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Mon, 12 Dec 2022 14:27:56 +0530 Subject: [PATCH 204/450] Filter dependencies that are got invoked --- .../zip/jballerina-tools/build.gradle | 1 + .../ComponentModelBuilder.java | 7 +- .../service/ServiceModelGenerator.java | 15 ++-- .../ServiceDeclarationNodeVisitor.java | 10 ++- .../ServiceMemberFunctionNodeVisitor.java | 73 +++++++++++++++---- .../model/service/Dependency.java | 2 +- 6 files changed, 71 insertions(+), 37 deletions(-) diff --git a/distribution/zip/jballerina-tools/build.gradle b/distribution/zip/jballerina-tools/build.gradle index 3033493710d1..a9a49ebcac99 100644 --- a/distribution/zip/jballerina-tools/build.gradle +++ b/distribution/zip/jballerina-tools/build.gradle @@ -96,6 +96,7 @@ dependencies { dist "com.atomikos:atomikos-util:${project.atomikosUtilVersion}" dist "com.atomikos:transactions:${project.atomikosTransactionsVersion}" + dist project(':architecture-model-generator') dist project(':ballerina-tools-api') dist project(':ballerina-parser') dist project(':ballerina-tools-api') diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ComponentModelBuilder.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ComponentModelBuilder.java index 9fb153048b2b..de570a711c50 100644 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ComponentModelBuilder.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ComponentModelBuilder.java @@ -24,12 +24,10 @@ import io.ballerina.architecturemodelgenerator.model.entity.Entity; import io.ballerina.architecturemodelgenerator.model.service.Service; import io.ballerina.compiler.api.SemanticModel; -import io.ballerina.projects.DocumentId; import io.ballerina.projects.Package; import io.ballerina.projects.PackageCompilation; import java.nio.file.Path; -import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; @@ -46,12 +44,10 @@ public ComponentModel constructComponentModel(Package currentPackage) { } public ComponentModel constructComponentModel(Package currentPackage, PackageCompilation packageCompilation) { - Map services = new HashMap<>(); // todo: Change to TypeDefinition Map entities = new HashMap<>(); PackageId packageId = new PackageId(currentPackage); - AtomicBoolean hasDiagnosticErrors = new AtomicBoolean(false); currentPackage.modules().forEach(module -> { @@ -59,7 +55,6 @@ public ComponentModel constructComponentModel(Package currentPackage, PackageCom if (module.moduleName().moduleNamePart() != null) { moduleRootPath = moduleRootPath.resolve(module.moduleName().moduleNamePart()); } - Collection documentIds = module.documentIds(); PackageCompilation currentPackageCompilation = packageCompilation == null ? currentPackage.getCompilation() : packageCompilation; SemanticModel currentSemanticModel = currentPackageCompilation.getSemanticModel(module.moduleId()); @@ -69,7 +64,7 @@ public ComponentModel constructComponentModel(Package currentPackage, PackageCom // todo : Check project diagnostics ServiceModelGenerator serviceModelGenerator = new ServiceModelGenerator( currentSemanticModel, packageId, moduleRootPath); - services.putAll(serviceModelGenerator.generate(documentIds, module, currentPackage)); + services.putAll(serviceModelGenerator.generate(module)); EntityModelGenerator entityModelGenerator = new EntityModelGenerator( currentSemanticModel, packageId, moduleRootPath); diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/ServiceModelGenerator.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/ServiceModelGenerator.java index adef3cfdbf86..79b4381de2ab 100644 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/ServiceModelGenerator.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/ServiceModelGenerator.java @@ -25,10 +25,8 @@ import io.ballerina.compiler.syntax.tree.SyntaxTree; import io.ballerina.projects.DocumentId; import io.ballerina.projects.Module; -import io.ballerina.projects.Package; import java.nio.file.Path; -import java.util.Collection; import java.util.HashMap; import java.util.Map; @@ -43,25 +41,22 @@ public class ServiceModelGenerator { private final ComponentModel.PackageId packageId; private final Path moduleRootPath; - public ServiceModelGenerator(SemanticModel semanticModel, ComponentModel.PackageId packageId, - Path moduleRootPath) { - + public ServiceModelGenerator(SemanticModel semanticModel, ComponentModel.PackageId packageId, Path moduleRootPath) { this.semanticModel = semanticModel; this.packageId = packageId; this.moduleRootPath = moduleRootPath; } - public Map generate(Collection documentIds, Module module, Package currentPackage) { + public Map generate(Module module) { Map services = new HashMap<>(); - for (DocumentId documentId : documentIds) { + for (DocumentId documentId : module.documentIds()) { SyntaxTree syntaxTree = module.document(documentId).syntaxTree(); Path filePath = moduleRootPath.resolve(syntaxTree.filePath()); - ServiceDeclarationNodeVisitor serviceNodeVisitor = new - ServiceDeclarationNodeVisitor(semanticModel, currentPackage, packageId, filePath); + ServiceDeclarationNodeVisitor serviceNodeVisitor = new ServiceDeclarationNodeVisitor(semanticModel, + syntaxTree, module.packageInstance(), packageId, filePath); syntaxTree.rootNode().accept(serviceNodeVisitor); serviceNodeVisitor.getServices().forEach(service -> { services.put(service.getServiceId(), service); - }); } return services; diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java index 9eccf8ccc0e4..91cd9d045e76 100644 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java @@ -42,6 +42,7 @@ import io.ballerina.compiler.syntax.tree.SeparatedNodeList; import io.ballerina.compiler.syntax.tree.ServiceDeclarationNode; import io.ballerina.compiler.syntax.tree.SimpleNameReferenceNode; +import io.ballerina.compiler.syntax.tree.SyntaxTree; import io.ballerina.compiler.syntax.tree.TypeDefinitionNode; import io.ballerina.compiler.syntax.tree.TypeDescriptorNode; import io.ballerina.compiler.syntax.tree.VariableDeclarationNode; @@ -64,16 +65,17 @@ public class ServiceDeclarationNodeVisitor extends NodeVisitor { private final SemanticModel semanticModel; + private final SyntaxTree syntaxTree; private final ComponentModel.PackageId packageId; private final Package currentPackage; private final List services = new LinkedList<>(); private final Path filePath; - public ServiceDeclarationNodeVisitor(SemanticModel semanticModel, Package currentPackage, + public ServiceDeclarationNodeVisitor(SemanticModel semanticModel, SyntaxTree syntaxTree, Package currentPackage, ComponentModel.PackageId packageId, Path filePath) { - this.packageId = packageId; this.semanticModel = semanticModel; + this.syntaxTree = syntaxTree; this.currentPackage = currentPackage; this.filePath = filePath; } @@ -105,12 +107,12 @@ public void visit(ServiceDeclarationNode serviceDeclarationNode) { ServiceMemberFunctionNodeVisitor serviceMemberFunctionNodeVisitor = new ServiceMemberFunctionNodeVisitor(serviceAnnotation.getId(), - semanticModel, currentPackage, packageId, filePath.toString()); + semanticModel, syntaxTree, currentPackage, packageId, filePath.toString()); serviceDeclarationNode.accept(serviceMemberFunctionNodeVisitor); services.add(new Service(serviceName.trim(), serviceAnnotation.getId(), getServiceType(serviceDeclarationNode), serviceMemberFunctionNodeVisitor.getResources(), serviceAnnotation, serviceMemberFunctionNodeVisitor.getRemoteFunctions(), - serviceMemberFunctionNodeVisitor.getDependencyList(), + serviceMemberFunctionNodeVisitor.getDependencies(), GeneratorUtils.getElementLocation(filePath.toString(), serviceDeclarationNode.lineRange()))); } diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java index d7ef3336e562..d218a00402fa 100644 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java @@ -45,9 +45,11 @@ import io.ballerina.compiler.syntax.tree.DefaultableParameterNode; import io.ballerina.compiler.syntax.tree.FunctionDefinitionNode; import io.ballerina.compiler.syntax.tree.FunctionSignatureNode; +import io.ballerina.compiler.syntax.tree.ModulePartNode; import io.ballerina.compiler.syntax.tree.Node; import io.ballerina.compiler.syntax.tree.NodeList; import io.ballerina.compiler.syntax.tree.NodeVisitor; +import io.ballerina.compiler.syntax.tree.NonTerminalNode; import io.ballerina.compiler.syntax.tree.ObjectFieldNode; import io.ballerina.compiler.syntax.tree.ParameterNode; import io.ballerina.compiler.syntax.tree.ParenthesisedTypeDescriptorNode; @@ -56,15 +58,20 @@ import io.ballerina.compiler.syntax.tree.ReturnTypeDescriptorNode; import io.ballerina.compiler.syntax.tree.SeparatedNodeList; import io.ballerina.compiler.syntax.tree.SyntaxKind; -import io.ballerina.compiler.syntax.tree.TypedBindingPatternNode; +import io.ballerina.compiler.syntax.tree.SyntaxTree; import io.ballerina.compiler.syntax.tree.UnionTypeDescriptorNode; -import io.ballerina.compiler.syntax.tree.VariableDeclarationNode; import io.ballerina.projects.Package; +import io.ballerina.tools.diagnostics.Location; +import io.ballerina.tools.text.LineRange; +import io.ballerina.tools.text.TextDocument; +import io.ballerina.tools.text.TextRange; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Optional; +import java.util.UUID; +import java.util.stream.Collectors; import static io.ballerina.architecturemodelgenerator.generators.GeneratorUtils.getClientModuleName; import static io.ballerina.architecturemodelgenerator.generators.GeneratorUtils.getElementLocation; @@ -79,18 +86,20 @@ public class ServiceMemberFunctionNodeVisitor extends NodeVisitor { private final String serviceId; private final SemanticModel semanticModel; + private final SyntaxTree syntaxTree; private final Package currentPackage; private List resources = new LinkedList<>(); private List remoteFunctions = new LinkedList<>(); - private final List dependencyList = new LinkedList<>(); + private final List dependencies = new LinkedList<>(); private final ComponentModel.PackageId packageId; private final String filePath; - public ServiceMemberFunctionNodeVisitor(String serviceId, SemanticModel semanticModel, Package currentPackage, - ComponentModel.PackageId packageId, String filePath) { - + public ServiceMemberFunctionNodeVisitor(String serviceId, SemanticModel semanticModel, SyntaxTree syntaxTree, + Package currentPackage, ComponentModel.PackageId packageId, + String filePath) { this.serviceId = serviceId; this.semanticModel = semanticModel; + this.syntaxTree = syntaxTree; this.currentPackage = currentPackage; this.packageId = packageId; this.filePath = filePath; @@ -104,8 +113,8 @@ public List getRemoteFunctions() { return remoteFunctions; } - public List getDependencyList() { - return dependencyList; + public List getDependencies() { + return dependencies; } @Override @@ -320,6 +329,9 @@ private List getReturnTypes(FunctionDefinitionNode functionDefinitionNod @Override public void visit(ObjectFieldNode objectFieldNode) { + if (isAnyReferredActionNode(objectFieldNode)) { + return; + } Node fieldTypeName = getReferredNode(objectFieldNode.typeName()); if (fieldTypeName != null) { Optional fieldTypeNameSymbol = semanticModel.symbol(fieldTypeName); @@ -331,23 +343,17 @@ public void visit(ObjectFieldNode objectFieldNode) { if (isClientClass) { String serviceId = objectFieldNode.metadata().isPresent() ? getServiceAnnotation(objectFieldNode.metadata().get().annotations(), filePath).getId() : - null; + UUID.randomUUID().toString(); Dependency dependency = new Dependency(serviceId, getClientModuleName(referredClassSymbol), getElementLocation(filePath, objectFieldNode.lineRange())); - dependencyList.add(dependency); + dependencies.add(dependency); } } } } } - @Override - public void visit(VariableDeclarationNode variableDeclarationNode) { - TypedBindingPatternNode typedBindingPatternNode = variableDeclarationNode.typedBindingPattern(); - typedBindingPatternNode.modify(); - } - @Override public void visit(ConstantDeclarationNode constantDeclarationNode) { @@ -390,4 +396,39 @@ private ClassSymbol getReferredClassSymbol(TypeSymbol symbol) { } return classSymbol; } + + private boolean isAnyReferredActionNode(ObjectFieldNode objectFieldNode) { + Optional objFieldNodeSymbol = semanticModel.symbol(objectFieldNode); + if (objFieldNodeSymbol.isEmpty()) { + return false; + } + boolean isAnyReferredActionNode = false; + List objFieldNodeRefs = semanticModel.references(objFieldNodeSymbol.get()) + .stream().map(Location::lineRange).collect(Collectors.toList()); + objFieldNodeRefsLoop: + for (LineRange lineRange : objFieldNodeRefs) { + Node referredNode = findNode(syntaxTree, lineRange); + while (!referredNode.kind().equals(SyntaxKind.SERVICE_DECLARATION) && + !referredNode.kind().equals(SyntaxKind.MODULE_PART)) { + if (referredNode.kind().equals(SyntaxKind.REMOTE_METHOD_CALL_ACTION) || + referredNode.kind().equals(SyntaxKind.CLIENT_RESOURCE_ACCESS_ACTION)) { + isAnyReferredActionNode = true; + break objFieldNodeRefsLoop; + } + referredNode = referredNode.parent(); + } + } + return isAnyReferredActionNode; + } + + private NonTerminalNode findNode(SyntaxTree syntaxTree, LineRange lineRange) { + if (lineRange == null) { + return null; + } + + TextDocument textDocument = syntaxTree.textDocument(); + int start = textDocument.textPositionFrom(lineRange.startLine()); + int end = textDocument.textPositionFrom(lineRange.endLine()); + return ((ModulePartNode) syntaxTree.rootNode()).findNode(TextRange.from(start, end - start), true); + } } diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Dependency.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Dependency.java index 07a2f1203a38..bf018ed906b0 100644 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Dependency.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Dependency.java @@ -24,7 +24,7 @@ /** * Represent the dependency of another service. * - * @since 2201.2.2 + * @since 2201.4.0 */ public class Dependency extends ModelElement { private final String serviceId; From ab9fe74b6721fcb34cce2bc3d788e5a8e496ae08 Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Mon, 12 Dec 2022 16:16:52 +0530 Subject: [PATCH 205/450] Fix typo --- distribution/zip/jballerina-tools/build.gradle | 2 +- .../build.gradle | 0 .../CompilationAnalysisTask.java | 0 .../ModelGeneratorCodeAnalyzer.java | 0 .../ModelGeneratorCompilerPlugin.java | 0 .../architecturemodelgeneratorplugin/PluginConstants.java | 0 .../diagnostic/DiagnosticMessage.java | 0 .../src/main/java/module-info.java | 0 .../services/io.ballerina.projects.plugins.CompilerPlugin | 0 settings.gradle | 4 ++-- 10 files changed, 3 insertions(+), 3 deletions(-) rename misc/compiler-plugins/modules/{architecture-model-generator-pligin => architecture-model-generator-plugin}/build.gradle (100%) rename misc/compiler-plugins/modules/{architecture-model-generator-pligin => architecture-model-generator-plugin}/src/main/java/io/ballerina/architecturemodelgeneratorplugin/CompilationAnalysisTask.java (100%) rename misc/compiler-plugins/modules/{architecture-model-generator-pligin => architecture-model-generator-plugin}/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCodeAnalyzer.java (100%) rename misc/compiler-plugins/modules/{architecture-model-generator-pligin => architecture-model-generator-plugin}/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCompilerPlugin.java (100%) rename misc/compiler-plugins/modules/{architecture-model-generator-pligin => architecture-model-generator-plugin}/src/main/java/io/ballerina/architecturemodelgeneratorplugin/PluginConstants.java (100%) rename misc/compiler-plugins/modules/{architecture-model-generator-pligin => architecture-model-generator-plugin}/src/main/java/io/ballerina/architecturemodelgeneratorplugin/diagnostic/DiagnosticMessage.java (100%) rename misc/compiler-plugins/modules/{architecture-model-generator-pligin => architecture-model-generator-plugin}/src/main/java/module-info.java (100%) rename misc/compiler-plugins/modules/{architecture-model-generator-pligin => architecture-model-generator-plugin}/src/main/resources/META-INF/services/io.ballerina.projects.plugins.CompilerPlugin (100%) diff --git a/distribution/zip/jballerina-tools/build.gradle b/distribution/zip/jballerina-tools/build.gradle index a9a49ebcac99..802db0d1a87a 100644 --- a/distribution/zip/jballerina-tools/build.gradle +++ b/distribution/zip/jballerina-tools/build.gradle @@ -124,7 +124,7 @@ dependencies { dist project(':ballerina-shell:shell-cli') dist project(':compiler-plugins:package-semantic-analyzer') dist project(':compiler-plugins:configurable-schema-generator') - dist project(':compiler-plugins:architecture-model-generator-pligin') + dist project(':compiler-plugins:architecture-model-generator-plugin') dist project(':identifier-util') datamapperLib project(':ballerinalang-data-mapper') diff --git a/misc/compiler-plugins/modules/architecture-model-generator-pligin/build.gradle b/misc/compiler-plugins/modules/architecture-model-generator-plugin/build.gradle similarity index 100% rename from misc/compiler-plugins/modules/architecture-model-generator-pligin/build.gradle rename to misc/compiler-plugins/modules/architecture-model-generator-plugin/build.gradle diff --git a/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/CompilationAnalysisTask.java b/misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/CompilationAnalysisTask.java similarity index 100% rename from misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/CompilationAnalysisTask.java rename to misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/CompilationAnalysisTask.java diff --git a/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCodeAnalyzer.java b/misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCodeAnalyzer.java similarity index 100% rename from misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCodeAnalyzer.java rename to misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCodeAnalyzer.java diff --git a/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCompilerPlugin.java b/misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCompilerPlugin.java similarity index 100% rename from misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCompilerPlugin.java rename to misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCompilerPlugin.java diff --git a/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/PluginConstants.java b/misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/PluginConstants.java similarity index 100% rename from misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/PluginConstants.java rename to misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/PluginConstants.java diff --git a/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/diagnostic/DiagnosticMessage.java b/misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/diagnostic/DiagnosticMessage.java similarity index 100% rename from misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/diagnostic/DiagnosticMessage.java rename to misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/diagnostic/DiagnosticMessage.java diff --git a/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/module-info.java b/misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/module-info.java similarity index 100% rename from misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/java/module-info.java rename to misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/module-info.java diff --git a/misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/resources/META-INF/services/io.ballerina.projects.plugins.CompilerPlugin b/misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/resources/META-INF/services/io.ballerina.projects.plugins.CompilerPlugin similarity index 100% rename from misc/compiler-plugins/modules/architecture-model-generator-pligin/src/main/resources/META-INF/services/io.ballerina.projects.plugins.CompilerPlugin rename to misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/resources/META-INF/services/io.ballerina.projects.plugins.CompilerPlugin diff --git a/settings.gradle b/settings.gradle index 79b65ff923fe..513800bd2c9d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -106,7 +106,7 @@ include(':debug-adapter:debug-adapter-cli') include(':debug-adapter:debug-adapter-runtime') include('semver-checker:semver-checker-cli') include('semver-checker:semver-checker-core') -include(':compiler-plugins:architecture-model-generator-pligin') +include(':compiler-plugins:architecture-model-generator-plugin') include(':compiler-plugins:package-semantic-analyzer') include(':compiler-plugins:configurable-schema-generator') include(':formatter:formatter-core') @@ -246,7 +246,7 @@ project(':debug-adapter:debug-adapter-cli').projectDir = file('misc/debug-adapte project(':debug-adapter:debug-adapter-runtime').projectDir = file('misc/debug-adapter/modules/debug-adapter-runtime') project(':semver-checker:semver-checker-core').projectDir = file('misc/semver-checker/modules/semver-checker-core') project(':semver-checker:semver-checker-cli').projectDir = file('misc/semver-checker/modules/semver-checker-cli') -project(':compiler-plugins:architecture-model-generator-pligin').projectDir = file('misc/compiler-plugins/modules/architecture-model-generator-pligin') +project(':compiler-plugins:architecture-model-generator-plugin').projectDir = file('misc/compiler-plugins/modules/architecture-model-generator-plugin') project(':compiler-plugins:package-semantic-analyzer').projectDir = file('misc/compiler-plugins/modules/package-semantic-analyzer') project(':compiler-plugins:configurable-schema-generator').projectDir = file('misc/compiler-plugins/modules/configurable-schema-generator') project(':formatter:formatter-core').projectDir = file('misc/formatter/modules/formatter-core') From 0a435a799a908274bb92920bd4fa9af962287ad0 Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Mon, 12 Dec 2022 16:18:15 +0530 Subject: [PATCH 206/450] Introduce abstract class for model generation --- .../ComponentModelBuilder.java | 13 +---- .../generators/GeneratorUtils.java | 16 +++++ .../generators/ModelGenerator.java | 58 +++++++++++++++++++ .../entity/EntityModelGenerator.java | 34 ++++------- .../service/ServiceModelGenerator.java | 26 ++++----- .../ServiceDeclarationNodeVisitor.java | 7 +-- .../ServiceMemberFunctionNodeVisitor.java | 38 +++--------- 7 files changed, 110 insertions(+), 82 deletions(-) create mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/ModelGenerator.java diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ComponentModelBuilder.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ComponentModelBuilder.java index de570a711c50..9acd436fd4ca 100644 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ComponentModelBuilder.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ComponentModelBuilder.java @@ -27,7 +27,6 @@ import io.ballerina.projects.Package; import io.ballerina.projects.PackageCompilation; -import java.nio.file.Path; import java.util.HashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; @@ -51,10 +50,6 @@ public ComponentModel constructComponentModel(Package currentPackage, PackageCom AtomicBoolean hasDiagnosticErrors = new AtomicBoolean(false); currentPackage.modules().forEach(module -> { - Path moduleRootPath = module.project().sourceRoot().toAbsolutePath(); - if (module.moduleName().moduleNamePart() != null) { - moduleRootPath = moduleRootPath.resolve(module.moduleName().moduleNamePart()); - } PackageCompilation currentPackageCompilation = packageCompilation == null ? currentPackage.getCompilation() : packageCompilation; SemanticModel currentSemanticModel = currentPackageCompilation.getSemanticModel(module.moduleId()); @@ -62,12 +57,10 @@ public ComponentModel constructComponentModel(Package currentPackage, PackageCom hasDiagnosticErrors.set(true); } // todo : Check project diagnostics - ServiceModelGenerator serviceModelGenerator = new ServiceModelGenerator( - currentSemanticModel, packageId, moduleRootPath); - services.putAll(serviceModelGenerator.generate(module)); + ServiceModelGenerator serviceModelGenerator = new ServiceModelGenerator(currentSemanticModel, module); + services.putAll(serviceModelGenerator.generate()); - EntityModelGenerator entityModelGenerator = new EntityModelGenerator( - currentSemanticModel, packageId, moduleRootPath); + EntityModelGenerator entityModelGenerator = new EntityModelGenerator(currentSemanticModel, module); entities.putAll(entityModelGenerator.generate()); }); diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/GeneratorUtils.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/GeneratorUtils.java index b157798bcd22..ab574af2bf28 100644 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/GeneratorUtils.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/GeneratorUtils.java @@ -29,12 +29,17 @@ import io.ballerina.compiler.syntax.tree.AnnotationNode; import io.ballerina.compiler.syntax.tree.ExpressionNode; import io.ballerina.compiler.syntax.tree.MappingFieldNode; +import io.ballerina.compiler.syntax.tree.ModulePartNode; import io.ballerina.compiler.syntax.tree.Node; import io.ballerina.compiler.syntax.tree.NodeList; +import io.ballerina.compiler.syntax.tree.NonTerminalNode; import io.ballerina.compiler.syntax.tree.SeparatedNodeList; import io.ballerina.compiler.syntax.tree.SpecificFieldNode; import io.ballerina.compiler.syntax.tree.SyntaxKind; +import io.ballerina.compiler.syntax.tree.SyntaxTree; import io.ballerina.tools.text.LineRange; +import io.ballerina.tools.text.TextDocument; +import io.ballerina.tools.text.TextRange; import java.util.LinkedHashMap; import java.util.List; @@ -152,4 +157,15 @@ public static String getClientModuleName(TypeSymbol typeSymbol) { } return clientModuleName; } + + public static NonTerminalNode findNode(SyntaxTree syntaxTree, LineRange lineRange) { + if (lineRange == null) { + return null; + } + + TextDocument textDocument = syntaxTree.textDocument(); + int start = textDocument.textPositionFrom(lineRange.startLine()); + int end = textDocument.textPositionFrom(lineRange.endLine()); + return ((ModulePartNode) syntaxTree.rootNode()).findNode(TextRange.from(start, end - start), true); + } } diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/ModelGenerator.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/ModelGenerator.java new file mode 100644 index 000000000000..bb6b6fb6ad3f --- /dev/null +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/ModelGenerator.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.ballerina.architecturemodelgenerator.generators; + +import io.ballerina.compiler.api.SemanticModel; +import io.ballerina.projects.Module; + +import java.nio.file.Path; + +/** + * Model Generator Abstract Class. + * + * @since 2201.4.0 + */ +public abstract class ModelGenerator { + private final SemanticModel semanticModel; + private final Module module; + private final Path moduleRootPath; + + public ModelGenerator(SemanticModel semanticModel, Module module) { + + this.semanticModel = semanticModel; + this.module = module; + Path moduleRootPath = module.project().sourceRoot().toAbsolutePath(); + if (module.moduleName().moduleNamePart() != null) { + moduleRootPath = moduleRootPath.resolve(module.moduleName().moduleNamePart()); + } + this.moduleRootPath = moduleRootPath; + } + + public SemanticModel getSemanticModel() { + return this.semanticModel; + } + + public Module getModule() { + return this.module; + } + + public Path getModuleRootPath() { + return moduleRootPath; + } +} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/entity/EntityModelGenerator.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/entity/EntityModelGenerator.java index 9ea53aa5a8d5..b3a2e413986e 100644 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/entity/EntityModelGenerator.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/entity/EntityModelGenerator.java @@ -18,10 +18,10 @@ package io.ballerina.architecturemodelgenerator.generators.entity; -import io.ballerina.architecturemodelgenerator.ComponentModel; import io.ballerina.architecturemodelgenerator.ComponentModel.PackageId; import io.ballerina.architecturemodelgenerator.ProjectDesignConstants.CardinalityValue; import io.ballerina.architecturemodelgenerator.generators.GeneratorUtils; +import io.ballerina.architecturemodelgenerator.generators.ModelGenerator; import io.ballerina.architecturemodelgenerator.model.ElementLocation; import io.ballerina.architecturemodelgenerator.model.entity.Association; import io.ballerina.architecturemodelgenerator.model.entity.Attribute; @@ -38,9 +38,9 @@ import io.ballerina.compiler.api.symbols.TypeReferenceTypeSymbol; import io.ballerina.compiler.api.symbols.TypeSymbol; import io.ballerina.compiler.api.symbols.UnionTypeSymbol; +import io.ballerina.projects.Module; import io.ballerina.tools.text.LineRange; -import java.nio.file.Path; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; @@ -58,29 +58,21 @@ * * @since 2201.2.2 */ -public class EntityModelGenerator { - - private final SemanticModel semanticModel; - private final ComponentModel.PackageId packageId; - private final Path moduleRootPath; +public class EntityModelGenerator extends ModelGenerator { private final Map types = new HashMap<>(); - public EntityModelGenerator(SemanticModel semanticModel, ComponentModel.PackageId packageId, - Path moduleRootPath) { - - this.semanticModel = semanticModel; - this.packageId = packageId; - this.moduleRootPath = moduleRootPath; + public EntityModelGenerator(SemanticModel semanticModel, Module module) { + super(semanticModel, module); } public Map generate() { - List symbols = semanticModel.moduleSymbols(); + List symbols = getSemanticModel().moduleSymbols(); for (Symbol symbol : symbols) { if (symbol.kind().equals(SymbolKind.TYPE_DEFINITION)) { TypeDefinitionSymbol typeDefinitionSymbol = (TypeDefinitionSymbol) symbol; if (typeDefinitionSymbol.typeDescriptor() instanceof RecordTypeSymbol) { - String entityName = getEntityName(packageId, typeDefinitionSymbol.moduleQualifiedName()); + String entityName = getEntityName(typeDefinitionSymbol.moduleQualifiedName()); RecordTypeSymbol recordTypeSymbol = (RecordTypeSymbol) typeDefinitionSymbol.typeDescriptor(); this.types.put(entityName, getType(recordTypeSymbol, entityName, getElementLocation(typeDefinitionSymbol), false)); @@ -112,12 +104,12 @@ private Attribute getAttribute(RecordFieldSymbol recordFieldSymbol, String entit boolean optional = recordFieldSymbol.isOptional(); String defaultValue = ""; //need to address boolean nillable = isNillable(recordFieldSymbol.typeDescriptor()); + String inlineRecordName = entityName + fieldName.substring(0, 1).toUpperCase(Locale.ROOT) + + fieldName.substring(1); if (fieldTypeDescKind.equals(TypeDescKind.RECORD)) { RecordTypeSymbol inlineRecordTypeSymbol = (RecordTypeSymbol) fieldTypeSymbol; fieldType = TypeDescKind.RECORD.getName(); - String inlineRecordName = entityName + fieldName.substring(0, 1).toUpperCase(Locale.ROOT) + - fieldName.substring(1); this.types.put(inlineRecordName, getType(inlineRecordTypeSymbol, inlineRecordName, getElementLocation(recordFieldSymbol), true)); String associateCardinality = optional ? CardinalityValue.ZERO_OR_ONE.getValue() : @@ -129,8 +121,6 @@ private Attribute getAttribute(RecordFieldSymbol recordFieldSymbol, String entit ((ArrayTypeSymbol) fieldTypeSymbol).memberTypeDescriptor().typeKind().equals(TypeDescKind.RECORD)) { RecordTypeSymbol inlineRecordTypeSymbol = (RecordTypeSymbol) ((ArrayTypeSymbol) fieldTypeSymbol).memberTypeDescriptor(); - String inlineRecordName = entityName + fieldName.substring(0, 1).toUpperCase(Locale.ROOT) + - fieldName.substring(1); fieldType = TypeDescKind.RECORD.getName() + ARRAY; String associateCardinality = optional ? CardinalityValue.ZERO_OR_MANY.getValue() : CardinalityValue.ONE_OR_MANY.getValue(); @@ -246,12 +236,12 @@ private String getAssociateCardinality(boolean isArray, boolean isOptional, bool /** * Build the FQN of the entity Ex: ballerina/reservation_api:0.1.0:Flight. * - * @param packageId * @param moduleQualifiedName * @return */ - private String getEntityName(PackageId packageId, String moduleQualifiedName) { + private String getEntityName(String moduleQualifiedName) { // moduleQualifiedName is not correct when there is a dot in package name + PackageId packageId = new PackageId(getModule().packageInstance()); String entityName; String[] nameSpits = moduleQualifiedName.split(COLON); if (packageId.getName().equals(nameSpits[0])) { // check whether the referenced type is from the same module @@ -334,7 +324,7 @@ private ElementLocation getElementLocation(Symbol symbol) { ElementLocation elementLocation = null; if (symbol.getLocation().isPresent()) { LineRange typeLineRange = symbol.getLocation().get().lineRange(); - String filePath = moduleRootPath.resolve(typeLineRange.filePath()).toAbsolutePath().toString(); + String filePath = getModuleRootPath().resolve(typeLineRange.filePath()).toAbsolutePath().toString(); elementLocation = GeneratorUtils.getElementLocation(filePath, typeLineRange); } return elementLocation; diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/ServiceModelGenerator.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/ServiceModelGenerator.java index 79b4381de2ab..a4ee4bbe5d09 100644 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/ServiceModelGenerator.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/ServiceModelGenerator.java @@ -18,7 +18,7 @@ package io.ballerina.architecturemodelgenerator.generators.service; -import io.ballerina.architecturemodelgenerator.ComponentModel; +import io.ballerina.architecturemodelgenerator.generators.ModelGenerator; import io.ballerina.architecturemodelgenerator.generators.service.nodevisitors.ServiceDeclarationNodeVisitor; import io.ballerina.architecturemodelgenerator.model.service.Service; import io.ballerina.compiler.api.SemanticModel; @@ -35,25 +35,19 @@ * * @since 2201.2.2 */ -public class ServiceModelGenerator { +public class ServiceModelGenerator extends ModelGenerator { - private final SemanticModel semanticModel; - private final ComponentModel.PackageId packageId; - private final Path moduleRootPath; - - public ServiceModelGenerator(SemanticModel semanticModel, ComponentModel.PackageId packageId, Path moduleRootPath) { - this.semanticModel = semanticModel; - this.packageId = packageId; - this.moduleRootPath = moduleRootPath; + public ServiceModelGenerator(SemanticModel semanticModel, Module module) { + super(semanticModel, module); } - public Map generate(Module module) { + public Map generate() { Map services = new HashMap<>(); - for (DocumentId documentId : module.documentIds()) { - SyntaxTree syntaxTree = module.document(documentId).syntaxTree(); - Path filePath = moduleRootPath.resolve(syntaxTree.filePath()); - ServiceDeclarationNodeVisitor serviceNodeVisitor = new ServiceDeclarationNodeVisitor(semanticModel, - syntaxTree, module.packageInstance(), packageId, filePath); + for (DocumentId documentId :getModule().documentIds()) { + SyntaxTree syntaxTree = getModule().document(documentId).syntaxTree(); + Path filePath = getModuleRootPath().resolve(syntaxTree.filePath()); + ServiceDeclarationNodeVisitor serviceNodeVisitor = new ServiceDeclarationNodeVisitor(getSemanticModel(), + syntaxTree, getModule().packageInstance(), filePath); syntaxTree.rootNode().accept(serviceNodeVisitor); serviceNodeVisitor.getServices().forEach(service -> { services.put(service.getServiceId(), service); diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java index 91cd9d045e76..295682e871ca 100644 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java @@ -18,7 +18,6 @@ package io.ballerina.architecturemodelgenerator.generators.service.nodevisitors; -import io.ballerina.architecturemodelgenerator.ComponentModel; import io.ballerina.architecturemodelgenerator.generators.GeneratorUtils; import io.ballerina.architecturemodelgenerator.model.service.Service; import io.ballerina.architecturemodelgenerator.model.service.ServiceAnnotation; @@ -66,14 +65,12 @@ public class ServiceDeclarationNodeVisitor extends NodeVisitor { private final SemanticModel semanticModel; private final SyntaxTree syntaxTree; - private final ComponentModel.PackageId packageId; private final Package currentPackage; private final List services = new LinkedList<>(); private final Path filePath; public ServiceDeclarationNodeVisitor(SemanticModel semanticModel, SyntaxTree syntaxTree, Package currentPackage, - ComponentModel.PackageId packageId, Path filePath) { - this.packageId = packageId; + Path filePath) { this.semanticModel = semanticModel; this.syntaxTree = syntaxTree; this.currentPackage = currentPackage; @@ -107,7 +104,7 @@ public void visit(ServiceDeclarationNode serviceDeclarationNode) { ServiceMemberFunctionNodeVisitor serviceMemberFunctionNodeVisitor = new ServiceMemberFunctionNodeVisitor(serviceAnnotation.getId(), - semanticModel, syntaxTree, currentPackage, packageId, filePath.toString()); + semanticModel, syntaxTree, currentPackage, filePath.toString()); serviceDeclarationNode.accept(serviceMemberFunctionNodeVisitor); services.add(new Service(serviceName.trim(), serviceAnnotation.getId(), getServiceType(serviceDeclarationNode), serviceMemberFunctionNodeVisitor.getResources(), diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java index d218a00402fa..556b4f11a372 100644 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java +++ b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java @@ -18,7 +18,7 @@ package io.ballerina.architecturemodelgenerator.generators.service.nodevisitors; -import io.ballerina.architecturemodelgenerator.ComponentModel; +import io.ballerina.architecturemodelgenerator.ComponentModel.PackageId; import io.ballerina.architecturemodelgenerator.ProjectDesignConstants.ParameterIn; import io.ballerina.architecturemodelgenerator.model.ElementLocation; import io.ballerina.architecturemodelgenerator.model.service.Dependency; @@ -45,11 +45,9 @@ import io.ballerina.compiler.syntax.tree.DefaultableParameterNode; import io.ballerina.compiler.syntax.tree.FunctionDefinitionNode; import io.ballerina.compiler.syntax.tree.FunctionSignatureNode; -import io.ballerina.compiler.syntax.tree.ModulePartNode; import io.ballerina.compiler.syntax.tree.Node; import io.ballerina.compiler.syntax.tree.NodeList; import io.ballerina.compiler.syntax.tree.NodeVisitor; -import io.ballerina.compiler.syntax.tree.NonTerminalNode; import io.ballerina.compiler.syntax.tree.ObjectFieldNode; import io.ballerina.compiler.syntax.tree.ParameterNode; import io.ballerina.compiler.syntax.tree.ParenthesisedTypeDescriptorNode; @@ -63,8 +61,6 @@ import io.ballerina.projects.Package; import io.ballerina.tools.diagnostics.Location; import io.ballerina.tools.text.LineRange; -import io.ballerina.tools.text.TextDocument; -import io.ballerina.tools.text.TextRange; import java.util.ArrayList; import java.util.LinkedList; @@ -73,6 +69,7 @@ import java.util.UUID; import java.util.stream.Collectors; +import static io.ballerina.architecturemodelgenerator.generators.GeneratorUtils.findNode; import static io.ballerina.architecturemodelgenerator.generators.GeneratorUtils.getClientModuleName; import static io.ballerina.architecturemodelgenerator.generators.GeneratorUtils.getElementLocation; import static io.ballerina.architecturemodelgenerator.generators.GeneratorUtils.getServiceAnnotation; @@ -91,17 +88,14 @@ public class ServiceMemberFunctionNodeVisitor extends NodeVisitor { private List resources = new LinkedList<>(); private List remoteFunctions = new LinkedList<>(); private final List dependencies = new LinkedList<>(); - private final ComponentModel.PackageId packageId; private final String filePath; public ServiceMemberFunctionNodeVisitor(String serviceId, SemanticModel semanticModel, SyntaxTree syntaxTree, - Package currentPackage, ComponentModel.PackageId packageId, - String filePath) { + Package currentPackage, String filePath) { this.serviceId = serviceId; this.semanticModel = semanticModel; this.syntaxTree = syntaxTree; this.currentPackage = currentPackage; - this.packageId = packageId; this.filePath = filePath; } @@ -241,7 +235,7 @@ private void getParameters(FunctionSignatureNode functionSignatureNode, boolean } private String getReferenceEntityName(TypeReferenceTypeSymbol typeReferenceTypeSymbol) { - + PackageId packageId = new PackageId(currentPackage); String currentPackageName = String.format ("%s/%s:%s", packageId.getOrg(), packageId.getName(), packageId.getVersion()); String referenceType = typeReferenceTypeSymbol.signature(); @@ -329,7 +323,7 @@ private List getReturnTypes(FunctionDefinitionNode functionDefinitionNod @Override public void visit(ObjectFieldNode objectFieldNode) { - if (isAnyReferredActionNode(objectFieldNode)) { + if (hasInvocationReferences(objectFieldNode)) { return; } Node fieldTypeName = getReferredNode(objectFieldNode.typeName()); @@ -397,38 +391,24 @@ private ClassSymbol getReferredClassSymbol(TypeSymbol symbol) { return classSymbol; } - private boolean isAnyReferredActionNode(ObjectFieldNode objectFieldNode) { - Optional objFieldNodeSymbol = semanticModel.symbol(objectFieldNode); + private boolean hasInvocationReferences(ObjectFieldNode clientDeclarationNode) { + Optional objFieldNodeSymbol = semanticModel.symbol(clientDeclarationNode); if (objFieldNodeSymbol.isEmpty()) { return false; } - boolean isAnyReferredActionNode = false; List objFieldNodeRefs = semanticModel.references(objFieldNodeSymbol.get()) .stream().map(Location::lineRange).collect(Collectors.toList()); - objFieldNodeRefsLoop: for (LineRange lineRange : objFieldNodeRefs) { Node referredNode = findNode(syntaxTree, lineRange); while (!referredNode.kind().equals(SyntaxKind.SERVICE_DECLARATION) && !referredNode.kind().equals(SyntaxKind.MODULE_PART)) { if (referredNode.kind().equals(SyntaxKind.REMOTE_METHOD_CALL_ACTION) || referredNode.kind().equals(SyntaxKind.CLIENT_RESOURCE_ACCESS_ACTION)) { - isAnyReferredActionNode = true; - break objFieldNodeRefsLoop; + return true; } referredNode = referredNode.parent(); } } - return isAnyReferredActionNode; - } - - private NonTerminalNode findNode(SyntaxTree syntaxTree, LineRange lineRange) { - if (lineRange == null) { - return null; - } - - TextDocument textDocument = syntaxTree.textDocument(); - int start = textDocument.textPositionFrom(lineRange.startLine()); - int end = textDocument.textPositionFrom(lineRange.endLine()); - return ((ModulePartNode) syntaxTree.rootNode()).findNode(TextRange.from(start, end - start), true); + return false; } } From a3f43f8413f1e1816c3885b3e88f57ae6cb505d5 Mon Sep 17 00:00:00 2001 From: Nadeeshan96 Date: Mon, 12 Dec 2022 16:48:01 +0530 Subject: [PATCH 207/450] Address PR review comments --- .../ballerinalang/test/runtime/util/CodeCoverageUtils.java | 6 ++++-- .../testerina/test/CodeCoverageReportTest.java | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/CodeCoverageUtils.java b/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/CodeCoverageUtils.java index e133815dd613..9050f259e311 100644 --- a/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/CodeCoverageUtils.java +++ b/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/CodeCoverageUtils.java @@ -71,6 +71,8 @@ public class CodeCoverageUtils { private static final PrintStream errStream = System.err; + private CodeCoverageUtils() {} + /** * Checks if a given code coverage report format was requested by user. * @@ -131,8 +133,8 @@ public static void unzipCompiledSource(Path source, Path destination, String org private static boolean isRequiredFile(String path, String orgName, boolean enableIncludesFilter, String includesInCoverage) { return !(path.contains("$_init") || path.contains("META-INF") || path.contains("/tests/") - || (path.contains("$frame$") && path.contains("module")) - || (path.contains("$frame$") && path.contains(orgName)) || path.contains("module-info.class") + || (path.contains("$frame$") && (path.contains("module") || path.contains(orgName))) + || path.contains("module-info.class") || (enableIncludesFilter && !isIncluded(path, includesInCoverage))); } diff --git a/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/CodeCoverageReportTest.java b/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/CodeCoverageReportTest.java index 21f7fe63e952..82693a89b09d 100644 --- a/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/CodeCoverageReportTest.java +++ b/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/CodeCoverageReportTest.java @@ -176,7 +176,7 @@ public void normalizedCoverageClassTest() throws BallerinaTestException { /** * Get the expected class elements per each package element in coverage XML. * - * @return HashMap> + * @return HashMap> */ private HashMap> getExpectedCoverageClasses() { HashMap> coverageClassMap = new HashMap<>(); From ae74a1877af1d467afa78f1f2ec9bf124bceb7f6 Mon Sep 17 00:00:00 2001 From: Fathima Dilhasha Date: Mon, 12 Dec 2022 10:55:55 +0530 Subject: [PATCH 208/450] Fix test failures --- .../projects/directory/BuildProject.java | 16 +++++++++------- .../projects/internal/ProjectFiles.java | 12 ++++++------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/directory/BuildProject.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/directory/BuildProject.java index d11206d7dec5..d7e3ac2af8e7 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/directory/BuildProject.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/directory/BuildProject.java @@ -142,13 +142,16 @@ private Optional generatedModulePath(ModuleId moduleId) { if (currentPackage().moduleIds().contains(moduleId)) { Optional generatedModulePath = Optional.of(sourceRoot. resolve(ProjectConstants.GENERATED_MODULES_ROOT)); - if (currentPackage().getDefaultModule().moduleId() == moduleId && + if (currentPackage().getDefaultModule().moduleId() == moduleId && generatedModulePath.isPresent() && Files.isDirectory(generatedModulePath.get())) { return generatedModulePath; } String moduleName = currentPackage().module(moduleId).moduleName().moduleNamePart(); - if (Files.isDirectory(Optional.of(generatedModulePath.get().resolve(moduleName)).get())) { - return Optional.of(generatedModulePath.get().resolve(moduleName)); + if (generatedModulePath.isPresent() && Files.isDirectory(generatedModulePath.get())) { + Optional generatedModuleDirPath = Optional.of(generatedModulePath.get().resolve(moduleName)); + if (generatedModuleDirPath.isPresent() && Files.isDirectory(generatedModuleDirPath.get())) { + return Optional.of(generatedModulePath.get().resolve(moduleName)); + } } } return Optional.empty(); @@ -161,10 +164,9 @@ public Optional documentPath(DocumentId documentId) { Optional modulePath = modulePath(moduleId); if (module.documentIds().contains(documentId)) { Optional generatedModulePath = generatedModulePath(moduleId); - if (generatedModulePath.isPresent()) { - if (Files.exists(generatedModulePath.get().resolve(module.document(documentId).name()))) { - return Optional.of(generatedModulePath.get().resolve(module.document(documentId).name())); - } + if (generatedModulePath.isPresent() && Files.exists( + generatedModulePath.get().resolve(module.document(documentId).name()))) { + return Optional.of(generatedModulePath.get().resolve(module.document(documentId).name())); } if (modulePath.isPresent()) { return Optional.of(modulePath.get().resolve(module.document(documentId).name())); diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ProjectFiles.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ProjectFiles.java index 09716ce6157a..614a8280d9fd 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ProjectFiles.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ProjectFiles.java @@ -150,15 +150,15 @@ private static ModuleData loadModule(Path moduleDirPath) { // If the module is not a newly generated module, explicitly load generated sources if (!ProjectConstants.GENERATED_MODULES_ROOT.equals(Optional.of( - moduleDirPath.getParent()).get().toFile().getName())) { + moduleDirPath.toAbsolutePath().getParent()).get().toFile().getName())) { // Generated sources root for default module Path generatedSourcesRoot = moduleDirPath.resolve(ProjectConstants.GENERATED_MODULES_ROOT); - if (ProjectConstants.MODULES_ROOT.equals(Optional.of(moduleDirPath.getParent()).get().toFile().getName())) { + if (ProjectConstants.MODULES_ROOT.equals(Optional.of( + moduleDirPath.toAbsolutePath().getParent()).get().toFile().getName())) { // generated sources root for non-default modules - generatedSourcesRoot = Optional.of(Optional.of(Optional.of(moduleDirPath.getParent()). - get().getParent()).get(). - resolve(ProjectConstants.GENERATED_MODULES_ROOT)).get(). - resolve(Optional.of(moduleDirPath.toFile()).get().getName()); + generatedSourcesRoot = Optional.of(Optional.of(Optional.of(moduleDirPath.toAbsolutePath().getParent()). + get().getParent()).get().resolve(ProjectConstants.GENERATED_MODULES_ROOT)) + .get().resolve(Optional.of(moduleDirPath.toFile()).get().getName()); } if (Files.isDirectory(generatedSourcesRoot)) { List generatedDocs = loadDocuments(generatedSourcesRoot); From ec4f1fc64a1695a08344f58ffe9f59b1a114e8a7 Mon Sep 17 00:00:00 2001 From: DimuthuMadushan Date: Tue, 13 Dec 2022 09:24:52 +0530 Subject: [PATCH 209/450] Apply suggestions from the code review --- .../main/resources/cli-help/ballerina-graphql.help | 14 +++++++------- .../main/resources/cli-help/ballerina-help.help | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cli/ballerina-cli/src/main/resources/cli-help/ballerina-graphql.help b/cli/ballerina-cli/src/main/resources/cli-help/ballerina-graphql.help index e6833739c181..860c3e2cbd34 100644 --- a/cli/ballerina-cli/src/main/resources/cli-help/ballerina-graphql.help +++ b/cli/ballerina-cli/src/main/resources/cli-help/ballerina-graphql.help @@ -1,6 +1,6 @@ NAME - ballerina-graphql - Generate Ballerina client sources for a GraphQL config file - and generate GraphQL schema for a Ballerina GraphQL service. + ballerina-graphql - Generate the Ballerina client sources for a GraphQL config file + and generate the GraphQL schema for a Ballerina GraphQL service. SYNOPSIS @@ -14,7 +14,7 @@ SYNOPSIS DESCRIPTION Generate the Ballerina GraphQL client sources for a given GraphQL config file configured with GraphQL schemas specified by GraphQL Schema Definition Language(SDL) and GraphQL - queries or export a GraphQL schema(SDL) for a given Ballerina GraphQL service. + queries or export a GraphQL schema (SDL) for a given Ballerina GraphQL service. The generated Ballerina sources or GraphQL schema files will be written into the provided output location. @@ -22,9 +22,9 @@ DESCRIPTION OPTIONS -i, --input - This is mandatory input. The given GraphQL config file input configured with GraphQL - schemas(SDL) and queries will generate the Ballerina GraphQL client sources. The given - Ballerina GraphQL service file input will generate the GraphQL schema(SDL) file + This is mandatory input. The given GraphQL config file which is configured with + GraphQL schemas (SDL) and queries, will generate the Ballerina GraphQL client sources. + The given Ballerina GraphQL service file will generate the GraphQL schema (SDL) file relevant to the service. -o, --output Location of the generated Ballerina source code or GraphQL schema. If this path is not @@ -32,7 +32,7 @@ OPTIONS run. -s, --service This service base path is used to identify the service that needs to generate the - GraphQL schema. This option is used with the command of GraphQL schema generation. + GraphQL schema. This option is used with the GraphQL schema generation command. If this base path is not specified, schemas will be generated for each of the GraphQL services in the input file. diff --git a/cli/ballerina-cli/src/main/resources/cli-help/ballerina-help.help b/cli/ballerina-cli/src/main/resources/cli-help/ballerina-help.help index 4d4fbaa97736..2ebae232e9a5 100755 --- a/cli/ballerina-cli/src/main/resources/cli-help/ballerina-help.help +++ b/cli/ballerina-cli/src/main/resources/cli-help/ballerina-help.help @@ -40,8 +40,8 @@ COMMANDS format Format Ballerina source files grpc Generate the Ballerina sources for a given Protocol Buffer definition - graphql Generate Ballerina client sources for a GraphQL config file - and generate GraphQL schema for a Ballerina GraphQL service. + graphql Generate the Ballerina client sources for a GraphQL config file + and generate the GraphQL schema for a Ballerina GraphQL service. openapi Generate the Ballerina sources for a given OpenAPI definition and vice versa asyncapi Generate the Ballerina sources for a given AsyncAPI definition From 1a5bde1a8eede5131d901fd43ac7911600ae9e67 Mon Sep 17 00:00:00 2001 From: Gayal Dassanayake Date: Tue, 29 Nov 2022 18:25:37 +0530 Subject: [PATCH 210/450] Add error diagnostic for single file project func mocking --- .../testerina/core/MockAnnotationProcessor.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java index beaaa093b3ea..3f8c890b74a2 100644 --- a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java +++ b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java @@ -18,6 +18,7 @@ package org.ballerinalang.testerina.core; import io.ballerina.projects.JarResolver; +import io.ballerina.projects.ModuleDescriptor; import io.ballerina.projects.util.ProjectConstants; import io.ballerina.tools.diagnostics.DiagnosticSeverity; import io.ballerina.tools.diagnostics.Location; @@ -55,6 +56,7 @@ import java.util.Map; import java.util.stream.Collectors; +import static io.ballerina.runtime.api.constants.RuntimeConstants.DOT; import static io.ballerina.runtime.api.constants.RuntimeConstants.FILE_NAME_PERIOD_SEPARATOR; /** @@ -109,6 +111,13 @@ public void process(SimpleVariableNode simpleVariableNode, List Date: Tue, 29 Nov 2022 18:26:01 +0530 Subject: [PATCH 211/450] Return if mock func name is invalid --- .../core/MockAnnotationProcessor.java | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java index 3f8c890b74a2..f9b89c454cd8 100644 --- a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java +++ b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java @@ -81,7 +81,7 @@ public class MockAnnotationProcessor extends AbstractCompilerPlugin { private Map packageEnvironmentMap; private SymbolResolver symbolResolver; private Types typeChecker; - private TesterinaRegistry registry = TesterinaRegistry.getInstance(); + private final TesterinaRegistry registry = TesterinaRegistry.getInstance(); /** * this property is used as a work-around to initialize test suites only once for a package as Compiler @@ -133,7 +133,11 @@ public void process(SimpleVariableNode simpleVariableNode, List # --> ` @@ -216,7 +220,7 @@ public void process(FunctionNode functionNode, List an PackageID functionToMockID = getPackageID(vals[0]); if (functionToMockID == null) { diagnosticLog.logDiagnostic(DiagnosticSeverity.ERROR, attachmentNode.getPosition(), - "could not find module specified"); + "could not find module specified '" + vals[0] + "'"); break; } @@ -227,13 +231,13 @@ public void process(FunctionNode functionNode, List an if (functionToMockType != null && mockFunctionType != null) { if (!typeChecker.isAssignable(mockFunctionType, functionToMockType)) { diagnosticLog.logDiagnostic(DiagnosticSeverity.ERROR, ((BLangFunction) functionNode).pos, - "incompatible types: expected " + functionToMockType.toString() - + " but found " + mockFunctionType.toString()); + "incompatible types: expected " + functionToMockType + + " but found " + mockFunctionType); break; } } else { diagnosticLog.logDiagnostic(DiagnosticSeverity.ERROR, attachmentNode.getPosition(), - "could not find functions in module"); + "could not find function " + vals[1] + " in module '" + vals[0] + "'"); break; } @@ -243,14 +247,12 @@ public void process(FunctionNode functionNode, List an bLangTestablePackage.addMockFunction(functionToMockID + MOCK_LEGACY_DELIMITER + vals[1], functionName); - if (functionToMockID != null) { - // Adding ` # --> ` to registry - String className = getQualifiedClassName(bLangTestablePackage, - functionToMockID.toString(), vals[1]); - vals[1] = vals[1].replaceAll("\\\\", ""); - registry.addMockFunctionsSourceMap(bLangTestablePackage.packageID.getName().toString() - + MODULE_DELIMITER + className + MOCK_LEGACY_DELIMITER + vals[1], functionName); - } + // Adding ` # --> ` to registry + String className = getQualifiedClassName(bLangTestablePackage, + functionToMockID.toString(), vals[1]); + vals[1] = vals[1].replaceAll("\\\\", ""); + registry.addMockFunctionsSourceMap(bLangTestablePackage.packageID.getName().toString() + + MODULE_DELIMITER + className + MOCK_LEGACY_DELIMITER + vals[1], functionName); } } } @@ -329,16 +331,17 @@ private String formatPackageName(String value, BLangPackage parent) { * * @param functionName Name of the function to mock * @param attachmentNode MockFunction object attachment node + * @return true if the provided function name valid */ - private void validateFunctionName(String functionName, PackageID functionToMockID, + private boolean validateFunctionName(String functionName, String moduleName, PackageID functionToMockID, AnnotationAttachmentNode attachmentNode) { if (functionToMockID == null) { diagnosticLog.logDiagnostic(DiagnosticSeverity.ERROR, attachmentNode.getPosition(), - "could not find module specified "); + "could not find module specified '" + moduleName + "'"); } else { if (functionName == null) { diagnosticLog.logDiagnostic(DiagnosticSeverity.ERROR, attachmentNode.getPosition(), - "Function name cannot be empty"); + "function name cannot be empty"); } else { // Iterate through package map entries for (Map.Entry entry : this.packageEnvironmentMap.entrySet()) { @@ -346,16 +349,16 @@ private void validateFunctionName(String functionName, PackageID functionToMockI // Check if the current package has the function name if (entry.getValue().scope.entries.containsKey(new Name(functionName))) { // Exit validate function if the function exists in the entry - return; + return true; } } } // If it reaches this part, then the function has'nt been found in both packages diagnosticLog.logDiagnostic(DiagnosticSeverity.ERROR, attachmentNode.getPosition(), - "Function \'" + functionName + "\' cannot be found in the package \'" - + functionToMockID.toString()); + "could not find function '" + functionName + "' in module '" + moduleName + "'"); } } + return false; } /** From 58fcbb43f7a78f0967ff0aa23398e5787252d0eb Mon Sep 17 00:00:00 2001 From: Gayal Dassanayake Date: Wed, 30 Nov 2022 13:36:18 +0530 Subject: [PATCH 212/450] Add test cases for single file, invalid name mocking --- .../InvalidFunctionMockingTestCase.java | 40 ++++++++++++++++--- .../Ballerina.toml | 5 +++ .../non-existent-function-mock2/main.bal | 2 + .../tests/test.bal | 4 ++ .../non-existent-module-mock2/Ballerina.toml | 4 ++ .../non-existent-module-mock2/main.bal | 6 +++ .../non-existent-module-mock2/tests/test.bal | 7 ++++ .../mocking/function-mock.bal | 19 +++++++++ 8 files changed, 82 insertions(+), 5 deletions(-) create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-function-mock2/Ballerina.toml create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-function-mock2/main.bal create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-function-mock2/tests/test.bal create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-module-mock2/Ballerina.toml create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-module-mock2/main.bal create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-module-mock2/tests/test.bal create mode 100644 tests/testerina-integration-test/src/test/resources/single-file-tests/mocking/function-mock.bal diff --git a/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/negative/InvalidFunctionMockingTestCase.java b/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/negative/InvalidFunctionMockingTestCase.java index 372ce44c02e4..7704c58a1dcf 100644 --- a/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/negative/InvalidFunctionMockingTestCase.java +++ b/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/negative/InvalidFunctionMockingTestCase.java @@ -44,21 +44,41 @@ public void testMockingNonExistingFunction() throws BallerinaTestException { String projectPath = projectBasedTestsPath.resolve("non-existent-function-mock").toString(); String output = balClient.runMainAndReadStdOut("test", new String[0], new HashMap<>(), projectPath, true); assertEquals(output.replaceAll("\r", ""), - "ERROR [tests/test.bal:(3:1,5:2)] could not find functions in module\n" + - "error: compilation contains errors"); + "ERROR [tests/test.bal:(3:1,5:2)] could not find function createJdbcClient in module " + + "'intg_tests/non_existent_function_mock:0.1.0'\n" + + "error: compilation contains errors"); } @Test - public void testMockingAFunctionInNonExistingModule() throws BallerinaTestException { + public void testMockingNonExistingFunction2() throws BallerinaTestException { + String projectPath = projectBasedTestsPath.resolve("non-existent-function-mock2").toString(); + String output = balClient.runMainAndReadStdOut("test", new String[0], new HashMap<>(), projectPath, true); + assertEquals(output.replaceAll("\r", ""), + "ERROR [tests/test.bal:(3:1,3:38)] could not find function 'intAdd' in module " + + "'intg_tests/non_existent_function_mock:0.1.0'\n" + + "error: compilation contains errors"); + } + + @Test + public void testMockingFunctionInNonExistingModule() throws BallerinaTestException { String projectPath = projectBasedTestsPath.resolve("non-existent-module-mock").toString(); String output = balClient.runMainAndReadStdOut("test", new String[0], new HashMap<>(), projectPath, true); assertEquals(output.replaceAll("\r", ""), - "ERROR [tests/test.bal:(3:1,6:2)] could not find module specified\n" + + "ERROR [tests/test.bal:(3:1,6:2)] could not find module specified 'intg_tests/module1:0.1.0'\n" + + "error: compilation contains errors"); + } + + @Test + public void testMockingFunctionInNonExistingModule2() throws BallerinaTestException { + String projectPath = projectBasedTestsPath.resolve("non-existent-module-mock2").toString(); + String output = balClient.runMainAndReadStdOut("test", new String[0], new HashMap<>(), projectPath, true); + assertEquals(output.replaceAll("\r", ""), + "ERROR [tests/test.bal:(3:1,6:2)] could not find module specified 'intg_tests/module1:0.1.0'\n" + "error: compilation contains errors"); } @Test - public void testMockingAFunctionWithIncompatibleTypes() throws BallerinaTestException { + public void testMockingFunctionWithIncompatibleTypes() throws BallerinaTestException { String projectPath = projectBasedTestsPath.resolve("incompatible-type-mock").toString(); String output = balClient.runMainAndReadStdOut("test", new String[0], new HashMap<>(), projectPath, true); assertEquals(output.replaceAll("\r", ""), @@ -66,4 +86,14 @@ public void testMockingAFunctionWithIncompatibleTypes() throws BallerinaTestExce "but found isolated function () returns (int)\n" + "error: compilation contains errors"); } + + @Test + public void testMockingFunctionInSingleFileProject() throws BallerinaTestException { + String projectPath = singleFileTestsPath.resolve("mocking").toString(); + String[] args = mergeCoverageArgs(new String[]{"function-mock.bal"}); + String output = balClient.runMainAndReadStdOut("test", args, new HashMap<>(), projectPath, true); + assertEquals(output.replaceAll("\r", ""), + "ERROR [function-mock.bal:(12:1,12:38)] Function mocking is not supported for single file projects\n" + + "error: compilation contains errors"); + } } diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-function-mock2/Ballerina.toml b/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-function-mock2/Ballerina.toml new file mode 100644 index 000000000000..0408e0d7c8c3 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-function-mock2/Ballerina.toml @@ -0,0 +1,5 @@ +[package] +org = "intg_tests" +name = "non_existent_function_mock" +version = "0.1.0" + diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-function-mock2/main.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-function-mock2/main.bal new file mode 100644 index 000000000000..6b71ef415c69 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-function-mock2/main.bal @@ -0,0 +1,2 @@ +public function main() { +} diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-function-mock2/tests/test.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-function-mock2/tests/test.bal new file mode 100644 index 000000000000..f5e8d7e0e3df --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-function-mock2/tests/test.bal @@ -0,0 +1,4 @@ +import ballerina/test; + +@test:Mock { functionName: "intAdd" } +test:MockFunction intAddMockFn = new(); diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-module-mock2/Ballerina.toml b/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-module-mock2/Ballerina.toml new file mode 100644 index 000000000000..3779a856faa1 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-module-mock2/Ballerina.toml @@ -0,0 +1,4 @@ +[package] +org = "intg_tests" +name = "non_existent_module_mock" +version = "0.1.0" diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-module-mock2/main.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-module-mock2/main.bal new file mode 100644 index 000000000000..c89f90dcf480 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-module-mock2/main.bal @@ -0,0 +1,6 @@ +public function main() { +} + +function createJdbcClient() returns string { + return "real client"; +} diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-module-mock2/tests/test.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-module-mock2/tests/test.bal new file mode 100644 index 000000000000..449ec935010b --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/non-existent-module-mock2/tests/test.bal @@ -0,0 +1,7 @@ +import ballerina/test; + +@test:Mock { + moduleName: "module1", + functionName: "createJdbcClient" +} +test:MockFunction intAddMockFn = new(); diff --git a/tests/testerina-integration-test/src/test/resources/single-file-tests/mocking/function-mock.bal b/tests/testerina-integration-test/src/test/resources/single-file-tests/mocking/function-mock.bal new file mode 100644 index 000000000000..3ebd3d424dac --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/single-file-tests/mocking/function-mock.bal @@ -0,0 +1,19 @@ +import ballerina/test; + +function intSub(int a, int b) returns int{ + return (a-b); +} + +function intAdd(int a, int b) returns int { + return (a+b); + +} + +@test:Mock { functionName: "intAdd" } +test:MockFunction intAddMockFn = new(); + +@test:Config{} +function functionMockingTest() { + test:when(intAddMockFn).call("intSub"); + test:assertEquals(intAdd(5,5),0); +} From acc5dbb8dc117169c5615efa56f8b4f79e5a865b Mon Sep 17 00:00:00 2001 From: Gayal Dassanayake Date: Wed, 30 Nov 2022 17:10:12 +0530 Subject: [PATCH 213/450] Rename validateFunctionName to isValidFunctionName --- .../ballerinalang/testerina/core/MockAnnotationProcessor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java index f9b89c454cd8..24b63884e69c 100644 --- a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java +++ b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java @@ -133,7 +133,7 @@ public void process(SimpleVariableNode simpleVariableNode, List Date: Tue, 6 Dec 2022 09:21:15 +0530 Subject: [PATCH 214/450] Fix error logs --- .../testerina/core/MockAnnotationProcessor.java | 8 ++++---- .../test/negative/InvalidFunctionMockingTestCase.java | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java index 24b63884e69c..eb22515e5e2b 100644 --- a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java +++ b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java @@ -115,7 +115,7 @@ public void process(SimpleVariableNode simpleVariableNode, List an PackageID functionToMockID = getPackageID(vals[0]); if (functionToMockID == null) { diagnosticLog.logDiagnostic(DiagnosticSeverity.ERROR, attachmentNode.getPosition(), - "could not find module specified '" + vals[0] + "'"); + "could not find specified module '" + vals[0] + "'"); break; } @@ -237,7 +237,7 @@ public void process(FunctionNode functionNode, List an } } else { diagnosticLog.logDiagnostic(DiagnosticSeverity.ERROR, attachmentNode.getPosition(), - "could not find function " + vals[1] + " in module '" + vals[0] + "'"); + "could not find function '" + vals[1] + "' in module '" + vals[0] + "'"); break; } @@ -337,7 +337,7 @@ private boolean isValidFunctionName(String functionName, String moduleName, Pack AnnotationAttachmentNode attachmentNode) { if (functionToMockID == null) { diagnosticLog.logDiagnostic(DiagnosticSeverity.ERROR, attachmentNode.getPosition(), - "could not find module specified '" + moduleName + "'"); + "could not find specified module '" + moduleName + "'"); } else { if (functionName == null) { diagnosticLog.logDiagnostic(DiagnosticSeverity.ERROR, attachmentNode.getPosition(), diff --git a/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/negative/InvalidFunctionMockingTestCase.java b/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/negative/InvalidFunctionMockingTestCase.java index 7704c58a1dcf..2edb77806548 100644 --- a/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/negative/InvalidFunctionMockingTestCase.java +++ b/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/negative/InvalidFunctionMockingTestCase.java @@ -44,7 +44,7 @@ public void testMockingNonExistingFunction() throws BallerinaTestException { String projectPath = projectBasedTestsPath.resolve("non-existent-function-mock").toString(); String output = balClient.runMainAndReadStdOut("test", new String[0], new HashMap<>(), projectPath, true); assertEquals(output.replaceAll("\r", ""), - "ERROR [tests/test.bal:(3:1,5:2)] could not find function createJdbcClient in module " + + "ERROR [tests/test.bal:(3:1,5:2)] could not find function 'createJdbcClient' in module " + "'intg_tests/non_existent_function_mock:0.1.0'\n" + "error: compilation contains errors"); } @@ -64,7 +64,7 @@ public void testMockingFunctionInNonExistingModule() throws BallerinaTestExcepti String projectPath = projectBasedTestsPath.resolve("non-existent-module-mock").toString(); String output = balClient.runMainAndReadStdOut("test", new String[0], new HashMap<>(), projectPath, true); assertEquals(output.replaceAll("\r", ""), - "ERROR [tests/test.bal:(3:1,6:2)] could not find module specified 'intg_tests/module1:0.1.0'\n" + + "ERROR [tests/test.bal:(3:1,6:2)] could not find specified module 'intg_tests/module1:0.1.0'\n" + "error: compilation contains errors"); } @@ -73,7 +73,7 @@ public void testMockingFunctionInNonExistingModule2() throws BallerinaTestExcept String projectPath = projectBasedTestsPath.resolve("non-existent-module-mock2").toString(); String output = balClient.runMainAndReadStdOut("test", new String[0], new HashMap<>(), projectPath, true); assertEquals(output.replaceAll("\r", ""), - "ERROR [tests/test.bal:(3:1,6:2)] could not find module specified 'intg_tests/module1:0.1.0'\n" + + "ERROR [tests/test.bal:(3:1,6:2)] could not find specified module 'intg_tests/module1:0.1.0'\n" + "error: compilation contains errors"); } @@ -93,7 +93,7 @@ public void testMockingFunctionInSingleFileProject() throws BallerinaTestExcepti String[] args = mergeCoverageArgs(new String[]{"function-mock.bal"}); String output = balClient.runMainAndReadStdOut("test", args, new HashMap<>(), projectPath, true); assertEquals(output.replaceAll("\r", ""), - "ERROR [function-mock.bal:(12:1,12:38)] Function mocking is not supported for single file projects\n" + + "ERROR [function-mock.bal:(12:1,12:38)] function mocking is not supported for single file projects\n" + "error: compilation contains errors"); } } From 59c0dd6d79656270beda22c783b191bbf177539a Mon Sep 17 00:00:00 2001 From: Gayal Dassanayake Date: Tue, 13 Dec 2022 11:36:42 +0530 Subject: [PATCH 215/450] Fix mock without record npe --- .../core/MockAnnotationProcessor.java | 57 +++++++++++-------- .../InvalidFunctionMockingTestCase.java | 38 +++++++++++++ .../Ballerina.toml | 5 ++ .../main.bal | 2 + .../tests/test.bal | 4 ++ .../Ballerina.toml | 5 ++ .../main.bal | 2 + .../tests/test.bal | 7 +++ .../Ballerina.toml | 5 ++ .../main.bal | 2 + .../tests/test.bal | 4 ++ .../Ballerina.toml | 5 ++ .../main.bal | 2 + .../tests/test.bal | 6 ++ 14 files changed, 119 insertions(+), 25 deletions(-) create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/empty-annotation-record-function-mock/Ballerina.toml create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/empty-annotation-record-function-mock/main.bal create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/empty-annotation-record-function-mock/tests/test.bal create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/empty-annotation-record-function-mock2/Ballerina.toml create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/empty-annotation-record-function-mock2/main.bal create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/empty-annotation-record-function-mock2/tests/test.bal create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/record-less-annotation-function-mock/Ballerina.toml create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/record-less-annotation-function-mock/main.bal create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/record-less-annotation-function-mock/tests/test.bal create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/record-less-annotation-function-mock2/Ballerina.toml create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/record-less-annotation-function-mock2/main.bal create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/record-less-annotation-function-mock2/tests/test.bal diff --git a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java index eb22515e5e2b..36b7f0586411 100644 --- a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java +++ b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/MockAnnotationProcessor.java @@ -127,32 +127,36 @@ public void process(SimpleVariableNode simpleVariableNode, List fields = - ((BLangRecordLiteral) attachmentNode.getExpression()).getFields(); - setAnnotationValues(fields, annotationValues, attachmentNode, parent); - PackageID functionToMockID = getPackageID(annotationValues[0]); - boolean validFunctionName = isValidFunctionName( - annotationValues[1], annotationValues[0], functionToMockID, attachmentNode); - if (!validFunctionName) { - return; - } - BLangTestablePackage bLangTestablePackage = - (BLangTestablePackage) ((BLangSimpleVariable) simpleVariableNode).parent; - // Value added to the map ' # --> ` - bLangTestablePackage.addMockFunction( - functionToMockID + MOCK_FN_DELIMITER + annotationValues[1], + if (null == attachmentNode.getExpression() + || attachmentNode.getExpression().getKind() != NodeKind.RECORD_LITERAL_EXPR) { + diagnosticLog.logDiagnostic(DiagnosticSeverity.ERROR, attachmentNode.getPosition(), + "annotation should be a record with 'functionName' and 'moduleName'(optional) fields"); + continue; + } + // Get list of attributes in the Mock annotation + List fields = + ((BLangRecordLiteral) attachmentNode.getExpression()).getFields(); + setAnnotationValues(fields, annotationValues, attachmentNode, parent); + PackageID functionToMockID = getPackageID(annotationValues[0]); + boolean validFunctionName = isValidFunctionName( + annotationValues[1], annotationValues[0], functionToMockID, attachmentNode); + if (!validFunctionName) { + return; + } + BLangTestablePackage bLangTestablePackage = + (BLangTestablePackage) ((BLangSimpleVariable) simpleVariableNode).parent; + // Value added to the map ' # --> ` + bLangTestablePackage.addMockFunction( + functionToMockID + MOCK_FN_DELIMITER + annotationValues[1], + mockFnObjectName); + + if (functionToMockID != null) { + // Adding ` # --> ` to registry + String className = getQualifiedClassName(bLangTestablePackage, + functionToMockID.toString(), annotationValues[1]); + registry.addMockFunctionsSourceMap(bLangTestablePackage.packageID.getName().toString() + + MODULE_DELIMITER + className + MOCK_FN_DELIMITER + annotationValues[1], mockFnObjectName); - - if (functionToMockID != null) { - // Adding ` # --> ` to registry - String className = getQualifiedClassName(bLangTestablePackage, - functionToMockID.toString(), annotationValues[1]); - registry.addMockFunctionsSourceMap(bLangTestablePackage.packageID.getName().toString() - + MODULE_DELIMITER + className + MOCK_FN_DELIMITER + annotationValues[1], - mockFnObjectName); - } } } else { // Throw an error saying its not a MockFunction object @@ -253,6 +257,9 @@ public void process(FunctionNode functionNode, List an vals[1] = vals[1].replaceAll("\\\\", ""); registry.addMockFunctionsSourceMap(bLangTestablePackage.packageID.getName().toString() + MODULE_DELIMITER + className + MOCK_LEGACY_DELIMITER + vals[1], functionName); + } else { + diagnosticLog.logDiagnostic(DiagnosticSeverity.ERROR, attachmentNode.getPosition(), + "annotation should be a record with 'functionName' and 'moduleName'(optional) fields"); } } } diff --git a/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/negative/InvalidFunctionMockingTestCase.java b/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/negative/InvalidFunctionMockingTestCase.java index 2edb77806548..b0ea4bca007a 100644 --- a/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/negative/InvalidFunctionMockingTestCase.java +++ b/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/negative/InvalidFunctionMockingTestCase.java @@ -59,6 +59,44 @@ public void testMockingNonExistingFunction2() throws BallerinaTestException { "error: compilation contains errors"); } + @Test + public void testMockingWithoutAnnotationRecord() throws BallerinaTestException { + String projectPath = projectBasedTestsPath.resolve("record-less-annotation-function-mock").toString(); + String output = balClient.runMainAndReadStdOut("test", new String[0], new HashMap<>(), projectPath, true); + assertEquals(output.replaceAll("\r", ""), + "ERROR [tests/test.bal:(3:1,3:11)] annotation should be a record with " + + "'functionName' and 'moduleName'(optional) fields\n" + + "error: compilation contains errors"); + } + + @Test + public void testMockingWithoutAnnotationRecord2() throws BallerinaTestException { + String projectPath = projectBasedTestsPath.resolve("record-less-annotation-function-mock2").toString(); + String output = balClient.runMainAndReadStdOut("test", new String[0], new HashMap<>(), projectPath, true); + assertEquals(output.replaceAll("\r", ""), + "ERROR [tests/test.bal:(3:1,3:11)] annotation should be a record with " + + "'functionName' and 'moduleName'(optional) fields\n" + + "error: compilation contains errors"); + } + + @Test + public void testMockingWithEmptyAnnotationRecord() throws BallerinaTestException { + String projectPath = projectBasedTestsPath.resolve("empty-annotation-record-function-mock").toString(); + String output = balClient.runMainAndReadStdOut("test", new String[0], new HashMap<>(), projectPath, true); + assertEquals(output.replaceAll("\r", ""), + "ERROR [tests/test.bal:(3:1,3:14)] function name cannot be empty\n" + + "error: compilation contains errors"); + } + + @Test + public void testMockingWithEmptyAnnotationRecord2() throws BallerinaTestException { + String projectPath = projectBasedTestsPath.resolve("empty-annotation-record-function-mock2").toString(); + String output = balClient.runMainAndReadStdOut("test", new String[0], new HashMap<>(), projectPath, true); + assertEquals(output.replaceAll("\r", ""), + "ERROR [tests/test.bal:(3:1,3:14)] function name cannot be empty\n" + + "error: compilation contains errors"); + } + @Test public void testMockingFunctionInNonExistingModule() throws BallerinaTestException { String projectPath = projectBasedTestsPath.resolve("non-existent-module-mock").toString(); diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/empty-annotation-record-function-mock/Ballerina.toml b/tests/testerina-integration-test/src/test/resources/project-based-tests/empty-annotation-record-function-mock/Ballerina.toml new file mode 100644 index 000000000000..743dde6dd614 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/empty-annotation-record-function-mock/Ballerina.toml @@ -0,0 +1,5 @@ +[package] +org = "intg_tests" +name = "empty_annot_rec_function_mock" +version = "0.1.0" + diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/empty-annotation-record-function-mock/main.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/empty-annotation-record-function-mock/main.bal new file mode 100644 index 000000000000..6b71ef415c69 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/empty-annotation-record-function-mock/main.bal @@ -0,0 +1,2 @@ +public function main() { +} diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/empty-annotation-record-function-mock/tests/test.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/empty-annotation-record-function-mock/tests/test.bal new file mode 100644 index 000000000000..e45d160ccbea --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/empty-annotation-record-function-mock/tests/test.bal @@ -0,0 +1,4 @@ +import ballerina/test; + +@test:Mock {} +test:MockFunction mock_intAdd = new (); diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/empty-annotation-record-function-mock2/Ballerina.toml b/tests/testerina-integration-test/src/test/resources/project-based-tests/empty-annotation-record-function-mock2/Ballerina.toml new file mode 100644 index 000000000000..743dde6dd614 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/empty-annotation-record-function-mock2/Ballerina.toml @@ -0,0 +1,5 @@ +[package] +org = "intg_tests" +name = "empty_annot_rec_function_mock" +version = "0.1.0" + diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/empty-annotation-record-function-mock2/main.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/empty-annotation-record-function-mock2/main.bal new file mode 100644 index 000000000000..6b71ef415c69 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/empty-annotation-record-function-mock2/main.bal @@ -0,0 +1,2 @@ +public function main() { +} diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/empty-annotation-record-function-mock2/tests/test.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/empty-annotation-record-function-mock2/tests/test.bal new file mode 100644 index 000000000000..5b02eec1bb97 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/empty-annotation-record-function-mock2/tests/test.bal @@ -0,0 +1,7 @@ +import ballerina/test; + +@test:Mock {} +function intAdd() returns int { + return 1; +} + diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/record-less-annotation-function-mock/Ballerina.toml b/tests/testerina-integration-test/src/test/resources/project-based-tests/record-less-annotation-function-mock/Ballerina.toml new file mode 100644 index 000000000000..e8b6b5877b8f --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/record-less-annotation-function-mock/Ballerina.toml @@ -0,0 +1,5 @@ +[package] +org = "intg_tests" +name = "recordless_annot_function_mock" +version = "0.1.0" + diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/record-less-annotation-function-mock/main.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/record-less-annotation-function-mock/main.bal new file mode 100644 index 000000000000..6b71ef415c69 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/record-less-annotation-function-mock/main.bal @@ -0,0 +1,2 @@ +public function main() { +} diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/record-less-annotation-function-mock/tests/test.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/record-less-annotation-function-mock/tests/test.bal new file mode 100644 index 000000000000..f7533e8208a9 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/record-less-annotation-function-mock/tests/test.bal @@ -0,0 +1,4 @@ +import ballerina/test; + +@test:Mock +test:MockFunction mock_intAdd = new (); diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/record-less-annotation-function-mock2/Ballerina.toml b/tests/testerina-integration-test/src/test/resources/project-based-tests/record-less-annotation-function-mock2/Ballerina.toml new file mode 100644 index 000000000000..e8b6b5877b8f --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/record-less-annotation-function-mock2/Ballerina.toml @@ -0,0 +1,5 @@ +[package] +org = "intg_tests" +name = "recordless_annot_function_mock" +version = "0.1.0" + diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/record-less-annotation-function-mock2/main.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/record-less-annotation-function-mock2/main.bal new file mode 100644 index 000000000000..6b71ef415c69 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/record-less-annotation-function-mock2/main.bal @@ -0,0 +1,2 @@ +public function main() { +} diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/record-less-annotation-function-mock2/tests/test.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/record-less-annotation-function-mock2/tests/test.bal new file mode 100644 index 000000000000..dd0fa8983121 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/record-less-annotation-function-mock2/tests/test.bal @@ -0,0 +1,6 @@ +import ballerina/test; + +@test:Mock +function intAdd() returns int { + return 1; +} From 60881cde7bf0d5c52d1bd8ff5ed6dc1d0701fba1 Mon Sep 17 00:00:00 2001 From: Nadeeshan96 Date: Tue, 13 Dec 2022 11:43:21 +0530 Subject: [PATCH 216/450] Fix failing tests --- .../semantics/analyzer/SymbolEnter.java | 17 ++++++++++------- .../model/symbols/BTypeDefinitionSymbol.java | 7 +------ .../semantics/model/symbols/Symbols.java | 11 ----------- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolEnter.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolEnter.java index 84819080a5cc..7c5606ceec0a 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolEnter.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolEnter.java @@ -1635,13 +1635,11 @@ public void visit(BLangTypeDefinition typeDefinition) { typeDefinition.setPrecedence(this.typePrecedence++); BSymbol typeDefSymbol = Symbols.createTypeDefinitionSymbol(Flags.asMask(typeDefinition.flagSet), - names.fromIdNode(typeDefinition.name), names.originalNameFromIdNode(typeDefinition.name), - env.enclPkg.packageID, definedType, env.scope.owner, typeDefinition.name.pos, - getOrigin(typeDefinition.name.value)); + names.fromIdNode(typeDefinition.name), env.enclPkg.packageID, definedType, env.scope.owner, + typeDefinition.name.pos, getOrigin(typeDefinition.name.value)); typeDefSymbol.markdownDocumentation = getMarkdownDocAttachment(typeDefinition.markdownDocumentationAttachment); BTypeSymbol typeSymbol = new BTypeSymbol(SymTag.TYPE_REF, typeDefSymbol.flags, typeDefSymbol.name, - typeDefSymbol.originalName, typeDefSymbol.pkgID, typeDefSymbol.type, typeDefSymbol.owner, - typeDefSymbol.pos, typeDefSymbol.origin); + typeDefSymbol.pkgID, typeDefSymbol.type, typeDefSymbol.owner, typeDefSymbol.pos, typeDefSymbol.origin); typeSymbol.markdownDocumentation = typeDefSymbol.markdownDocumentation; ((BTypeDefinitionSymbol) typeDefSymbol).referenceType = new BTypeReferenceType(definedType, typeSymbol, typeDefSymbol.type.flags); @@ -1910,11 +1908,16 @@ private BEnumSymbol createEnumSymbol(BLangTypeDefinition typeDefinition, BType d } BEnumSymbol enumSymbol = new BEnumSymbol(enumMembers, Flags.asMask(typeDefinition.flagSet), - names.fromIdNode(typeDefinition.name), names.originalNameFromIdNode(typeDefinition.name), - env.enclPkg.packageID, definedType, env.scope.owner, + names.fromIdNode(typeDefinition.name), names.fromIdNode(typeDefinition.name), + env.enclPkg.symbol.pkgID, definedType, env.scope.owner, typeDefinition.pos, SOURCE); + enumSymbol.name = names.fromIdNode(typeDefinition.name); + enumSymbol.originalName = names.fromIdNode(typeDefinition.name); + enumSymbol.flags |= Flags.asMask(typeDefinition.flagSet); + enumSymbol.markdownDocumentation = getMarkdownDocAttachment(typeDefinition.markdownDocumentationAttachment); + enumSymbol.pkgID = env.enclPkg.packageID; return enumSymbol; } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/BTypeDefinitionSymbol.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/BTypeDefinitionSymbol.java index 7b60aa0ef6e3..001dc4a6368e 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/BTypeDefinitionSymbol.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/BTypeDefinitionSymbol.java @@ -41,12 +41,7 @@ public class BTypeDefinitionSymbol extends BSymbol implements Annotatable { public BTypeDefinitionSymbol(long flags, Name name, PackageID pkgID, BType type, BSymbol owner, Location pos, SymbolOrigin origin) { - this(flags, name, name, pkgID, type, owner, pos, origin); - } - - public BTypeDefinitionSymbol(long flags, Name name, Name originalName, PackageID pkgID, BType type, BSymbol owner, - Location pos, SymbolOrigin origin) { - super(SymTag.TYPE_DEF, flags, name, originalName, pkgID, type, owner, pos, origin); + super(SymTag.TYPE_DEF, flags, name, pkgID, type, owner, pos, origin); this.kind = SymbolKind.TYPE_DEF; this.annAttachments = new ArrayList<>(); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/Symbols.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/Symbols.java index 66f7da7be03e..c2ed153c4acf 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/Symbols.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/symbols/Symbols.java @@ -190,17 +190,6 @@ public static BTypeDefinitionSymbol createTypeDefinitionSymbol(long flags, return new BTypeDefinitionSymbol(flags, name, pkgID, type, owner, pos, origin); } - public static BTypeDefinitionSymbol createTypeDefinitionSymbol(long flags, - Name name, - Name originalName, - PackageID pkgID, - BType type, - BSymbol owner, - Location pos, - SymbolOrigin origin) { - return new BTypeDefinitionSymbol(flags, name, originalName, pkgID, type, owner, pos, origin); - } - public static BInvokableTypeSymbol createInvokableTypeSymbol(int symTag, long flags, From 3c500c69447ccb4e9a0631aa1e91a43e5c26f3e5 Mon Sep 17 00:00:00 2001 From: Imesha Sudasingha Date: Tue, 13 Dec 2022 14:11:29 +0530 Subject: [PATCH 217/450] Update FieldAccessCompletionResolver simple name ref type finding logic --- .../util/FieldAccessCompletionResolver.java | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/FieldAccessCompletionResolver.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/FieldAccessCompletionResolver.java index c2cd3f4aed22..083232afe247 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/FieldAccessCompletionResolver.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/util/FieldAccessCompletionResolver.java @@ -18,7 +18,6 @@ package org.ballerinalang.langserver.completions.util; import io.ballerina.compiler.api.ModuleID; -import io.ballerina.compiler.api.SemanticModel; import io.ballerina.compiler.api.symbols.ArrayTypeSymbol; import io.ballerina.compiler.api.symbols.FunctionSymbol; import io.ballerina.compiler.api.symbols.FunctionTypeSymbol; @@ -80,27 +79,15 @@ public FieldAccessCompletionResolver(PositionedOperationContext context) { @Override public Optional transform(SimpleNameReferenceNode node) { - Optional symbol = this.getSymbolByName(context.visibleSymbols(context.getCursorPosition()), - node.name().text()); - - if (node.parent().kind() == SyntaxKind.FIELD_ACCESS) { - Optional semanticModel = this.context.currentSemanticModel(); - if (semanticModel.isEmpty()) { - return Optional.empty(); - } - - Optional typeSymbol = semanticModel.get() - .typeOf(((FieldAccessExpressionNode) node.parent()).expression()); - if (typeSymbol.isPresent()) { - return SymbolUtil.getTypeDescriptor(typeSymbol.get()); - } - } - - if (symbol.isEmpty()) { - return Optional.empty(); + Optional typeSymbol = this.context.currentSemanticModel() + .flatMap(semanticModel -> semanticModel.typeOf(node)); + if (typeSymbol.isPresent()) { + return typeSymbol; } - return SymbolUtil.getTypeDescriptor(symbol.get()); + List visibleSymbols = context.visibleSymbols(context.getCursorPosition()); + return this.getSymbolByName(visibleSymbols, node.name().text()) + .flatMap(SymbolUtil::getTypeDescriptor); } @Override From 904c2edc88972e3fec1c50a2f6b288d3564bb122 Mon Sep 17 00:00:00 2001 From: mohan Date: Tue, 13 Dec 2022 16:01:16 +0530 Subject: [PATCH 218/450] Add revamped examples for strings langlib --- .../lang.string/src/main/ballerina/string.bal | 154 +++++++++++++++++- 1 file changed, 149 insertions(+), 5 deletions(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index 3c28d0f98fab..bb9437740027 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -25,6 +25,10 @@ public type RegExp regexp:RegExp; # Returns the length of the string. # +# ```ballerina +# "Hello, World!".length() ⇒ 13; +# ``` +# # + str - the string # + return - the number of characters (code points) in parameter `str` public isolated function length(string str) returns int = @java:Method { @@ -36,6 +40,13 @@ public isolated function length(string str) returns int = @java:Method { # # The iterator will yield the substrings of length 1 in order. # +# ```ballerina +# object { +# public isolated function next() returns record {|string:Char value;|}?; +# } iterator = "Hello, World!".iterator(); +# iterator.next() ⇒ {"value":"H"} +# ``` +# # + str - the string to be iterated over # + return - a new iterator object public isolated function iterator(string str) returns object { @@ -47,6 +58,13 @@ public isolated function iterator(string str) returns object { # Concatenates zero or more strings. # +# ```ballerina +# "http://worldtimeapi.org".concat("/api/timezone/", "Asia", "/", "Colombo") ⇒ http://worldtimeapi.org/api/timezone/Asia/Colombo +# +# // Alternative approach to achieve the same as above. +# string:concat("http://worldtimeapi.org", "/api/timezone/", "Asia", "/", "Colombo") ⇒ http://worldtimeapi.org/api/timezone/Asia/Colombo +# ``` +# # + strs - strings to be concatenated # + return - concatenation of all of the parameter `strs`; empty string if parameter `strs` is empty public isolated function concat(string... strs) returns string = @java:Method { @@ -56,6 +74,10 @@ public isolated function concat(string... strs) returns string = @java:Method { # Returns the code point of a character in a string. # +# ```ballerina +# "Hello, World!".getCodePoint(3) ⇒ 108 +# ``` +# # + str - the string # + index - an index in parameter `str` # + return - the Unicode code point of the character at parameter `index` in parameter `str` @@ -66,6 +88,14 @@ public isolated function getCodePoint(string str, int index) returns int = @java # Returns a substring of a string. # +# ```ballerina +# "Hello, my name is John".substring(18, 22) ⇒ "John" +# +# // Consider only the start index. In this situation, +# // input string length would be considered as end index. +# "Hello, my name is John".substring(7) ⇒ "my name is John" +# ``` +# # + str - source string. # + startIndex - the starting index, inclusive # + endIndex - the ending index, exclusive @@ -82,6 +112,10 @@ public isolated function substring(string str, int startIndex, int endIndex = st # but the ordering will often not be consistent with cultural expectations # for sorted order. # +# ```ballerina +# "Austria".codePointCompare("Australia") ⇒ 1 +# ``` +# # + str1 - the first string to be compared # + str2 - the second string to be compared # + return - an int that is less than, equal to or greater than zero, @@ -93,6 +127,15 @@ public isolated function codePointCompare(string str1, string str2) returns int # Joins zero or more strings together with a separator. # +# ```ballerina +# // Join multiple strings with space as the separator. +# string:'join(" ", "Ballerina", "is", "a", "programming", "language") ⇒ "Ballerina is a programming language" +# +# // Join multiple strings with comma as the separator. +# string[] array = ["John", "23", "USA", "Computer Science", "Swimmer"]; +# string:'join(",", ...array) ⇒ "John,23,USA,Computer Science,Swimmer" +# ``` +# # + separator - separator string # + strs - strings to be joined # + return - a string consisting of all of parameter `strs` concatenated in order @@ -104,6 +147,13 @@ public isolated function 'join(string separator, string... strs) returns string # Finds the first occurrence of one string in another string. # +# ```ballerina +# "New Zealand".indexOf("land") ⇒ 7 +# +# // Search for the first occurrence of a string from a specific index onwards. +# "Ballerinalang is a unique programming language".indexOf("lang", 15) ⇒ 38 +# ``` +# # + str - the string in which to search # + substr - the string to search for # + startIndex - index to start searching from @@ -116,6 +166,13 @@ public isolated function indexOf(string str, string substr, int startIndex = 0) # Finds the last occurrence of one string in another string. # +# ```ballerina +# "Ballerinalang is a unique programming language".lastIndexOf("lang") ⇒ 38 +# +# // Search for the last occurrence of a string from a specific index onwards. +# "Ballerinalang is a unique programming language".lastIndexOf("lang", 15) ⇒ 9 +# ``` +# # + str - the string in which to search # + substr - the string to search for # + startIndex - index to start searching backwards from @@ -129,6 +186,13 @@ returns int? = @java:Method { # Tests whether a string includes another string. # +# ```ballerina +# "Hello World! from Ballerina".includes("Bal") ⇒ true +# +# // Check for the occurrence of a string from a specific index onwards. +# "Hello World! from Ballerina".includes("Hello", 10) ⇒ false +# ``` +# # + str - the string in which to search # + substr - the string to search for # + startIndex - index to start searching from @@ -141,6 +205,10 @@ public isolated function includes(string str, string substr, int startIndex = 0) # Tests whether a string starts with another string. # +# ```ballerina +# "Welcome to Ballerina programming language".startsWith("Welcome") ⇒ true +# ``` +# # + str - the string to be tested # + substr - the starting string # + return - true if parameter `str` starts with parameter `substr`; false otherwise @@ -151,6 +219,10 @@ public isolated function startsWith(string str, string substr) returns boolean = # Tests whether a string ends with another string. # +# ```ballerina +# "Welcome to Ballerina programming language".endsWith("language") ⇒ true +# ``` +# # + str - the string to be tested # + substr - the ending string # + return - true if parameter `str` ends with parameter `substr`; false otherwise @@ -167,6 +239,10 @@ public isolated function endsWith(string str, string substr) returns boolean = @ # # Other characters are left unchanged. # +# ```ballerina +# "HELLO, World!".toLowerAscii() ⇒ "hello, world!" +# ``` +# # + str - the string to be converted # + return - parameter `str` with any occurrences of A-Z converted to a-z public isolated function toLowerAscii(string str) returns string = @java:Method { @@ -178,6 +254,10 @@ public isolated function toLowerAscii(string str) returns string = @java:Method # # Other characters are left unchanged. # +# ```ballerina +# "hello, World!".toUpperAscii() ⇒ "HELLO, WORLD!" +# ``` +# # + str - the string to be converted # + return - parameter `str` with any occurrences of a-z converted to A-Z public isolated function toUpperAscii(string str) returns string = @java:Method { @@ -189,6 +269,10 @@ public isolated function toUpperAscii(string str) returns string = @java:Method # # A character in the range a-z is treated the same as the corresponding character in the range A-Z. # +# ```ballerina +# "BALLERINA".equalsIgnoreCaseAscii("ballerina") ⇒ true +# ``` +# # + str1 - the first string to be compared # + str2 - the second string to be compared # + return - true if parameter `str1` is the same as parameter `str2`, treating upper-case and lower-case @@ -202,6 +286,10 @@ public isolated function equalsIgnoreCaseAscii(string str1, string str2) returns # # The ASCII white space characters are 0x9...0xD, 0x20. # +# ```ballerina +# " BALLERINA ".trim() ⇒ "BALLERINA" +# ``` +# # + str - the string # + return - parameter `str` with leading or trailing ASCII white space characters removed public isolated function trim(string str) returns string = @java:Method { @@ -211,6 +299,10 @@ public isolated function trim(string str) returns string = @java:Method { # Represents a string as an array of bytes using UTF-8. # +# ```ballerina +# "Hello, World!".toBytes() ⇒ [72,101,108,108,111,44,32,87,111,114,108,100,33] +# ``` +# # + str - the string # + return - UTF-8 byte array public isolated function toBytes(string str) returns byte[] = @java:Method { @@ -220,6 +312,10 @@ public isolated function toBytes(string str) returns byte[] = @java:Method { # Constructs a string from its UTF-8 representation in bytes. # +# ```ballerina +# string:fromBytes([72, 101, 108, 108, 111, 32, 66, 97, 108, 108, 101, 114, 105, 110, 97, 33]) ⇒ Hello, World! +# ``` +# # + bytes - UTF-8 byte array # + return - parameter `bytes` converted to string or error public isolated function fromBytes(byte[] bytes) returns string|error = @java:Method { @@ -229,6 +325,10 @@ public isolated function fromBytes(byte[] bytes) returns string|error = @java:Me # Converts a string to an array of code points. # +# ```ballerina +# "Hello, world 🌎".toCodePointInts() ⇒ [72,101,108,108,111,44,32,119,111,114,108,100,32,127758] +# ``` +# # + str - the string # + return - an array with a code point for each character of parameter `str` public isolated function toCodePointInts(string str) returns int[] = @java:Method { @@ -238,6 +338,10 @@ public isolated function toCodePointInts(string str) returns int[] = @java:Metho # Converts a single character string to a code point. # +# ```ballerina +# string:toCodePointInt("a") ⇒ 97 +# ``` +# # + ch - a single character string # + return - the code point of parameter `ch` public isolated function toCodePointInt(Char ch) returns int = @java:Method { @@ -250,6 +354,10 @@ public isolated function toCodePointInt(Char ch) returns int = @java:Method { # An int is a valid code point if it is in the range 0 to 0x10FFFF inclusive, # but not in the range 0xD800 or 0xDFFF inclusive. # +# ```ballerina +# string:fromCodePointInts([66, 97, 108, 108, 101, 114, 105, 110, 97]) ⇒ "Ballerina" +# ``` +# # + codePoints - an array of ints, each specifying a code point # + return - a string with a character for each code point in parameter `codePoints`; or an error # if any member of parameter `codePoints` is not a valid code point @@ -263,6 +371,10 @@ public isolated function fromCodePointInts(int[] codePoints) returns string|erro # An int is a valid code point if it is in the range 0 to 0x10FFFF inclusive, # but not in the range 0xD800 or 0xDFFF inclusive. # +# ```ballerina +# string:fromCodePointInt(97) ⇒ "a" +# ``` +# # + codePoint - an int specifying a code point # + return - a single character string whose code point is parameter `codePoint`; or an error # if parameter `codePoint` is not a valid code point @@ -275,6 +387,11 @@ public isolated function fromCodePointInt(int codePoint) returns Char|error = @j # Adds sufficient `padChar` characters at the start of `str` to make its length be `len`. # If the length of `str` is >= `len`, returns `str`. # +# ```ballerina +# // Provide "0" as the custom padding char. +# "100Km".padStart(10, "0") ⇒ "00000100Km" +# ``` +# # + str - the string to pad # + len - the length of the string to be returned # + padChar - the character to use for padding `str`; defaults to a space character @@ -288,6 +405,11 @@ public isolated function padStart(string str, int len, Char padChar = " ") retur # Adds sufficient `padChar` characters to the end of `str` to make its length be `len`. # If the length of `str` is >= `len`, returns `str`. # +# ```ballerina +# // Provide "!" as the custom padding char. +# "Ballerina for developers".padEnd(30, "!") ⇒ "Ballerina for developers!!!!!!" +# ``` +# # + str - the string to pad # + len - the length of the string to be returned # + padChar - the character to use for padding `str`; defaults to a space character @@ -302,6 +424,10 @@ public isolated function padEnd(string str, int len, Char padChar = " ") returns # Sufficient zero characters are added to `str` to make its length be `len`. # If the length of `str` is >= `len`, returns `str`. # +# ```ballerina +# "-256".padZero(9) ⇒ "-00000256" +# ``` +# # + str - the string to pad # + len - the length of the string to be returned # + zeroChar - the character to use for the zero; defaults to ASCII zero `0` @@ -311,13 +437,31 @@ public isolated function padZero(string str, int len, Char zeroChar = "0") retur name: "padZero" } external; -# True if there is a match of `re` against all of `str`. -# Use `includesMatch` to test whether `re` matches somewhere in `str`. -public function matches(string str, RegExp 're) returns boolean { +# Tests whether there is a full match of a regular expression with a string. +# A match of a regular expression in a string is a full match if it +# starts at index 0 and ends at index `n`, where `n` is the length of the string. +# This is equivalent to `regex:isFullMatch(re, str)`. +# +# ```ballerina +# "Ballerina".matches(re `Bal.*`) ⇒ true +# ``` +# +# + str - the string +# + re - the regular expression +# + return - true if there is full match of `re` with `str`, and false otherwise +public isolated function matches(string str, RegExp 're) returns boolean { return 're.isFullMatch(str); } -# True if there is a match for `re` anywhere in `str` -public function includesMatch(string str, RegExp 're, int startIndex = 0) returns boolean { +# Tests whether there is a match of a regular expression somewhere within a string. +# This is equivalent to `regexp:find(re, str, startIndex) != ()`. +# ```ballerina +# "New Zealand".includesMatch(re `lan?`) ⇒ true +# ``` +# +# + str - the string to be matched +# + re - the regular expression +# + return - true if the is a match of `re` somewhere within `str`, otherwise false +public isolated function includesMatch(string str, RegExp 're, int startIndex = 0) returns boolean { return 're.find(str, startIndex) != (); } From 10a3f700d569142502902b939b6f095440f913cc Mon Sep 17 00:00:00 2001 From: mohan Date: Tue, 13 Dec 2022 16:05:32 +0530 Subject: [PATCH 219/450] update comments --- langlib/lang.string/src/main/ballerina/string.bal | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index bb9437740027..3f7e75f1d936 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -388,7 +388,6 @@ public isolated function fromCodePointInt(int codePoint) returns Char|error = @j # If the length of `str` is >= `len`, returns `str`. # # ```ballerina -# // Provide "0" as the custom padding char. # "100Km".padStart(10, "0") ⇒ "00000100Km" # ``` # @@ -406,7 +405,6 @@ public isolated function padStart(string str, int len, Char padChar = " ") retur # If the length of `str` is >= `len`, returns `str`. # # ```ballerina -# // Provide "!" as the custom padding char. # "Ballerina for developers".padEnd(30, "!") ⇒ "Ballerina for developers!!!!!!" # ``` # @@ -455,6 +453,7 @@ public isolated function matches(string str, RegExp 're) returns boolean { # Tests whether there is a match of a regular expression somewhere within a string. # This is equivalent to `regexp:find(re, str, startIndex) != ()`. +# # ```ballerina # "New Zealand".includesMatch(re `lan?`) ⇒ true # ``` From 286e5f0d3bb33d2fbfa6f75be4c4bbb0406d21fd Mon Sep 17 00:00:00 2001 From: Chiran Fernando Date: Wed, 2 Nov 2022 15:13:04 +0530 Subject: [PATCH 220/450] Cherry pick #38525 --- .../lang.regexp/src/main/ballerina/regexp.bal | 231 ++++++++++++++---- .../ballerinalang/langlib/regexp/Find.java | 25 +- .../langlib/regexp/RegexUtil.java | 14 ++ .../ballerinalang/langlib/regexp/Replace.java | 64 ----- .../ballerinalang/langlib/regexp/Split.java | 45 ++++ .../lang.string/src/main/ballerina/string.bal | 30 ++- .../langlib/test/LangLibRegexpTest.java | 3 +- .../langlib/test/LangLibStringTest.java | 11 + .../test/resources/test-src/regexp_test.bal | 191 ++++++--------- .../resources/test-src/stringlib_test.bal | 63 +++++ 10 files changed, 429 insertions(+), 248 deletions(-) delete mode 100644 langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/Replace.java create mode 100644 langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/Split.java diff --git a/langlib/lang.regexp/src/main/ballerina/regexp.bal b/langlib/lang.regexp/src/main/ballerina/regexp.bal index 0c5762ef1827..a507d36fd1ff 100644 --- a/langlib/lang.regexp/src/main/ballerina/regexp.bal +++ b/langlib/lang.regexp/src/main/ballerina/regexp.bal @@ -22,13 +22,27 @@ import ballerina/jballerina.java; @builtinSubtype public type RegExp any; +# A span of a string. +# A span is a substring of another string. public type Span readonly & object { + # The index within the string where the span starts. public int startIndex; + # The index within the string following the end of the span. + # The length of the span is `endIndex - startIndex`. public int endIndex; - // This avoids constructing a potentially long string unless and until it is needed. + # Returns a string with the content of the span. public isolated function substring() returns string; }; +# A list providing detailed information about the match of a regular expression within string. +# Each member of the list identifies the `Span` within the string matched +# by each of the regular expression's capturing groups. +# The member with index 0 corresponds to the entire regular expression. +# The group with index i, where i > 1,is the i-th capturing group; +# this will be nil if the match of the regular expression did not use +# a match of the capturing group. +# The capturing groups within a regular expression are ordered by the position +# of their opening parenthesis. public type Groups readonly & [Span, Span?...]; type SpanAsTupleType [int, int, string]; @@ -37,7 +51,12 @@ type GroupsAsSpanArrayType SpanAsTupleType[]; type GroupsArrayType GroupsAsSpanArrayType[]; -# Returns the span of the first match that starts at or after startIndex. +# Returns the first match of a regular expression within a string. +# +# + re - the regular expression +# + str - the string in which to look for a match of `re` +# + startIndex - the index within `str` at which to start looking for a match +# + return - a `Span` describing the match, or nil if no match was found public isolated function find(RegExp re, string str, int startIndex = 0) returns Span? { SpanAsTupleType? resultArr = findImpl(re, str, startIndex); if (resultArr is SpanAsTupleType) { @@ -51,18 +70,21 @@ isolated function findImpl(RegExp reExp, string str, int startIndex = 0) returns name: "find" } external; +isolated function findAllImpl(RegExp reExp, string str, int startIndex = 0) returns GroupsAsSpanArrayType? = @java:Method { + 'class: "org.ballerinalang.langlib.regexp.Find", + name: "findAll" +} external; + +# Returns the `Groups` for the first match of a regular expression within a string. +# +# + re - the regular expression +# + str - the string in which to look for a match of `re` +# + startIndex - the index within `str` at which to start looking for a match +# + return - a `Groups` list describing the match, or nil if no match was found public isolated function findGroups(RegExp re, string str, int startIndex = 0) returns Groups? { GroupsAsSpanArrayType? resultArr = findGroupsImpl(re, str, startIndex); if (resultArr is GroupsAsSpanArrayType) { - SpanAsTupleType firstMatch = resultArr[0]; - Span firstMatchSpan = new java:SpanImpl(firstMatch[0], firstMatch[1], firstMatch[2]); - Span[] spanArr = []; - foreach int index in 1 ..< resultArr.length() { - SpanAsTupleType matchGroup = resultArr[index]; - Span spanObj = new java:SpanImpl(matchGroup[0], matchGroup[1], matchGroup[2]); - spanArr.push(spanObj); - } - return [firstMatchSpan, ...spanArr]; + return getGroupWithCaptureGroupSpans(resultArr); } } @@ -71,10 +93,17 @@ isolated function findGroupsImpl(RegExp reExp, string str, int startIndex = 0) r name: "findGroups" } external; -# Return all non-overlapping matches. +# Returns a list of all the matches of a regular expression within a string. +# After one match is found, it looks for the next match starting where the previous +# match ended, so the list of matches will be non-overlapping. +# +# + re - the regular expression +# + str - the string in which to look for matches of `re` +# + startIndex - the index within `str` at which to start looking for matches +# + return - a list containing a `Span` for each match found public isolated function findAll(RegExp re, string str, int startIndex = 0) returns Span[] { Span[] spanArr = []; - GroupsAsSpanArrayType? resultArr = findGroupsImpl(re, str, startIndex); + GroupsAsSpanArrayType? resultArr = findAllImpl(re, str, startIndex); if (resultArr is GroupsAsSpanArrayType) { foreach SpanAsTupleType tpl in resultArr { spanArr.push(new java:SpanImpl(tpl[0], tpl[1], tpl[2])); @@ -83,34 +112,53 @@ public isolated function findAll(RegExp re, string str, int startIndex = 0) retu return spanArr; } -# Return all non-overlapping matches. +# Returns the `Groups` of all the matches of a regular expression within a string. +# After one match is found, it looks for the next match starting where the previous +# match ended, so the list of matches will be non-overlapping. +# +# + re - the regular expression +# + str - the string in which to look for matches of `re` +# + startIndex - the index within `str` at which to start looking for matches +# + return - a list containing a `Group` for each match found public isolated function findAllGroups(RegExp re, string str, int startIndex = 0) returns Groups[] { GroupsArrayType? resultArr = findAllGroupsImpl(re, str, startIndex); if (resultArr is GroupsArrayType) { Groups[] groupArrRes = []; foreach GroupsAsSpanArrayType groupArr in resultArr { - int resultArrLength = groupArr.length(); - SpanAsTupleType firstMatch = groupArr[0]; - Span firstMatchSpan = new java:SpanImpl(firstMatch[0], firstMatch[1], firstMatch[2]); - Span[] spanArr = []; - foreach int index in 1 ..< resultArrLength { - SpanAsTupleType matchGroup = groupArr[index]; - Span spanObj = new java:SpanImpl(matchGroup[0], matchGroup[1], matchGroup[2]); - spanArr.push(spanObj); - } - Groups g = [firstMatchSpan, ...spanArr]; - groupArrRes.push(g); + Groups groups = getGroupWithCaptureGroupSpans(groupArr); + groupArrRes.push(groups); } return groupArrRes; } return []; } +isolated function getGroupWithCaptureGroupSpans(GroupsAsSpanArrayType groupArr) returns Groups { + int resultArrLength = groupArr.length(); + SpanAsTupleType firstMatch = groupArr[0]; + Span firstMatchSpan = new java:SpanImpl(firstMatch[0], firstMatch[1], firstMatch[2]); + Span[] spanArr = []; + foreach int index in 1 ..< resultArrLength { + SpanAsTupleType matchGroup = groupArr[index]; + Span spanObj = new java:SpanImpl(matchGroup[0], matchGroup[1], matchGroup[2]); + spanArr.push(spanObj); + } + Groups groups = [firstMatchSpan, ...spanArr]; + return groups; +} + isolated function findAllGroupsImpl(RegExp reExp, string str, int startIndex = 0) returns GroupsArrayType? = @java:Method { 'class: "org.ballerinalang.langlib.regexp.Find", name: "findAllGroups" } external; +# Tests whether there is a match of a regular expression at a specific index in the string. +# +# + re - the regular expression +# + str - the string in which to look for a match of `re` +# + startIndex - the index within `str` at which to look for a match; defaults to zero +# + return - a `Span` describing the match, or nil if `re` did not match at that index; the startIndex of the +# `Span` will always be equal to `startIndex` public isolated function matchAt(RegExp re, string str, int startIndex = 0) returns Span? { SpanAsTupleType? resultArr = matchAtImpl(re, str, startIndex); if (resultArr is SpanAsTupleType) { @@ -124,6 +172,13 @@ isolated function matchAtImpl(RegExp reExp, string str, int startIndex = 0) retu name: "matchAt" } external; +# Returns the `Groups` of the match of a regular expression at a specific index in the string. +# +# + re - the regular expression +# + str - the string in which to look for a match of `re` +# + startIndex - the index within `str` at which to look for a match; defaults to zero +# + return - a `Groups` list describing the match, or nil if `re` did not match at that index; the startIndex of the +# first `Span` in the list will always be equal to the `startIndex` of the first member of the list public isolated function matchGroupsAt(RegExp re, string str, int startIndex = 0) returns Groups? { GroupsAsSpanArrayType? resultArr = matchGroupsAtImpl(re, str, startIndex); if (resultArr is GroupsAsSpanArrayType) { @@ -144,7 +199,13 @@ isolated function matchGroupsAtImpl(RegExp reExp, string str, int startIndex = 0 name: "matchGroupsAt" } external; -# Says whether there is a match of the RegExp that starts at the beginning of the string and ends at the end of the string. +# Tests whether there is full match of regular expression with a string. +# A match of a regular expression in a string is a full match if it +# starts at index 0 and ends at index `n`, where `n` is the length of the string. +# +# + re - the regular expression +# + str - the string +# + return - true if there is full match of `re` with `str`, and false otherwise public isolated function isFullMatch(RegExp re, string str) returns boolean { return isFullMatchImpl(re, str); } @@ -154,50 +215,124 @@ isolated function isFullMatchImpl(RegExp reExp, string str) returns boolean = @j name: "isFullMatch" } external; -# Says whether there is a match of the RegExp that starts at the beginning of the string and ends at the end of the string. +# Returns the `Groups` of the match of a regular expression that is a full match of a string. +# A match of the regular expression in a string is a full match if it +# starts at index 0 and ends at index `n`, where `n` is the length of the string. +# +# + re - the regular expression +# + str - the string in which to look for a match of `re` +# + return - a `Groups` list describing the match, or nil if there is not a full match; the +# first `Span` in the list will be all of `str` public isolated function fullMatchGroups(RegExp re, string str) returns Groups? { return matchGroupsAt(re, str); } -public type ReplacerFunction function (Groups groups) returns string; +# A function that constructs the replacement for the match of a regular expression. +# The `groups` parameter describes the match for which the replacement is to be constructed. +public type ReplacerFunction isolated function (Groups groups) returns string; +# The replacement for the match of a regular expression found within a string. +# A string value specifies that the replacement is a fixed string. +# A function that specifies that the replacement is constructed by calling a function for each match. public type Replacement ReplacerFunction|string; -# Replaces the first occurrence of a regular expression. +# Replaces the first match of a regular expression. +# +# + re - the regular expression +# + str - the string in which to perform the replacements +# + replacement - a `Replacement` that gives the replacement for the match +# + startIndex - the index within `str` at which to start looking for a match; defaults to zero +# + return - `str` with the first match, if any, replaced by the string specified by `replacement` public isolated function replace(RegExp re, string str, Replacement replacement, int startIndex = 0) returns string { - string replacementStr = ""; Groups? findResult = findGroups(re, str, startIndex); if findResult is () { return str; } - if (replacement is ReplacerFunction) { - replacementStr = replacement(findResult); - } else { - replacementStr = replacement; + Span span = findResult[0]; + int index = 0; + int strLength = length(str); + string updatedString = substring(str, index, span.startIndex) + + getReplacementString(findResult, replacement); + index = span.endIndex; + if index < strLength { + updatedString += substring(str, index, strLength); } - return replaceFromString(re, str, replacementStr, startIndex); + return updatedString; } -isolated function replaceFromString(RegExp reExp, string str, string replacementStr, int startIndex) returns string = @java:Method { - 'class: "org.ballerinalang.langlib.regexp.Replace", - name: "replaceFromString" -} external; - -# Replaces all occurrences of a regular expression. +# Replaces all matches of a regular expression. +# After one match is found, it looks for the next match starting where the previous +# match ended, so the matches will be non-overlapping. +# +# + re - the regular expression +# + str - the string in which to perform the replacements +# + replacement - a `Replacement` that gives the replacement for each match +# + startIndex - the index within `str` at which to start looking for matches; defaults to zero +# + return - `str` with every match replaced by the string specified by `replacement` public isolated function replaceAll(RegExp re, string str, Replacement replacement, int startIndex = 0) returns string { - Groups? findResult = findGroups(re, str, startIndex); - if findResult is () { + Groups[] findResult = findAllGroups(re, str, startIndex); + if findResult.length() == 0 { return str; } - string replacementStr = replacement is ReplacerFunction ? replacement(findResult) : replacement; - return replaceAllFromString(re, str, replacementStr, startIndex); + string prefixStr = ""; + if (startIndex != 0) { + prefixStr = substring(str, 0, startIndex); + } + string updatedString = ""; + int index = 0; + foreach Groups groups in findResult { + Span span = groups[0]; + updatedString += substring(str, index, span.startIndex) + + getReplacementString(groups, replacement); + index = span.endIndex; + } + if index < length(str) { + updatedString += substring(str, index, length(str)); + } + return prefixStr + updatedString; +} + +isolated function substring(string str, int startIndex, int endIndex = length(str)) returns string = +@java:Method { + 'class: "org.ballerinalang.langlib.regexp.RegexUtil", + name: "substring" +} external; + +# Returns the length of the string. +# +# + str - the string +# + return - the number of characters (code points) in parameter `str` +isolated function length(string str) returns int = @java:Method { + 'class: "org.ballerinalang.langlib.regexp.RegexUtil", + name: "length" +} external; + +isolated function getReplacementString(Groups groups, Replacement replacement) returns string { + if replacement is string { + return replacement; + } + return replacement(groups); } -isolated function replaceAllFromString(RegExp reExp, string str, string replacementStr, int startIndex) returns string = @java:Method { - 'class: "org.ballerinalang.langlib.regexp.Replace", - name: "replaceAllFromString" +# Splits a string into substrings separated by matches of a regular expression. +# This finds the the non-overlapping matches of a regular expression and +# returns a list of substrings of `str` that occur before the first match, +# between matches, or after the last match. If there are no matches, then +# `[str]` will be returned. +# +# + re - the regular expression that specifies the separator +# + str - the string to be split +# + return - a list of substrings of `str` separated by matches of `re` +public isolated function split(RegExp re, string str) returns string[] = @java:Method { + 'class: "org.ballerinalang.langlib.regexp.Split", + name: "split" } external; +# Constructs a regular expression from a string. +# The syntax of the regular expression is the same as accepted by the `re` tagged data template expression. +# +# + str - the string representation of a regular expression +# + return - the regular expression, or an error value if `str` is not a valid regular expression public isolated function fromString(string str) returns RegExp|error = @java:Method { 'class: "org.ballerinalang.langlib.regexp.FromString", name: "fromString" diff --git a/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/Find.java b/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/Find.java index 36fc9e3e11f6..f5266084bfa2 100644 --- a/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/Find.java +++ b/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/Find.java @@ -43,6 +43,25 @@ public static BArray find(BRegexpValue regExp, BString str, int startIndex) { } public static BArray findGroups(BRegexpValue regExp, BString str, int startIndex) { + Matcher matcher = RegexUtil.getMatcher(regExp, str); + BArray resultArray = ValueCreator.createArrayValue(GROUPS_AS_SPAN_ARRAY_TYPE); + matcher.region(startIndex, str.length()); + if (matcher.find()) { + resultArray.append(RegexUtil.getGroupZeroAsSpan(matcher)); + if (matcher.groupCount() != 0) { + BArray spanArr = RegexUtil.getMatcherGroupsAsSpanArr(matcher); + for (int i = 0; i < spanArr.getLength(); i++) { + resultArray.append(spanArr.get(i)); + } + } + } + if (resultArray.getLength() == 0) { + return null; + } + return resultArray; + } + + public static BArray findAll(BRegexpValue regExp, BString str, int startIndex) { Matcher matcher = RegexUtil.getMatcher(regExp, str); BArray resultArray = ValueCreator.createArrayValue(GROUPS_AS_SPAN_ARRAY_TYPE); matcher.region(startIndex, str.length()); @@ -60,12 +79,6 @@ public static BArray findAllGroups(BRegexpValue regExp, BString str, int startIn matcher.region(startIndex, str.length()); BArray groupArray = ValueCreator.createArrayValue(RegexUtil.GROUPS_ARRAY_TYPE); while (matcher.find()) { - if (matcher.groupCount() == 0) { - BArray group = ValueCreator.createArrayValue(GROUPS_AS_SPAN_ARRAY_TYPE); - group.append(RegexUtil.getGroupZeroAsSpan(matcher)); - groupArray.append(group); - break; - } BArray group = RegexUtil.getMatcherGroupsAsSpanArr(matcher); if (group.getLength() != 0) { groupArray.append(group); diff --git a/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/RegexUtil.java b/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/RegexUtil.java index 933ecb45d738..9a00effe8a01 100644 --- a/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/RegexUtil.java +++ b/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/RegexUtil.java @@ -15,6 +15,7 @@ * specific language governing permissions and limitations * under the License. */ + package org.ballerinalang.langlib.regexp; import io.ballerina.runtime.api.PredefinedTypes; @@ -66,6 +67,11 @@ static BArray getGroupZeroAsSpan(Matcher matcher) { static BArray getMatcherGroupsAsSpanArr(Matcher matcher) { BArray group = ValueCreator.createArrayValue(GROUPS_AS_SPAN_ARRAY_TYPE); + if (matcher.groupCount() == 0) { + BArray span = getGroupZeroAsSpan(matcher); + group.append(span); + return group; + } for (int i = 1; i <= matcher.groupCount(); i++) { int matcherStart = matcher.start(i); if (matcherStart == -1) { @@ -79,4 +85,12 @@ static BArray getMatcherGroupsAsSpanArr(Matcher matcher) { } return group; } + + public static BString substring(BString value, long startIndex, long endIndex) { + return value.substring((int) startIndex, (int) endIndex); + } + + public static long length(BString value) { + return value.length(); + } } diff --git a/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/Replace.java b/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/Replace.java deleted file mode 100644 index c130cb4d463e..000000000000 --- a/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/Replace.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.ballerinalang.langlib.regexp; - -import io.ballerina.runtime.api.utils.StringUtils; -import io.ballerina.runtime.api.values.BRegexpValue; -import io.ballerina.runtime.api.values.BString; - -import java.util.regex.Matcher; - -/** - * Native implementation of lang.regexp:replace(string). - * - * @since 2201.3.0 - */ -public class Replace { - - public static BString replaceFromString(BRegexpValue regExp, BString str, BString replacingStr, int startIndex) { - return replaceFromString(regExp, str, replacingStr, startIndex, false); - } - - public static BString replaceAllFromString(BRegexpValue regExp, BString str, BString replacingStr, int startIndex) { - return replaceFromString(regExp, str, replacingStr, startIndex, true); - } - - private static BString replaceFromString(BRegexpValue regExp, BString str, BString replacingStr, int startIndex, - boolean isReplaceAll) { - String originalStr = str.getValue(); - String replacementString = replacingStr.getValue(); - String prefixStr = ""; - String subStr = originalStr; - if (startIndex != 0) { - prefixStr = originalStr.substring(0, startIndex); - subStr = originalStr.substring(startIndex); - } - Matcher matcher = RegexUtil.getMatcher(regExp, subStr); - if (matcher.find()) { - String updatedSubStr; - if (isReplaceAll) { - updatedSubStr = matcher.replaceAll(replacementString); - } else { - updatedSubStr = matcher.replaceFirst(replacementString); - } - return StringUtils.fromString(prefixStr + updatedSubStr); - } - return str; - } -} diff --git a/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/Split.java b/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/Split.java new file mode 100644 index 000000000000..d625f1dbbc5a --- /dev/null +++ b/langlib/lang.regexp/src/main/java/org/ballerinalang/langlib/regexp/Split.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.ballerinalang.langlib.regexp; + +import io.ballerina.runtime.api.utils.StringUtils; +import io.ballerina.runtime.api.values.BArray; +import io.ballerina.runtime.api.values.BRegexpValue; +import io.ballerina.runtime.api.values.BString; +import io.ballerina.runtime.internal.regexp.RegExpFactory; +import io.ballerina.runtime.internal.values.RegExpValue; + +/** + * Native implementation of lang.regexp:split(string). + * + * @since 2201.3.0 + */ +public class Split { + + public static BArray split(BRegexpValue regExp, BString str) { + String originalString = str.getValue(); + RegExpValue translatedRegExpVal = RegExpFactory.translateRegExpConstructs((RegExpValue) regExp); + String regex = StringUtils.getStringValue(translatedRegExpVal, null); + String[] splitStrArr = originalString.split(regex); + if (splitStrArr.length == 0) { + splitStrArr = new String[]{originalString}; + } + return StringUtils.fromStringArray(splitStrArr); + } +} diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index 3c28d0f98fab..3c712f3f62ff 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -21,8 +21,6 @@ import ballerina/lang.regexp; @builtinSubtype type Char string; -public type RegExp regexp:RegExp; - # Returns the length of the string. # # + str - the string @@ -311,13 +309,27 @@ public isolated function padZero(string str, int len, Char zeroChar = "0") retur name: "padZero" } external; -# True if there is a match of `re` against all of `str`. -# Use `includesMatch` to test whether `re` matches somewhere in `str`. -public function matches(string str, RegExp 're) returns boolean { - return 're.isFullMatch(str); +# Refers to the `RegExp` type defined by lang.regexp module. +public type RegExp regexp:RegExp; + +# Tests whether there is a full match of a regular expression with a string. +# A match of a regular expression in a string is a full match if it +# starts at index 0 and ends at index `n`, where `n` is the length of the string. +# This is equivalent to `regex:isFullMatch(re, str)`. +# +# + str - the string +# + re - the regular expression +# + return - true if there is full match of `re` with `str`, and false otherwise +public function matches(string str, RegExp re) returns boolean { + return re.isFullMatch(str); } -# True if there is a match for `re` anywhere in `str` -public function includesMatch(string str, RegExp 're, int startIndex = 0) returns boolean { - return 're.find(str, startIndex) != (); +# Tests whether there is a match of a regular expression somewhere within a string. +# This is equivalent to `regexp:find(re, str, startIndex) != ()`. +# +# + str - the string to be matched +# + re - the regular expression +# + return - true if the is a match of `re` somewhere within `str`, otherwise false +public function includesMatch(string str, RegExp re, int startIndex = 0) returns boolean { + return re.find(str, startIndex) != (); } diff --git a/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/LangLibRegexpTest.java b/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/LangLibRegexpTest.java index 63570b9831ea..0dd49029dcc0 100644 --- a/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/LangLibRegexpTest.java +++ b/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/LangLibRegexpTest.java @@ -65,7 +65,8 @@ public Object[] testRegexLangLibFunctions() { "testFindAllGroups", "testFromString", "testFromStringNegative", - "testLangLibFuncWithNamedArgExpr" + "testLangLibFuncWithNamedArgExpr", + "testSplit" }; } } diff --git a/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/LangLibStringTest.java b/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/LangLibStringTest.java index 4537b5f08701..be3e94b2c09d 100644 --- a/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/LangLibStringTest.java +++ b/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/LangLibStringTest.java @@ -349,6 +349,17 @@ public void testPadZero() { BRunUtil.invoke(compileResult, "testPadZero"); } + @Test + public void testMatches() { + BRunUtil.invoke(compileResult, "testMatches"); + } + + @Test + public void testIncludesMatch() { + BRunUtil.invoke(compileResult, "testIncludesMatch"); + } + + @Test public void stringlibNegativeTest() { int err = 0; diff --git a/langlib/langlib-test/src/test/resources/test-src/regexp_test.bal b/langlib/langlib-test/src/test/resources/test-src/regexp_test.bal index 24885f03df84..a3657377883e 100644 --- a/langlib/langlib-test/src/test/resources/test-src/regexp_test.bal +++ b/langlib/langlib-test/src/test/resources/test-src/regexp_test.bal @@ -80,33 +80,13 @@ function testFindGroups() { regexp:Groups? res2 = regExpr2.findGroups(str2); assertTrue(res2 is regexp:Groups); regexp:Groups resultGroups2 = res2; - assertEquality(5, resultGroups2.length()); + assertEquality(1, resultGroups2.length()); regexp:Span resultSpan2_1 = resultGroups2[0]; assertEquality(0, resultSpan2_1.startIndex); assertEquality(3, resultSpan2_1.endIndex); assertEquality("GFG", resultSpan2_1.substring()); - regexp:Span resultSpan2_2 = resultGroups2[1]; - assertEquality(4, resultSpan2_2.startIndex); - assertEquality(7, resultSpan2_2.endIndex); - assertEquality("GFG", resultSpan2_2.substring()); - - regexp:Span resultSpan2_3 = resultGroups2[2]; - assertEquality(8, resultSpan2_3.startIndex); - assertEquality(11, resultSpan2_3.endIndex); - assertEquality("GFG", resultSpan2_3.substring()); - - regexp:Span resultSpan2_4 = resultGroups2[3]; - assertEquality(12, resultSpan2_4.startIndex); - assertEquality(15, resultSpan2_4.endIndex); - assertEquality("GFG", resultSpan2_4.substring()); - - regexp:Span resultSpan2_5 = resultGroups2[4]; - assertEquality(16, resultSpan2_5.startIndex); - assertEquality(19, resultSpan2_5.endIndex); - assertEquality("GFG", resultSpan2_5.substring()); - regexp:Groups? res3 = regExpr2.findGroups(str2, 15); assertTrue(res3 is regexp:Groups); regexp:Groups resultGroups3 = res3; @@ -128,158 +108,73 @@ function testFindGroups() { assertEquality("GFGFGF", resultSpan3_1.substring()); regexp:Span resultSpan3_2 = resultGroups4[1]; - assertEquality(6, resultSpan3_2.startIndex); - assertEquality(12, resultSpan3_2.endIndex); - assertEquality("GFGFGF", resultSpan3_2.substring()); + assertEquality(0, resultSpan3_2.startIndex); + assertEquality(3, resultSpan3_2.endIndex); + assertEquality("GFG", resultSpan3_2.substring()); regexp:Span resultSpan3_3 = resultGroups4[2]; - assertEquality(12, resultSpan3_3.startIndex); - assertEquality(18, resultSpan3_3.endIndex); - assertEquality("GFGFGF", resultSpan3_3.substring()); + assertEquality(3, resultSpan3_3.startIndex); + assertEquality(6, resultSpan3_3.endIndex); + assertEquality("FGF", resultSpan3_3.substring()); string str3 = "Betty Botter bought some butter but she said the butter’s bitter."; var regExpr4 = re `[bB].tt[a-z]*`; regexp:Groups? res5 = regExpr4.findGroups(str3); assertTrue(res5 is regexp:Groups); regexp:Groups resultGroups5 = res5; - assertEquality(5, resultGroups5.length()); + assertEquality(1, resultGroups5.length()); regexp:Span resultSpan5_1 = resultGroups5[0]; assertEquality(0, resultSpan5_1.startIndex); assertEquality(5, resultSpan5_1.endIndex); assertEquality("Betty", resultSpan5_1.substring()); - regexp:Span resultSpan5_2 = resultGroups5[1]; - assertEquality(6, resultSpan5_2.startIndex); - assertEquality(12, resultSpan5_2.endIndex); - assertEquality("Botter", resultSpan5_2.substring()); - string str4 = "ABC&&DEF"; var regExpr5 = re `[C&&D]`; regexp:Groups? res6 = regExpr5.findGroups(str4); assertTrue(res6 is regexp:Groups); regexp:Groups resultGroups6 = res6; - assertEquality(4, resultGroups6.length()); + assertEquality(1, resultGroups6.length()); regexp:Span resultSpan6_1 = resultGroups6[0]; assertEquality(2, resultSpan6_1.startIndex); assertEquality(3, resultSpan6_1.endIndex); assertEquality("C", resultSpan6_1.substring()); - regexp:Span resultSpan6_2 = resultGroups6[1]; - assertEquality(3, resultSpan6_2.startIndex); - assertEquality(4, resultSpan6_2.endIndex); - assertEquality("&", resultSpan6_2.substring()); - - regexp:Span resultSpan6_3 = resultGroups6[2]; - assertEquality(4, resultSpan6_3.startIndex); - assertEquality(5, resultSpan6_3.endIndex); - assertEquality("&", resultSpan6_3.substring()); - - regexp:Span resultSpan6_4 = resultGroups6[3]; - assertEquality(5, resultSpan6_4.startIndex); - assertEquality(6, resultSpan6_4.endIndex); - assertEquality("D", resultSpan6_4.substring()); - string str5 = "A B\nC\tD\rE"; var regExpr6 = re `.`; regexp:Groups? res7 = regExpr6.findGroups(str5); assertTrue(res7 is regexp:Groups); regexp:Groups resultGroups7 = res7; - assertEquality(7, resultGroups7.length()); + assertEquality(1, resultGroups7.length()); regexp:Span resultSpan7_1 = resultGroups7[0]; assertEquality(0, resultSpan7_1.startIndex); assertEquality(1, resultSpan7_1.endIndex); assertEquality("A", resultSpan7_1.substring()); - regexp:Span resultSpan7_2 = resultGroups7[1]; - assertEquality(1, resultSpan7_2.startIndex); - assertEquality(2, resultSpan7_2.endIndex); - assertEquality(" ", resultSpan7_2.substring()); - - regexp:Span resultSpan7_3 = resultGroups7[2]; - assertEquality(2, resultSpan7_3.startIndex); - assertEquality(3, resultSpan7_3.endIndex); - assertEquality("B", resultSpan7_3.substring()); - - regexp:Span resultSpan7_4 = resultGroups7[3]; - assertEquality(4, resultSpan7_4.startIndex); - assertEquality(5, resultSpan7_4.endIndex); - assertEquality("C", resultSpan7_4.substring()); - - regexp:Span resultSpan7_5 = resultGroups7[4]; - assertEquality(5, resultSpan7_5.startIndex); - assertEquality(6, resultSpan7_5.endIndex); - assertEquality("\t", resultSpan7_5.substring()); - - regexp:Span resultSpan7_6 = resultGroups7[5]; - assertEquality(6, resultSpan7_6.startIndex); - assertEquality(7, resultSpan7_6.endIndex); - assertEquality("D", resultSpan7_6.substring()); - - regexp:Span resultSpan7_7 = resultGroups7[6]; - assertEquality(8, resultSpan7_7.startIndex); - assertEquality(9, resultSpan7_7.endIndex); - assertEquality("E", resultSpan7_7.substring()); - string str6 = "A B\nC\tD\rE"; var regExpr7 = re `\s`; regexp:Groups? res8 = regExpr7.findGroups(str6); assertTrue(res8 is regexp:Groups); regexp:Groups resultGroups8 = res8; - assertEquality(4, resultGroups8.length()); + assertEquality(1, resultGroups8.length()); regexp:Span resultSpan8_1 = resultGroups8[0]; assertEquality(1, resultSpan8_1.startIndex); assertEquality(2, resultSpan8_1.endIndex); assertEquality(" ", resultSpan8_1.substring()); - regexp:Span resultSpan8_2 = resultGroups8[1]; - assertEquality(3, resultSpan8_2.startIndex); - assertEquality(4, resultSpan8_2.endIndex); - assertEquality("\n", resultSpan8_2.substring()); - - regexp:Span resultSpan8_3 = resultGroups8[2]; - assertEquality(5, resultSpan8_3.startIndex); - assertEquality(6, resultSpan8_3.endIndex); - assertEquality("\t", resultSpan8_3.substring()); - - regexp:Span resultSpan8_4 = resultGroups8[3]; - assertEquality(7, resultSpan8_4.startIndex); - assertEquality(8, resultSpan8_4.endIndex); - assertEquality("\r", resultSpan8_4.substring()); - var regExpr8 = re `\S`; regexp:Groups? res9 = regExpr8.findGroups(str6); assertTrue(res9 is regexp:Groups); regexp:Groups resultGroups9 = res9; - assertEquality(5, resultGroups9.length()); + assertEquality(1, resultGroups9.length()); regexp:Span resultSpan9_1 = resultGroups9[0]; assertEquality(0, resultSpan9_1.startIndex); assertEquality(1, resultSpan9_1.endIndex); assertEquality("A", resultSpan9_1.substring()); - - regexp:Span resultSpan9_2 = resultGroups9[1]; - assertEquality(2, resultSpan9_2.startIndex); - assertEquality(3, resultSpan9_2.endIndex); - assertEquality("B", resultSpan9_2.substring()); - - regexp:Span resultSpan9_3 = resultGroups9[2]; - assertEquality(4, resultSpan9_3.startIndex); - assertEquality(5, resultSpan9_3.endIndex); - assertEquality("C", resultSpan9_3.substring()); - - regexp:Span resultSpan9_4 = resultGroups9[3]; - assertEquality(6, resultSpan9_4.startIndex); - assertEquality(7, resultSpan9_4.endIndex); - assertEquality("D", resultSpan9_4.substring()); - - regexp:Span resultSpan9_5 = resultGroups9[4]; - assertEquality(8, resultSpan9_5.startIndex); - assertEquality(9, resultSpan9_5.endIndex); - assertEquality("E", resultSpan9_5.substring()); } function testFindAll() { @@ -449,7 +344,7 @@ function testFindAllGroups() { string:RegExp regExpr4 = re `a|b`; regexp:Groups[] groupsArr4 = regExpr4.findAllGroups(str2); - assertEquality(1, groupsArr4.length()); + assertEquality(4, groupsArr4.length()); regexp:Groups groups4_1 = groupsArr4[0]; regexp:Span? resultSpanOrNil4_1_1 = groups4_1[0]; @@ -662,11 +557,11 @@ function testReplaceAll() { string str5 = "100000100011"; string result5 = regExpr4.replaceAll(str5, replacementFunctionForReplaceAll); - assertEquality("121211", result5); + assertEquality("151311", result5); } isolated function replacementFunctionForReplaceAll(regexp:Groups groups) returns string { - return groups.length().toString(); + return groups[0].substring().length().toString(); } function testFromString() { @@ -1035,6 +930,62 @@ function testFromStringNegative() { } } +function testSplit() { + string str1 = "abc cde efg"; + string[] arrExpected1 = ["abc", "cde", "efg"]; + var regExpr1 = re ` `; + string[] resArr1 = regExpr1.split(str1); + assertEquality(3, resArr1.length()); + assertEquality(arrExpected1, resArr1); + + string str2 = "abc,cde,efg"; + var regExpr2 = re `,`; + string[] resArr2 = regExpr2.split(str2); + assertEquality(3, resArr2.length()); + assertEquality(arrExpected1, resArr2); + + string str3 = "amal,,kamal,,nimal,,sunimal,"; + string[] arrExpected2 = ["amal", "kamal", "nimal", "sunimal,"]; + string[] resArr3 = re `,,`.split(str3); + assertEquality(4, resArr3.length()); + assertEquality(arrExpected2, resArr3); + + string[] arrExpected4 = [str3]; + string[] resArr4 = re ` `.split(str3); + assertEquality(1, resArr4.length()); + assertEquality(arrExpected4, resArr4); + + string str5 = "ballerina@geeks@wso2"; + string[] arrExpected5 = ["ballerina", "geeks", "wso2"]; + string[] resArr5 = re `@`.split(str5); + assertEquality(3, resArr5.length()); + assertEquality(arrExpected5, resArr5); + + string str6 = "ballerina.geeks.wso2"; + string[] arrExpected6 = [str6]; + string[] resArr6 = re `.`.split(str6); + assertEquality(1, resArr6.length()); + assertEquality(arrExpected6, resArr6); + + string str7 = "zzzzayyyybxxxxawwww"; + string[] arrExpected7 = ["zzzz", "yyyy", "xxxx", "wwww"]; + string[] resArr7 = re `[a-c]`.split(str7); + assertEquality(4, resArr7.length()); + assertEquality(arrExpected7, resArr7); + + string str8 = "apple|9|1.88;2.78|0#10"; + string[] resArr8 = re `[|;#]`.split(str8); + string[] arrExpected8 = ["apple", "9", "1.88", "2.78", "0", "10"]; + assertEquality(6, resArr8.length()); + assertEquality(arrExpected8, resArr8); + + string str9 = "1 2 3 4 5"; + string[] resArr9 = re `\s+`.split(str9); + string[] arrExpected9 = ["1", "2", "3", "4", "5"]; + assertEquality(5, resArr9.length()); + assertEquality(arrExpected9, resArr9); +} + function testLangLibFuncWithNamedArgExpr() { regexp:Span? res1 = regexp:find(re = re `World`, str = "HelloWorld"); assertTrue(res1 is regexp:Span); diff --git a/langlib/langlib-test/src/test/resources/test-src/stringlib_test.bal b/langlib/langlib-test/src/test/resources/test-src/stringlib_test.bal index 2c3c8912ffed..a3ac455e51a0 100644 --- a/langlib/langlib-test/src/test/resources/test-src/stringlib_test.bal +++ b/langlib/langlib-test/src/test/resources/test-src/stringlib_test.bal @@ -632,6 +632,61 @@ function testPadZero() { assertEquals("000", y38); } +function testMatches() { + string stringToMatch1 = "This Should Match"; + string:RegExp regex1 = re `Th.*ch`; + boolean result1 = stringToMatch1.matches(regex1); + assertTrue(result1); + + string:RegExp regex2 = re `Should`; + boolean result2 = stringToMatch1.matches(regex2); + assertFalse(result2); + + string stringToMatch3 = "abc1"; + string:RegExp regex3 = re `([a-z0-9]{5,})`; + boolean result3 = stringToMatch3.matches(regex3); + assertFalse(result3); + + string stringToMatch4 = "abc12"; + boolean result4 = stringToMatch4.matches(regex3); + assertTrue(result4); + + string stringToMatch5 = "abc123"; + boolean result5 = stringToMatch5.matches(regex3); + assertTrue(result5); +} + +function testIncludesMatch() { + string stringToMatch1 = "This Should Match"; + string:RegExp regex1 = re `Th.*ch`; + boolean result1 = stringToMatch1.includesMatch(regex1); + assertTrue(result1); + + string:RegExp regex2 = re `Should`; + boolean result2 = stringToMatch1.includesMatch(regex2); + assertTrue(result2); + + string stringToMatch3 = "abc1"; + string:RegExp regex3 = re `([a-z0-9]{5,})`; + boolean result3 = stringToMatch3.includesMatch(regex3); + assertFalse(result3); + + string stringToMatch4 = "Betty Botter bought some butter but she said the butter’s bitter."; + string:RegExp regex4 = re `[bB].tt[a-z]*`; + boolean result4 = stringToMatch4.includesMatch(regex4); + assertTrue(result4); + + string stringToMatch5 = "HelloWorld"; + string:RegExp regex5 = re `[0-9]`; + boolean result5 = stringToMatch5.includesMatch(regex5); + assertFalse(result5); + + string stringToMatch6 = "An apple is nice"; + string:RegExp regex6 = re `apple|orange|pear|banana|kiwi`; + boolean result6 = stringToMatch6.includesMatch(regex6); + assertTrue(result6); +} + const ASSERTION_ERROR_REASON = "AssertionError"; function assertEquals(anydata expected, anydata actual) { @@ -645,3 +700,11 @@ function assertEquals(anydata expected, anydata actual) { + "], but found [" + actual.toString() + "] of type [" + actT.toString() + "]"; panic error(ASSERTION_ERROR_REASON, message = msg); } + +function assertTrue(anydata actual) { + assertEquals(true, actual); +} + +function assertFalse(anydata actual) { + assertEquals(false, actual); +} From de53b66b9a7a62e039aba6f8f74632b4699ac297 Mon Sep 17 00:00:00 2001 From: gabilang Date: Tue, 13 Dec 2022 16:40:36 +0530 Subject: [PATCH 221/450] Fix failing test after sync with master --- .../safeErrorAssignmentWithQueryAction | 256 ++++++++++-------- 1 file changed, 148 insertions(+), 108 deletions(-) diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/bir/bir-dump/safeErrorAssignmentWithQueryAction b/tests/jballerina-unit-test/src/test/resources/test-src/bir/bir-dump/safeErrorAssignmentWithQueryAction index 2992bacfbfb7..bc42b2511dfb 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/bir/bir-dump/safeErrorAssignmentWithQueryAction +++ b/tests/jballerina-unit-test/src/test/resources/test-src/bir/bir-dump/safeErrorAssignmentWithQueryAction @@ -11,43 +11,46 @@ safeErrorAssignmentWithQueryAction function() -> error|() { %28(SYNTHETIC) int; %29(SYNTHETIC) int; %30(SYNTHETIC) int|error; - %39(SYNTHETIC) (); - %40(SYNTHETIC) error|(); - %41(SYNTHETIC) ballerina/lang.__internal:0.0.0:$anonType$return$createIntRange$_0; + %39(SYNTHETIC) ballerina/lang.__internal:0.0.0:$anonType$return$createIntRange$_0; + %41(SYNTHETIC) int; %43(SYNTHETIC) int; - %45(SYNTHETIC) int; - %49(TEMP) ballerina/lang.__internal:0.0.0:$anonType$return$createIntRange$_0; - %50(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamPipeline; - %51(SYNTHETIC) ballerina/lang.__internal:0.0.0:$anonType$return$createIntRange$_0; + %47(TEMP) ballerina/lang.__internal:0.0.0:$anonType$return$createIntRange$_0; + %48(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamPipeline; + %49(SYNTHETIC) ballerina/lang.__internal:0.0.0:$anonType$return$createIntRange$_0; + %51(SYNTHETIC) typeDesc; %53(SYNTHETIC) typeDesc; - %55(SYNTHETIC) typeDesc; - %61(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamFunction; - %62(SYNTHETIC) function(ballerina/lang.query:0.0.0:_Frame) -> ballerina/lang.query:0.0.0:_Frame|error|(); - %66(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamPipeline; - %68(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamFunction; - %72(TEMP) (); - %73(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamFunction; - %74(SYNTHETIC) function(ballerina/lang.query:0.0.0:_Frame) -> any|error; - %78(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamPipeline; - %80(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamFunction; - %84(TEMP) (); - %85(SYNTHETIC) stream, typeRefDesc<>>; - %86(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamPipeline; - %90(SYNTHETIC) error|(); + %55(SYNTHETIC) boolean; + %62(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamFunction; + %63(SYNTHETIC) function(ballerina/lang.query:0.0.0:_Frame) -> ballerina/lang.query:0.0.0:_Frame|error|(); + %67(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamPipeline; + %69(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamFunction; + %73(TEMP) (); + %74(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamFunction; + %75(SYNTHETIC) function(ballerina/lang.query:0.0.0:_Frame) -> any|error; + %79(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamPipeline; + %81(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamFunction; + %85(TEMP) (); + %86(SYNTHETIC) stream, typeRefDesc<>>; + %87(SYNTHETIC) ballerina/lang.query:0.0.0:_StreamPipeline; + %91(SYNTHETIC) any|error{map}; %92(SYNTHETIC) stream, typeRefDesc<>>; - %95(TEMP) any|error{map}; - %98(TEMP) boolean; - %109(SYNTHETIC) (); - %110(SYNTHETIC) typeRefDesc<>|(); - %119(SYNTHETIC) (); - %120(SYNTHETIC) error{map}|(); - %128(LOCAL) string; - %130(SYNTHETIC) (); - %131(SYNTHETIC) error|(); - %140(SYNTHETIC) (); - %141(SYNTHETIC) Error|(); - %151(SYNTHETIC) (); - %152(SYNTHETIC) Error|(); + %99(SYNTHETIC) error{map}; + %103(TEMP) error{map}; + %104(SYNTHETIC) boolean; + %117(TEMP) error{map}; + %118(SYNTHETIC) error; + %131(TEMP) error|(); + %133(SYNTHETIC) (); + %134(SYNTHETIC) typeRefDesc<>|(); + %143(SYNTHETIC) (); + %144(SYNTHETIC) error|(); + %152(LOCAL) string; + %154(SYNTHETIC) (); + %155(SYNTHETIC) error|(); + %164(SYNTHETIC) (); + %165(SYNTHETIC) Error|(); + %175(SYNTHETIC) (); + %176(SYNTHETIC) Error|(); bb0 { %2 = foo() -> bb1; @@ -80,11 +83,11 @@ safeErrorAssignmentWithQueryAction function() -> error|() { bb7 { %8 = %16; %0 = %8; - GOTO bb47; + GOTO bb56; } bb8 { %0 = %11; - GOTO bb47; + GOTO bb56; } bb9 { %30 = bar() -> bb10; @@ -103,147 +106,184 @@ safeErrorAssignmentWithQueryAction function() -> error|() { } bb13 { %28 = %29; - %43 = ConstLoad 1; - %45 = ConstLoad 2; - %49 = createIntRange(%43, %45) -> bb14; + %41 = ConstLoad 1; + %43 = ConstLoad 2; + %47 = createIntRange(%41, %43) -> bb14; } bb14 { - %41 = %49; - %51 = %41; + %39 = %47; + %49 = %39; + %51 = newType error|(); %53 = newType error|(); - %55 = newType error|(); - %50 = createPipeline(%51, %53, %55) -> bb15; + %55 = ConstLoad false; + %48 = createPipeline(%49, %51, %53, %55) -> bb15; } bb15 { - %62 = fp $anon/.:0.0.0::$streamLambda$_0; - %61 = createInputFunction(%62) -> bb16; + %63 = fp $anon/.:0.0.0::$streamLambda$_0; + %62 = createInputFunction(%63) -> bb16; } bb16 { - %66 = %50; - %68 = %61; - %72 = addStreamFunction(%66, %68) -> bb17; + %67 = %48; + %69 = %62; + %73 = addStreamFunction(%67, %69) -> bb17; } bb17 { - %74 = fp $anon/.:0.0.0::$streamLambda$_1; - %73 = createDoFunction(%74) -> bb18; + %75 = fp $anon/.:0.0.0::$streamLambda$_1; + %74 = createDoFunction(%75) -> bb18; } bb18 { - %78 = %50; - %80 = %73; - %84 = addStreamFunction(%78, %80) -> bb19; + %79 = %48; + %81 = %74; + %85 = addStreamFunction(%79, %81) -> bb19; } bb19 { - %86 = %50; - %85 = getStreamFromPipeline(%86) -> bb20; + %87 = %48; + %86 = getStreamFromPipeline(%87) -> bb20; } bb20 { - %92 = %85; - %95 = consumeStream(%92) -> bb21; + %92 = %86; + %91 = consumeStream(%92) -> bb21; } bb21 { - %90 = %95; - %4 = %90 is (); - %98 = not %4; - %98? bb22 : bb23; + %4 = %91 is error{map}; + %4? bb22 : bb24; } bb22 { - %0 = %90; - GOTO bb47; + %99 = %91; + %103 = getQueryErrorRootCause(%99) -> bb23; } bb23 { - %40 = %90; - %4 = %40 is (); - %4? bb24 : bb25; + %0 = %103; + GOTO bb56; } bb24 { - %39 = <()> %40; - GOTO bb26; + %4 = %91 is (); + %4? bb25 : bb26; } bb25 { - %8 = %40; - GOTO bb4; + %104 = ConstLoad true; + GOTO bb27; } bb26 { - %110 = baz() -> bb27; + %104 = %91 is error{map}; + GOTO bb27; } bb27 { - %98 = %110 is (); - %98? bb28 : bb29; + %4 = not %104; + %4? bb28 : bb29; } bb28 { - %109 = <()> %110; - GOTO bb30; + %0 = %91; + GOTO bb56; } bb29 { - %8 = %110; - GOTO bb4; + %4 = %91 is ballerina/lang.query:0.0.0:CompleteEarlyError|ballerina/lang.query:0.0.0:Error; + %4? bb30 : bb32; } bb30 { - %120 = foo() -> bb31; + %118 = %91; + %103 = getQueryErrorRootCause(%118) -> bb31; } bb31 { - %4 = %120 is (); - %4? bb32 : bb33; + %117 = %103; + %91 = }> %117; + GOTO bb32; } bb32 { - %119 = <()> %120; - GOTO bb42; + %4 = %91 is ballerina/lang.query:0.0.0:CompleteEarlyError|ballerina/lang.query:0.0.0:Error; + %4? bb33 : bb35; } bb33 { - %8 = %120; - GOTO bb34; + %118 = }> %91; + %103 = getQueryErrorRootCause(%118) -> bb34; } bb34 { - %128 = ConstLoad abc; - %131 = foo() -> bb35; + %117 = %103; + %91 = }> %117; + GOTO bb35; } bb35 { - %98 = %131 is (); - %98? bb36 : bb37; + %131 = }|()> %91; + %134 = baz() -> bb36; } bb36 { - %130 = <()> %131; - GOTO bb38; + %4 = %134 is (); + %4? bb37 : bb38; } bb37 { - %8 = %131; - GOTO bb4; + %133 = <()> %134; + GOTO bb39; } bb38 { - %141 = baz() -> bb39; + %8 = %134; + GOTO bb4; } bb39 { - %4 = %141 is (); - %4? bb40 : bb41; + %144 = foo() -> bb40; } bb40 { - %140 = <()> %141; - GOTO bb46; + %4 = %144 is (); + %4? bb41 : bb42; } bb41 { - %8 = %141; - GOTO bb4; + %143 = <()> %144; + GOTO bb51; } bb42 { - %152 = baz() -> bb43; + %8 = %144; + GOTO bb43; } bb43 { - %98 = %152 is (); - %98? bb44 : bb45; + %152 = ConstLoad abc; + %155 = foo() -> bb44; } bb44 { - %151 = <()> %152; - GOTO bb46; + %4 = %155 is (); + %4? bb45 : bb46; } bb45 { - %8 = %152; - GOTO bb34; + %154 = <()> %155; + GOTO bb47; } bb46 { - %0 = ConstLoad 0; - GOTO bb47; + %8 = %155; + GOTO bb4; } bb47 { + %165 = baz() -> bb48; + } + bb48 { + %4 = %165 is (); + %4? bb49 : bb50; + } + bb49 { + %164 = <()> %165; + GOTO bb55; + } + bb50 { + %8 = %165; + GOTO bb4; + } + bb51 { + %176 = baz() -> bb52; + } + bb52 { + %4 = %176 is (); + %4? bb53 : bb54; + } + bb53 { + %175 = <()> %176; + GOTO bb55; + } + bb54 { + %8 = %176; + GOTO bb43; + } + bb55 { + %0 = ConstLoad 0; + GOTO bb56; + } + bb56 { return; } From ac92cb83ba42080fdd84bda52c5e3326a76a48da Mon Sep 17 00:00:00 2001 From: gabilang Date: Tue, 13 Dec 2022 17:07:02 +0530 Subject: [PATCH 222/450] Add default case to the switch statement --- .../runtime/internal/TypeConverter.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeConverter.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeConverter.java index 186609d57388..de3c050bfc33 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeConverter.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TypeConverter.java @@ -931,16 +931,19 @@ public static Double stringToFloat(String value) throws NumberFormatException { public static boolean hasFloatOrDecimalLiteralSuffix(String value) { int length = value.length(); - if (length != 0) { - switch (value.substring(value.length() - 1)) { - case "F": - case "f": - case "D": - case "d": - return true; - } + if (length == 0) { + return false; + } + + switch (value.charAt(length - 1)) { + case 'F': + case 'f': + case 'D': + case 'd': + return true; + default: + return false; } - return false; } public static Boolean stringToBoolean(String value) throws NumberFormatException { From 5f5c454e2e46ed851d2d2c14c110da373b4779a9 Mon Sep 17 00:00:00 2001 From: mohan Date: Tue, 13 Dec 2022 18:24:20 +0530 Subject: [PATCH 223/450] Add revamped examples for streams langlib --- .../lang.stream/src/main/ballerina/stream.bal | 49 ++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/langlib/lang.stream/src/main/ballerina/stream.bal b/langlib/lang.stream/src/main/ballerina/stream.bal index f9ba35359565..b498479547e9 100644 --- a/langlib/lang.stream/src/main/ballerina/stream.bal +++ b/langlib/lang.stream/src/main/ballerina/stream.bal @@ -43,6 +43,12 @@ type Type1 any|error; # Selects the members from a stream for which a function returns true. # +# ```ballerina +# stream scoreStream = [45, 60, 75, 30, 90].toStream(); +# stream filtered = scoreStream.filter(score => score > 50); +# filtered.next() ⇒ {"value":60} +# ``` +# # + stm - the stream # + func - a predicate to apply to each member to test whether it should be selected # + return - new stream only containing members of parameter `stm` for which parameter `func` evaluates to true @@ -55,6 +61,11 @@ public isolated function filter(stream stm, @isolatedParam # Returns the next element in the stream wrapped in a record or () if the stream ends. # +# ```ballerina +# stream greetingStream = ["Hello", "Bonjour", "Hola", "Ciao"].toStream(); +# greetingStream.next() ⇒ {"value":"Hello"} +# ``` +# # + stm - The stream # + return - If the stream has elements, return the element wrapped in a record with single field called `value`, # otherwise returns () @@ -76,6 +87,12 @@ public isolated function next(stream stm) returns record { # Applies a function to each member of a stream and returns a stream of the results. # +# ```ballerina +# stream ms = [14.5f, 45.5f, 6.8f, 4f].toStream(); +# stream cms = ms.'map(m => m * 100.0); +# cms.next() ⇒ {"value":1450.0} +# ``` +# # + stm - the stream # + func - a function to apply to each member # + return - new stream containing result of applying parameter `func` to each member of parameter `stm` in order @@ -91,6 +108,11 @@ public isolated function 'map(stream stm, @isolatedParam fu # The combining function takes the combined value so far and a member of the stream, # and returns a new combined value. # +# ```ballerina +# stream scoreStream = [45, 60, 75, 30, 90].toStream(); +# scoreStream.reduce(isolated function (int total, int score) returns int => total + score, 0) ⇒ 300 +# ``` +# # + stm - the stream # + func - combining function # + initial - initial value for the first argument of combining parameter `func` @@ -115,6 +137,15 @@ public isolated function reduce(stream stm, # # The parameter `func` is applied to each member of parameter `stm` stream in order. # +# ```ballerina +# stream scoreStream = [45, 60, 75, 30, 90].toStream(); +# int total = 0; +# scoreStream.forEach(function(int score) { +# total += score; +# }); +# total ⇒ 300 +# ``` +# # + stm - the stream # + func - a function to apply to each member # + return - () if the close completed successfully, otherwise an error @@ -136,6 +167,14 @@ public isolated function forEach(stream stm, # Returns an iterator over a stream. # +# ```ballerina +# stream scoreStream = [45, 60, 75, 30, 90].toStream(); +# object { +# public isolated function next() returns record {|int value;|}?; +# } iterator = scoreStream.iterator(); +# iterator.next() ⇒ {"value":45} +# ``` +# # + stm - the stream # + return - a new iterator object that will iterate over the members of parameter `stm`. public isolated function iterator(stream stm) returns object { @@ -148,8 +187,14 @@ public isolated function iterator(stream stm) returns objec # Closes a stream. # +# ```ballerina +# stream scoreStream = [45, 60, 75, 30, 90].toStream(); +# _ = scoreStream.close(); +# scoreStream.next() ⇒ {"value":45} +# ``` +# # This releases any system resources being used by the stream. -# Closing a stream that has already been closed has no efffect and returns `()`. +# Closing a stream that has already been closed has no effect and returns `()`. # # + stm - the stream to close # + return - () if the close completed successfully, otherwise an error @@ -162,4 +207,4 @@ public isolated function close(stream stm) returns Completi return itrObj.close(); } return; -} +} \ No newline at end of file From 82b2b7cc6397ad23c1130d397faa12a162d81f56 Mon Sep 17 00:00:00 2001 From: mohan Date: Tue, 13 Dec 2022 18:48:22 +0530 Subject: [PATCH 224/450] Fix test cases due to doc changes --- .../extensions/symbol/SymbolDocumentationTest.java | 12 ++++++++++-- .../signature/expressions/config/exprLangLibs1.json | 2 +- .../signature/expressions/config/exprLangLibs2.json | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolDocumentationTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolDocumentationTest.java index 5a0be727f4ec..c777ff635205 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolDocumentationTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolDocumentationTest.java @@ -204,7 +204,11 @@ public void testLangLibDocumentation() throws IOException { Assert.assertNotEquals(symbolInfoResponse.getDocumentation(), null); Assert.assertEquals(symbolInfoResponse.getDocumentation().getDescription(), - "Returns the length of the string.\n"); + "Returns the length of the string.\n" + + "\n" + + "```ballerina\n" + + "\"Hello, World!\".length() ⇒ 13;\n" + + "```\n"); Assert.assertEquals(symbolInfoResponse.getDocumentation().getReturnValueDescription(), "the number of characters (code points) in parameter `str`"); Assert.assertEquals(symbolInfoResponse.getDocumentation().getParameters(), null); @@ -224,7 +228,11 @@ public void testLangLibDocumentationWithQualifiedIdentifier() throws IOException Assert.assertNotEquals(symbolInfoResponse.getDocumentation(), null); Assert.assertEquals(symbolInfoResponse.getDocumentation().getDescription(), - "Returns the length of the string.\n"); + "Returns the length of the string.\n" + + "\n" + + "```ballerina\n" + + "\"Hello, World!\".length() ⇒ 13;\n" + + "```\n"); Assert.assertEquals(symbolInfoResponse.getDocumentation().getReturnValueDescription(), "the number of characters (code points) in parameter `str`"); Assert.assertEquals(symbolInfoResponse.getDocumentation().getParameters().get(0).getName(), "str"); diff --git a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json index c7b26ab00312..6d0dcd38efd6 100644 --- a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json +++ b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json @@ -12,7 +12,7 @@ "documentation": { "right": { "kind": "markdown", - "value": "**Description** \nReturns a substring of a string." + "value": "**Description** \nReturns a substring of a string.\n\n```ballerina\n\"Hello, my name is John\".substring(18, 22) \u21d2 \"John\"\n// Consider only the start index. In this situation,\n// input string length would be considered as end index.\n\"Hello, my name is John\".substring(7) \u21d2 \"my name is John\"\n```" } }, "parameters": [ diff --git a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json index 61f43f63f302..513cd51e08eb 100644 --- a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json +++ b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json @@ -12,7 +12,7 @@ "documentation": { "right": { "kind": "markdown", - "value": "**Description** \nReturns a substring of a string." + "value": "**Description** \nReturns a substring of a string.\n\n```ballerina\n\"Hello, my name is John\".substring(18, 22) \u21d2 \"John\"\n// Consider only the start index. In this situation,\n// input string length would be considered as end index.\n\"Hello, my name is John\".substring(7) \u21d2 \"my name is John\"\n```" } }, "parameters": [ From 28ab2ec6c6646fab2faa4dfb85fdd374f26cabbb Mon Sep 17 00:00:00 2001 From: Mohanadarshan V Date: Wed, 14 Dec 2022 12:18:50 +0530 Subject: [PATCH 225/450] Update langlib/lang.string/src/main/ballerina/string.bal Co-authored-by: Maryam Ziyad --- langlib/lang.string/src/main/ballerina/string.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index 3f7e75f1d936..0901b5682fe3 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -187,7 +187,7 @@ returns int? = @java:Method { # Tests whether a string includes another string. # # ```ballerina -# "Hello World! from Ballerina".includes("Bal") ⇒ true +# "Hello World, from Ballerina".includes("Bal") ⇒ true # # // Check for the occurrence of a string from a specific index onwards. # "Hello World! from Ballerina".includes("Hello", 10) ⇒ false From 6865067bef6505a6cfef09845817b54cbfa8152a Mon Sep 17 00:00:00 2001 From: Mohanadarshan V Date: Wed, 14 Dec 2022 12:19:33 +0530 Subject: [PATCH 226/450] Update langlib/lang.string/src/main/ballerina/string.bal Co-authored-by: Maryam Ziyad --- langlib/lang.string/src/main/ballerina/string.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index 0901b5682fe3..6a56608fcb02 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -206,7 +206,7 @@ public isolated function includes(string str, string substr, int startIndex = 0) # Tests whether a string starts with another string. # # ```ballerina -# "Welcome to Ballerina programming language".startsWith("Welcome") ⇒ true +# "Welcome to the Ballerina programming language".startsWith("Welcome") ⇒ true # ``` # # + str - the string to be tested From 7db2fe2513b50d7096d24304df1522c5ed1d504c Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 14 Dec 2022 12:37:34 +0530 Subject: [PATCH 227/450] Add fixes based on review comments --- langlib/lang.string/src/main/ballerina/string.bal | 12 ++++-------- .../extensions/symbol/SymbolDocumentationTest.java | 6 ++++-- .../signature/expressions/config/exprLangLibs1.json | 2 +- .../signature/expressions/config/exprLangLibs2.json | 2 +- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index 6a56608fcb02..f11a69bf0df3 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -25,8 +25,9 @@ public type RegExp regexp:RegExp; # Returns the length of the string. # -# ```ballerina -# "Hello, World!".length() ⇒ 13; +# ``` +# string greeting = "Hello, World!"; +# greeting.length() ⇒ 13; # ``` # # + str - the string @@ -89,11 +90,8 @@ public isolated function getCodePoint(string str, int index) returns int = @java # Returns a substring of a string. # # ```ballerina -# "Hello, my name is John".substring(18, 22) ⇒ "John" -# -# // Consider only the start index. In this situation, -# // input string length would be considered as end index. # "Hello, my name is John".substring(7) ⇒ "my name is John" +# "Hello, my name is John".substring(18, 22) ⇒ "John" # ``` # # + str - source string. @@ -128,10 +126,8 @@ public isolated function codePointCompare(string str1, string str2) returns int # Joins zero or more strings together with a separator. # # ```ballerina -# // Join multiple strings with space as the separator. # string:'join(" ", "Ballerina", "is", "a", "programming", "language") ⇒ "Ballerina is a programming language" # -# // Join multiple strings with comma as the separator. # string[] array = ["John", "23", "USA", "Computer Science", "Swimmer"]; # string:'join(",", ...array) ⇒ "John,23,USA,Computer Science,Swimmer" # ``` diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolDocumentationTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolDocumentationTest.java index c777ff635205..4d516f74bf9c 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolDocumentationTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolDocumentationTest.java @@ -207,7 +207,8 @@ public void testLangLibDocumentation() throws IOException { "Returns the length of the string.\n" + "\n" + "```ballerina\n" + - "\"Hello, World!\".length() ⇒ 13;\n" + + "string greeting = \"Hello, World!\";\n" + + "greeting.length() ⇒ 13;\n" + "```\n"); Assert.assertEquals(symbolInfoResponse.getDocumentation().getReturnValueDescription(), "the number of characters (code points) in parameter `str`"); @@ -231,7 +232,8 @@ public void testLangLibDocumentationWithQualifiedIdentifier() throws IOException "Returns the length of the string.\n" + "\n" + "```ballerina\n" + - "\"Hello, World!\".length() ⇒ 13;\n" + + "string greeting = \"Hello, World!\";\n" + + "greeting.length() ⇒ 13;\n" + "```\n"); Assert.assertEquals(symbolInfoResponse.getDocumentation().getReturnValueDescription(), "the number of characters (code points) in parameter `str`"); diff --git a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json index 6d0dcd38efd6..aabd4b154fab 100644 --- a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json +++ b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json @@ -12,7 +12,7 @@ "documentation": { "right": { "kind": "markdown", - "value": "**Description** \nReturns a substring of a string.\n\n```ballerina\n\"Hello, my name is John\".substring(18, 22) \u21d2 \"John\"\n// Consider only the start index. In this situation,\n// input string length would be considered as end index.\n\"Hello, my name is John\".substring(7) \u21d2 \"my name is John\"\n```" + "value": "**Description** \nReturns a substring of a string.\n\n```ballerina\n\"Hello, my name is John\".substring(7) \u21d2 \"my name is John\"\n\"Hello, my name is John\".substring(18, 22) ⇒ \"John\"\n```" } }, "parameters": [ diff --git a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json index 513cd51e08eb..444fff6aab7d 100644 --- a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json +++ b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json @@ -12,7 +12,7 @@ "documentation": { "right": { "kind": "markdown", - "value": "**Description** \nReturns a substring of a string.\n\n```ballerina\n\"Hello, my name is John\".substring(18, 22) \u21d2 \"John\"\n// Consider only the start index. In this situation,\n// input string length would be considered as end index.\n\"Hello, my name is John\".substring(7) \u21d2 \"my name is John\"\n```" + "value": "**Description** \nReturns a substring of a string.\n\n```ballerina\n\"Hello, my name is John\".substring(7) \u21d2 \"my name is John\"\n\"Hello, my name is John\".substring(18, 22) ⇒ \"John\"\n```" } }, "parameters": [ From 1cc74e201f5edb6b35a14d5b977bccf33d07b4eb Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 14 Dec 2022 12:38:32 +0530 Subject: [PATCH 228/450] Add fixes based on review comments --- langlib/lang.string/src/main/ballerina/string.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index f11a69bf0df3..1307627c20d5 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -25,7 +25,7 @@ public type RegExp regexp:RegExp; # Returns the length of the string. # -# ``` +# ```ballerina # string greeting = "Hello, World!"; # greeting.length() ⇒ 13; # ``` From 64edfa0b1fd96226ab504e0c010cc7b0d7cb7a16 Mon Sep 17 00:00:00 2001 From: HindujaB Date: Wed, 14 Dec 2022 12:56:59 +0530 Subject: [PATCH 229/450] Move error type constants init to ordered call --- .../internal/values/TupleValueImpl.java | 17 -------------- .../compiler/bir/codegen/JvmConstants.java | 1 + .../bir/codegen/split/JvmConstantsGen.java | 4 ++++ .../bir/codegen/split/JvmCreateTypeGen.java | 5 ++++ .../constants/JvmErrorTypeConstantsGen.java | 23 +++++-------------- 5 files changed, 16 insertions(+), 34 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TupleValueImpl.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TupleValueImpl.java index 4ce72ad96336..4db430b27195 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TupleValueImpl.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TupleValueImpl.java @@ -393,23 +393,6 @@ public void add(long index, BString value) { // ------------------------------------------------------------------------------------------------------------- - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (o == null || getClass() != o.getClass()) { - return false; - } - - TupleValueImpl that = (TupleValueImpl) o; - return minSize == that.minSize && - hasRestElement == that.hasRestElement && - tupleType.equals(that.tupleType) && - Arrays.equals(refValues, that.refValues); - } - /** * Append value to the existing array. * diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java index 8f902109784a..d669a39756cc 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmConstants.java @@ -319,6 +319,7 @@ public class JvmConstants { public static final String B_TUPLE_TYPE_POPULATE_METHOD = "$populate_tuple_types"; public static final String B_ARRAY_TYPE_POPULATE_METHOD = "$populate_array_types"; public static final String B_TYPEREF_TYPE_POPULATE_METHOD = "$populate_typeref_types"; + public static final String B_ERROR_TYPE_POPULATE_METHOD = "$populate_error_typeS"; public static final String MODULE_INIT_METHOD_PREFIX = "$module_init"; public static final String CONSTANT_INIT_METHOD_PREFIX = "$constant_init"; public static final String ANNOTATIONS_METHOD_PREFIX = "$process_annotations"; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmConstantsGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmConstantsGen.java index b76e53125ef3..a9031ac8d52d 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmConstantsGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmConstantsGen.java @@ -162,6 +162,10 @@ public String getUnionTypeConstantClass() { return unionTypeConstantsGen.getUnionTypeConstantClass(); } + public String getErrorTypeConstantClass() { + return errorTypeConstantsGen.getErrorTypeConstantClass(); + } + public String getConstantClass() { return jvmBallerinaConstantsGen.getConstantClass(); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmCreateTypeGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmCreateTypeGen.java index 41e853047f34..c3c0829b132c 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmCreateTypeGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmCreateTypeGen.java @@ -94,6 +94,8 @@ import static org.wso2.ballerinalang.compiler.bir.codegen.JvmCodeGenUtil.getModuleLevelClassName; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_ARRAY_TYPE_INIT_METHOD; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_ARRAY_TYPE_POPULATE_METHOD; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_ERROR_TYPE_INIT_METHOD; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_ERROR_TYPE_POPULATE_METHOD; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_TUPLE_TYPE_INIT_METHOD; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_TUPLE_TYPE_POPULATE_METHOD; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_TYPEREF_TYPE_INIT_METHOD; @@ -188,16 +190,19 @@ void createTypeConstants(ClassWriter cw) { String arrayTypeConstantClass = jvmConstantsGen.getArrayTypeConstantClass(); String tupleTypeConstantsClass = jvmConstantsGen.getTupleTypeConstantsClass(); String unionTypeConstantClass = jvmConstantsGen.getUnionTypeConstantClass(); + String errorTypeConstantClass = jvmConstantsGen.getErrorTypeConstantClass(); mv.visitMethodInsn(INVOKESTATIC, refTypeConstantsClass, B_TYPEREF_TYPE_INIT_METHOD, "()V", false); mv.visitMethodInsn(INVOKESTATIC, arrayTypeConstantClass, B_ARRAY_TYPE_INIT_METHOD, "()V", false); mv.visitMethodInsn(INVOKESTATIC, tupleTypeConstantsClass, B_TUPLE_TYPE_INIT_METHOD, "()V", false); mv.visitMethodInsn(INVOKESTATIC, unionTypeConstantClass, B_UNION_TYPE_INIT_METHOD, "()V", false); + mv.visitMethodInsn(INVOKESTATIC, errorTypeConstantClass, B_ERROR_TYPE_INIT_METHOD, "()V", false); mv.visitMethodInsn(INVOKESTATIC, refTypeConstantsClass, B_TYPEREF_TYPE_POPULATE_METHOD, "()V", false); mv.visitMethodInsn(INVOKESTATIC, arrayTypeConstantClass, B_ARRAY_TYPE_POPULATE_METHOD, "()V", false); mv.visitMethodInsn(INVOKESTATIC, tupleTypeConstantsClass, B_TUPLE_TYPE_POPULATE_METHOD, "()V", false); mv.visitMethodInsn(INVOKESTATIC, unionTypeConstantClass, B_UNION_TYPE_POPULATE_METHOD, "()V", false); + mv.visitMethodInsn(INVOKESTATIC, errorTypeConstantClass, B_ERROR_TYPE_POPULATE_METHOD, "()V", false); mv.visitInsn(RETURN); mv.visitMaxs(0, 0); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmErrorTypeConstantsGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmErrorTypeConstantsGen.java index 94117c3df3ca..657112005eb3 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmErrorTypeConstantsGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmErrorTypeConstantsGen.java @@ -41,7 +41,8 @@ import static org.objectweb.asm.Opcodes.ACC_STATIC; import static org.objectweb.asm.Opcodes.GETSTATIC; import static org.objectweb.asm.Opcodes.INVOKESTATIC; -import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_ERROR_TYPE_INIT_METHOD_PREFIX; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_ERROR_TYPE_INIT_METHOD; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.B_ERROR_TYPE_POPULATE_METHOD; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.GET_ERROR_TYPE_IMPL; import static org.wso2.ballerinalang.compiler.bir.codegen.split.constants.JvmConstantGenCommons.genMethodReturn; import static org.wso2.ballerinalang.compiler.bir.codegen.split.constants.JvmConstantGenCommons.generateConstantsClassInit; @@ -68,7 +69,7 @@ public JvmErrorTypeConstantsGen(PackageID packageID, BTypeHashComparator bTypeHa JvmConstants.ERROR_TYPE_CONSTANT_CLASS_NAME); cw = new BallerinaClassWriter(COMPUTE_FRAMES); generateConstantsClassInit(cw, errorVarConstantsClass); - visitErrorTypeInitMethod(); + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, B_ERROR_TYPE_INIT_METHOD, "()V", null, null); funcNames = new ArrayList<>(); errorTypeVarMap = new TreeMap<>(bTypeHashComparator); } @@ -86,11 +87,6 @@ public String add(BErrorType type) { return varName; } - private void visitErrorTypeInitMethod() { - mv = cw.visitMethod(ACC_STATIC, B_ERROR_TYPE_INIT_METHOD_PREFIX + methodCount++, - "()V", null, null); - } - private String generateBErrorInits(BErrorType type) { String varName = JvmConstants.ERROR_TYPE_VAR_PREFIX + constantIndex++; visitBErrorField(varName); @@ -128,23 +124,16 @@ public void generateGetBErrorType(MethodVisitor mv, String varName) { public void generateClass(Map jarEntries) { genMethodReturn(mv); - visitErrorTypeInitMethod(); + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, B_ERROR_TYPE_POPULATE_METHOD, "()V", null, null); for (String funcName : funcNames) { mv.visitMethodInsn(INVOKESTATIC, errorVarConstantsClass, funcName, "()V", false); } genMethodReturn(mv); - generateStaticInitializer(cw); cw.visitEnd(); jarEntries.put(errorVarConstantsClass + ".class", cw.toByteArray()); } - private void generateStaticInitializer(ClassWriter cw) { - MethodVisitor methodVisitor = cw.visitMethod(ACC_STATIC, "", "()V", null, null); - for (int i = 0; i < methodCount; i++) { - methodVisitor.visitMethodInsn(INVOKESTATIC, errorVarConstantsClass, - B_ERROR_TYPE_INIT_METHOD_PREFIX + i, - "()V", false); - } - genMethodReturn(methodVisitor); + public String getErrorTypeConstantClass() { + return this.errorVarConstantsClass; } } From 82d135f1b5431795dccdeb64cb9ba4fdc94746fc Mon Sep 17 00:00:00 2001 From: malinthar Date: Wed, 14 Dec 2022 12:51:31 +0530 Subject: [PATCH 230/450] Add missing order direction keywords in order by context --- .../context/QueryPipelineNodeContext.java | 55 +++++++ ...uery_expr_ctx_orderby_clause_config10.json | 144 ++++++++++++++++++ ...uery_expr_ctx_orderby_clause_config11.json | 126 +++++++++++++++ ...query_expr_ctx_orderby_clause_source10.bal | 7 + ...query_expr_ctx_orderby_clause_source11.bal | 7 + 5 files changed, 339 insertions(+) create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_orderby_clause_config10.json create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_orderby_clause_config11.json create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/query_expression/source/query_expr_ctx_orderby_clause_source10.bal create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/query_expression/source/query_expr_ctx_orderby_clause_source11.bal diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/QueryPipelineNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/QueryPipelineNodeContext.java index 972abb3983ad..3b3a23a5ccb8 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/QueryPipelineNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/QueryPipelineNodeContext.java @@ -15,12 +15,18 @@ */ package org.ballerinalang.langserver.completions.providers.context; +import io.ballerina.compiler.syntax.tree.IntermediateClauseNode; import io.ballerina.compiler.syntax.tree.JoinClauseNode; import io.ballerina.compiler.syntax.tree.NonTerminalNode; +import io.ballerina.compiler.syntax.tree.OrderByClauseNode; +import io.ballerina.compiler.syntax.tree.OrderKeyNode; import io.ballerina.compiler.syntax.tree.QueryPipelineNode; +import io.ballerina.compiler.syntax.tree.SeparatedNodeList; import io.ballerina.compiler.syntax.tree.SyntaxKind; import io.ballerina.compiler.syntax.tree.WhereClauseNode; +import io.ballerina.tools.text.LinePosition; import org.ballerinalang.annotation.JavaSPIService; +import org.ballerinalang.langserver.common.utils.PositionUtil; import org.ballerinalang.langserver.commons.BallerinaCompletionContext; import org.ballerinalang.langserver.commons.completion.LSCompletionItem; import org.ballerinalang.langserver.completions.SnippetCompletionItem; @@ -29,6 +35,7 @@ import org.ballerinalang.langserver.completions.util.Snippet; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; /** @@ -67,6 +74,15 @@ This particular section hits when there is at least one statement below (1) and completionItems.add(new SnippetCompletionItem(context, Snippet.KW_FROM.get())); completionItems.add(new SnippetCompletionItem(context, Snippet.CLAUSE_FROM.get())); completionItems.addAll(QueryExpressionUtil.getCommonKeywordCompletions(context)); + + if (onSuggestDirectionKeywords(context, node)) { + /* + Covers the following. + order by key d + */ + completionItems.add(new SnippetCompletionItem(context, Snippet.KW_ASCENDING.get())); + completionItems.add(new SnippetCompletionItem(context, Snippet.KW_DESCENDING.get())); + } } else if (onMissingJoinKeyword(context)) { /* Covers the following (1) [intermediate-clause] outer @@ -94,4 +110,43 @@ private boolean onMissingJoinKeyword(BallerinaCompletionContext context) { return !evalNode.isMissing() && evalNode.kind() == SyntaxKind.JOIN_CLAUSE && ((JoinClauseNode) evalNode).joinKeyword().isMissing(); } + + /** + * Check if order direction keywords can be suggested. + * @param context completion context + * @param node QueryPipeLine node + * @return + */ + private boolean onSuggestDirectionKeywords(BallerinaCompletionContext context, QueryPipelineNode node) { + if (!onMissingWhereNode(context) || context.currentSyntaxTree().isEmpty()) { + return false; + } + + int cursor = context.getCursorPositionInTree(); + NonTerminalNode nextIntermediate = context.getNodeAtCursor().parent(); + LinePosition startLinePosition = nextIntermediate.lineRange().startLine(); + int startOffset = PositionUtil.getPositionOffset(PositionUtil.toPosition(startLinePosition), + context.currentSyntaxTree().get()); + + Iterator iterator = node.intermediateClauses().iterator(); + IntermediateClauseNode closestNode = null; + while (iterator.hasNext()) { + IntermediateClauseNode next = iterator.next(); + int endOffset = PositionUtil.getPositionOffset(PositionUtil.toPosition(next.lineRange().endLine()), + context.currentSyntaxTree().get()); + if (endOffset < startOffset) { + closestNode = next; + } + } + if (closestNode.kind() != SyntaxKind.ORDER_BY_CLAUSE) { + return false; + } + SeparatedNodeList orderKeyNodes = ((OrderByClauseNode) closestNode).orderKey(); + if (orderKeyNodes.isEmpty()) { + return false; + } + + OrderKeyNode lastOrderKey = orderKeyNodes.get(orderKeyNodes.size() - 1); + return cursor > lastOrderKey.textRange().endOffset(); + } } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_orderby_clause_config10.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_orderby_clause_config10.json new file mode 100644 index 000000000000..308bcc859c05 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_orderby_clause_config10.json @@ -0,0 +1,144 @@ +{ + "position": { + "line": 3, + "character": 20 + }, + "source": "query_expression/source/query_expr_ctx_orderby_clause_source10.bal", + "items": [ + { + "label": "from", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "from", + "insertText": "from ", + "insertTextFormat": "Snippet" + }, + { + "label": "from clause", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "P", + "filterText": "from", + "insertText": "from ${1:var} ${2:item} in ${3}", + "insertTextFormat": "Snippet" + }, + { + "label": "where", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "where", + "insertText": "where ", + "insertTextFormat": "Snippet" + }, + { + "label": "let", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "let", + "insertText": "let", + "insertTextFormat": "Snippet" + }, + { + "label": "let clause", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "P", + "filterText": "let", + "insertText": "let ${1:var} ${2:varName} = ${3}", + "insertTextFormat": "Snippet" + }, + { + "label": "outer", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "outer", + "insertText": "outer ", + "insertTextFormat": "Snippet" + }, + { + "label": "join", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "join", + "insertText": "join ", + "insertTextFormat": "Snippet" + }, + { + "label": "join clause", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "P", + "filterText": "join", + "insertText": "join ${1:var} ${2:varName} in ${3:expr} on ${4:onExpr} equals ${5:equalsExpr}", + "insertTextFormat": "Snippet" + }, + { + "label": "order by", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "order by", + "insertText": "order by ", + "insertTextFormat": "Snippet" + }, + { + "label": "limit", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "limit", + "insertText": "limit ", + "insertTextFormat": "Snippet" + }, + { + "label": "do", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "P", + "filterText": "do", + "insertText": "do {\n\t${1}\n}", + "insertTextFormat": "Snippet" + }, + { + "label": "select", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "select", + "insertText": "select ", + "insertTextFormat": "Snippet" + }, + { + "label": "from", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "from", + "insertText": "from ", + "insertTextFormat": "Snippet" + }, + { + "label": "ascending", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "ascending", + "insertText": "ascending", + "insertTextFormat": "Snippet" + }, + { + "label": "descending", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "descending", + "insertText": "descending", + "insertTextFormat": "Snippet" + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_orderby_clause_config11.json b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_orderby_clause_config11.json new file mode 100644 index 000000000000..8c5355e4dba1 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/config/query_expr_ctx_orderby_clause_config11.json @@ -0,0 +1,126 @@ +{ + "position": { + "line": 4, + "character": 18 + }, + "source": "query_expression/source/query_expr_ctx_orderby_clause_source11.bal", + "items": [ + { + "label": "from", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "from", + "insertText": "from ", + "insertTextFormat": "Snippet" + }, + { + "label": "from clause", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "P", + "filterText": "from", + "insertText": "from ${1:var} ${2:item} in ${3}", + "insertTextFormat": "Snippet" + }, + { + "label": "where", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "where", + "insertText": "where ", + "insertTextFormat": "Snippet" + }, + { + "label": "let", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "let", + "insertText": "let", + "insertTextFormat": "Snippet" + }, + { + "label": "let clause", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "P", + "filterText": "let", + "insertText": "let ${1:var} ${2:varName} = ${3}", + "insertTextFormat": "Snippet" + }, + { + "label": "outer", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "outer", + "insertText": "outer ", + "insertTextFormat": "Snippet" + }, + { + "label": "join", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "join", + "insertText": "join ", + "insertTextFormat": "Snippet" + }, + { + "label": "join clause", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "P", + "filterText": "join", + "insertText": "join ${1:var} ${2:varName} in ${3:expr} on ${4:onExpr} equals ${5:equalsExpr}", + "insertTextFormat": "Snippet" + }, + { + "label": "order by", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "order by", + "insertText": "order by ", + "insertTextFormat": "Snippet" + }, + { + "label": "limit", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "limit", + "insertText": "limit ", + "insertTextFormat": "Snippet" + }, + { + "label": "do", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "P", + "filterText": "do", + "insertText": "do {\n\t${1}\n}", + "insertTextFormat": "Snippet" + }, + { + "label": "select", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "select", + "insertText": "select ", + "insertTextFormat": "Snippet" + }, + { + "label": "from", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "Q", + "filterText": "from", + "insertText": "from ", + "insertTextFormat": "Snippet" + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/source/query_expr_ctx_orderby_clause_source10.bal b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/source/query_expr_ctx_orderby_clause_source10.bal new file mode 100644 index 000000000000..263c7136fa36 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/source/query_expr_ctx_orderby_clause_source10.bal @@ -0,0 +1,7 @@ +function testQueryExpression() { + + int[] topX = from int i in [1, 2, 3] + order by i d + limit 10 + select i; +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/query_expression/source/query_expr_ctx_orderby_clause_source11.bal b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/source/query_expr_ctx_orderby_clause_source11.bal new file mode 100644 index 000000000000..d14174fd4260 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/query_expression/source/query_expr_ctx_orderby_clause_source11.bal @@ -0,0 +1,7 @@ +function testQueryExpression() { + + int[] topX = from int i in [1, 2, 3] + order by i + limit 10 d + select i; +} From ec9c5bc00ceff92e0f07f64443d3133fadb12a98 Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 14 Dec 2022 13:01:27 +0530 Subject: [PATCH 231/450] Add fixes based on review comments --- langlib/lang.string/src/main/ballerina/string.bal | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index 1307627c20d5..53edb2a66d04 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -91,7 +91,7 @@ public isolated function getCodePoint(string str, int index) returns int = @java # # ```ballerina # "Hello, my name is John".substring(7) ⇒ "my name is John" -# "Hello, my name is John".substring(18, 22) ⇒ "John" +# "Hello, my name is John Anderson".substring(18, 22) ⇒ "John" # ``` # # + str - source string. @@ -310,6 +310,7 @@ public isolated function toBytes(string str) returns byte[] = @java:Method { # # ```ballerina # string:fromBytes([72, 101, 108, 108, 111, 32, 66, 97, 108, 108, 101, 114, 105, 110, 97, 33]) ⇒ Hello, World! +# string:fromBytes([12, 45, 45]) ⇒ error # ``` # # + bytes - UTF-8 byte array From eaa97eb4e9f52ce604b75ea084102dd9ab6ed6de Mon Sep 17 00:00:00 2001 From: malinthar Date: Tue, 13 Dec 2022 15:12:05 +0530 Subject: [PATCH 232/450] Fix NPE in ArrayTypeSymbol --- .../compiler/api/impl/SymbolFactory.java | 7 ++-- .../symbols/BallerinaArrayTypeSymbol.java | 2 +- .../codeaction/CreateVariableTest.java | 1 + ...ariableAssignmentRequiredCodeAction46.json | 38 +++++++++++++++++++ .../source/createVariableWithMethodCall1.bal | 4 ++ 5 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/create-variable/config/variableAssignmentRequiredCodeAction46.json create mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/create-variable/source/createVariableWithMethodCall1.bal diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFactory.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFactory.java index 9ac47cc55a03..2d4ceae79695 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFactory.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFactory.java @@ -364,11 +364,12 @@ public BallerinaVariableSymbol createVariableSymbol(BVarSymbol symbol, String na } private boolean isReadonlyIntersectionArrayType(BType type) { - if (type.tag == TypeTags.INTERSECTION && type.tsymbol.getOrigin() == SymbolOrigin.VIRTUAL) { + if (type.tsymbol != null && type.tag == TypeTags.INTERSECTION + && type.tsymbol.getOrigin() == SymbolOrigin.VIRTUAL) { return true; } - if (type.tag == TypeTags.ARRAY) { + if (type.tsymbol != null && type.tag == TypeTags.ARRAY) { return isReadonlyIntersectionArrayType(((BArrayType) type).getElementType()); } @@ -711,7 +712,7 @@ public BallerinaAnnotationAttachmentSymbol createAnnotAttachment(BAnnotationAtta annotAttachment).attachmentValueSymbol; return new BallerinaAnnotationAttachmentSymbol(annotAttachment.getOriginalName().getValue(), (BAnnotationAttachmentSymbol.BConstAnnotationAttachmentSymbol) annotAttachment, - annotationSymbol, createConstantValue(attachmentValue.value), context); + annotationSymbol, createConstantValue(attachmentValue.value), context); } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaArrayTypeSymbol.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaArrayTypeSymbol.java index c16853184663..3e9a4f7c4648 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaArrayTypeSymbol.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaArrayTypeSymbol.java @@ -52,7 +52,7 @@ public TypeSymbol memberTypeDescriptor() { if (this.memberTypeDesc == null) { TypesFactory typesFactory = TypesFactory.getInstance(this.context); BType eType = ((BArrayType) this.getBType()).eType; - if (eType.tsymbol.getOrigin() == SymbolOrigin.VIRTUAL) { + if (eType.tsymbol != null && eType.tsymbol.getOrigin() == SymbolOrigin.VIRTUAL) { this.memberTypeDesc = typesFactory.getTypeDescriptor(eType, eType.tsymbol, true); } else { this.memberTypeDesc = typesFactory.getTypeDescriptor(eType); diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/CreateVariableTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/CreateVariableTest.java index a1bd6e88bfa8..288ebbc092a1 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/CreateVariableTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/CreateVariableTest.java @@ -96,6 +96,7 @@ public Object[][] dataProvider() { {"variableAssignmentRequiredCodeAction43.json"}, {"variableAssignmentRequiredCodeAction44.json"}, {"variableAssignmentRequiredCodeAction45.json"}, + {"variableAssignmentRequiredCodeAction46.json"}, {"ignoreReturnValueCodeAction.json"}, {"projectVariableAssignmentRequiredCodeAction1.json"}, {"projectVariableAssignmentRequiredCodeAction2.json"}, diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/create-variable/config/variableAssignmentRequiredCodeAction46.json b/language-server/modules/langserver-core/src/test/resources/codeaction/create-variable/config/variableAssignmentRequiredCodeAction46.json new file mode 100644 index 000000000000..d3416e945be8 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/create-variable/config/variableAssignmentRequiredCodeAction46.json @@ -0,0 +1,38 @@ +{ + "position": { + "line": 2, + "character": 17 + }, + "source": "createVariableWithMethodCall1.bal", + "description": "Test create variable code action with lang lib method", + "expected": [ + { + "title": "Create variable", + "kind": "quickfix", + "edits": [ + { + "range": { + "start": { + "line": 2, + "character": 4 + }, + "end": { + "line": 2, + "character": 4 + } + }, + "newText": "[int, string][] enumerate = " + } + ], + "command": { + "title": "Rename Variable", + "command": "ballerina.action.rename", + "arguments": [ + "createVariableWithMethodCall1.bal", + 108 + ] + }, + "resolvable": false + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/create-variable/source/createVariableWithMethodCall1.bal b/language-server/modules/langserver-core/src/test/resources/codeaction/create-variable/source/createVariableWithMethodCall1.bal new file mode 100644 index 000000000000..f3d7b06adddc --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/create-variable/source/createVariableWithMethodCall1.bal @@ -0,0 +1,4 @@ +public function main() { + string[] greetings = ["Hello", "Bonjour", "Hola", "Ciao"]; + greetings.enumerate(); +} From b079685d905ab2b570868af0a870f9ca742c8f39 Mon Sep 17 00:00:00 2001 From: malinthar Date: Tue, 13 Dec 2022 15:32:46 +0530 Subject: [PATCH 233/450] Address review suggestions --- .../compiler/api/impl/SymbolFactory.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFactory.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFactory.java index 2d4ceae79695..38f0dbb1807b 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFactory.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFactory.java @@ -275,7 +275,7 @@ public BallerinaFunctionSymbol createFunctionSymbol(BInvokableSymbol invokableSy } return builder.withTypeDescriptor((FunctionTypeSymbol) typesFactory - .getTypeDescriptor(invokableSymbol.type, invokableSymbol.type.tsymbol, true)) + .getTypeDescriptor(invokableSymbol.type, invokableSymbol.type.tsymbol, true)) .build(); } @@ -364,8 +364,10 @@ public BallerinaVariableSymbol createVariableSymbol(BVarSymbol symbol, String na } private boolean isReadonlyIntersectionArrayType(BType type) { - if (type.tsymbol != null && type.tag == TypeTags.INTERSECTION - && type.tsymbol.getOrigin() == SymbolOrigin.VIRTUAL) { + if (type.tsymbol != null) { + return false; + } + if (type.tag == TypeTags.INTERSECTION && type.tsymbol.getOrigin() == SymbolOrigin.VIRTUAL) { return true; } @@ -433,7 +435,7 @@ public ParameterSymbol createBallerinaParameter(BVarSymbol symbol, ParameterKind } return new BallerinaParameterSymbol(name, typeDescriptor, qualifiers, annotSymbols, annotAttachments, - kind, symbol, this.context); + kind, symbol, this.context); } public PathParameterSymbol createPathParamSymbol(BVarSymbol symbol, PathSegment.Kind kind) { @@ -453,7 +455,7 @@ public PathParameterSymbol createPathParamSymbol(BVarSymbol symbol, PathSegment. public BallerinaTypeDefinitionSymbol createTypeDefinition(BSymbol typeSymbol, String name) { BallerinaTypeDefinitionSymbol.TypeDefSymbolBuilder symbolBuilder = new BallerinaTypeDefinitionSymbol.TypeDefSymbolBuilder(name, typeSymbol, - this.context); + this.context); if (Symbols.isFlagOn(typeSymbol.flags, Flags.PUBLIC)) { symbolBuilder.withQualifier(Qualifier.PUBLIC); @@ -565,9 +567,9 @@ public BallerinaServiceDeclarationSymbol createServiceDeclSymbol(BServiceSymbol public BallerinaConstantSymbol createConstantSymbol(BConstantSymbol constantSymbol, String name) { BallerinaConstantSymbol.ConstantSymbolBuilder symbolBuilder = new BallerinaConstantSymbol.ConstantSymbolBuilder(name, constantSymbol, - this.context); + this.context); symbolBuilder.withTypeDescriptor(typesFactory.getTypeDescriptor(constantSymbol.type)) - .withBroaderTypeDescriptor(typesFactory.getTypeDescriptor(constantSymbol.literalType)); + .withBroaderTypeDescriptor(typesFactory.getTypeDescriptor(constantSymbol.literalType)); // Check whether the constant-symbol has a missing constant expression if (constantSymbol.getConstValue() != null) { @@ -694,7 +696,7 @@ public BallerinaAnnotationAttachmentSymbol createAnnotAttachment(BAnnotationAtta /** * Create an annotation attachment symbol. * - * @param annotAttachment annotation attachment + * @param annotAttachment annotation attachment * @param annotationSymbol annotation symbol * @return {@link BallerinaAnnotationAttachmentSymbol} symbol generated */ From 02ba33997f3f8ca24f6fd68571fc24237e32dc49 Mon Sep 17 00:00:00 2001 From: malinthar Date: Tue, 13 Dec 2022 15:39:39 +0530 Subject: [PATCH 234/450] Remove unwanted formatting changes --- .../compiler/api/impl/SymbolFactory.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFactory.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFactory.java index 38f0dbb1807b..0caf059f1f38 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFactory.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFactory.java @@ -275,7 +275,7 @@ public BallerinaFunctionSymbol createFunctionSymbol(BInvokableSymbol invokableSy } return builder.withTypeDescriptor((FunctionTypeSymbol) typesFactory - .getTypeDescriptor(invokableSymbol.type, invokableSymbol.type.tsymbol, true)) + .getTypeDescriptor(invokableSymbol.type, invokableSymbol.type.tsymbol, true)) .build(); } @@ -371,7 +371,7 @@ private boolean isReadonlyIntersectionArrayType(BType type) { return true; } - if (type.tsymbol != null && type.tag == TypeTags.ARRAY) { + if (type.tag == TypeTags.ARRAY) { return isReadonlyIntersectionArrayType(((BArrayType) type).getElementType()); } @@ -435,7 +435,7 @@ public ParameterSymbol createBallerinaParameter(BVarSymbol symbol, ParameterKind } return new BallerinaParameterSymbol(name, typeDescriptor, qualifiers, annotSymbols, annotAttachments, - kind, symbol, this.context); + kind, symbol, this.context); } public PathParameterSymbol createPathParamSymbol(BVarSymbol symbol, PathSegment.Kind kind) { @@ -455,7 +455,7 @@ public PathParameterSymbol createPathParamSymbol(BVarSymbol symbol, PathSegment. public BallerinaTypeDefinitionSymbol createTypeDefinition(BSymbol typeSymbol, String name) { BallerinaTypeDefinitionSymbol.TypeDefSymbolBuilder symbolBuilder = new BallerinaTypeDefinitionSymbol.TypeDefSymbolBuilder(name, typeSymbol, - this.context); + this.context); if (Symbols.isFlagOn(typeSymbol.flags, Flags.PUBLIC)) { symbolBuilder.withQualifier(Qualifier.PUBLIC); @@ -567,9 +567,9 @@ public BallerinaServiceDeclarationSymbol createServiceDeclSymbol(BServiceSymbol public BallerinaConstantSymbol createConstantSymbol(BConstantSymbol constantSymbol, String name) { BallerinaConstantSymbol.ConstantSymbolBuilder symbolBuilder = new BallerinaConstantSymbol.ConstantSymbolBuilder(name, constantSymbol, - this.context); + this.context); symbolBuilder.withTypeDescriptor(typesFactory.getTypeDescriptor(constantSymbol.type)) - .withBroaderTypeDescriptor(typesFactory.getTypeDescriptor(constantSymbol.literalType)); + .withBroaderTypeDescriptor(typesFactory.getTypeDescriptor(constantSymbol.literalType)); // Check whether the constant-symbol has a missing constant expression if (constantSymbol.getConstValue() != null) { @@ -696,7 +696,7 @@ public BallerinaAnnotationAttachmentSymbol createAnnotAttachment(BAnnotationAtta /** * Create an annotation attachment symbol. * - * @param annotAttachment annotation attachment + * @param annotAttachment annotation attachment * @param annotationSymbol annotation symbol * @return {@link BallerinaAnnotationAttachmentSymbol} symbol generated */ @@ -714,7 +714,7 @@ public BallerinaAnnotationAttachmentSymbol createAnnotAttachment(BAnnotationAtta annotAttachment).attachmentValueSymbol; return new BallerinaAnnotationAttachmentSymbol(annotAttachment.getOriginalName().getValue(), (BAnnotationAttachmentSymbol.BConstAnnotationAttachmentSymbol) annotAttachment, - annotationSymbol, createConstantValue(attachmentValue.value), context); + annotationSymbol, createConstantValue(attachmentValue.value), context); } From f5fe1cb617e0ecd5807f5e475a26460f8ce23305 Mon Sep 17 00:00:00 2001 From: malinthar Date: Tue, 13 Dec 2022 18:40:55 +0530 Subject: [PATCH 235/450] Fix faling semantic api test cases --- .../java/io/ballerina/compiler/api/impl/SymbolFactory.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFactory.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFactory.java index 0caf059f1f38..5308783eddc5 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFactory.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFactory.java @@ -364,13 +364,9 @@ public BallerinaVariableSymbol createVariableSymbol(BVarSymbol symbol, String na } private boolean isReadonlyIntersectionArrayType(BType type) { - if (type.tsymbol != null) { - return false; - } - if (type.tag == TypeTags.INTERSECTION && type.tsymbol.getOrigin() == SymbolOrigin.VIRTUAL) { + if (type.tag == TypeTags.INTERSECTION && type.tsymbol != null && type.tsymbol.getOrigin() == SymbolOrigin.VIRTUAL) { return true; } - if (type.tag == TypeTags.ARRAY) { return isReadonlyIntersectionArrayType(((BArrayType) type).getElementType()); } From 63911e74d45ab0683fb2029a5193c7d41bae6417 Mon Sep 17 00:00:00 2001 From: malinthar Date: Tue, 13 Dec 2022 18:47:37 +0530 Subject: [PATCH 236/450] Fix checkstyle issue --- .../java/io/ballerina/compiler/api/impl/SymbolFactory.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFactory.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFactory.java index 5308783eddc5..329e2d2743a5 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFactory.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFactory.java @@ -364,7 +364,8 @@ public BallerinaVariableSymbol createVariableSymbol(BVarSymbol symbol, String na } private boolean isReadonlyIntersectionArrayType(BType type) { - if (type.tag == TypeTags.INTERSECTION && type.tsymbol != null && type.tsymbol.getOrigin() == SymbolOrigin.VIRTUAL) { + if (type.tag == TypeTags.INTERSECTION + && type.tsymbol != null && type.tsymbol.getOrigin() == SymbolOrigin.VIRTUAL) { return true; } if (type.tag == TypeTags.ARRAY) { From ea3c93780f45c86fb527163279e3b7bcf86b27d3 Mon Sep 17 00:00:00 2001 From: HindujaB Date: Wed, 14 Dec 2022 13:20:03 +0530 Subject: [PATCH 237/450] Fix checkStyle error --- .../io/ballerina/runtime/internal/values/TypedescValueImpl.java | 1 - 1 file changed, 1 deletion(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TypedescValueImpl.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TypedescValueImpl.java index 5ebb730caa1c..89a70fc2e7db 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TypedescValueImpl.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TypedescValueImpl.java @@ -18,7 +18,6 @@ package io.ballerina.runtime.internal.values; import io.ballerina.runtime.api.TypeTags; -import io.ballerina.runtime.api.types.TupleType; import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.values.BInitialValueEntry; import io.ballerina.runtime.api.values.BLink; From a300e68494953fe2b1559997e6dd55432b810fac Mon Sep 17 00:00:00 2001 From: Thevakumar-Luheerathan Date: Wed, 14 Dec 2022 15:15:15 +0530 Subject: [PATCH 238/450] Generate image module wise during function mocking --- .../cli/task/RunNativeImageTestTask.java | 259 ++++++++---------- .../io/ballerina/cli/utils/NativeUtils.java | 232 ++++++++-------- 2 files changed, 241 insertions(+), 250 deletions(-) diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java index 6fea9121d743..a92c3d8907de 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java @@ -20,10 +20,7 @@ import io.ballerina.cli.utils.BuildTime; import io.ballerina.cli.utils.MethodCallReplaceVisitor; -import io.ballerina.cli.utils.OrigMockFunctionReplaceVisitor; import io.ballerina.cli.utils.TestUtils; -import io.ballerina.projects.Document; -import io.ballerina.projects.DocumentId; import io.ballerina.projects.JBallerinaBackend; import io.ballerina.projects.JarLibrary; import io.ballerina.projects.JarResolver; @@ -39,6 +36,7 @@ import io.ballerina.projects.ProjectKind; import io.ballerina.projects.internal.model.Target; import org.apache.commons.compress.utils.IOUtils; +import org.ballerinalang.test.runtime.entity.MockFunctionReplaceVisitor; import org.ballerinalang.test.runtime.entity.ModuleStatus; import org.ballerinalang.test.runtime.entity.TestReport; import org.ballerinalang.test.runtime.entity.TestSuite; @@ -49,6 +47,7 @@ import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.Opcodes; +import org.objectweb.asm.Type; import org.wso2.ballerinalang.util.Lists; import java.io.File; @@ -148,9 +147,9 @@ public RunNativeImageTestTask(PrintStream out, PrintStream errStream, boolean re this.listGroups = listGroups; } - //Get modified class bytes for function mock + public static byte[] getModifiedClassBytes(String className, List functionNames, TestSuite suite, - ClassLoader classLoader, List modifiedMethods) { + ClassLoader classLoader) { Class functionToMockClass; try { functionToMockClass = classLoader.loadClass(className); @@ -162,11 +161,6 @@ public static byte[] getModifiedClassBytes(String className, List functi boolean readFromBytes = false; for (Method method1 : functionToMockClass.getDeclaredMethods()) { if (functionNames.contains(MOCK_FN_DELIMITER + method1.getName())) { - if (modifiedMethods.contains(className + "-" + method1.getName())) { - continue; - } else { - modifiedMethods.add(className + "-" + method1.getName()); - } String desugaredMockFunctionName = MOCK_FUNC_NAME_PREFIX + method1.getName(); String testClassName = TesterinaUtils.getQualifiedClassName(suite.getOrgName(), suite.getTestPackageID(), suite.getVersion(), @@ -180,19 +174,14 @@ public static byte[] getModifiedClassBytes(String className, List functi for (Method method2 : testClass.getDeclaredMethods()) { if (method2.getName().equals(desugaredMockFunctionName)) { if (!readFromBytes) { - classFile = replaceMethodBody(method1); + classFile = replaceMethodBody(method1, method2); readFromBytes = true; } else { - classFile = replaceMethodBody(classFile, method1); + classFile = replaceMethodBody(classFile, method1, method2); } } } } else if (functionNames.contains(MOCK_LEGACY_DELIMITER + method1.getName())) { - if (modifiedMethods.contains(className + "-" + method1.getName())) { - continue; - } else { - modifiedMethods.add(className + "-" + method1.getName()); - } String key = className + MOCK_LEGACY_DELIMITER + method1.getName(); String mockFunctionName = suite.getMockFunctionNamesMap().get(key); if (mockFunctionName != null) { @@ -206,10 +195,10 @@ public static byte[] getModifiedClassBytes(String className, List functi for (Method method2 : mockFunctionClass.getDeclaredMethods()) { if (method2.getName().equals(mockFunctionName)) { if (!readFromBytes) { - classFile = replaceMethodBody(method1); + classFile = replaceMethodBody(method1, method2); readFromBytes = true; } else { - classFile = replaceMethodBody(classFile, method1); + classFile = replaceMethodBody(classFile, method1, method2); } } } @@ -252,10 +241,10 @@ public static byte[] getModifiedTestClassBytes(String className, List fu for (Method method2 : testClass.getDeclaredMethods()) { if (method2.getName().equals(desugaredMockFunctionName)) { if (!readFromBytes) { - classFile = replaceTestClzMethodBody(testDocumentClass, method2, method1); + classFile = replaceTestClzMethodCall(testDocumentClass, method2, method1); readFromBytes = true; } else { - classFile = replaceTestClzMethodBody(classFile, method2, method1); + classFile = replaceTestClzMethodCall(classFile, method2, method1); } } } @@ -273,10 +262,10 @@ public static byte[] getModifiedTestClassBytes(String className, List fu for (Method method2 : mockFunctionClass.getDeclaredMethods()) { if (method2.getName().equals(mockFunctionName)) { if (!readFromBytes) { - classFile = replaceTestClzMethodBody(testDocumentClass, method1, method2); + classFile = replaceTestClzMethodCall(testDocumentClass, method1, method2); readFromBytes = true; } else { - classFile = replaceTestClzMethodBody(classFile, method1, method2); + classFile = replaceTestClzMethodCall(classFile, method1, method2); } } } @@ -288,7 +277,7 @@ public static byte[] getModifiedTestClassBytes(String className, List fu return classFile; } - private static byte[] replaceTestClzMethodBody(Class testDocumentClass, Method toFunc, Method fromFunc) { + private static byte[] replaceTestClzMethodCall(Class testDocumentClass, Method toFunc, Method fromFunc) { Class clazz = testDocumentClass; ClassReader cr; try { @@ -305,7 +294,7 @@ private static byte[] replaceTestClzMethodBody(Class testDocumentClass, Metho return cw.toByteArray(); } - private static byte[] replaceTestClzMethodBody(byte[] classFile, Method toFunc, Method fromFunc) { + private static byte[] replaceTestClzMethodCall(byte[] classFile, Method toFunc, Method fromFunc) { ClassReader cr = new ClassReader(classFile); ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); ClassVisitor cv = new MethodCallReplaceVisitor(Opcodes.ASM7, cw, toFunc, fromFunc); @@ -313,7 +302,7 @@ private static byte[] replaceTestClzMethodBody(byte[] classFile, Method toFunc, return cw.toByteArray(); } - private static byte[] replaceMethodBody(Method method) { + private static byte[] replaceMethodBody(Method method, Method mockMethod) { Class clazz = method.getDeclaringClass(); ClassReader cr; try { @@ -325,16 +314,17 @@ private static byte[] replaceMethodBody(Method method) { + clazz.getSimpleName()); } ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); - ClassVisitor cv = new OrigMockFunctionReplaceVisitor(Opcodes.ASM7, cw, method); + ClassVisitor cv = new MockFunctionReplaceVisitor(Opcodes.ASM7, cw, method.getName(), + Type.getMethodDescriptor(method), mockMethod); cr.accept(cv, 0); return cw.toByteArray(); } - //Move mocked function as $ORIG_function - private static byte[] replaceMethodBody(byte[] classFile, Method method) { + private static byte[] replaceMethodBody(byte[] classFile, Method method, Method mockMethod) { ClassReader cr = new ClassReader(classFile); ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); - ClassVisitor cv = new OrigMockFunctionReplaceVisitor(Opcodes.ASM7, cw, method); + ClassVisitor cv = new MockFunctionReplaceVisitor(Opcodes.ASM7, cw, method.getName(), + Type.getMethodDescriptor(method), mockMethod); cr.accept(cv, 0); return cw.toByteArray(); } @@ -419,17 +409,17 @@ public void execute(Project project) { JarResolver jarResolver = jBallerinaBackend.jarResolver(); TestProcessor testProcessor = new TestProcessor(jarResolver); List moduleNamesList = new ArrayList<>(); - Map testSuiteMap = new HashMap<>(); List updatedSingleExecTests; // Only tests in packages are executed so default packages i.e. single bal files which has the package name // as "." are ignored. This is to be consistent with the "bal test" command which only executes tests // in packages. - //Track modified functions in a module jar and Have a mpping between modified jar and original jar - Map originalVsModifiedJarMap = new HashMap<>(); - List modifiedMethods = new ArrayList<>(); + // Create seperate test suite map for each module. + List> testSuiteMapEntries = new ArrayList<>(); + boolean isMockFunctionExist = false; for (ModuleDescriptor moduleDescriptor : project.currentPackage().moduleDependencyGraph().toTopologicallySortedList()) { + HashMap testSuiteMap = new HashMap<>(); Module module = project.currentPackage().module(moduleDescriptor.name()); ModuleName moduleName = module.moduleName(); @@ -450,76 +440,102 @@ public void execute(Project project) { suite.setSourceFileName(project.sourceRoot().getFileName().toString()); } suite.setReportRequired(report || coverage); - try { - modifyJarForFunctionMock(suite, target, module, - originalVsModifiedJarMap, modifiedMethods); - } catch (IOException e) { - throw createLauncherException("error occurred while running tests", e); + if (!isMockFunctionExist) { + isMockFunctionExist = !suite.getMockFunctionNamesMap().isEmpty(); } String resolvedModuleName = module.isDefaultModule() ? moduleName.toString() : module.moduleName().moduleNamePart(); testSuiteMap.put(resolvedModuleName, suite); + testSuiteMapEntries.add(testSuiteMap); moduleNamesList.add(resolvedModuleName); } - try { - Path nativeConfigPath = target.getNativeConfigPath(); - createReflectConfig(nativeConfigPath, project.currentPackage(), testSuiteMap); - } catch (IOException e) { - throw createLauncherException("error while generating the necessary graalvm reflection config ", e); + // If the function mocking does not exist, combine all test suite map entries + if (!isMockFunctionExist){ + HashMap testSuiteMap = testSuiteMapEntries.remove(0); + while (testSuiteMapEntries.size() > 0) { + testSuiteMap.putAll(testSuiteMapEntries.remove(0)); + } + testSuiteMapEntries.add(testSuiteMap); } - //Remove all mock function entries from test suites - for (Map.Entry testSuiteEntry : testSuiteMap.entrySet()) { - TestSuite testSuite = testSuiteEntry.getValue(); - if (!testSuite.getMockFunctionNamesMap().isEmpty()) { - testSuite.removeAllMockFunctions(); + //Execute each testsuite within list one by one + for (Map testSuiteMap : testSuiteMapEntries ) { + try { + Path nativeConfigPath = target.getNativeConfigPath(); + createReflectConfig(nativeConfigPath, project.currentPackage(), testSuiteMap); + } catch (IOException e) { + throw createLauncherException("error while generating the necessary graalvm reflection config ", e); } - } - TestUtils.writeToTestSuiteJson(testSuiteMap, testsCachePath); + // Try to modify jar if the testsuite map contains only one entry + if (testSuiteMap.size() == 1) { + TestSuite testSuite = testSuiteMap.values().toArray(new TestSuite[0])[0]; + String moduleName = testSuite.getPackageID(); + try { + modifyJarForFunctionMock(testSuite, target, moduleName); + } catch (IOException e) { + throw createLauncherException("error occurred while running tests", e); + } + } - if (hasTests) { - int testResult = 1; - try { - testResult = runTestSuiteWithNativeImage(project.currentPackage(), jBallerinaBackend, target, - originalVsModifiedJarMap); + //Remove all mock function entries from test suites + for (Map.Entry testSuiteEntry : testSuiteMap.entrySet()) { + TestSuite testSuite = testSuiteEntry.getValue(); + if (!testSuite.getMockFunctionNamesMap().isEmpty()) { + testSuite.removeAllMockFunctions(); + } + } - if (report || coverage) { - for (String moduleName : moduleNamesList) { - ModuleStatus moduleStatus = TestUtils.loadModuleStatusFromFile( - testsCachePath.resolve(moduleName).resolve(TesterinaConstants.STATUS_FILE)); + //Write the testsuite to the disk + TestUtils.writeToTestSuiteJson(testSuiteMap, testsCachePath); - if (!moduleName.equals(project.currentPackage().packageName().toString())) { - moduleName = ModuleName.from(project.currentPackage().packageName(), moduleName).toString(); + + if (hasTests) { + int testResult = 1; + try { + testResult = runTestSuiteWithNativeImage(project.currentPackage(), target, testSuiteMap); + + if (report || coverage) { + for (Map.Entry testSuiteEntry : testSuiteMap.entrySet()) { + String moduleName = testSuiteEntry.getKey(); + ModuleStatus moduleStatus = TestUtils.loadModuleStatusFromFile( + testsCachePath.resolve(moduleName).resolve(TesterinaConstants.STATUS_FILE)); + + if (!moduleName.equals(project.currentPackage().packageName().toString())) { + moduleName = ModuleName.from(project.currentPackage().packageName(), moduleName).toString(); + } + testReport.addModuleStatus(moduleName, moduleStatus); } - testReport.addModuleStatus(moduleName, moduleStatus); - } - try { - generateCoverage(project, testReport, jBallerinaBackend, - this.includesInCoverage, this.coverageReportFormat, this.coverageModules); - generateTesterinaReports(project, testReport, this.out, target); - } catch (IOException e) { - TestUtils.cleanTempCache(project, cachesRoot); - throw createLauncherException("error occurred while generating test report :", e); } + } catch (IOException e) { + TestUtils.cleanTempCache(project, cachesRoot); + throw createLauncherException("error occurred while running tests", e); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); } - } catch (IOException e) { - TestUtils.cleanTempCache(project, cachesRoot); - throw createLauncherException("error occurred while running tests", e); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - if (testResult != 0) { + if (testResult != 0) { + TestUtils.cleanTempCache(project, cachesRoot); + throw createLauncherException("there are test failures"); + } + } + } + if ((report || coverage) && hasTests) { + try { + generateCoverage(project, testReport, jBallerinaBackend, + this.includesInCoverage, this.coverageReportFormat, this.coverageModules); + generateTesterinaReports(project, testReport, this.out, target); + } catch (IOException e) { TestUtils.cleanTempCache(project, cachesRoot); - throw createLauncherException("there are test failures"); + throw createLauncherException("error occurred while generating test report :", e); } } + // Cleanup temp cache for SingleFileProject TestUtils.cleanTempCache(project, cachesRoot); if (project.buildOptions().dumpBuildTime()) { @@ -527,19 +543,11 @@ public void execute(Project project) { } } - private int runTestSuiteWithNativeImage(Package currentPackage, JBallerinaBackend jBallerinaBackend, Target target, - Map originalVsModifiedJarMap) + private int runTestSuiteWithNativeImage(Package currentPackage, Target target, + Map testSuiteMap) throws IOException, InterruptedException { String packageName = currentPackage.packageName().toString(); - String classPath = getClassPath(jBallerinaBackend, currentPackage); - String modClassPath; - for (Map.Entry functionMockModuleMapping : originalVsModifiedJarMap.entrySet()) { - String moduleJar = functionMockModuleMapping.getKey(); - String replacedJar = originalVsModifiedJarMap.get(moduleJar); - modClassPath = classPath.replace(moduleJar, replacedJar); - classPath = modClassPath; - - } + String classPath = getClassPath(testSuiteMap); String jacocoAgentJarPath = ""; String nativeImageCommand = System.getenv("GRAALVM_HOME"); @@ -614,6 +622,9 @@ private int runTestSuiteWithNativeImage(Package currentPackage, JBallerinaBacken cmdArgs.add("@" + (nativeConfigPath.resolve("native-image-args.txt"))); nativeArgs.addAll(Lists.of("-cp", classPath)); + if (testSuiteMap.size() == 1) { + packageName = (testSuiteMap.values().toArray(new TestSuite[0])[0]).getPackageID(); + } // set name and path nativeArgs.add("-H:Name=" + packageName); @@ -664,6 +675,20 @@ private int runTestSuiteWithNativeImage(Package currentPackage, JBallerinaBacken } } + private String getClassPath(Map testSuiteMap) { + List dependencies = new ArrayList<>(); + for ( Map.Entry testSuiteEntry : testSuiteMap.entrySet()) { + dependencies.addAll(testSuiteEntry.getValue().getTestExecutionDependencies()); + + } + dependencies = dependencies.stream().distinct().collect(Collectors.toList()); + + StringJoiner classPath = new StringJoiner(File.pathSeparator); + dependencies.stream().forEach(classPath::add); + return classPath.toString(); + } + + private String getClassPath(JBallerinaBackend jBallerinaBackend, Package currentPackage) { List dependencies = new ArrayList<>(); JarResolver jarResolver = jBallerinaBackend.jarResolver(); @@ -687,10 +712,7 @@ private String getClassPath(JBallerinaBackend jBallerinaBackend, Package current return classPath.toString(); } - private void modifyJarForFunctionMock(TestSuite testSuite, Target target, Module module, - Map originalVsModifiedJarMap, - List modifiedMethods) throws IOException { - String moduleName = module.moduleName().toString(); + private void modifyJarForFunctionMock(TestSuite testSuite, Target target, String moduleName) throws IOException { String testJarName = testSuite.getOrgName() + HYPHEN + moduleName + HYPHEN + testSuite.getVersion() + HYPHEN + TESTABLE + JAR_EXTENSION; String testJarPath = ""; @@ -743,13 +765,9 @@ private void modifyJarForFunctionMock(TestSuite testSuite, Target target, Module mainJarName = mainJarVsClassEntry.getKey(); modifiedJarName = mainJarName + HYPHEN + MODIFIED + JAR_EXTENSION; - //If module jar is modified already, use modified one for (String testExecutionDependency : testExecutionDependencies) { if (testExecutionDependency.contains(mainJarName) && !testExecutionDependency.contains(TESTABLE)) { mainJarPath = testExecutionDependency; - if (originalVsModifiedJarMap.containsKey(mainJarPath)) { - mainJarPath = originalVsModifiedJarMap.get(mainJarPath); - } } } //Add module jar path to classloader URLs @@ -762,8 +780,7 @@ private void modifyJarForFunctionMock(TestSuite testSuite, Target target, Module Map modifiedClassDef = new HashMap<>(); for (String className : mainJarVsClassEntry.getValue()) { List functionNamesList = classVsMockFunctionsMap.get(className); - byte[] classFile = getModifiedClassBytes(className, functionNamesList, testSuite, classLoader, - modifiedMethods); + byte[] classFile = getModifiedClassBytes(className, functionNamesList, testSuite, classLoader); modifiedClassDef.put(className, classFile); } @@ -775,46 +792,8 @@ private void modifyJarForFunctionMock(TestSuite testSuite, Target target, Module //Dump modified jar dumpJar(modifiedClassDef, unmodifiedFiles, modifiedJarPath); - //Have a modified jar mapping to modify graal vm classpath - if (!originalVsModifiedJarMap.containsKey(mainJarPath)) { - originalVsModifiedJarMap.put(mainJarPath, modifiedJarPath); - } - } - - //Modify testable jar for function mocking - Map modifiedTestClassDef = new HashMap<>(); - for (DocumentId testDocId : module.testDocumentIds()) { - //Get the class for test document - Document testDocument = module.document(testDocId); - String testDocumentName = testDocument.name().replace(".bal", "") - .replace("/", "."); - String testDocumentClassName = TesterinaUtils.getQualifiedClassName(testSuite.getOrgName(), - testSuite.getTestPackageID(), testSuite.getVersion(), testDocumentName); - Class testDocumentClass; - try { - testDocumentClass = classLoader.loadClass(testDocumentClassName); - } catch (Throwable e) { - throw createLauncherException("failed to load class: " + testDocumentClassName); - } - - //Replace the original functions(mocked) in test document with the corresponding $MOCK_ function - byte[] classFile = new byte[0]; - for (Map.Entry> entry : classVsMockFunctionsMap.entrySet()) { - String className = entry.getKey(); - List functionNamesList = entry.getValue(); - classFile = getModifiedTestClassBytes(className, functionNamesList, testSuite, classLoader, - testDocumentClass, classFile); - } - modifiedTestClassDef.put(testDocumentClassName, classFile); - } - //Get all unmodified classes within testable jar and dump modified version - Map unmodifiedTestFiles = loadUnmodifiedFilesWithinJar(testJarPath); - String modifiedTestJarPath = testJarPath.replace(JAR_EXTENSION, HYPHEN + MODIFIED + JAR_EXTENSION); - dumpJar(modifiedTestClassDef, unmodifiedTestFiles, modifiedTestJarPath); - - //Have a modified jar mapping to modify graal vm classpath - if (!originalVsModifiedJarMap.containsKey(testJarPath)) { - originalVsModifiedJarMap.put(testJarPath, modifiedTestJarPath); + testExecutionDependencies.remove(mainJarPath); + testExecutionDependencies.add(modifiedJarPath); } } diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java index d5f9ba6b5f40..7dda824492d9 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java @@ -21,9 +21,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; -import io.ballerina.projects.Module; import io.ballerina.projects.Package; -import io.ballerina.projects.util.ProjectUtils; import io.ballerina.runtime.internal.util.RuntimeUtils; import org.ballerinalang.test.runtime.entity.TestSuite; @@ -45,6 +43,8 @@ import static io.ballerina.runtime.api.constants.RuntimeConstants.FILE_NAME_PERIOD_SEPARATOR; import static org.ballerinalang.test.runtime.util.TesterinaConstants.ANON_ORG; import static org.ballerinalang.test.runtime.util.TesterinaConstants.DOT; +import static org.ballerinalang.test.runtime.util.TesterinaConstants.MOCK_FN_DELIMITER; +import static org.ballerinalang.test.runtime.util.TesterinaConstants.MOCK_LEGACY_DELIMITER; /** * Utility functions and classes for test native-image generation. @@ -67,109 +67,110 @@ public static void createReflectConfig(Path nativeConfigPath, Package currentPac - for (Module module : currentPackage.modules()) { - if (module.testDocumentIds().size() != 0) { - String name = module.moduleName().toString(); - String moduleName = ProjectUtils.getJarFileName(module); - - //Add init class - ReflectConfigClass testInitRefConfClz = new ReflectConfigClass(getQualifiedClassName(org, name, version, - MODULE_INIT_CLASS_NAME)); - - testInitRefConfClz.addReflectConfigClassMethod( - new ReflectConfigClassMethod( - "$moduleInit", - new String[]{"io.ballerina.runtime.internal.scheduling.Strand"} - ) - ); - - testInitRefConfClz.addReflectConfigClassMethod( - new ReflectConfigClassMethod( - "$moduleStart", - new String[]{"io.ballerina.runtime.internal.scheduling.Strand"} - ) - ); - - testInitRefConfClz.addReflectConfigClassMethod( - new ReflectConfigClassMethod( - "$moduleStop", - new String[]{"io.ballerina.runtime.internal.scheduling.RuntimeRegistry"} - ) - ); - //Add configuration mapper - ReflectConfigClass testConfigurationMapperRefConfClz = new ReflectConfigClass( - getQualifiedClassName(org, name, version, MODULE_CONFIGURATION_MAPPER)); - - testConfigurationMapperRefConfClz.addReflectConfigClassMethod( - new ReflectConfigClassMethod( - "$configureInit", - new String[]{"java.lang.String[]", "java.nio.file.Path[]", "java.lang.String"} - ) - ); - ReflectConfigClass testTestExecuteGeneratedRefConfClz = new ReflectConfigClass( - testSuiteMap.get(moduleName).getTestUtilityFunctions().get("__execute__")); - testTestExecuteGeneratedRefConfClz.addReflectConfigClassMethod( - new ReflectConfigClassMethod( - "__execute__", - new String[]{ - "io.ballerina.runtime.internal.scheduling.Strand", - "io.ballerina.runtime.api.values.BString", - "io.ballerina.runtime.api.values.BString", - "io.ballerina.runtime.api.values.BString", - "io.ballerina.runtime.api.values.BString", - "io.ballerina.runtime.api.values.BString", - "io.ballerina.runtime.api.values.BString", - "io.ballerina.runtime.api.values.BString", - "io.ballerina.runtime.api.values.BString", - "io.ballerina.runtime.api.values.BString", - "io.ballerina.runtime.api.values.BString" - } - ) - ); - //Add classes with $MOCK_function methods (mock function case) - if (!testSuiteMap.get(moduleName).getMockFunctionNamesMap().isEmpty()) { - ReflectConfigClass testNameZeroNameRefConfClz = new ReflectConfigClass(getQualifiedClassName( - org, name, version, name.replace(DOT, FILE_NAME_PERIOD_SEPARATOR))); - testNameZeroNameRefConfClz.setQueryAllDeclaredMethods(true); - testNameZeroNameRefConfClz.setAllDeclaredFields(true); - testNameZeroNameRefConfClz.setUnsafeAllocated(true); - classList.add(testNameZeroNameRefConfClz); - } - - //Add all class values to the array - classList.add(testInitRefConfClz); - classList.add(testConfigurationMapperRefConfClz); - classList.add(testTestExecuteGeneratedRefConfClz); - + for (Map.Entry entry : testSuiteMap.entrySet()) { + String moduleName = entry.getKey(); + TestSuite testSuite = entry.getValue(); + String name = testSuite.getPackageID(); + + //Add init class + ReflectConfigClass testInitRefConfClz = new ReflectConfigClass(getQualifiedClassName(org, name, version, + MODULE_INIT_CLASS_NAME)); + + testInitRefConfClz.addReflectConfigClassMethod( + new ReflectConfigClassMethod( + "$moduleInit", + new String[]{"io.ballerina.runtime.internal.scheduling.Strand"} + ) + ); + + testInitRefConfClz.addReflectConfigClassMethod( + new ReflectConfigClassMethod( + "$moduleStart", + new String[]{"io.ballerina.runtime.internal.scheduling.Strand"} + ) + ); + + testInitRefConfClz.addReflectConfigClassMethod( + new ReflectConfigClassMethod( + "$moduleStop", + new String[]{"io.ballerina.runtime.internal.scheduling.RuntimeRegistry"} + ) + ); + //Add configuration mapper + ReflectConfigClass testConfigurationMapperRefConfClz = new ReflectConfigClass( + getQualifiedClassName(org, name, version, MODULE_CONFIGURATION_MAPPER)); + + testConfigurationMapperRefConfClz.addReflectConfigClassMethod( + new ReflectConfigClassMethod( + "$configureInit", + new String[]{"java.lang.String[]", "java.nio.file.Path[]", "java.lang.String"} + ) + ); + ReflectConfigClass testTestExecuteGeneratedRefConfClz = new ReflectConfigClass( + testSuiteMap.get(moduleName).getTestUtilityFunctions().get("__execute__")); + testTestExecuteGeneratedRefConfClz.addReflectConfigClassMethod( + new ReflectConfigClassMethod( + "__execute__", + new String[]{ + "io.ballerina.runtime.internal.scheduling.Strand", + "io.ballerina.runtime.api.values.BString", + "io.ballerina.runtime.api.values.BString", + "io.ballerina.runtime.api.values.BString", + "io.ballerina.runtime.api.values.BString", + "io.ballerina.runtime.api.values.BString", + "io.ballerina.runtime.api.values.BString", + "io.ballerina.runtime.api.values.BString", + "io.ballerina.runtime.api.values.BString", + "io.ballerina.runtime.api.values.BString", + "io.ballerina.runtime.api.values.BString" + } + ) + ); + //Add classes with $MOCK_function methods (mock function case) + if (!testSuiteMap.get(moduleName).getMockFunctionNamesMap().isEmpty()) { + ReflectConfigClass functionMockingEntryClz = new ReflectConfigClass(getQualifiedClassName( + org, name, version, name.replace(DOT, FILE_NAME_PERIOD_SEPARATOR))); + functionMockingEntryClz.setQueryAllDeclaredMethods(true); + functionMockingEntryClz.setAllDeclaredFields(true); + functionMockingEntryClz.setUnsafeAllocated(true); + classList.add(functionMockingEntryClz); } - } - //Add classes corresponding to test documents - Path mockedFunctionClassPath = nativeConfigPath.resolve("mocked-func-class-map.json"); - File mockedFunctionClassFile = new File(mockedFunctionClassPath.toString()); - if (mockedFunctionClassFile.isFile()) { - BufferedReader br = Files.newBufferedReader(mockedFunctionClassPath, StandardCharsets.UTF_8); - Gson gsonRead = new Gson(); - Map testFileMockedFunctionMapping = gsonRead.fromJson(br, - new TypeToken>() { - }.getType()); - if (!testFileMockedFunctionMapping.isEmpty()) { - ReflectConfigClass originalTestFileRefConfClz; - for (Map.Entry testFileMockedFunctionMappingEntry : - testFileMockedFunctionMapping.entrySet()) { - String moduleName = testFileMockedFunctionMappingEntry.getKey().split("-")[0]; - String testFile = testFileMockedFunctionMappingEntry.getKey().split("-")[1]; - String[] mockedFunctions = testFileMockedFunctionMappingEntry.getValue(); - originalTestFileRefConfClz = new ReflectConfigClass(getQualifiedClassName(org, moduleName, - version, testFile)); - for (int i = 0; i < mockedFunctions.length; i++) { - originalTestFileRefConfClz.addReflectConfigClassMethod( - new ReflectConfigClassMethod(mockedFunctions[i])); - originalTestFileRefConfClz.setUnsafeAllocated(true); - originalTestFileRefConfClz.setAllDeclaredFields(true); - originalTestFileRefConfClz.setQueryAllDeclaredMethods(true); + //Add all class values to the array + classList.add(testInitRefConfClz); + classList.add(testConfigurationMapperRefConfClz); + classList.add(testTestExecuteGeneratedRefConfClz); + + //Add classes corresponding to test documents + Path mockedFunctionClassPath = nativeConfigPath.resolve("mocked-func-class-map.json"); + File mockedFunctionClassFile = new File(mockedFunctionClassPath.toString()); + if (mockedFunctionClassFile.isFile()) { + BufferedReader br = Files.newBufferedReader(mockedFunctionClassPath, StandardCharsets.UTF_8); + Gson gsonRead = new Gson(); + Map testFileMockedFunctionMapping = gsonRead.fromJson(br, + new TypeToken>() { + }.getType()); + if (!testFileMockedFunctionMapping.isEmpty()) { + ReflectConfigClass originalTestFileRefConfClz; + for (Map.Entry testFileMockedFunctionMappingEntry : + testFileMockedFunctionMapping.entrySet()) { + String moduleNameForTestClz = testFileMockedFunctionMappingEntry.getKey().split("-")[0]; + if (!moduleNameForTestClz.equals(name)) { + continue; + } + String testFile = testFileMockedFunctionMappingEntry.getKey().split("-")[1]; + String[] mockedFunctions = testFileMockedFunctionMappingEntry.getValue(); + originalTestFileRefConfClz = new ReflectConfigClass(getQualifiedClassName(org, moduleNameForTestClz, + version, testFile)); + for (int i = 0; i < mockedFunctions.length; i++) { + originalTestFileRefConfClz.addReflectConfigClassMethod( + new ReflectConfigClassMethod(mockedFunctions[i])); + originalTestFileRefConfClz.setUnsafeAllocated(true); + originalTestFileRefConfClz.setAllDeclaredFields(true); + originalTestFileRefConfClz.setQueryAllDeclaredMethods(true); + } + classList.add(originalTestFileRefConfClz); } - classList.add(originalTestFileRefConfClz); } } } @@ -214,16 +215,27 @@ private static void extractMockFunctionClassMapping(Map testS for (Map.Entry testSuiteEntry : testSuiteMap.entrySet()) { TestSuite suite = testSuiteEntry.getValue(); for (Map.Entry mockFunctionEntry : suite.getMockFunctionNamesMap().entrySet()) { - String mockFunctionId = mockFunctionEntry.getKey(); - String mockFunctionClass = mockFunctionId.split("#")[0]; - String mockFunction = mockFunctionId.split("#")[1]; - if (mockFunctionClassMapping.containsKey(mockFunctionClass)) { - mockFunctionClassMapping.get(mockFunctionClass).add("$ORIG_" + mockFunction); + String key = mockFunctionEntry.getKey(); + String functionToMockClassName; + String functionToMock; + if (key.indexOf(MOCK_LEGACY_DELIMITER) == -1) { + functionToMockClassName = key.substring(0, key.indexOf(MOCK_FN_DELIMITER)); + functionToMock = key.substring(key.indexOf(MOCK_FN_DELIMITER)+1); + } else if (key.indexOf(MOCK_FN_DELIMITER) == -1) { + functionToMockClassName = key.substring(0, key.indexOf(MOCK_LEGACY_DELIMITER)); + functionToMock = key.substring(key.indexOf(MOCK_LEGACY_DELIMITER)+1); } else { - List mockFunctionList = new ArrayList<>(); - mockFunctionList.add("$ORIG_" + mockFunction); - mockFunctionClassMapping.put(mockFunctionClass, mockFunctionList); + if (key.indexOf(MOCK_FN_DELIMITER) < key.indexOf(MOCK_LEGACY_DELIMITER)) { + functionToMockClassName = key.substring(0, key.indexOf(MOCK_FN_DELIMITER)); + functionToMock = key.substring(key.indexOf(MOCK_FN_DELIMITER)+1); + } else { + functionToMockClassName = key.substring(0, key.indexOf(MOCK_LEGACY_DELIMITER)); + functionToMock = key.substring(key.indexOf(MOCK_LEGACY_DELIMITER)+1); + } } + functionToMock = functionToMock.replaceAll("\\\\", ""); + mockFunctionClassMapping.computeIfAbsent(functionToMockClassName, + k -> new ArrayList<>()).add("$ORIG_" + functionToMock); } } } From 335d662fab034156d7eddfa1bf80cf1c7e6d8e7f Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 14 Dec 2022 15:33:05 +0530 Subject: [PATCH 239/450] Add new line --- langlib/lang.stream/src/main/ballerina/stream.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langlib/lang.stream/src/main/ballerina/stream.bal b/langlib/lang.stream/src/main/ballerina/stream.bal index b498479547e9..0f692e0b69e2 100644 --- a/langlib/lang.stream/src/main/ballerina/stream.bal +++ b/langlib/lang.stream/src/main/ballerina/stream.bal @@ -207,4 +207,4 @@ public isolated function close(stream stm) returns Completi return itrObj.close(); } return; -} \ No newline at end of file +} From 994c46dff74bc15bb758f1986d6eee75622c99a5 Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 14 Dec 2022 15:45:34 +0530 Subject: [PATCH 240/450] Fix test cases --- .../resources/signature/expressions/config/exprLangLibs1.json | 2 +- .../resources/signature/expressions/config/exprLangLibs2.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json index aabd4b154fab..445df2ee0ba6 100644 --- a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json +++ b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json @@ -12,7 +12,7 @@ "documentation": { "right": { "kind": "markdown", - "value": "**Description** \nReturns a substring of a string.\n\n```ballerina\n\"Hello, my name is John\".substring(7) \u21d2 \"my name is John\"\n\"Hello, my name is John\".substring(18, 22) ⇒ \"John\"\n```" + "value": "**Description** \nReturns a substring of a string.\n\n```ballerina\n\"Hello, my name is John\".substring(7) \u21d2 \"my name is John\"\n\"Hello, my name is John Anderson\".substring(18, 22) \u21d2 \"John\"\n```" } }, "parameters": [ diff --git a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json index 444fff6aab7d..2553e2ee9f72 100644 --- a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json +++ b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json @@ -12,7 +12,7 @@ "documentation": { "right": { "kind": "markdown", - "value": "**Description** \nReturns a substring of a string.\n\n```ballerina\n\"Hello, my name is John\".substring(7) \u21d2 \"my name is John\"\n\"Hello, my name is John\".substring(18, 22) ⇒ \"John\"\n```" + "value": "**Description** \nReturns a substring of a string.\n\n```ballerina\n\"Hello, my name is John\".substring(7) \u21d2 \"my name is John\"\n\"Hello, my name is John Anderson\".substring(18, 22) \u21d2 \"John\"\n```" } }, "parameters": [ From 390cc18a695f3d42fc7b6b45e94f7453df69595d Mon Sep 17 00:00:00 2001 From: Thevakumar-Luheerathan Date: Wed, 14 Dec 2022 16:29:45 +0530 Subject: [PATCH 241/450] Remove code coverage and add warning --- .../cli/task/RunNativeImageTestTask.java | 63 +++---------------- 1 file changed, 8 insertions(+), 55 deletions(-) diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java index a92c3d8907de..99205295c1dc 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java @@ -80,7 +80,6 @@ import static io.ballerina.cli.launcher.LauncherUtils.createLauncherException; import static io.ballerina.cli.utils.NativeUtils.createReflectConfig; -import static io.ballerina.cli.utils.TestUtils.generateCoverage; import static io.ballerina.cli.utils.TestUtils.generateTesterinaReports; import static io.ballerina.projects.util.ProjectConstants.BIN_DIR_NAME; import static io.ballerina.runtime.api.constants.RuntimeConstants.FILE_NAME_PERIOD_SEPARATOR; @@ -97,9 +96,6 @@ import static org.ballerinalang.test.runtime.util.TesterinaConstants.MODIFIED; import static org.ballerinalang.test.runtime.util.TesterinaConstants.PATH_SEPARATOR; import static org.ballerinalang.test.runtime.util.TesterinaConstants.TESTABLE; -import static org.wso2.ballerinalang.compiler.util.ProjectDirConstants.BALLERINA_HOME; -import static org.wso2.ballerinalang.compiler.util.ProjectDirConstants.BALLERINA_HOME_BRE; -import static org.wso2.ballerinalang.compiler.util.ProjectDirConstants.BALLERINA_HOME_LIB; /** * Task for executing tests. @@ -381,7 +377,11 @@ public void execute(Project project) { report = project.buildOptions().testReport(); coverage = project.buildOptions().codeCoverage(); - if (report || coverage) { + if (coverage) { + this.out.println("WARNING: Code coverage generation is not supported currently by Ballerina native test"); + } + + if (report) { testReport = new TestReport(); } @@ -439,7 +439,7 @@ public void execute(Project project) { if (project.kind() == ProjectKind.SINGLE_FILE_PROJECT) { suite.setSourceFileName(project.sourceRoot().getFileName().toString()); } - suite.setReportRequired(report || coverage); + suite.setReportRequired(report); if (!isMockFunctionExist) { isMockFunctionExist = !suite.getMockFunctionNamesMap().isEmpty(); } @@ -499,7 +499,7 @@ public void execute(Project project) { try { testResult = runTestSuiteWithNativeImage(project.currentPackage(), target, testSuiteMap); - if (report || coverage) { + if (report) { for (Map.Entry testSuiteEntry : testSuiteMap.entrySet()) { String moduleName = testSuiteEntry.getKey(); ModuleStatus moduleStatus = TestUtils.loadModuleStatusFromFile( @@ -524,10 +524,8 @@ public void execute(Project project) { } } } - if ((report || coverage) && hasTests) { + if (report && hasTests) { try { - generateCoverage(project, testReport, jBallerinaBackend, - this.includesInCoverage, this.coverageReportFormat, this.coverageModules); generateTesterinaReports(project, testReport, this.out, target); } catch (IOException e) { TestUtils.cleanTempCache(project, cachesRoot); @@ -565,51 +563,6 @@ private int runTestSuiteWithNativeImage(Package currentPackage, Target target, "Install it using: gu install native-image"); } - if (coverage) { - // Generate the exec in a separate process - List execArgs = new ArrayList<>(); - execArgs.add(System.getProperty("java.command")); - - String mainClassName = TesterinaConstants.TESTERINA_LAUNCHER_CLASS_NAME; - - jacocoAgentJarPath = Paths.get(System.getProperty(BALLERINA_HOME)).resolve(BALLERINA_HOME_BRE) - .resolve(BALLERINA_HOME_LIB).resolve(TesterinaConstants.AGENT_FILE_NAME).toString(); - - String agentCommand = "-javaagent:" + - jacocoAgentJarPath + "=destfile=" - + target.getTestsCachePath().resolve(TesterinaConstants.COVERAGE_DIR) - .resolve(TesterinaConstants.EXEC_FILE_NAME); - - if (!TesterinaConstants.DOT.equals(packageName) && this.includesInCoverage == null) { - // add user defined classes for generating the jacoco exec file - agentCommand += ",includes=" + currentPackage.packageOrg().toString() + ".*"; - } else { - agentCommand += ",includes=" + this.includesInCoverage; - } - - execArgs.add(agentCommand); - execArgs.addAll(Lists.of("-cp", classPath)); - execArgs.add(mainClassName); - - // Adds arguments to be read at the Test Runner - execArgs.add(target.path().toString()); - execArgs.add(jacocoAgentJarPath); - execArgs.add(Boolean.toString(report)); - execArgs.add(Boolean.toString(coverage)); - execArgs.add(this.groupList != null ? this.groupList : ""); - execArgs.add(this.disableGroupList != null ? this.disableGroupList : ""); - execArgs.add(this.singleExecTests != null ? this.singleExecTests : ""); - execArgs.add(Boolean.toString(isRerunTestExecution)); - execArgs.add(Boolean.toString(listGroups)); - - ProcessBuilder processBuilder = new ProcessBuilder(execArgs).inheritIO(); - Process proc = processBuilder.start(); - - if (proc.waitFor() != 0) { - out.println("Jacoco exec generation failed"); - } - } - List cmdArgs = new ArrayList<>(); List nativeArgs = new ArrayList<>(); cmdArgs.add(nativeImageCommand); From daf333d96e96700f46e817654782bb6102b53557 Mon Sep 17 00:00:00 2001 From: Nadeeshan96 Date: Wed, 14 Dec 2022 16:54:40 +0530 Subject: [PATCH 242/450] Refactor BLangNodeBuilder --- .../compiler/parser/BLangNodeBuilder.java | 34 ++++++++----------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java index f9c983aa9169..0e5757e7ac70 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java @@ -883,9 +883,8 @@ private void createAnonymousTypeDefForConstantDeclaration(BLangConstant constant BLangTypeDefinition typeDef = (BLangTypeDefinition) TreeBuilder.createTypeDefinition(); this.anonTypeNameSuffixes.push(constantNode.name.value); String genName = anonymousModelHelper.getNextAnonymousTypeKey(packageID, anonTypeNameSuffixes); - IdentifierNode anonTypeGenName = createIdentifier(symTable.builtinPos, genName); - setOriginalNameForAnonTypeGenName(anonTypeGenName); this.anonTypeNameSuffixes.pop(); + IdentifierNode anonTypeGenName = createIdentifier(symTable.builtinPos, genName, constantNode.name.value); typeDef.setName(anonTypeGenName); typeDef.flagSet.add(Flag.PUBLIC); typeDef.flagSet.add(Flag.ANONYMOUS); @@ -1045,32 +1044,21 @@ private void reverseFlatMap(List> listOfLists, List result) { } private BLangUserDefinedType deSugarTypeAsUserDefType(BLangType toIndirect) { - BLangTypeDefinition bLTypeDef = createTypeDefinitionWithTypeNode(toIndirect); + BLangTypeDefinition bLTypeDef = createTypeDefinitionWithTypeNode(toIndirect, null); Location pos = toIndirect.pos; addToTop(bLTypeDef); return createUserDefinedType(pos, (BLangIdentifier) TreeBuilder.createIdentifierNode(), bLTypeDef.name); } - private void setOriginalNameForAnonTypeGenName(IdentifierNode anonTypeGenName) { - if (!this.anonTypeNameSuffixes.isEmpty()) { - StringBuilder originalName = new StringBuilder( - this.anonTypeNameSuffixes.elementAt(this.anonTypeNameSuffixes.size() - 1)); - for (int i = this.anonTypeNameSuffixes.size() - 2; i >= 0; i--) { - originalName.append(DOLLAR).append(this.anonTypeNameSuffixes.elementAt(i)); - } - anonTypeGenName.setOriginalValue(originalName.toString()); - } - } - - private BLangTypeDefinition createTypeDefinitionWithTypeNode(BLangType toIndirect) { + private BLangTypeDefinition createTypeDefinitionWithTypeNode(BLangType toIndirect, String originalName) { Location pos = toIndirect.pos; BLangTypeDefinition bLTypeDef = (BLangTypeDefinition) TreeBuilder.createTypeDefinition(); // Generate a name for the anonymous object String genName = anonymousModelHelper.getNextAnonymousTypeKey(packageID, this.anonTypeNameSuffixes); - IdentifierNode anonTypeGenName = createIdentifier(symTable.builtinPos, genName); - setOriginalNameForAnonTypeGenName(anonTypeGenName); + IdentifierNode anonTypeGenName = originalName == null ? createIdentifier(symTable.builtinPos, genName) + : createIdentifier(symTable.builtinPos, genName, originalName); bLTypeDef.setName(anonTypeGenName); bLTypeDef.flagSet.add(Flag.PUBLIC); bLTypeDef.flagSet.add(Flag.ANONYMOUS); @@ -3850,14 +3838,16 @@ public BLangConstant transformEnumMember(EnumMemberNode member, Boolean publicQu BLangFiniteTypeNode typeNodeAssociated = (BLangFiniteTypeNode) TreeBuilder.createFiniteTypeNode(); literal.originalValue = null; typeNodeAssociated.addValue(deepLiteral); - bLangConstant.associatedTypeDefinition = createTypeDefinitionWithTypeNode(typeNodeAssociated); + bLangConstant.associatedTypeDefinition = createTypeDefinitionWithTypeNode(typeNodeAssociated, + memberName.value); } else { bLangConstant.associatedTypeDefinition = null; } } else { BLangFiniteTypeNode typeNodeAssociated = (BLangFiniteTypeNode) TreeBuilder.createFiniteTypeNode(); typeNodeAssociated.addValue(deepLiteral); - bLangConstant.associatedTypeDefinition = createTypeDefinitionWithTypeNode(typeNodeAssociated); + bLangConstant.associatedTypeDefinition = createTypeDefinitionWithTypeNode(typeNodeAssociated, + memberName.value); } this.anonTypeNameSuffixes.pop(); return bLangConstant; @@ -5945,6 +5935,10 @@ private BLangIdentifier createIdentifier(Location pos, Token token, boolean isXM } private BLangIdentifier createIdentifier(Location pos, String value) { + return createIdentifier(pos, value, value); + } + + private BLangIdentifier createIdentifier(Location pos, String value, String originalValue) { BLangIdentifier bLIdentifer = (BLangIdentifier) TreeBuilder.createIdentifierNode(); if (value == null) { return bLIdentifer; @@ -5957,7 +5951,7 @@ private BLangIdentifier createIdentifier(Location pos, String value) { bLIdentifer.setValue(Utils.unescapeUnicodeCodepoints(value)); bLIdentifer.setLiteral(false); } - bLIdentifer.setOriginalValue(value); + bLIdentifer.setOriginalValue(originalValue); bLIdentifer.pos = pos; return bLIdentifer; } From d6d84547593443b74fe3d5feb2e170216deba39e Mon Sep 17 00:00:00 2001 From: Shammi Kolonne Date: Wed, 14 Dec 2022 19:53:10 +0530 Subject: [PATCH 243/450] Remove extra new line in Dependencies.toml --- .../resources/expectedDependencies.toml | 1 - .../java/io/ballerina/projects/util/ProjectUtils.java | 8 ++++---- .../Dependencies.toml | 1 - .../hierarchical_pkg_names/package_b/Dependencies.toml | 1 + .../src/test/resources/myproject/Dependencies.toml | 1 - .../myproject/resources/expectedDependencies.toml | 1 - .../package_c_1_0_0/resources/Dependencies-0001-1.toml | 1 - .../package_c_1_0_0/resources/Dependencies-0001-2.toml | 1 - .../resources/Dependencies-0002.toml | 1 - .../resources/Dependencies.toml | 1 - .../resources/Dependencies-0003-1.toml | 1 - .../resources/Dependencies-0003-2.toml | 1 - .../resources/Dependencies.toml | 1 - .../package_f_1_0_0/resources/Dependencies-0006-1.toml | 1 - .../resources/Dependencies-0006-2.toml | 1 - .../resources/Dependencies-0006-3.toml | 1 - .../resources/Dependencies.toml | 1 - .../package_i_1_0_0/resources/Dependencies-0004-1.toml | 1 - .../package_l_1_0_0/resources/Dependencies-0005-1.toml | 1 - .../package_l_1_0_0/resources/Dependencies-0005-2.toml | 1 - .../project_o/resources/Dependencies.toml | 1 - .../project_o_with_import/resources/Dependencies.toml | 1 - .../resources/Dependencies.toml | 1 - .../resources/Dependencies.toml | 1 - .../resources/Dependencies_NoSticky.toml | 1 - .../project_s/resources/Dependencies.toml | 1 - .../project_s/resources/Dependencies_NoSticky.toml | 1 - .../project_t/resources/Dependencies.toml | 1 - .../project_t_with_import/resources/Dependencies.toml | 1 - .../package_a/Dependencies.toml | 1 + .../package_b/Dependencies.toml | 1 + .../package_d/resources/expectedDependencies.toml | 1 - .../package_f/resources/UpdatedDependencies.toml | 1 - .../resources/UpdatedDependencies.toml | 1 - .../package_missing_transitive_dep/Dependencies.toml | 1 + .../package_n/Dependencies.toml | 1 - .../package_d/resources/expectedDependencies.toml | 1 - 37 files changed, 8 insertions(+), 36 deletions(-) diff --git a/cli/ballerina-cli/src/test/resources/test-resources/validProjectWoRootPkgInDepsToml/resources/expectedDependencies.toml b/cli/ballerina-cli/src/test/resources/test-resources/validProjectWoRootPkgInDepsToml/resources/expectedDependencies.toml index 4dce8d3c07ce..5ccf30181c95 100644 --- a/cli/ballerina-cli/src/test/resources/test-resources/validProjectWoRootPkgInDepsToml/resources/expectedDependencies.toml +++ b/cli/ballerina-cli/src/test/resources/test-resources/validProjectWoRootPkgInDepsToml/resources/expectedDependencies.toml @@ -25,4 +25,3 @@ modules = [ {org = "foo", packageName = "winery", moduleName = "winery"} ] - diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectUtils.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectUtils.java index 411ed419e8d8..a0f6bfd4ceb3 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectUtils.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectUtils.java @@ -734,15 +734,15 @@ public static String getDependenciesTomlContent(Collection { + content.append("\n"); PackageDescriptor descriptor = graphDependency.packageInstance().descriptor(); addDependencyContent(content, descriptor.org().value(), descriptor.name().value(), descriptor.version().value().toString(), null, Collections.emptyList(), Collections.emptyList()); - content.append("\n"); }); return String.valueOf(content); } @@ -760,14 +760,14 @@ public static String getDependenciesTomlContent(List pkgDependencies StringBuilder content = new StringBuilder(comment); content.append("[ballerina]\n"); content.append("dependencies-toml-version = \"").append(ProjectConstants.DEPENDENCIES_TOML_VERSION) - .append("\"\n\n"); + .append("\"\n"); // write dependencies from package dependency graph pkgDependencies.forEach(dependency -> { + content.append("\n"); addDependencyContent(content, dependency.getOrg(), dependency.getName(), dependency.getVersion(), getDependencyScope(dependency.getScope()), dependency.getDependencies(), dependency.getModules()); - content.append("\n"); }); return String.valueOf(content); } diff --git a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/package_comp_plugin_code_modify_add_function/Dependencies.toml b/project-api/project-api-test/src/test/resources/compiler_plugin_tests/package_comp_plugin_code_modify_add_function/Dependencies.toml index cb41770a10f1..79267b3bb8a3 100644 --- a/project-api/project-api-test/src/test/resources/compiler_plugin_tests/package_comp_plugin_code_modify_add_function/Dependencies.toml +++ b/project-api/project-api-test/src/test/resources/compiler_plugin_tests/package_comp_plugin_code_modify_add_function/Dependencies.toml @@ -14,4 +14,3 @@ modules = [ {org = "samjs", packageName = "package_comp_plugin_code_modify_add_function", moduleName = "package_comp_plugin_code_modify_add_function"} ] - diff --git a/project-api/project-api-test/src/test/resources/hierarchical_pkg_names/package_b/Dependencies.toml b/project-api/project-api-test/src/test/resources/hierarchical_pkg_names/package_b/Dependencies.toml index 005b4b82f2dd..e4c85b78bd7b 100644 --- a/project-api/project-api-test/src/test/resources/hierarchical_pkg_names/package_b/Dependencies.toml +++ b/project-api/project-api-test/src/test/resources/hierarchical_pkg_names/package_b/Dependencies.toml @@ -23,3 +23,4 @@ modules = [ org = "samjs" name = "package_c" version = "0.1.0" + diff --git a/project-api/project-api-test/src/test/resources/myproject/Dependencies.toml b/project-api/project-api-test/src/test/resources/myproject/Dependencies.toml index c4ed02bae887..626152a6741a 100644 --- a/project-api/project-api-test/src/test/resources/myproject/Dependencies.toml +++ b/project-api/project-api-test/src/test/resources/myproject/Dependencies.toml @@ -29,4 +29,3 @@ modules = [ {org = "samjs", packageName = "package_k", moduleName = "package_k.mod_k2"} ] - diff --git a/project-api/project-api-test/src/test/resources/myproject/resources/expectedDependencies.toml b/project-api/project-api-test/src/test/resources/myproject/resources/expectedDependencies.toml index c4ed02bae887..626152a6741a 100644 --- a/project-api/project-api-test/src/test/resources/myproject/resources/expectedDependencies.toml +++ b/project-api/project-api-test/src/test/resources/myproject/resources/expectedDependencies.toml @@ -29,4 +29,3 @@ modules = [ {org = "samjs", packageName = "package_k", moduleName = "package_k.mod_k2"} ] - diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_c_1_0_0/resources/Dependencies-0001-1.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_c_1_0_0/resources/Dependencies-0001-1.toml index 8696bece24ab..6c6087ff42f3 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_c_1_0_0/resources/Dependencies-0001-1.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_c_1_0_0/resources/Dependencies-0001-1.toml @@ -35,4 +35,3 @@ modules = [ {org = "adv_res", packageName = "package_c", moduleName = "package_c"} ] - diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_c_1_0_0/resources/Dependencies-0001-2.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_c_1_0_0/resources/Dependencies-0001-2.toml index e3f8ccddcf93..31ea988f5a44 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_c_1_0_0/resources/Dependencies-0001-2.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_c_1_0_0/resources/Dependencies-0001-2.toml @@ -35,4 +35,3 @@ modules = [ {org = "adv_res", packageName = "package_c", moduleName = "package_c"} ] - diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_c_1_0_0_new_import/resources/Dependencies-0002.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_c_1_0_0_new_import/resources/Dependencies-0002.toml index be8760cb3930..2ac5a0c48bc1 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_c_1_0_0_new_import/resources/Dependencies-0002.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_c_1_0_0_new_import/resources/Dependencies-0002.toml @@ -41,4 +41,3 @@ modules = [ {org = "adv_res", packageName = "package_c", moduleName = "package_c"} ] - diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_c_1_0_0_new_import/resources/Dependencies.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_c_1_0_0_new_import/resources/Dependencies.toml index 8696bece24ab..6c6087ff42f3 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_c_1_0_0_new_import/resources/Dependencies.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_c_1_0_0_new_import/resources/Dependencies.toml @@ -35,4 +35,3 @@ modules = [ {org = "adv_res", packageName = "package_c", moduleName = "package_c"} ] - diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_c_1_0_0_remove_import/resources/Dependencies-0003-1.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_c_1_0_0_remove_import/resources/Dependencies-0003-1.toml index 41478cc30905..82b10c72f7e9 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_c_1_0_0_remove_import/resources/Dependencies-0003-1.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_c_1_0_0_remove_import/resources/Dependencies-0003-1.toml @@ -35,4 +35,3 @@ modules = [ {org = "adv_res", packageName = "package_c", moduleName = "package_c"} ] - diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_c_1_0_0_remove_import/resources/Dependencies-0003-2.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_c_1_0_0_remove_import/resources/Dependencies-0003-2.toml index e3f8ccddcf93..31ea988f5a44 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_c_1_0_0_remove_import/resources/Dependencies-0003-2.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_c_1_0_0_remove_import/resources/Dependencies-0003-2.toml @@ -35,4 +35,3 @@ modules = [ {org = "adv_res", packageName = "package_c", moduleName = "package_c"} ] - diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_c_1_0_0_remove_import/resources/Dependencies.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_c_1_0_0_remove_import/resources/Dependencies.toml index be8760cb3930..2ac5a0c48bc1 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_c_1_0_0_remove_import/resources/Dependencies.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_c_1_0_0_remove_import/resources/Dependencies.toml @@ -41,4 +41,3 @@ modules = [ {org = "adv_res", packageName = "package_c", moduleName = "package_c"} ] - diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_f_1_0_0/resources/Dependencies-0006-1.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_f_1_0_0/resources/Dependencies-0006-1.toml index 0c021eb749ec..50089961c960 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_f_1_0_0/resources/Dependencies-0006-1.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_f_1_0_0/resources/Dependencies-0006-1.toml @@ -36,4 +36,3 @@ modules = [ {org = "adv_res", packageName = "package_f", moduleName = "package_f"} ] - diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_f_1_0_0_remove_import_d/resources/Dependencies-0006-2.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_f_1_0_0_remove_import_d/resources/Dependencies-0006-2.toml index 002f9178fd25..25611ca845c2 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_f_1_0_0_remove_import_d/resources/Dependencies-0006-2.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_f_1_0_0_remove_import_d/resources/Dependencies-0006-2.toml @@ -25,4 +25,3 @@ modules = [ {org = "adv_res", packageName = "package_f", moduleName = "package_f"} ] - diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_f_1_0_0_remove_import_d/resources/Dependencies-0006-3.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_f_1_0_0_remove_import_d/resources/Dependencies-0006-3.toml index 7142d4f30dbb..7d44faaf6dd5 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_f_1_0_0_remove_import_d/resources/Dependencies-0006-3.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_f_1_0_0_remove_import_d/resources/Dependencies-0006-3.toml @@ -33,4 +33,3 @@ modules = [ {org = "adv_res", packageName = "package_f", moduleName = "package_f"} ] - diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_f_1_0_0_remove_import_d/resources/Dependencies.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_f_1_0_0_remove_import_d/resources/Dependencies.toml index 0c021eb749ec..50089961c960 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_f_1_0_0_remove_import_d/resources/Dependencies.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_f_1_0_0_remove_import_d/resources/Dependencies.toml @@ -36,4 +36,3 @@ modules = [ {org = "adv_res", packageName = "package_f", moduleName = "package_f"} ] - diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_i_1_0_0/resources/Dependencies-0004-1.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_i_1_0_0/resources/Dependencies-0004-1.toml index 3c84ac826a11..545129637dd4 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_i_1_0_0/resources/Dependencies-0004-1.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_i_1_0_0/resources/Dependencies-0004-1.toml @@ -33,4 +33,3 @@ org = "ballerinai" name = "package_g" version = "0.0.0" - diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_l_1_0_0/resources/Dependencies-0005-1.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_l_1_0_0/resources/Dependencies-0005-1.toml index 982036bfa792..ac6367b27515 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_l_1_0_0/resources/Dependencies-0005-1.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_l_1_0_0/resources/Dependencies-0005-1.toml @@ -47,4 +47,3 @@ dependencies = [ {org = "adv_res", name = "package_e"} ] - diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_l_1_0_0/resources/Dependencies-0005-2.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_l_1_0_0/resources/Dependencies-0005-2.toml index 438acfc4102f..82dc0d7b784e 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_l_1_0_0/resources/Dependencies-0005-2.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/package_l_1_0_0/resources/Dependencies-0005-2.toml @@ -47,4 +47,3 @@ dependencies = [ {org = "adv_res", name = "package_e"} ] - diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_o/resources/Dependencies.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_o/resources/Dependencies.toml index a11626402163..cbe5ff5a8cbf 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_o/resources/Dependencies.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_o/resources/Dependencies.toml @@ -33,4 +33,3 @@ modules = [ {org = "adv_res", packageName = "project_o", moduleName = "project_o"} ] - diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_o_with_import/resources/Dependencies.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_o_with_import/resources/Dependencies.toml index 0988fb394009..bcf3a350eecc 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_o_with_import/resources/Dependencies.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_o_with_import/resources/Dependencies.toml @@ -37,4 +37,3 @@ modules = [ {org = "adv_res", packageName = "project_o", moduleName = "project_o"} ] - diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_o_with_import_local_dependency/resources/Dependencies.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_o_with_import_local_dependency/resources/Dependencies.toml index 75837e4089ca..f280c7ee27c3 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_o_with_import_local_dependency/resources/Dependencies.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_o_with_import_local_dependency/resources/Dependencies.toml @@ -37,4 +37,3 @@ modules = [ {org = "adv_res", packageName = "project_o", moduleName = "project_o"} ] - diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_q_pre_release_only/resources/Dependencies.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_q_pre_release_only/resources/Dependencies.toml index 01599f309e9e..b62f88e24bba 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_q_pre_release_only/resources/Dependencies.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_q_pre_release_only/resources/Dependencies.toml @@ -25,4 +25,3 @@ modules = [ {org = "adv_res", packageName = "package_q_pre_release_only", moduleName = "package_q_pre_release_only"} ] - diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_q_pre_release_only/resources/Dependencies_NoSticky.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_q_pre_release_only/resources/Dependencies_NoSticky.toml index ed2f2b910eff..715bf06565bd 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_q_pre_release_only/resources/Dependencies_NoSticky.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_q_pre_release_only/resources/Dependencies_NoSticky.toml @@ -25,4 +25,3 @@ modules = [ {org = "adv_res", packageName = "package_q_pre_release_only", moduleName = "package_q_pre_release_only"} ] - diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_s/resources/Dependencies.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_s/resources/Dependencies.toml index bf03b63ad1f3..1a939d983e9a 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_s/resources/Dependencies.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_s/resources/Dependencies.toml @@ -25,4 +25,3 @@ modules = [ {org = "adv_res", packageName = "project_s", moduleName = "project_s"} ] - diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_s/resources/Dependencies_NoSticky.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_s/resources/Dependencies_NoSticky.toml index 2960126ac672..190c9eb25b29 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_s/resources/Dependencies_NoSticky.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_s/resources/Dependencies_NoSticky.toml @@ -26,4 +26,3 @@ modules = [ {org = "adv_res", packageName = "project_s", moduleName = "project_s"} ] - diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_t/resources/Dependencies.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_t/resources/Dependencies.toml index 6023cfc49aba..aad733b95693 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_t/resources/Dependencies.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_t/resources/Dependencies.toml @@ -26,4 +26,3 @@ modules = [ {org = "adv_res", packageName = "project_t", moduleName = "project_t"} ] - diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_t_with_import/resources/Dependencies.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_t_with_import/resources/Dependencies.toml index adcfff19d5b4..1b4def3c53a5 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_t_with_import/resources/Dependencies.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_integration_tests/project_t_with_import/resources/Dependencies.toml @@ -35,4 +35,3 @@ modules = [ {org = "adv_res", packageName = "project_t", moduleName = "project_t"} ] - diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/package_a/Dependencies.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/package_a/Dependencies.toml index f78ef195f01e..648a3d2583e4 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/package_a/Dependencies.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/package_a/Dependencies.toml @@ -23,3 +23,4 @@ modules = [ org = "samjs" name = "package_b" version = "0.1.0" + diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/package_b/Dependencies.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/package_b/Dependencies.toml index 005b4b82f2dd..e4c85b78bd7b 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/package_b/Dependencies.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/package_b/Dependencies.toml @@ -23,3 +23,4 @@ modules = [ org = "samjs" name = "package_c" version = "0.1.0" + diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/package_d/resources/expectedDependencies.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/package_d/resources/expectedDependencies.toml index 110a3391eb28..5e81bbe28811 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/package_d/resources/expectedDependencies.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/package_d/resources/expectedDependencies.toml @@ -44,4 +44,3 @@ modules = [ {org = "samjs", packageName = "package_e", moduleName = "package_e"} ] - diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/package_f/resources/UpdatedDependencies.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/package_f/resources/UpdatedDependencies.toml index 233332059605..a2f0ba711d19 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/package_f/resources/UpdatedDependencies.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/package_f/resources/UpdatedDependencies.toml @@ -57,4 +57,3 @@ modules = [ {org = "samjs", packageName = "package_f", moduleName = "package_f"} ] - diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/package_f_old_local/resources/UpdatedDependencies.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/package_f_old_local/resources/UpdatedDependencies.toml index 7d881d9c3c79..54163aa7edba 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/package_f_old_local/resources/UpdatedDependencies.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/package_f_old_local/resources/UpdatedDependencies.toml @@ -57,4 +57,3 @@ modules = [ {org = "samjs", packageName = "package_f_local", moduleName = "package_f_local"} ] - diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/package_missing_transitive_dep/Dependencies.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/package_missing_transitive_dep/Dependencies.toml index d411e19f1c33..2f5137303674 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/package_missing_transitive_dep/Dependencies.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/package_missing_transitive_dep/Dependencies.toml @@ -7,3 +7,4 @@ version = "0.1.0" org = "samjs" name = "package_kk" version = "1.0.0" + diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/package_n/Dependencies.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/package_n/Dependencies.toml index 734da6387149..fb06868883de 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/package_n/Dependencies.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/package_n/Dependencies.toml @@ -25,4 +25,3 @@ modules = [ {org = "samjs", packageName = "package_o", moduleName = "package_o"} ] - diff --git a/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/packages_for_various_dist_test/package_d/resources/expectedDependencies.toml b/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/packages_for_various_dist_test/package_d/resources/expectedDependencies.toml index 110a3391eb28..5e81bbe28811 100644 --- a/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/packages_for_various_dist_test/package_d/resources/expectedDependencies.toml +++ b/project-api/project-api-test/src/test/resources/projects_for_resolution_tests/packages_for_various_dist_test/package_d/resources/expectedDependencies.toml @@ -44,4 +44,3 @@ modules = [ {org = "samjs", packageName = "package_e", moduleName = "package_e"} ] - From c4d76274b903baf98dd23fb693b8cfade199c376 Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 14 Dec 2022 20:32:03 +0530 Subject: [PATCH 244/450] Update fromBytes example --- langlib/lang.string/src/main/ballerina/string.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index 53edb2a66d04..a6aaa0a84404 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -310,7 +310,7 @@ public isolated function toBytes(string str) returns byte[] = @java:Method { # # ```ballerina # string:fromBytes([72, 101, 108, 108, 111, 32, 66, 97, 108, 108, 101, 114, 105, 110, 97, 33]) ⇒ Hello, World! -# string:fromBytes([12, 45, 45]) ⇒ error +# string:fromBytes(base64 `lang`) ⇒ error # ``` # # + bytes - UTF-8 byte array From 6f9a264bdc063282cf319de28a50758ee68d60da Mon Sep 17 00:00:00 2001 From: Shammi Kolonne Date: Tue, 13 Dec 2022 10:40:02 +0530 Subject: [PATCH 245/450] Fix issues with package name in bal new --- .../io/ballerina/cli/cmd/NewCommandTest.java | 25 +++++++++++++++++++ .../ballerina/projects/util/ProjectUtils.java | 11 ++++++++ 2 files changed, 36 insertions(+) diff --git a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/NewCommandTest.java b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/NewCommandTest.java index dd767b93884f..e78e286c0ed5 100644 --- a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/NewCommandTest.java +++ b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/NewCommandTest.java @@ -721,6 +721,31 @@ public void testNewCommandWithInvalidPackageNames1(String packageName, String ou Assert.assertEquals(buildLog.replaceAll("\r", ""), getOutput(outputLog)); } + @DataProvider(name = "PackageNameHasOnlyNonAlphanumeric") + public Object[][] providePackageNameHasOnlyNonAlphanumeric() { + return new Object[][] { + { "#", "my_package" }, + { "_", "my_package" } + }; + } + @Test(description = "Test new command with package name has only non alpha-numeric characters", + dataProvider = "PackageNameHasOnlyNonAlphanumeric") + public void testNewCommandWithPackageNameHasOnlyNonAlphanumeric(String pkgName, String derivedPkgName) + throws IOException { + String[] args = {pkgName}; + NewCommand newCommand = new NewCommand(tmpDir, printStream, false); + new CommandLine(newCommand).parseArgs(args); + newCommand.execute(); + Path packageDir = tmpDir.resolve(pkgName); + Assert.assertTrue(Files.exists(packageDir)); + Assert.assertTrue(Files.exists(packageDir.resolve(ProjectConstants.BALLERINA_TOML))); + Assert.assertTrue(Files.exists(packageDir.resolve("main.bal"))); + String buildOutput = readOutput().replaceAll("\r", ""); + Assert.assertEquals(buildOutput, "package name is derived as '" + derivedPkgName + "'. " + + "Edit the Ballerina.toml to change it.\n\n" + + "Created new package '" + derivedPkgName + "' at " + pkgName + ".\n"); + } + static class Copy extends SimpleFileVisitor { private Path fromPath; private Path toPath; diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectUtils.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectUtils.java index 411ed419e8d8..4c5542f5a660 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectUtils.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/util/ProjectUtils.java @@ -118,6 +118,7 @@ public class ProjectUtils { private static final String USER_HOME = "user.home"; private static final Pattern separatedIdentifierPattern = Pattern.compile("^[a-zA-Z0-9_.]*$"); private static final Pattern onlyDotsPattern = Pattern.compile("^[.]+$"); + private static final Pattern onlyNonAlphanumericPattern = Pattern.compile("^[^a-zA-Z0-9]+$"); private static final Pattern orgNamePattern = Pattern.compile("^[a-zA-Z0-9_]*$"); /** @@ -306,6 +307,10 @@ public static String guessOrgName() { * @return package name */ public static String guessPkgName(String packageName, String template) { + if (!validateOnlyNonAlphanumeric(packageName)) { + packageName = "my_package"; + } + if (!validatePackageName(packageName)) { packageName = packageName.replaceAll("[^a-zA-Z0-9_.]", "_"); } @@ -720,6 +725,12 @@ private static boolean validateDotSeparatedIdentifiers(String identifiers) { return m.matches() && !mm.matches(); } + private static boolean validateOnlyNonAlphanumeric(String identifiers) { + Matcher m = onlyNonAlphanumericPattern.matcher(identifiers); + + return !m.matches(); + } + /** * Get `Dependencies.toml` content as a string. * From 9fe5703da7acab83158451f86040ecf8b27f7fcc Mon Sep 17 00:00:00 2001 From: mindula Date: Tue, 6 Dec 2022 15:08:42 +0530 Subject: [PATCH 246/450] Fix extract to function code action and CCE in create type code action --- .../langserver/codeaction/CodeActionUtil.java | 2 +- .../providers/CreateTypeCodeAction.java | 4 +- .../codeaction/CreateTypeCodeActionTest.java | 3 +- .../ExtractToFunctionCodeActionTest.java | 1 + .../config/create_type_in_record_type.json | 28 +++++++++++++ .../source/create_type_in_record_type.bal | 5 +++ ...tract_to_function_stmts_foreach_stmt2.json | 42 +++++++++++++++++++ ...xtract_to_function_stmts_foreach_stmt2.bal | 12 ++++++ 8 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/create-type/config/create_type_in_record_type.json create mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/create-type/source/create_type_in_record_type.bal create mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/config/extract_to_function_stmts_foreach_stmt2.json create mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/source/extract_to_function_stmts_foreach_stmt2.bal diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/CodeActionUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/CodeActionUtil.java index 1b8af7527fbb..c2cf63e1e26c 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/CodeActionUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/CodeActionUtil.java @@ -298,7 +298,7 @@ public static Map getPossibleTypeSymbols(TypeSymbol typeDesc signature = "(" + newArrType.memberTypeDescriptor().signature() + ")[]"; break; default: - signature = newArrType.signature(); + signature = entry.getValue() + "[]"; } typesMap.put(newArrType, signature); }); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/CreateTypeCodeAction.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/CreateTypeCodeAction.java index 8c0fd40b8666..6415b6dc6436 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/CreateTypeCodeAction.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/CreateTypeCodeAction.java @@ -89,14 +89,14 @@ public List getCodeActions(Diagnostic diagnostic, // This is to be aligned with the open-by-default principle where we become conservative // on what we send (return) StringBuilder sb = new StringBuilder(); - sb.append("type ").append(name.get().getValue()) + sb.append("type ").append(name.get()) .append(" record {").append(isReturnType ? "|" : "") .append(CommonUtil.LINE_SEPARATOR); sb.append(paddingStr).append(CommonUtil.LINE_SEPARATOR); sb.append(isReturnType ? "|" : "").append("};").append(CommonUtil.LINE_SEPARATOR); sb.append(CommonUtil.LINE_SEPARATOR); - String title = String.format("Create record '%s'", name.get().getValue()); + String title = String.format("Create record '%s'", name.get()); CodeAction codeAction = CodeActionUtil.createCodeAction(title, List.of(new TextEdit(range, sb.toString())), context.fileUri(), CodeActionKind.QuickFix); return List.of(codeAction); diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/CreateTypeCodeActionTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/CreateTypeCodeActionTest.java index 4bfb76b61d29..84dab08b5478 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/CreateTypeCodeActionTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/CreateTypeCodeActionTest.java @@ -39,7 +39,8 @@ public void test(String config) throws IOException, WorkspaceDocumentException { public Object[][] dataProvider() { return new Object[][]{ {"create_type_in_return_type1.json"}, - {"create_type_in_function_body1.json"} + {"create_type_in_function_body1.json"}, + {"create_type_in_record_type.json"} }; } diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToFunctionCodeActionTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToFunctionCodeActionTest.java index ac374f66ce5a..1925c11e1fa4 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToFunctionCodeActionTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToFunctionCodeActionTest.java @@ -88,6 +88,7 @@ public Object[][] dataProvider() { {"extract_to_function_stmts_lock_stmt.json"}, {"extract_to_function_stmts_foreach_stmt.json"}, + {"extract_to_function_stmts_foreach_stmt2.json"}, {"extract_to_function_stmts_foreach_stmt_with_range_expr.json"}, {"extract_to_function_stmts_foreach_stmt_without_iterable_declared_inside.json"}, diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/create-type/config/create_type_in_record_type.json b/language-server/modules/langserver-core/src/test/resources/codeaction/create-type/config/create_type_in_record_type.json new file mode 100644 index 000000000000..0e0ebd991d1f --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/create-type/config/create_type_in_record_type.json @@ -0,0 +1,28 @@ +{ + "position": { + "line": 0, + "character": 17 + }, + "source": "create_type_in_record_type.bal", + "expected": [ + { + "title": "Create record 're'", + "kind": "quickfix", + "edits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "type re record {\n \n};\n\n" + } + ] + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/create-type/source/create_type_in_record_type.bal b/language-server/modules/langserver-core/src/test/resources/codeaction/create-type/source/create_type_in_record_type.bal new file mode 100644 index 000000000000..086e783f3953 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/create-type/source/create_type_in_record_type.bal @@ -0,0 +1,5 @@ +type FuelEntry re + +function testFunction() { + +} diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/config/extract_to_function_stmts_foreach_stmt2.json b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/config/extract_to_function_stmts_foreach_stmt2.json new file mode 100644 index 000000000000..4d19a0d0bd57 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/config/extract_to_function_stmts_foreach_stmt2.json @@ -0,0 +1,42 @@ +{ + "position": { + "line": 9, + "character": 14 + }, + "source": "extract_to_function_stmts_foreach_stmt2.bal", + "expected": [ + { + "title": "Extract to function", + "kind": "refactor.extract", + "edits": [ + { + "range": { + "start": { + "line": 11, + "character": 1 + }, + "end": { + "line": 11, + "character": 1 + } + }, + "newText": "\n\nfunction extracted(TestRecordType[] rec, TestRecordType[] result) returns () {\n return rec.push(...result);\n}\n" + }, + { + "range": { + "start": { + "line": 9, + "character": 8 + }, + "end": { + "line": 9, + "character": 27 + } + }, + "newText": "extracted(rec, result)" + } + ] + } + ], + "description": "Extract to function for foreach statement, checks the basic foreach statement" +} diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/source/extract_to_function_stmts_foreach_stmt2.bal b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/source/extract_to_function_stmts_foreach_stmt2.bal new file mode 100644 index 000000000000..85d3173f7d1f --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/source/extract_to_function_stmts_foreach_stmt2.bal @@ -0,0 +1,12 @@ +type TestRecordType record { + string name; + int age; +}; + +public function TestFunc(string[] names, int age) returns string[]|error { + TestRecordType[] rec = []; + foreach var item in names { + TestRecordType[] result = [{name: "John", age: 20}]; + rec.push(...result); + } +} From 8a201da7df3745aa40d4a3da8f09e8610eabfba6 Mon Sep 17 00:00:00 2001 From: mindula Date: Thu, 15 Dec 2022 09:26:33 +0530 Subject: [PATCH 247/450] Address review suggestions --- .../langserver/codeaction/CodeActionUtil.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/CodeActionUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/CodeActionUtil.java index c2cf63e1e26c..2328469964b9 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/CodeActionUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/CodeActionUtil.java @@ -295,10 +295,13 @@ public static Map getPossibleTypeSymbols(TypeSymbol typeDesc switch (newArrType.memberTypeDescriptor().typeKind()) { case FUNCTION: case UNION: - signature = "(" + newArrType.memberTypeDescriptor().signature() + ")[]"; + String typeName = FunctionGenerator.processModuleIDsInText(importsAcceptor, + newArrType.memberTypeDescriptor().signature(), context); + signature = "(" + typeName + ")[]"; break; default: - signature = entry.getValue() + "[]"; + signature = FunctionGenerator.processModuleIDsInText(importsAcceptor, + newArrType.signature(), context); } typesMap.put(newArrType, signature); }); From c49249df7c6102c7032e55853628c7975bd88c49 Mon Sep 17 00:00:00 2001 From: Mohanadarshan V Date: Thu, 15 Dec 2022 12:21:00 +0530 Subject: [PATCH 248/450] Update langlib/lang.stream/src/main/ballerina/stream.bal Co-authored-by: Maryam Ziyad --- langlib/lang.stream/src/main/ballerina/stream.bal | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/langlib/lang.stream/src/main/ballerina/stream.bal b/langlib/lang.stream/src/main/ballerina/stream.bal index 0f692e0b69e2..9a852b0c31bf 100644 --- a/langlib/lang.stream/src/main/ballerina/stream.bal +++ b/langlib/lang.stream/src/main/ballerina/stream.bal @@ -45,8 +45,7 @@ type Type1 any|error; # # ```ballerina # stream scoreStream = [45, 60, 75, 30, 90].toStream(); -# stream filtered = scoreStream.filter(score => score > 50); -# filtered.next() ⇒ {"value":60} +# scoreStream.filter(score => score > 50).next() ⇒ {"value":60} # ``` # # + stm - the stream From 55bf8815adaeb155396d41b476c846ba9edbb29a Mon Sep 17 00:00:00 2001 From: Thevakumar-Luheerathan Date: Thu, 15 Dec 2022 12:32:12 +0530 Subject: [PATCH 249/450] Add a mocking test case --- .../io/ballerina/cli/cmd/TestNativeImageCommandTest.java | 3 ++- .../resources/test-resources/mockFunctionNative/main.bal | 5 +++++ .../mockFunctionNative/modules/util/tests/lib_test.bal | 6 ++++++ .../mockFunctionNative/modules/util2/util2.bal | 5 +++++ .../test-resources/mockFunctionNative/tests/tes.bal | 6 ++++++ .../main/java/io/ballerina/projects/JBallerinaBackend.java | 5 +++-- 6 files changed, 27 insertions(+), 3 deletions(-) diff --git a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestNativeImageCommandTest.java b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestNativeImageCommandTest.java index 7c87dcd3b3f0..1c8a3be91551 100644 --- a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestNativeImageCommandTest.java +++ b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestNativeImageCommandTest.java @@ -74,6 +74,7 @@ public void testNativeFunctionMockTests() throws IOException { Assert.assertTrue(buildLog.contains("[pass] intAddTest2")); Assert.assertTrue(buildLog.contains("[pass] intAddTest3")); Assert.assertTrue(buildLog.contains("[pass] intAddTest4")); - + Assert.assertTrue(buildLog.contains("[pass] intAddInsideTest")); + Assert.assertTrue(buildLog.contains("[pass] intDivInsideTest")); } } diff --git a/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/main.bal b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/main.bal index 1641fce4acf2..a9c77336fc52 100644 --- a/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/main.bal +++ b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/main.bal @@ -2,3 +2,8 @@ function intAdd(int a, int b) returns int { return (a+b); } + +function intAddInside(int a, int b) returns int { + int c = intAdd(a, b); + return c + 100; +} \ No newline at end of file diff --git a/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util/tests/lib_test.bal b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util/tests/lib_test.bal index 8bfbf287d68a..ad21dfaba0d7 100644 --- a/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util/tests/lib_test.bal +++ b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util/tests/lib_test.bal @@ -48,6 +48,12 @@ function intAddTest() { } +@test:Config {} +function intDivInsideTest() { + test:when(mockFunc1).thenReturn(100); + test:assertEquals(util3:intDivInside(10, 10), 200); +} + function intSub(int a, int b) returns int { return (a - b); } diff --git a/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util2/util2.bal b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util2/util2.bal index d4ef8219adca..e807aed5c67a 100644 --- a/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util2/util2.bal +++ b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/modules/util2/util2.bal @@ -2,3 +2,8 @@ public function intDiv(int a, int b) returns int { return (a / b); } + +public function intDivInside(int a, int b) returns int { + int c = intDiv(a, b); + return c + 100; +} \ No newline at end of file diff --git a/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/tests/tes.bal b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/tests/tes.bal index ce8d224f56e8..93baa446d56a 100644 --- a/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/tests/tes.bal +++ b/cli/ballerina-cli/src/test/resources/test-resources/mockFunctionNative/tests/tes.bal @@ -37,6 +37,12 @@ function intAddTest4() { } +@test:Config {} +function intAddInsideTest() { + test:when(intAddMockFn).thenReturn(210); + test:assertEquals(intAddInside(33, 35), 310); +} + function intSub(int a, int b) returns int { return (a - b); } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/JBallerinaBackend.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/JBallerinaBackend.java index c82e18e6a9b9..3839ee8fa4ab 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/JBallerinaBackend.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/JBallerinaBackend.java @@ -547,8 +547,9 @@ private Path emitGraalExecutable(Path executableFilePath) { String nativeImageCommand = System.getenv("GRAALVM_HOME"); if (nativeImageCommand == null) { - throw new ProjectException("graalVM installation directory not found. Set GRAALVM_HOME as an " + - "environment variable"); + throw new ProjectException("GraalVM installation directory not found. Set GRAALVM_HOME as an " + + "environment variable\nHINT: to install GraalVM follow the below link\n" + + "https://ballerina.io/learn/build-a-native-executable/#configure-graalvm"); } nativeImageCommand += File.separator + BIN_DIR_NAME + File.separator + (OS.contains("win") ? "native-image.cmd" : "native-image"); From cdb9e0ec7f5351c4208f287869cded386f94474d Mon Sep 17 00:00:00 2001 From: mohan Date: Thu, 15 Dec 2022 12:43:44 +0530 Subject: [PATCH 250/450] Address review comments --- langlib/lang.stream/src/main/ballerina/stream.bal | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/langlib/lang.stream/src/main/ballerina/stream.bal b/langlib/lang.stream/src/main/ballerina/stream.bal index 9a852b0c31bf..8ac0cf0b477d 100644 --- a/langlib/lang.stream/src/main/ballerina/stream.bal +++ b/langlib/lang.stream/src/main/ballerina/stream.bal @@ -61,8 +61,8 @@ public isolated function filter(stream stm, @isolatedParam # Returns the next element in the stream wrapped in a record or () if the stream ends. # # ```ballerina -# stream greetingStream = ["Hello", "Bonjour", "Hola", "Ciao"].toStream(); -# greetingStream.next() ⇒ {"value":"Hello"} +# stream scoreStream = [45, 60, 75, 30, 90].toStream(); +# scoreStream.next() ⇒ {"value":45} # ``` # # + stm - The stream @@ -189,7 +189,6 @@ public isolated function iterator(stream stm) returns objec # ```ballerina # stream scoreStream = [45, 60, 75, 30, 90].toStream(); # _ = scoreStream.close(); -# scoreStream.next() ⇒ {"value":45} # ``` # # This releases any system resources being used by the stream. From 7cc6acedd1f8e80ea5ce12d32fb6a8c038833fe7 Mon Sep 17 00:00:00 2001 From: mohan Date: Thu, 15 Dec 2022 14:57:54 +0530 Subject: [PATCH 251/450] Update examples --- .../lang.string/src/main/ballerina/string.bal | 27 +++++++++---------- .../symbol/SymbolDocumentationTest.java | 6 ++--- .../expressions/config/exprLangLibs1.json | 2 +- .../expressions/config/exprLangLibs2.json | 2 +- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index a6aaa0a84404..c3b4385e7be6 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -26,8 +26,7 @@ public type RegExp regexp:RegExp; # Returns the length of the string. # # ```ballerina -# string greeting = "Hello, World!"; -# greeting.length() ⇒ 13; +# "Hello, World!".length() ⇒ 13; # ``` # # + str - the string @@ -90,8 +89,8 @@ public isolated function getCodePoint(string str, int index) returns int = @java # Returns a substring of a string. # # ```ballerina -# "Hello, my name is John".substring(7) ⇒ "my name is John" -# "Hello, my name is John Anderson".substring(18, 22) ⇒ "John" +# "Hello, my name is John".substring(7) ⇒ my name is John +# "Hello, my name is John Anderson".substring(18, 22) ⇒ John # ``` # # + str - source string. @@ -126,10 +125,10 @@ public isolated function codePointCompare(string str1, string str2) returns int # Joins zero or more strings together with a separator. # # ```ballerina -# string:'join(" ", "Ballerina", "is", "a", "programming", "language") ⇒ "Ballerina is a programming language" +# string:'join(" ", "Ballerina", "is", "a", "programming", "language") ⇒ Ballerina is a programming language # # string[] array = ["John", "23", "USA", "Computer Science", "Swimmer"]; -# string:'join(",", ...array) ⇒ "John,23,USA,Computer Science,Swimmer" +# string:'join(",", ...array) ⇒ John,23,USA,Computer Science,Swimmer # ``` # # + separator - separator string @@ -236,7 +235,7 @@ public isolated function endsWith(string str, string substr) returns boolean = @ # Other characters are left unchanged. # # ```ballerina -# "HELLO, World!".toLowerAscii() ⇒ "hello, world!" +# "HELLO, World!".toLowerAscii() ⇒ hello, world! # ``` # # + str - the string to be converted @@ -251,7 +250,7 @@ public isolated function toLowerAscii(string str) returns string = @java:Method # Other characters are left unchanged. # # ```ballerina -# "hello, World!".toUpperAscii() ⇒ "HELLO, WORLD!" +# "hello, World!".toUpperAscii() ⇒ HELLO, WORLD! # ``` # # + str - the string to be converted @@ -283,7 +282,7 @@ public isolated function equalsIgnoreCaseAscii(string str1, string str2) returns # The ASCII white space characters are 0x9...0xD, 0x20. # # ```ballerina -# " BALLERINA ".trim() ⇒ "BALLERINA" +# " BALLERINA ".trim() ⇒ BALLERINA # ``` # # + str - the string @@ -352,7 +351,7 @@ public isolated function toCodePointInt(Char ch) returns int = @java:Method { # but not in the range 0xD800 or 0xDFFF inclusive. # # ```ballerina -# string:fromCodePointInts([66, 97, 108, 108, 101, 114, 105, 110, 97]) ⇒ "Ballerina" +# string:fromCodePointInts([66, 97, 108, 108, 101, 114, 105, 110, 97]) ⇒ Ballerina # ``` # # + codePoints - an array of ints, each specifying a code point @@ -369,7 +368,7 @@ public isolated function fromCodePointInts(int[] codePoints) returns string|erro # but not in the range 0xD800 or 0xDFFF inclusive. # # ```ballerina -# string:fromCodePointInt(97) ⇒ "a" +# string:fromCodePointInt(97) ⇒ a # ``` # # + codePoint - an int specifying a code point @@ -385,7 +384,7 @@ public isolated function fromCodePointInt(int codePoint) returns Char|error = @j # If the length of `str` is >= `len`, returns `str`. # # ```ballerina -# "100Km".padStart(10, "0") ⇒ "00000100Km" +# "100Km".padStart(10, "0") ⇒ 00000100Km # ``` # # + str - the string to pad @@ -402,7 +401,7 @@ public isolated function padStart(string str, int len, Char padChar = " ") retur # If the length of `str` is >= `len`, returns `str`. # # ```ballerina -# "Ballerina for developers".padEnd(30, "!") ⇒ "Ballerina for developers!!!!!!" +# "Ballerina for developers".padEnd(30, "!") ⇒ Ballerina for developers!!!!!! # ``` # # + str - the string to pad @@ -420,7 +419,7 @@ public isolated function padEnd(string str, int len, Char padChar = " ") returns # If the length of `str` is >= `len`, returns `str`. # # ```ballerina -# "-256".padZero(9) ⇒ "-00000256" +# "-256".padZero(9) ⇒ -00000256 # ``` # # + str - the string to pad diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolDocumentationTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolDocumentationTest.java index 4d516f74bf9c..c777ff635205 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolDocumentationTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolDocumentationTest.java @@ -207,8 +207,7 @@ public void testLangLibDocumentation() throws IOException { "Returns the length of the string.\n" + "\n" + "```ballerina\n" + - "string greeting = \"Hello, World!\";\n" + - "greeting.length() ⇒ 13;\n" + + "\"Hello, World!\".length() ⇒ 13;\n" + "```\n"); Assert.assertEquals(symbolInfoResponse.getDocumentation().getReturnValueDescription(), "the number of characters (code points) in parameter `str`"); @@ -232,8 +231,7 @@ public void testLangLibDocumentationWithQualifiedIdentifier() throws IOException "Returns the length of the string.\n" + "\n" + "```ballerina\n" + - "string greeting = \"Hello, World!\";\n" + - "greeting.length() ⇒ 13;\n" + + "\"Hello, World!\".length() ⇒ 13;\n" + "```\n"); Assert.assertEquals(symbolInfoResponse.getDocumentation().getReturnValueDescription(), "the number of characters (code points) in parameter `str`"); diff --git a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json index 445df2ee0ba6..865f34d59f54 100644 --- a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json +++ b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json @@ -12,7 +12,7 @@ "documentation": { "right": { "kind": "markdown", - "value": "**Description** \nReturns a substring of a string.\n\n```ballerina\n\"Hello, my name is John\".substring(7) \u21d2 \"my name is John\"\n\"Hello, my name is John Anderson\".substring(18, 22) \u21d2 \"John\"\n```" + "value": "**Description** \nReturns a substring of a string.\n\n```ballerina\n\"Hello, my name is John\".substring(7) \u21d2 my name is John\n\"Hello, my name is John Anderson\".substring(18, 22) \u21d2 John\n```" } }, "parameters": [ diff --git a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json index 2553e2ee9f72..9e430561af9b 100644 --- a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json +++ b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json @@ -12,7 +12,7 @@ "documentation": { "right": { "kind": "markdown", - "value": "**Description** \nReturns a substring of a string.\n\n```ballerina\n\"Hello, my name is John\".substring(7) \u21d2 \"my name is John\"\n\"Hello, my name is John Anderson\".substring(18, 22) \u21d2 \"John\"\n```" + "value": "**Description** \nReturns a substring of a string.\n\n```ballerina\n\"Hello, my name is John\".substring(7) \u21d2 my name is John\n\"Hello, my name is John Anderson\".substring(18, 22) \u21d2 John\n```" } }, "parameters": [ From 09c29061c4f8931f637c1d0e48f7579c05c3dad0 Mon Sep 17 00:00:00 2001 From: mohan Date: Fri, 2 Dec 2022 07:38:30 +0530 Subject: [PATCH 252/450] Add initial examples related to string operations --- .../lang.string/src/main/ballerina/string.bal | 127 +++++++++++++++++- 1 file changed, 121 insertions(+), 6 deletions(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index 3c28d0f98fab..fac8d47375e3 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -24,7 +24,12 @@ type Char string; public type RegExp regexp:RegExp; # Returns the length of the string. -# +# +# ```ballerina +# string hello = "Hello, World!"; +# int length = hello.length(); +# ``` +# # + str - the string # + return - the number of characters (code points) in parameter `str` public isolated function length(string str) returns int = @java:Method { @@ -35,7 +40,14 @@ public isolated function length(string str) returns int = @java:Method { # Returns an iterator over the string. # # The iterator will yield the substrings of length 1 in order. -# +# +# ```ballerina +# string greeting = "Hello, World. This is from Ballerina!"; +# object { +# public isolated function next() returns record {|string:Char value;|}?; +# } iterator = greeting.iterator(); +# ``` +# # + str - the string to be iterated over # + return - a new iterator object public isolated function iterator(string str) returns object { @@ -47,6 +59,13 @@ public isolated function iterator(string str) returns object { # Concatenates zero or more strings. # +# ```ballerina +# string hostname = "http://worldtimeapi.org"; +# string continent = "Asia"; +# string city = "Colombo"; +# string worldTimeAPIUrl = hostname.concat("/api/timezone/", continent, "/", city); +# +# ``` # + strs - strings to be concatenated # + return - concatenation of all of the parameter `strs`; empty string if parameter `strs` is empty public isolated function concat(string... strs) returns string = @java:Method { @@ -54,8 +73,13 @@ public isolated function concat(string... strs) returns string = @java:Method { name: "concat" } external; -# Returns the code point of a character in a string. +# Returns the unicode code point of a character in a string. # +# ```ballerina +# string hello = "Hello, World!"; +# int codePoint = hello.getCodePoint(3); +# ``` +# # + str - the string # + index - an index in parameter `str` # + return - the Unicode code point of the character at parameter `index` in parameter `str` @@ -66,6 +90,11 @@ public isolated function getCodePoint(string str, int index) returns int = @java # Returns a substring of a string. # +# ```ballerina +# string intro = "Hello, my name is John"; +# string name = intro.substring(18, 22); +# ``` +# # + str - source string. # + startIndex - the starting index, inclusive # + endIndex - the ending index, exclusive @@ -81,6 +110,10 @@ public isolated function substring(string str, int startIndex, int endIndex = st # This orders strings in a consistent and well-defined way, # but the ordering will often not be consistent with cultural expectations # for sorted order. +# +# ```ballerina +# int codePointCompare = "Austria".codePointCompare("Australia"); +# ``` # # + str1 - the first string to be compared # + str2 - the second string to be compared @@ -93,6 +126,12 @@ public isolated function codePointCompare(string str1, string str2) returns int # Joins zero or more strings together with a separator. # +# ```ballerina +# string introString = string:'join(" ", "Ballerina", "is", "a", "statically", "typed,", "concurrent", "programming", "language"); +# +# string student = string:'join(",", "John", "23", "USA", "Computer Science", "Swimmer"); +# ``` +# # + separator - separator string # + strs - strings to be joined # + return - a string consisting of all of parameter `strs` concatenated in order @@ -103,7 +142,10 @@ public isolated function 'join(string separator, string... strs) returns string } external; # Finds the first occurrence of one string in another string. -# +# ```ballerina +# int? firstIndex = "Newzeland".indexOf("land"); +# ``` +# # + str - the string in which to search # + substr - the string to search for # + startIndex - index to start searching from @@ -115,6 +157,10 @@ public isolated function indexOf(string str, string substr, int startIndex = 0) } external; # Finds the last occurrence of one string in another string. +# +# ```ballerina +# int? lastIndex = "There are multiple programming languages. Ballerinalang is unique among them".lastIndexOf("lang"); +# ``` # # + str - the string in which to search # + substr - the string to search for @@ -129,6 +175,10 @@ returns int? = @java:Method { # Tests whether a string includes another string. # +# ```ballerina +# boolean isIncludes = "Hello World! from Ballerina".includes("Bal"); +# ``` +# # + str - the string in which to search # + substr - the string to search for # + startIndex - index to start searching from @@ -141,6 +191,10 @@ public isolated function includes(string str, string substr, int startIndex = 0) # Tests whether a string starts with another string. # +# ```ballerina +# boolean isStarts = "Welcome to Ballerina programming language".includes("Welcome"); +# ``` +# # + str - the string to be tested # + substr - the starting string # + return - true if parameter `str` starts with parameter `substr`; false otherwise @@ -151,6 +205,10 @@ public isolated function startsWith(string str, string substr) returns boolean = # Tests whether a string ends with another string. # +# ```ballerina +# boolean isEnds = "Welcome to Ballerina programming language".includes("language"); +# ``` +# # + str - the string to be tested # + substr - the ending string # + return - true if parameter `str` ends with parameter `substr`; false otherwise @@ -166,6 +224,10 @@ public isolated function endsWith(string str, string substr) returns boolean = @ # Converts occurrences of A-Z to a-z. # # Other characters are left unchanged. +# +# ```ballerina +# string lowerCaseString = "HELLO, World!".toLowerAscii(); +# ``` # # + str - the string to be converted # + return - parameter `str` with any occurrences of A-Z converted to a-z @@ -177,6 +239,10 @@ public isolated function toLowerAscii(string str) returns string = @java:Method # Converts occurrences of a-z to A-Z. # # Other characters are left unchanged. +# +# ```ballerina +# string lowerCaseString = "hello, World!".toUpperAscii(); +# ``` # # + str - the string to be converted # + return - parameter `str` with any occurrences of a-z converted to A-Z @@ -189,6 +255,10 @@ public isolated function toUpperAscii(string str) returns string = @java:Method # # A character in the range a-z is treated the same as the corresponding character in the range A-Z. # +# ```ballerina +# boolean isEquals = "BALLERINA".equalsIgnoreCaseAscii("ballerina"); +# ``` +# # + str1 - the first string to be compared # + str2 - the second string to be compared # + return - true if parameter `str1` is the same as parameter `str2`, treating upper-case and lower-case @@ -202,6 +272,10 @@ public isolated function equalsIgnoreCaseAscii(string str1, string str2) returns # # The ASCII white space characters are 0x9...0xD, 0x20. # +# ```ballerina +# string trimedString = " BALLERINA ".trim(); +# ``` +# # + str - the string # + return - parameter `str` with leading or trailing ASCII white space characters removed public isolated function trim(string str) returns string = @java:Method { @@ -211,6 +285,10 @@ public isolated function trim(string str) returns string = @java:Method { # Represents a string as an array of bytes using UTF-8. # +# ```ballerina +# byte[] stringAsBytes = "Hello, World!".toBytes(); +# ``` +# # + str - the string # + return - UTF-8 byte array public isolated function toBytes(string str) returns byte[] = @java:Method { @@ -220,6 +298,11 @@ public isolated function toBytes(string str) returns byte[] = @java:Method { # Constructs a string from its UTF-8 representation in bytes. # +# ```ballerin +# byte[] bytes = [72, 101, 108, 108, 111, 32, 66, 97, 108, 108, 101, 114, 105, 110, 97, 33]; +# string stringValue = check string:fromBytes(bytes); +# ``` +# # + bytes - UTF-8 byte array # + return - parameter `bytes` converted to string or error public isolated function fromBytes(byte[] bytes) returns string|error = @java:Method { @@ -229,6 +312,11 @@ public isolated function fromBytes(byte[] bytes) returns string|error = @java:Me # Converts a string to an array of code points. # +# ```ballerina +# string hello = "Hello, world 🌎 from Ballerina. Tryout Ballerina"; +# int[] charCodePoints = hello.toCodePointInts(); +# ``` +# # + str - the string # + return - an array with a code point for each character of parameter `str` public isolated function toCodePointInts(string str) returns int[] = @java:Method { @@ -237,6 +325,10 @@ public isolated function toCodePointInts(string str) returns int[] = @java:Metho } external; # Converts a single character string to a code point. +# +# ```ballerina +# int charCodePoint = string:toCodePointInt("a"); +# ``` # # + ch - a single character string # + return - the code point of parameter `ch` @@ -249,6 +341,11 @@ public isolated function toCodePointInt(Char ch) returns int = @java:Method { # # An int is a valid code point if it is in the range 0 to 0x10FFFF inclusive, # but not in the range 0xD800 or 0xDFFF inclusive. +# +# ```ballerina +# int[] codePoints = [66,97,108,108,101,114,105,110,97]; +# string stringValue = check string:fromCodePointInts(codePoints); +# ``` # # + codePoints - an array of ints, each specifying a code point # + return - a string with a character for each code point in parameter `codePoints`; or an error @@ -262,6 +359,10 @@ public isolated function fromCodePointInts(int[] codePoints) returns string|erro # # An int is a valid code point if it is in the range 0 to 0x10FFFF inclusive, # but not in the range 0xD800 or 0xDFFF inclusive. +# +# ```ballerina +# string:Char charValue = check string:fromCodePointInt(97); +# ``` # # + codePoint - an int specifying a code point # + return - a single character string whose code point is parameter `codePoint`; or an error @@ -275,6 +376,11 @@ public isolated function fromCodePointInt(int codePoint) returns Char|error = @j # Adds sufficient `padChar` characters at the start of `str` to make its length be `len`. # If the length of `str` is >= `len`, returns `str`. # +# ```ballerina +# // Providing "0" as the custom padding char +# string distanceAsFixedLengthString = "100Km".padStart(10, "0"); +# ``` +# # + str - the string to pad # + len - the length of the string to be returned # + padChar - the character to use for padding `str`; defaults to a space character @@ -287,6 +393,11 @@ public isolated function padStart(string str, int len, Char padChar = " ") retur # Adds padding to the end of a string. # Adds sufficient `padChar` characters to the end of `str` to make its length be `len`. # If the length of `str` is >= `len`, returns `str`. +# +# ```ballerina +# // Providing "!" as the custom padding char +# string quote = "Ballerina for developers".padEnd(30, "!"); +# ``` # # + str - the string to pad # + len - the length of the string to be returned @@ -302,6 +413,10 @@ public isolated function padEnd(string str, int len, Char padChar = " ") returns # Sufficient zero characters are added to `str` to make its length be `len`. # If the length of `str` is >= `len`, returns `str`. # +# ```ballerina +# string paddedString = "-256".padZero(9); +# ``` +# # + str - the string to pad # + len - the length of the string to be returned # + zeroChar - the character to use for the zero; defaults to ASCII zero `0` @@ -313,11 +428,11 @@ public isolated function padZero(string str, int len, Char zeroChar = "0") retur # True if there is a match of `re` against all of `str`. # Use `includesMatch` to test whether `re` matches somewhere in `str`. -public function matches(string str, RegExp 're) returns boolean { +public isolated function matches(string str, RegExp 're) returns boolean { return 're.isFullMatch(str); } # True if there is a match for `re` anywhere in `str` -public function includesMatch(string str, RegExp 're, int startIndex = 0) returns boolean { +public isolated function includesMatch(string str, RegExp 're, int startIndex = 0) returns boolean { return 're.find(str, startIndex) != (); } From 4c8b20ee7e04ce4accad7090ba74fb22b69008db Mon Sep 17 00:00:00 2001 From: mohan Date: Fri, 2 Dec 2022 10:08:40 +0530 Subject: [PATCH 253/450] Add minor fix --- langlib/lang.string/src/main/ballerina/string.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index fac8d47375e3..db343861d721 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -298,7 +298,7 @@ public isolated function toBytes(string str) returns byte[] = @java:Method { # Constructs a string from its UTF-8 representation in bytes. # -# ```ballerin +# ```ballerina # byte[] bytes = [72, 101, 108, 108, 111, 32, 66, 97, 108, 108, 101, 114, 105, 110, 97, 33]; # string stringValue = check string:fromBytes(bytes); # ``` From 29cadf9c5d8ef83718cf61adc7efb0a2588c9d4f Mon Sep 17 00:00:00 2001 From: mohan Date: Fri, 2 Dec 2022 12:20:41 +0530 Subject: [PATCH 254/450] Revert "Add initial examples related to string operations" This reverts commit 8db240f2 --- .../lang.string/src/main/ballerina/string.bal | 127 +----------------- 1 file changed, 6 insertions(+), 121 deletions(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index db343861d721..3c28d0f98fab 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -24,12 +24,7 @@ type Char string; public type RegExp regexp:RegExp; # Returns the length of the string. -# -# ```ballerina -# string hello = "Hello, World!"; -# int length = hello.length(); -# ``` -# +# # + str - the string # + return - the number of characters (code points) in parameter `str` public isolated function length(string str) returns int = @java:Method { @@ -40,14 +35,7 @@ public isolated function length(string str) returns int = @java:Method { # Returns an iterator over the string. # # The iterator will yield the substrings of length 1 in order. -# -# ```ballerina -# string greeting = "Hello, World. This is from Ballerina!"; -# object { -# public isolated function next() returns record {|string:Char value;|}?; -# } iterator = greeting.iterator(); -# ``` -# +# # + str - the string to be iterated over # + return - a new iterator object public isolated function iterator(string str) returns object { @@ -59,13 +47,6 @@ public isolated function iterator(string str) returns object { # Concatenates zero or more strings. # -# ```ballerina -# string hostname = "http://worldtimeapi.org"; -# string continent = "Asia"; -# string city = "Colombo"; -# string worldTimeAPIUrl = hostname.concat("/api/timezone/", continent, "/", city); -# -# ``` # + strs - strings to be concatenated # + return - concatenation of all of the parameter `strs`; empty string if parameter `strs` is empty public isolated function concat(string... strs) returns string = @java:Method { @@ -73,13 +54,8 @@ public isolated function concat(string... strs) returns string = @java:Method { name: "concat" } external; -# Returns the unicode code point of a character in a string. +# Returns the code point of a character in a string. # -# ```ballerina -# string hello = "Hello, World!"; -# int codePoint = hello.getCodePoint(3); -# ``` -# # + str - the string # + index - an index in parameter `str` # + return - the Unicode code point of the character at parameter `index` in parameter `str` @@ -90,11 +66,6 @@ public isolated function getCodePoint(string str, int index) returns int = @java # Returns a substring of a string. # -# ```ballerina -# string intro = "Hello, my name is John"; -# string name = intro.substring(18, 22); -# ``` -# # + str - source string. # + startIndex - the starting index, inclusive # + endIndex - the ending index, exclusive @@ -110,10 +81,6 @@ public isolated function substring(string str, int startIndex, int endIndex = st # This orders strings in a consistent and well-defined way, # but the ordering will often not be consistent with cultural expectations # for sorted order. -# -# ```ballerina -# int codePointCompare = "Austria".codePointCompare("Australia"); -# ``` # # + str1 - the first string to be compared # + str2 - the second string to be compared @@ -126,12 +93,6 @@ public isolated function codePointCompare(string str1, string str2) returns int # Joins zero or more strings together with a separator. # -# ```ballerina -# string introString = string:'join(" ", "Ballerina", "is", "a", "statically", "typed,", "concurrent", "programming", "language"); -# -# string student = string:'join(",", "John", "23", "USA", "Computer Science", "Swimmer"); -# ``` -# # + separator - separator string # + strs - strings to be joined # + return - a string consisting of all of parameter `strs` concatenated in order @@ -142,10 +103,7 @@ public isolated function 'join(string separator, string... strs) returns string } external; # Finds the first occurrence of one string in another string. -# ```ballerina -# int? firstIndex = "Newzeland".indexOf("land"); -# ``` -# +# # + str - the string in which to search # + substr - the string to search for # + startIndex - index to start searching from @@ -157,10 +115,6 @@ public isolated function indexOf(string str, string substr, int startIndex = 0) } external; # Finds the last occurrence of one string in another string. -# -# ```ballerina -# int? lastIndex = "There are multiple programming languages. Ballerinalang is unique among them".lastIndexOf("lang"); -# ``` # # + str - the string in which to search # + substr - the string to search for @@ -175,10 +129,6 @@ returns int? = @java:Method { # Tests whether a string includes another string. # -# ```ballerina -# boolean isIncludes = "Hello World! from Ballerina".includes("Bal"); -# ``` -# # + str - the string in which to search # + substr - the string to search for # + startIndex - index to start searching from @@ -191,10 +141,6 @@ public isolated function includes(string str, string substr, int startIndex = 0) # Tests whether a string starts with another string. # -# ```ballerina -# boolean isStarts = "Welcome to Ballerina programming language".includes("Welcome"); -# ``` -# # + str - the string to be tested # + substr - the starting string # + return - true if parameter `str` starts with parameter `substr`; false otherwise @@ -205,10 +151,6 @@ public isolated function startsWith(string str, string substr) returns boolean = # Tests whether a string ends with another string. # -# ```ballerina -# boolean isEnds = "Welcome to Ballerina programming language".includes("language"); -# ``` -# # + str - the string to be tested # + substr - the ending string # + return - true if parameter `str` ends with parameter `substr`; false otherwise @@ -224,10 +166,6 @@ public isolated function endsWith(string str, string substr) returns boolean = @ # Converts occurrences of A-Z to a-z. # # Other characters are left unchanged. -# -# ```ballerina -# string lowerCaseString = "HELLO, World!".toLowerAscii(); -# ``` # # + str - the string to be converted # + return - parameter `str` with any occurrences of A-Z converted to a-z @@ -239,10 +177,6 @@ public isolated function toLowerAscii(string str) returns string = @java:Method # Converts occurrences of a-z to A-Z. # # Other characters are left unchanged. -# -# ```ballerina -# string lowerCaseString = "hello, World!".toUpperAscii(); -# ``` # # + str - the string to be converted # + return - parameter `str` with any occurrences of a-z converted to A-Z @@ -255,10 +189,6 @@ public isolated function toUpperAscii(string str) returns string = @java:Method # # A character in the range a-z is treated the same as the corresponding character in the range A-Z. # -# ```ballerina -# boolean isEquals = "BALLERINA".equalsIgnoreCaseAscii("ballerina"); -# ``` -# # + str1 - the first string to be compared # + str2 - the second string to be compared # + return - true if parameter `str1` is the same as parameter `str2`, treating upper-case and lower-case @@ -272,10 +202,6 @@ public isolated function equalsIgnoreCaseAscii(string str1, string str2) returns # # The ASCII white space characters are 0x9...0xD, 0x20. # -# ```ballerina -# string trimedString = " BALLERINA ".trim(); -# ``` -# # + str - the string # + return - parameter `str` with leading or trailing ASCII white space characters removed public isolated function trim(string str) returns string = @java:Method { @@ -285,10 +211,6 @@ public isolated function trim(string str) returns string = @java:Method { # Represents a string as an array of bytes using UTF-8. # -# ```ballerina -# byte[] stringAsBytes = "Hello, World!".toBytes(); -# ``` -# # + str - the string # + return - UTF-8 byte array public isolated function toBytes(string str) returns byte[] = @java:Method { @@ -298,11 +220,6 @@ public isolated function toBytes(string str) returns byte[] = @java:Method { # Constructs a string from its UTF-8 representation in bytes. # -# ```ballerina -# byte[] bytes = [72, 101, 108, 108, 111, 32, 66, 97, 108, 108, 101, 114, 105, 110, 97, 33]; -# string stringValue = check string:fromBytes(bytes); -# ``` -# # + bytes - UTF-8 byte array # + return - parameter `bytes` converted to string or error public isolated function fromBytes(byte[] bytes) returns string|error = @java:Method { @@ -312,11 +229,6 @@ public isolated function fromBytes(byte[] bytes) returns string|error = @java:Me # Converts a string to an array of code points. # -# ```ballerina -# string hello = "Hello, world 🌎 from Ballerina. Tryout Ballerina"; -# int[] charCodePoints = hello.toCodePointInts(); -# ``` -# # + str - the string # + return - an array with a code point for each character of parameter `str` public isolated function toCodePointInts(string str) returns int[] = @java:Method { @@ -325,10 +237,6 @@ public isolated function toCodePointInts(string str) returns int[] = @java:Metho } external; # Converts a single character string to a code point. -# -# ```ballerina -# int charCodePoint = string:toCodePointInt("a"); -# ``` # # + ch - a single character string # + return - the code point of parameter `ch` @@ -341,11 +249,6 @@ public isolated function toCodePointInt(Char ch) returns int = @java:Method { # # An int is a valid code point if it is in the range 0 to 0x10FFFF inclusive, # but not in the range 0xD800 or 0xDFFF inclusive. -# -# ```ballerina -# int[] codePoints = [66,97,108,108,101,114,105,110,97]; -# string stringValue = check string:fromCodePointInts(codePoints); -# ``` # # + codePoints - an array of ints, each specifying a code point # + return - a string with a character for each code point in parameter `codePoints`; or an error @@ -359,10 +262,6 @@ public isolated function fromCodePointInts(int[] codePoints) returns string|erro # # An int is a valid code point if it is in the range 0 to 0x10FFFF inclusive, # but not in the range 0xD800 or 0xDFFF inclusive. -# -# ```ballerina -# string:Char charValue = check string:fromCodePointInt(97); -# ``` # # + codePoint - an int specifying a code point # + return - a single character string whose code point is parameter `codePoint`; or an error @@ -376,11 +275,6 @@ public isolated function fromCodePointInt(int codePoint) returns Char|error = @j # Adds sufficient `padChar` characters at the start of `str` to make its length be `len`. # If the length of `str` is >= `len`, returns `str`. # -# ```ballerina -# // Providing "0" as the custom padding char -# string distanceAsFixedLengthString = "100Km".padStart(10, "0"); -# ``` -# # + str - the string to pad # + len - the length of the string to be returned # + padChar - the character to use for padding `str`; defaults to a space character @@ -393,11 +287,6 @@ public isolated function padStart(string str, int len, Char padChar = " ") retur # Adds padding to the end of a string. # Adds sufficient `padChar` characters to the end of `str` to make its length be `len`. # If the length of `str` is >= `len`, returns `str`. -# -# ```ballerina -# // Providing "!" as the custom padding char -# string quote = "Ballerina for developers".padEnd(30, "!"); -# ``` # # + str - the string to pad # + len - the length of the string to be returned @@ -413,10 +302,6 @@ public isolated function padEnd(string str, int len, Char padChar = " ") returns # Sufficient zero characters are added to `str` to make its length be `len`. # If the length of `str` is >= `len`, returns `str`. # -# ```ballerina -# string paddedString = "-256".padZero(9); -# ``` -# # + str - the string to pad # + len - the length of the string to be returned # + zeroChar - the character to use for the zero; defaults to ASCII zero `0` @@ -428,11 +313,11 @@ public isolated function padZero(string str, int len, Char zeroChar = "0") retur # True if there is a match of `re` against all of `str`. # Use `includesMatch` to test whether `re` matches somewhere in `str`. -public isolated function matches(string str, RegExp 're) returns boolean { +public function matches(string str, RegExp 're) returns boolean { return 're.isFullMatch(str); } # True if there is a match for `re` anywhere in `str` -public isolated function includesMatch(string str, RegExp 're, int startIndex = 0) returns boolean { +public function includesMatch(string str, RegExp 're, int startIndex = 0) returns boolean { return 're.find(str, startIndex) != (); } From 8c941f38f9168fd7594a50d7ba40231fde66ef43 Mon Sep 17 00:00:00 2001 From: mohan Date: Tue, 13 Dec 2022 16:01:16 +0530 Subject: [PATCH 255/450] Add revamped examples for strings langlib --- .../lang.string/src/main/ballerina/string.bal | 154 +++++++++++++++++- 1 file changed, 149 insertions(+), 5 deletions(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index 3c28d0f98fab..bb9437740027 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -25,6 +25,10 @@ public type RegExp regexp:RegExp; # Returns the length of the string. # +# ```ballerina +# "Hello, World!".length() ⇒ 13; +# ``` +# # + str - the string # + return - the number of characters (code points) in parameter `str` public isolated function length(string str) returns int = @java:Method { @@ -36,6 +40,13 @@ public isolated function length(string str) returns int = @java:Method { # # The iterator will yield the substrings of length 1 in order. # +# ```ballerina +# object { +# public isolated function next() returns record {|string:Char value;|}?; +# } iterator = "Hello, World!".iterator(); +# iterator.next() ⇒ {"value":"H"} +# ``` +# # + str - the string to be iterated over # + return - a new iterator object public isolated function iterator(string str) returns object { @@ -47,6 +58,13 @@ public isolated function iterator(string str) returns object { # Concatenates zero or more strings. # +# ```ballerina +# "http://worldtimeapi.org".concat("/api/timezone/", "Asia", "/", "Colombo") ⇒ http://worldtimeapi.org/api/timezone/Asia/Colombo +# +# // Alternative approach to achieve the same as above. +# string:concat("http://worldtimeapi.org", "/api/timezone/", "Asia", "/", "Colombo") ⇒ http://worldtimeapi.org/api/timezone/Asia/Colombo +# ``` +# # + strs - strings to be concatenated # + return - concatenation of all of the parameter `strs`; empty string if parameter `strs` is empty public isolated function concat(string... strs) returns string = @java:Method { @@ -56,6 +74,10 @@ public isolated function concat(string... strs) returns string = @java:Method { # Returns the code point of a character in a string. # +# ```ballerina +# "Hello, World!".getCodePoint(3) ⇒ 108 +# ``` +# # + str - the string # + index - an index in parameter `str` # + return - the Unicode code point of the character at parameter `index` in parameter `str` @@ -66,6 +88,14 @@ public isolated function getCodePoint(string str, int index) returns int = @java # Returns a substring of a string. # +# ```ballerina +# "Hello, my name is John".substring(18, 22) ⇒ "John" +# +# // Consider only the start index. In this situation, +# // input string length would be considered as end index. +# "Hello, my name is John".substring(7) ⇒ "my name is John" +# ``` +# # + str - source string. # + startIndex - the starting index, inclusive # + endIndex - the ending index, exclusive @@ -82,6 +112,10 @@ public isolated function substring(string str, int startIndex, int endIndex = st # but the ordering will often not be consistent with cultural expectations # for sorted order. # +# ```ballerina +# "Austria".codePointCompare("Australia") ⇒ 1 +# ``` +# # + str1 - the first string to be compared # + str2 - the second string to be compared # + return - an int that is less than, equal to or greater than zero, @@ -93,6 +127,15 @@ public isolated function codePointCompare(string str1, string str2) returns int # Joins zero or more strings together with a separator. # +# ```ballerina +# // Join multiple strings with space as the separator. +# string:'join(" ", "Ballerina", "is", "a", "programming", "language") ⇒ "Ballerina is a programming language" +# +# // Join multiple strings with comma as the separator. +# string[] array = ["John", "23", "USA", "Computer Science", "Swimmer"]; +# string:'join(",", ...array) ⇒ "John,23,USA,Computer Science,Swimmer" +# ``` +# # + separator - separator string # + strs - strings to be joined # + return - a string consisting of all of parameter `strs` concatenated in order @@ -104,6 +147,13 @@ public isolated function 'join(string separator, string... strs) returns string # Finds the first occurrence of one string in another string. # +# ```ballerina +# "New Zealand".indexOf("land") ⇒ 7 +# +# // Search for the first occurrence of a string from a specific index onwards. +# "Ballerinalang is a unique programming language".indexOf("lang", 15) ⇒ 38 +# ``` +# # + str - the string in which to search # + substr - the string to search for # + startIndex - index to start searching from @@ -116,6 +166,13 @@ public isolated function indexOf(string str, string substr, int startIndex = 0) # Finds the last occurrence of one string in another string. # +# ```ballerina +# "Ballerinalang is a unique programming language".lastIndexOf("lang") ⇒ 38 +# +# // Search for the last occurrence of a string from a specific index onwards. +# "Ballerinalang is a unique programming language".lastIndexOf("lang", 15) ⇒ 9 +# ``` +# # + str - the string in which to search # + substr - the string to search for # + startIndex - index to start searching backwards from @@ -129,6 +186,13 @@ returns int? = @java:Method { # Tests whether a string includes another string. # +# ```ballerina +# "Hello World! from Ballerina".includes("Bal") ⇒ true +# +# // Check for the occurrence of a string from a specific index onwards. +# "Hello World! from Ballerina".includes("Hello", 10) ⇒ false +# ``` +# # + str - the string in which to search # + substr - the string to search for # + startIndex - index to start searching from @@ -141,6 +205,10 @@ public isolated function includes(string str, string substr, int startIndex = 0) # Tests whether a string starts with another string. # +# ```ballerina +# "Welcome to Ballerina programming language".startsWith("Welcome") ⇒ true +# ``` +# # + str - the string to be tested # + substr - the starting string # + return - true if parameter `str` starts with parameter `substr`; false otherwise @@ -151,6 +219,10 @@ public isolated function startsWith(string str, string substr) returns boolean = # Tests whether a string ends with another string. # +# ```ballerina +# "Welcome to Ballerina programming language".endsWith("language") ⇒ true +# ``` +# # + str - the string to be tested # + substr - the ending string # + return - true if parameter `str` ends with parameter `substr`; false otherwise @@ -167,6 +239,10 @@ public isolated function endsWith(string str, string substr) returns boolean = @ # # Other characters are left unchanged. # +# ```ballerina +# "HELLO, World!".toLowerAscii() ⇒ "hello, world!" +# ``` +# # + str - the string to be converted # + return - parameter `str` with any occurrences of A-Z converted to a-z public isolated function toLowerAscii(string str) returns string = @java:Method { @@ -178,6 +254,10 @@ public isolated function toLowerAscii(string str) returns string = @java:Method # # Other characters are left unchanged. # +# ```ballerina +# "hello, World!".toUpperAscii() ⇒ "HELLO, WORLD!" +# ``` +# # + str - the string to be converted # + return - parameter `str` with any occurrences of a-z converted to A-Z public isolated function toUpperAscii(string str) returns string = @java:Method { @@ -189,6 +269,10 @@ public isolated function toUpperAscii(string str) returns string = @java:Method # # A character in the range a-z is treated the same as the corresponding character in the range A-Z. # +# ```ballerina +# "BALLERINA".equalsIgnoreCaseAscii("ballerina") ⇒ true +# ``` +# # + str1 - the first string to be compared # + str2 - the second string to be compared # + return - true if parameter `str1` is the same as parameter `str2`, treating upper-case and lower-case @@ -202,6 +286,10 @@ public isolated function equalsIgnoreCaseAscii(string str1, string str2) returns # # The ASCII white space characters are 0x9...0xD, 0x20. # +# ```ballerina +# " BALLERINA ".trim() ⇒ "BALLERINA" +# ``` +# # + str - the string # + return - parameter `str` with leading or trailing ASCII white space characters removed public isolated function trim(string str) returns string = @java:Method { @@ -211,6 +299,10 @@ public isolated function trim(string str) returns string = @java:Method { # Represents a string as an array of bytes using UTF-8. # +# ```ballerina +# "Hello, World!".toBytes() ⇒ [72,101,108,108,111,44,32,87,111,114,108,100,33] +# ``` +# # + str - the string # + return - UTF-8 byte array public isolated function toBytes(string str) returns byte[] = @java:Method { @@ -220,6 +312,10 @@ public isolated function toBytes(string str) returns byte[] = @java:Method { # Constructs a string from its UTF-8 representation in bytes. # +# ```ballerina +# string:fromBytes([72, 101, 108, 108, 111, 32, 66, 97, 108, 108, 101, 114, 105, 110, 97, 33]) ⇒ Hello, World! +# ``` +# # + bytes - UTF-8 byte array # + return - parameter `bytes` converted to string or error public isolated function fromBytes(byte[] bytes) returns string|error = @java:Method { @@ -229,6 +325,10 @@ public isolated function fromBytes(byte[] bytes) returns string|error = @java:Me # Converts a string to an array of code points. # +# ```ballerina +# "Hello, world 🌎".toCodePointInts() ⇒ [72,101,108,108,111,44,32,119,111,114,108,100,32,127758] +# ``` +# # + str - the string # + return - an array with a code point for each character of parameter `str` public isolated function toCodePointInts(string str) returns int[] = @java:Method { @@ -238,6 +338,10 @@ public isolated function toCodePointInts(string str) returns int[] = @java:Metho # Converts a single character string to a code point. # +# ```ballerina +# string:toCodePointInt("a") ⇒ 97 +# ``` +# # + ch - a single character string # + return - the code point of parameter `ch` public isolated function toCodePointInt(Char ch) returns int = @java:Method { @@ -250,6 +354,10 @@ public isolated function toCodePointInt(Char ch) returns int = @java:Method { # An int is a valid code point if it is in the range 0 to 0x10FFFF inclusive, # but not in the range 0xD800 or 0xDFFF inclusive. # +# ```ballerina +# string:fromCodePointInts([66, 97, 108, 108, 101, 114, 105, 110, 97]) ⇒ "Ballerina" +# ``` +# # + codePoints - an array of ints, each specifying a code point # + return - a string with a character for each code point in parameter `codePoints`; or an error # if any member of parameter `codePoints` is not a valid code point @@ -263,6 +371,10 @@ public isolated function fromCodePointInts(int[] codePoints) returns string|erro # An int is a valid code point if it is in the range 0 to 0x10FFFF inclusive, # but not in the range 0xD800 or 0xDFFF inclusive. # +# ```ballerina +# string:fromCodePointInt(97) ⇒ "a" +# ``` +# # + codePoint - an int specifying a code point # + return - a single character string whose code point is parameter `codePoint`; or an error # if parameter `codePoint` is not a valid code point @@ -275,6 +387,11 @@ public isolated function fromCodePointInt(int codePoint) returns Char|error = @j # Adds sufficient `padChar` characters at the start of `str` to make its length be `len`. # If the length of `str` is >= `len`, returns `str`. # +# ```ballerina +# // Provide "0" as the custom padding char. +# "100Km".padStart(10, "0") ⇒ "00000100Km" +# ``` +# # + str - the string to pad # + len - the length of the string to be returned # + padChar - the character to use for padding `str`; defaults to a space character @@ -288,6 +405,11 @@ public isolated function padStart(string str, int len, Char padChar = " ") retur # Adds sufficient `padChar` characters to the end of `str` to make its length be `len`. # If the length of `str` is >= `len`, returns `str`. # +# ```ballerina +# // Provide "!" as the custom padding char. +# "Ballerina for developers".padEnd(30, "!") ⇒ "Ballerina for developers!!!!!!" +# ``` +# # + str - the string to pad # + len - the length of the string to be returned # + padChar - the character to use for padding `str`; defaults to a space character @@ -302,6 +424,10 @@ public isolated function padEnd(string str, int len, Char padChar = " ") returns # Sufficient zero characters are added to `str` to make its length be `len`. # If the length of `str` is >= `len`, returns `str`. # +# ```ballerina +# "-256".padZero(9) ⇒ "-00000256" +# ``` +# # + str - the string to pad # + len - the length of the string to be returned # + zeroChar - the character to use for the zero; defaults to ASCII zero `0` @@ -311,13 +437,31 @@ public isolated function padZero(string str, int len, Char zeroChar = "0") retur name: "padZero" } external; -# True if there is a match of `re` against all of `str`. -# Use `includesMatch` to test whether `re` matches somewhere in `str`. -public function matches(string str, RegExp 're) returns boolean { +# Tests whether there is a full match of a regular expression with a string. +# A match of a regular expression in a string is a full match if it +# starts at index 0 and ends at index `n`, where `n` is the length of the string. +# This is equivalent to `regex:isFullMatch(re, str)`. +# +# ```ballerina +# "Ballerina".matches(re `Bal.*`) ⇒ true +# ``` +# +# + str - the string +# + re - the regular expression +# + return - true if there is full match of `re` with `str`, and false otherwise +public isolated function matches(string str, RegExp 're) returns boolean { return 're.isFullMatch(str); } -# True if there is a match for `re` anywhere in `str` -public function includesMatch(string str, RegExp 're, int startIndex = 0) returns boolean { +# Tests whether there is a match of a regular expression somewhere within a string. +# This is equivalent to `regexp:find(re, str, startIndex) != ()`. +# ```ballerina +# "New Zealand".includesMatch(re `lan?`) ⇒ true +# ``` +# +# + str - the string to be matched +# + re - the regular expression +# + return - true if the is a match of `re` somewhere within `str`, otherwise false +public isolated function includesMatch(string str, RegExp 're, int startIndex = 0) returns boolean { return 're.find(str, startIndex) != (); } From dab889db16fa76b6dca7441d8b22919d72ac61d2 Mon Sep 17 00:00:00 2001 From: mohan Date: Tue, 13 Dec 2022 16:05:32 +0530 Subject: [PATCH 256/450] update comments --- langlib/lang.string/src/main/ballerina/string.bal | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index bb9437740027..3f7e75f1d936 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -388,7 +388,6 @@ public isolated function fromCodePointInt(int codePoint) returns Char|error = @j # If the length of `str` is >= `len`, returns `str`. # # ```ballerina -# // Provide "0" as the custom padding char. # "100Km".padStart(10, "0") ⇒ "00000100Km" # ``` # @@ -406,7 +405,6 @@ public isolated function padStart(string str, int len, Char padChar = " ") retur # If the length of `str` is >= `len`, returns `str`. # # ```ballerina -# // Provide "!" as the custom padding char. # "Ballerina for developers".padEnd(30, "!") ⇒ "Ballerina for developers!!!!!!" # ``` # @@ -455,6 +453,7 @@ public isolated function matches(string str, RegExp 're) returns boolean { # Tests whether there is a match of a regular expression somewhere within a string. # This is equivalent to `regexp:find(re, str, startIndex) != ()`. +# # ```ballerina # "New Zealand".includesMatch(re `lan?`) ⇒ true # ``` From e0cbc43cc6a942c2f369295f98c28d497ae6e283 Mon Sep 17 00:00:00 2001 From: mohan Date: Tue, 13 Dec 2022 18:48:22 +0530 Subject: [PATCH 257/450] Fix test cases due to doc changes --- .../extensions/symbol/SymbolDocumentationTest.java | 12 ++++++++++-- .../signature/expressions/config/exprLangLibs1.json | 2 +- .../signature/expressions/config/exprLangLibs2.json | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolDocumentationTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolDocumentationTest.java index 5a0be727f4ec..c777ff635205 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolDocumentationTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolDocumentationTest.java @@ -204,7 +204,11 @@ public void testLangLibDocumentation() throws IOException { Assert.assertNotEquals(symbolInfoResponse.getDocumentation(), null); Assert.assertEquals(symbolInfoResponse.getDocumentation().getDescription(), - "Returns the length of the string.\n"); + "Returns the length of the string.\n" + + "\n" + + "```ballerina\n" + + "\"Hello, World!\".length() ⇒ 13;\n" + + "```\n"); Assert.assertEquals(symbolInfoResponse.getDocumentation().getReturnValueDescription(), "the number of characters (code points) in parameter `str`"); Assert.assertEquals(symbolInfoResponse.getDocumentation().getParameters(), null); @@ -224,7 +228,11 @@ public void testLangLibDocumentationWithQualifiedIdentifier() throws IOException Assert.assertNotEquals(symbolInfoResponse.getDocumentation(), null); Assert.assertEquals(symbolInfoResponse.getDocumentation().getDescription(), - "Returns the length of the string.\n"); + "Returns the length of the string.\n" + + "\n" + + "```ballerina\n" + + "\"Hello, World!\".length() ⇒ 13;\n" + + "```\n"); Assert.assertEquals(symbolInfoResponse.getDocumentation().getReturnValueDescription(), "the number of characters (code points) in parameter `str`"); Assert.assertEquals(symbolInfoResponse.getDocumentation().getParameters().get(0).getName(), "str"); diff --git a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json index c7b26ab00312..6d0dcd38efd6 100644 --- a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json +++ b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json @@ -12,7 +12,7 @@ "documentation": { "right": { "kind": "markdown", - "value": "**Description** \nReturns a substring of a string." + "value": "**Description** \nReturns a substring of a string.\n\n```ballerina\n\"Hello, my name is John\".substring(18, 22) \u21d2 \"John\"\n// Consider only the start index. In this situation,\n// input string length would be considered as end index.\n\"Hello, my name is John\".substring(7) \u21d2 \"my name is John\"\n```" } }, "parameters": [ diff --git a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json index 61f43f63f302..513cd51e08eb 100644 --- a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json +++ b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json @@ -12,7 +12,7 @@ "documentation": { "right": { "kind": "markdown", - "value": "**Description** \nReturns a substring of a string." + "value": "**Description** \nReturns a substring of a string.\n\n```ballerina\n\"Hello, my name is John\".substring(18, 22) \u21d2 \"John\"\n// Consider only the start index. In this situation,\n// input string length would be considered as end index.\n\"Hello, my name is John\".substring(7) \u21d2 \"my name is John\"\n```" } }, "parameters": [ From ae98a3dbe1d5301d73f353deb9bab8d501c0716b Mon Sep 17 00:00:00 2001 From: Mohanadarshan V Date: Wed, 14 Dec 2022 12:18:50 +0530 Subject: [PATCH 258/450] Update langlib/lang.string/src/main/ballerina/string.bal Co-authored-by: Maryam Ziyad --- langlib/lang.string/src/main/ballerina/string.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index 3f7e75f1d936..0901b5682fe3 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -187,7 +187,7 @@ returns int? = @java:Method { # Tests whether a string includes another string. # # ```ballerina -# "Hello World! from Ballerina".includes("Bal") ⇒ true +# "Hello World, from Ballerina".includes("Bal") ⇒ true # # // Check for the occurrence of a string from a specific index onwards. # "Hello World! from Ballerina".includes("Hello", 10) ⇒ false From 5aebef27f84d4a40b0784a10d70a269c708d993c Mon Sep 17 00:00:00 2001 From: Mohanadarshan V Date: Wed, 14 Dec 2022 12:19:33 +0530 Subject: [PATCH 259/450] Update langlib/lang.string/src/main/ballerina/string.bal Co-authored-by: Maryam Ziyad --- langlib/lang.string/src/main/ballerina/string.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index 0901b5682fe3..6a56608fcb02 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -206,7 +206,7 @@ public isolated function includes(string str, string substr, int startIndex = 0) # Tests whether a string starts with another string. # # ```ballerina -# "Welcome to Ballerina programming language".startsWith("Welcome") ⇒ true +# "Welcome to the Ballerina programming language".startsWith("Welcome") ⇒ true # ``` # # + str - the string to be tested From 63cfa794ca0208b27afecd81d55e89fcd4b25406 Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 14 Dec 2022 12:37:34 +0530 Subject: [PATCH 260/450] Add fixes based on review comments --- langlib/lang.string/src/main/ballerina/string.bal | 12 ++++-------- .../extensions/symbol/SymbolDocumentationTest.java | 6 ++++-- .../signature/expressions/config/exprLangLibs1.json | 2 +- .../signature/expressions/config/exprLangLibs2.json | 2 +- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index 6a56608fcb02..f11a69bf0df3 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -25,8 +25,9 @@ public type RegExp regexp:RegExp; # Returns the length of the string. # -# ```ballerina -# "Hello, World!".length() ⇒ 13; +# ``` +# string greeting = "Hello, World!"; +# greeting.length() ⇒ 13; # ``` # # + str - the string @@ -89,11 +90,8 @@ public isolated function getCodePoint(string str, int index) returns int = @java # Returns a substring of a string. # # ```ballerina -# "Hello, my name is John".substring(18, 22) ⇒ "John" -# -# // Consider only the start index. In this situation, -# // input string length would be considered as end index. # "Hello, my name is John".substring(7) ⇒ "my name is John" +# "Hello, my name is John".substring(18, 22) ⇒ "John" # ``` # # + str - source string. @@ -128,10 +126,8 @@ public isolated function codePointCompare(string str1, string str2) returns int # Joins zero or more strings together with a separator. # # ```ballerina -# // Join multiple strings with space as the separator. # string:'join(" ", "Ballerina", "is", "a", "programming", "language") ⇒ "Ballerina is a programming language" # -# // Join multiple strings with comma as the separator. # string[] array = ["John", "23", "USA", "Computer Science", "Swimmer"]; # string:'join(",", ...array) ⇒ "John,23,USA,Computer Science,Swimmer" # ``` diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolDocumentationTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolDocumentationTest.java index c777ff635205..4d516f74bf9c 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolDocumentationTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolDocumentationTest.java @@ -207,7 +207,8 @@ public void testLangLibDocumentation() throws IOException { "Returns the length of the string.\n" + "\n" + "```ballerina\n" + - "\"Hello, World!\".length() ⇒ 13;\n" + + "string greeting = \"Hello, World!\";\n" + + "greeting.length() ⇒ 13;\n" + "```\n"); Assert.assertEquals(symbolInfoResponse.getDocumentation().getReturnValueDescription(), "the number of characters (code points) in parameter `str`"); @@ -231,7 +232,8 @@ public void testLangLibDocumentationWithQualifiedIdentifier() throws IOException "Returns the length of the string.\n" + "\n" + "```ballerina\n" + - "\"Hello, World!\".length() ⇒ 13;\n" + + "string greeting = \"Hello, World!\";\n" + + "greeting.length() ⇒ 13;\n" + "```\n"); Assert.assertEquals(symbolInfoResponse.getDocumentation().getReturnValueDescription(), "the number of characters (code points) in parameter `str`"); diff --git a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json index 6d0dcd38efd6..aabd4b154fab 100644 --- a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json +++ b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json @@ -12,7 +12,7 @@ "documentation": { "right": { "kind": "markdown", - "value": "**Description** \nReturns a substring of a string.\n\n```ballerina\n\"Hello, my name is John\".substring(18, 22) \u21d2 \"John\"\n// Consider only the start index. In this situation,\n// input string length would be considered as end index.\n\"Hello, my name is John\".substring(7) \u21d2 \"my name is John\"\n```" + "value": "**Description** \nReturns a substring of a string.\n\n```ballerina\n\"Hello, my name is John\".substring(7) \u21d2 \"my name is John\"\n\"Hello, my name is John\".substring(18, 22) ⇒ \"John\"\n```" } }, "parameters": [ diff --git a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json index 513cd51e08eb..444fff6aab7d 100644 --- a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json +++ b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json @@ -12,7 +12,7 @@ "documentation": { "right": { "kind": "markdown", - "value": "**Description** \nReturns a substring of a string.\n\n```ballerina\n\"Hello, my name is John\".substring(18, 22) \u21d2 \"John\"\n// Consider only the start index. In this situation,\n// input string length would be considered as end index.\n\"Hello, my name is John\".substring(7) \u21d2 \"my name is John\"\n```" + "value": "**Description** \nReturns a substring of a string.\n\n```ballerina\n\"Hello, my name is John\".substring(7) \u21d2 \"my name is John\"\n\"Hello, my name is John\".substring(18, 22) ⇒ \"John\"\n```" } }, "parameters": [ From e8cd365a398a98532fa462bed17b2ce335f168de Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 14 Dec 2022 12:38:32 +0530 Subject: [PATCH 261/450] Add fixes based on review comments --- langlib/lang.string/src/main/ballerina/string.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index f11a69bf0df3..1307627c20d5 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -25,7 +25,7 @@ public type RegExp regexp:RegExp; # Returns the length of the string. # -# ``` +# ```ballerina # string greeting = "Hello, World!"; # greeting.length() ⇒ 13; # ``` From 9a3ff1965e3ccfc07b4d77a5e7efc475707b78ad Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 14 Dec 2022 13:01:27 +0530 Subject: [PATCH 262/450] Add fixes based on review comments --- langlib/lang.string/src/main/ballerina/string.bal | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index 1307627c20d5..53edb2a66d04 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -91,7 +91,7 @@ public isolated function getCodePoint(string str, int index) returns int = @java # # ```ballerina # "Hello, my name is John".substring(7) ⇒ "my name is John" -# "Hello, my name is John".substring(18, 22) ⇒ "John" +# "Hello, my name is John Anderson".substring(18, 22) ⇒ "John" # ``` # # + str - source string. @@ -310,6 +310,7 @@ public isolated function toBytes(string str) returns byte[] = @java:Method { # # ```ballerina # string:fromBytes([72, 101, 108, 108, 111, 32, 66, 97, 108, 108, 101, 114, 105, 110, 97, 33]) ⇒ Hello, World! +# string:fromBytes([12, 45, 45]) ⇒ error # ``` # # + bytes - UTF-8 byte array From 50a27309eefdc74379140c2063bf7a8d1ddd6578 Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 14 Dec 2022 15:45:34 +0530 Subject: [PATCH 263/450] Fix test cases --- .../resources/signature/expressions/config/exprLangLibs1.json | 2 +- .../resources/signature/expressions/config/exprLangLibs2.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json index aabd4b154fab..445df2ee0ba6 100644 --- a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json +++ b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json @@ -12,7 +12,7 @@ "documentation": { "right": { "kind": "markdown", - "value": "**Description** \nReturns a substring of a string.\n\n```ballerina\n\"Hello, my name is John\".substring(7) \u21d2 \"my name is John\"\n\"Hello, my name is John\".substring(18, 22) ⇒ \"John\"\n```" + "value": "**Description** \nReturns a substring of a string.\n\n```ballerina\n\"Hello, my name is John\".substring(7) \u21d2 \"my name is John\"\n\"Hello, my name is John Anderson\".substring(18, 22) \u21d2 \"John\"\n```" } }, "parameters": [ diff --git a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json index 444fff6aab7d..2553e2ee9f72 100644 --- a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json +++ b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json @@ -12,7 +12,7 @@ "documentation": { "right": { "kind": "markdown", - "value": "**Description** \nReturns a substring of a string.\n\n```ballerina\n\"Hello, my name is John\".substring(7) \u21d2 \"my name is John\"\n\"Hello, my name is John\".substring(18, 22) ⇒ \"John\"\n```" + "value": "**Description** \nReturns a substring of a string.\n\n```ballerina\n\"Hello, my name is John\".substring(7) \u21d2 \"my name is John\"\n\"Hello, my name is John Anderson\".substring(18, 22) \u21d2 \"John\"\n```" } }, "parameters": [ From b6e040b2c5eaacba20b93d94a79f1c70d4da482c Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 14 Dec 2022 20:32:03 +0530 Subject: [PATCH 264/450] Update fromBytes example --- langlib/lang.string/src/main/ballerina/string.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index 53edb2a66d04..a6aaa0a84404 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -310,7 +310,7 @@ public isolated function toBytes(string str) returns byte[] = @java:Method { # # ```ballerina # string:fromBytes([72, 101, 108, 108, 111, 32, 66, 97, 108, 108, 101, 114, 105, 110, 97, 33]) ⇒ Hello, World! -# string:fromBytes([12, 45, 45]) ⇒ error +# string:fromBytes(base64 `lang`) ⇒ error # ``` # # + bytes - UTF-8 byte array From b4e090c244bb694e6b70fa5a81a242b775005766 Mon Sep 17 00:00:00 2001 From: mohan Date: Thu, 15 Dec 2022 14:57:54 +0530 Subject: [PATCH 265/450] Update examples --- .../lang.string/src/main/ballerina/string.bal | 27 +++++++++---------- .../symbol/SymbolDocumentationTest.java | 6 ++--- .../expressions/config/exprLangLibs1.json | 2 +- .../expressions/config/exprLangLibs2.json | 2 +- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index a6aaa0a84404..c3b4385e7be6 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -26,8 +26,7 @@ public type RegExp regexp:RegExp; # Returns the length of the string. # # ```ballerina -# string greeting = "Hello, World!"; -# greeting.length() ⇒ 13; +# "Hello, World!".length() ⇒ 13; # ``` # # + str - the string @@ -90,8 +89,8 @@ public isolated function getCodePoint(string str, int index) returns int = @java # Returns a substring of a string. # # ```ballerina -# "Hello, my name is John".substring(7) ⇒ "my name is John" -# "Hello, my name is John Anderson".substring(18, 22) ⇒ "John" +# "Hello, my name is John".substring(7) ⇒ my name is John +# "Hello, my name is John Anderson".substring(18, 22) ⇒ John # ``` # # + str - source string. @@ -126,10 +125,10 @@ public isolated function codePointCompare(string str1, string str2) returns int # Joins zero or more strings together with a separator. # # ```ballerina -# string:'join(" ", "Ballerina", "is", "a", "programming", "language") ⇒ "Ballerina is a programming language" +# string:'join(" ", "Ballerina", "is", "a", "programming", "language") ⇒ Ballerina is a programming language # # string[] array = ["John", "23", "USA", "Computer Science", "Swimmer"]; -# string:'join(",", ...array) ⇒ "John,23,USA,Computer Science,Swimmer" +# string:'join(",", ...array) ⇒ John,23,USA,Computer Science,Swimmer # ``` # # + separator - separator string @@ -236,7 +235,7 @@ public isolated function endsWith(string str, string substr) returns boolean = @ # Other characters are left unchanged. # # ```ballerina -# "HELLO, World!".toLowerAscii() ⇒ "hello, world!" +# "HELLO, World!".toLowerAscii() ⇒ hello, world! # ``` # # + str - the string to be converted @@ -251,7 +250,7 @@ public isolated function toLowerAscii(string str) returns string = @java:Method # Other characters are left unchanged. # # ```ballerina -# "hello, World!".toUpperAscii() ⇒ "HELLO, WORLD!" +# "hello, World!".toUpperAscii() ⇒ HELLO, WORLD! # ``` # # + str - the string to be converted @@ -283,7 +282,7 @@ public isolated function equalsIgnoreCaseAscii(string str1, string str2) returns # The ASCII white space characters are 0x9...0xD, 0x20. # # ```ballerina -# " BALLERINA ".trim() ⇒ "BALLERINA" +# " BALLERINA ".trim() ⇒ BALLERINA # ``` # # + str - the string @@ -352,7 +351,7 @@ public isolated function toCodePointInt(Char ch) returns int = @java:Method { # but not in the range 0xD800 or 0xDFFF inclusive. # # ```ballerina -# string:fromCodePointInts([66, 97, 108, 108, 101, 114, 105, 110, 97]) ⇒ "Ballerina" +# string:fromCodePointInts([66, 97, 108, 108, 101, 114, 105, 110, 97]) ⇒ Ballerina # ``` # # + codePoints - an array of ints, each specifying a code point @@ -369,7 +368,7 @@ public isolated function fromCodePointInts(int[] codePoints) returns string|erro # but not in the range 0xD800 or 0xDFFF inclusive. # # ```ballerina -# string:fromCodePointInt(97) ⇒ "a" +# string:fromCodePointInt(97) ⇒ a # ``` # # + codePoint - an int specifying a code point @@ -385,7 +384,7 @@ public isolated function fromCodePointInt(int codePoint) returns Char|error = @j # If the length of `str` is >= `len`, returns `str`. # # ```ballerina -# "100Km".padStart(10, "0") ⇒ "00000100Km" +# "100Km".padStart(10, "0") ⇒ 00000100Km # ``` # # + str - the string to pad @@ -402,7 +401,7 @@ public isolated function padStart(string str, int len, Char padChar = " ") retur # If the length of `str` is >= `len`, returns `str`. # # ```ballerina -# "Ballerina for developers".padEnd(30, "!") ⇒ "Ballerina for developers!!!!!!" +# "Ballerina for developers".padEnd(30, "!") ⇒ Ballerina for developers!!!!!! # ``` # # + str - the string to pad @@ -420,7 +419,7 @@ public isolated function padEnd(string str, int len, Char padChar = " ") returns # If the length of `str` is >= `len`, returns `str`. # # ```ballerina -# "-256".padZero(9) ⇒ "-00000256" +# "-256".padZero(9) ⇒ -00000256 # ``` # # + str - the string to pad diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolDocumentationTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolDocumentationTest.java index 4d516f74bf9c..c777ff635205 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolDocumentationTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/extensions/symbol/SymbolDocumentationTest.java @@ -207,8 +207,7 @@ public void testLangLibDocumentation() throws IOException { "Returns the length of the string.\n" + "\n" + "```ballerina\n" + - "string greeting = \"Hello, World!\";\n" + - "greeting.length() ⇒ 13;\n" + + "\"Hello, World!\".length() ⇒ 13;\n" + "```\n"); Assert.assertEquals(symbolInfoResponse.getDocumentation().getReturnValueDescription(), "the number of characters (code points) in parameter `str`"); @@ -232,8 +231,7 @@ public void testLangLibDocumentationWithQualifiedIdentifier() throws IOException "Returns the length of the string.\n" + "\n" + "```ballerina\n" + - "string greeting = \"Hello, World!\";\n" + - "greeting.length() ⇒ 13;\n" + + "\"Hello, World!\".length() ⇒ 13;\n" + "```\n"); Assert.assertEquals(symbolInfoResponse.getDocumentation().getReturnValueDescription(), "the number of characters (code points) in parameter `str`"); diff --git a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json index 445df2ee0ba6..865f34d59f54 100644 --- a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json +++ b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs1.json @@ -12,7 +12,7 @@ "documentation": { "right": { "kind": "markdown", - "value": "**Description** \nReturns a substring of a string.\n\n```ballerina\n\"Hello, my name is John\".substring(7) \u21d2 \"my name is John\"\n\"Hello, my name is John Anderson\".substring(18, 22) \u21d2 \"John\"\n```" + "value": "**Description** \nReturns a substring of a string.\n\n```ballerina\n\"Hello, my name is John\".substring(7) \u21d2 my name is John\n\"Hello, my name is John Anderson\".substring(18, 22) \u21d2 John\n```" } }, "parameters": [ diff --git a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json index 2553e2ee9f72..9e430561af9b 100644 --- a/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json +++ b/language-server/modules/langserver-core/src/test/resources/signature/expressions/config/exprLangLibs2.json @@ -12,7 +12,7 @@ "documentation": { "right": { "kind": "markdown", - "value": "**Description** \nReturns a substring of a string.\n\n```ballerina\n\"Hello, my name is John\".substring(7) \u21d2 \"my name is John\"\n\"Hello, my name is John Anderson\".substring(18, 22) \u21d2 \"John\"\n```" + "value": "**Description** \nReturns a substring of a string.\n\n```ballerina\n\"Hello, my name is John\".substring(7) \u21d2 my name is John\n\"Hello, my name is John Anderson\".substring(18, 22) \u21d2 John\n```" } }, "parameters": [ From 4f73c87ab092201122a4e169bb286196f715300c Mon Sep 17 00:00:00 2001 From: mohan Date: Fri, 2 Dec 2022 07:38:30 +0530 Subject: [PATCH 266/450] Add initial examples related to string operations --- .../lang.string/src/main/ballerina/string.bal | 127 +++++++++++++++++- 1 file changed, 121 insertions(+), 6 deletions(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index 3c28d0f98fab..fac8d47375e3 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -24,7 +24,12 @@ type Char string; public type RegExp regexp:RegExp; # Returns the length of the string. -# +# +# ```ballerina +# string hello = "Hello, World!"; +# int length = hello.length(); +# ``` +# # + str - the string # + return - the number of characters (code points) in parameter `str` public isolated function length(string str) returns int = @java:Method { @@ -35,7 +40,14 @@ public isolated function length(string str) returns int = @java:Method { # Returns an iterator over the string. # # The iterator will yield the substrings of length 1 in order. -# +# +# ```ballerina +# string greeting = "Hello, World. This is from Ballerina!"; +# object { +# public isolated function next() returns record {|string:Char value;|}?; +# } iterator = greeting.iterator(); +# ``` +# # + str - the string to be iterated over # + return - a new iterator object public isolated function iterator(string str) returns object { @@ -47,6 +59,13 @@ public isolated function iterator(string str) returns object { # Concatenates zero or more strings. # +# ```ballerina +# string hostname = "http://worldtimeapi.org"; +# string continent = "Asia"; +# string city = "Colombo"; +# string worldTimeAPIUrl = hostname.concat("/api/timezone/", continent, "/", city); +# +# ``` # + strs - strings to be concatenated # + return - concatenation of all of the parameter `strs`; empty string if parameter `strs` is empty public isolated function concat(string... strs) returns string = @java:Method { @@ -54,8 +73,13 @@ public isolated function concat(string... strs) returns string = @java:Method { name: "concat" } external; -# Returns the code point of a character in a string. +# Returns the unicode code point of a character in a string. # +# ```ballerina +# string hello = "Hello, World!"; +# int codePoint = hello.getCodePoint(3); +# ``` +# # + str - the string # + index - an index in parameter `str` # + return - the Unicode code point of the character at parameter `index` in parameter `str` @@ -66,6 +90,11 @@ public isolated function getCodePoint(string str, int index) returns int = @java # Returns a substring of a string. # +# ```ballerina +# string intro = "Hello, my name is John"; +# string name = intro.substring(18, 22); +# ``` +# # + str - source string. # + startIndex - the starting index, inclusive # + endIndex - the ending index, exclusive @@ -81,6 +110,10 @@ public isolated function substring(string str, int startIndex, int endIndex = st # This orders strings in a consistent and well-defined way, # but the ordering will often not be consistent with cultural expectations # for sorted order. +# +# ```ballerina +# int codePointCompare = "Austria".codePointCompare("Australia"); +# ``` # # + str1 - the first string to be compared # + str2 - the second string to be compared @@ -93,6 +126,12 @@ public isolated function codePointCompare(string str1, string str2) returns int # Joins zero or more strings together with a separator. # +# ```ballerina +# string introString = string:'join(" ", "Ballerina", "is", "a", "statically", "typed,", "concurrent", "programming", "language"); +# +# string student = string:'join(",", "John", "23", "USA", "Computer Science", "Swimmer"); +# ``` +# # + separator - separator string # + strs - strings to be joined # + return - a string consisting of all of parameter `strs` concatenated in order @@ -103,7 +142,10 @@ public isolated function 'join(string separator, string... strs) returns string } external; # Finds the first occurrence of one string in another string. -# +# ```ballerina +# int? firstIndex = "Newzeland".indexOf("land"); +# ``` +# # + str - the string in which to search # + substr - the string to search for # + startIndex - index to start searching from @@ -115,6 +157,10 @@ public isolated function indexOf(string str, string substr, int startIndex = 0) } external; # Finds the last occurrence of one string in another string. +# +# ```ballerina +# int? lastIndex = "There are multiple programming languages. Ballerinalang is unique among them".lastIndexOf("lang"); +# ``` # # + str - the string in which to search # + substr - the string to search for @@ -129,6 +175,10 @@ returns int? = @java:Method { # Tests whether a string includes another string. # +# ```ballerina +# boolean isIncludes = "Hello World! from Ballerina".includes("Bal"); +# ``` +# # + str - the string in which to search # + substr - the string to search for # + startIndex - index to start searching from @@ -141,6 +191,10 @@ public isolated function includes(string str, string substr, int startIndex = 0) # Tests whether a string starts with another string. # +# ```ballerina +# boolean isStarts = "Welcome to Ballerina programming language".includes("Welcome"); +# ``` +# # + str - the string to be tested # + substr - the starting string # + return - true if parameter `str` starts with parameter `substr`; false otherwise @@ -151,6 +205,10 @@ public isolated function startsWith(string str, string substr) returns boolean = # Tests whether a string ends with another string. # +# ```ballerina +# boolean isEnds = "Welcome to Ballerina programming language".includes("language"); +# ``` +# # + str - the string to be tested # + substr - the ending string # + return - true if parameter `str` ends with parameter `substr`; false otherwise @@ -166,6 +224,10 @@ public isolated function endsWith(string str, string substr) returns boolean = @ # Converts occurrences of A-Z to a-z. # # Other characters are left unchanged. +# +# ```ballerina +# string lowerCaseString = "HELLO, World!".toLowerAscii(); +# ``` # # + str - the string to be converted # + return - parameter `str` with any occurrences of A-Z converted to a-z @@ -177,6 +239,10 @@ public isolated function toLowerAscii(string str) returns string = @java:Method # Converts occurrences of a-z to A-Z. # # Other characters are left unchanged. +# +# ```ballerina +# string lowerCaseString = "hello, World!".toUpperAscii(); +# ``` # # + str - the string to be converted # + return - parameter `str` with any occurrences of a-z converted to A-Z @@ -189,6 +255,10 @@ public isolated function toUpperAscii(string str) returns string = @java:Method # # A character in the range a-z is treated the same as the corresponding character in the range A-Z. # +# ```ballerina +# boolean isEquals = "BALLERINA".equalsIgnoreCaseAscii("ballerina"); +# ``` +# # + str1 - the first string to be compared # + str2 - the second string to be compared # + return - true if parameter `str1` is the same as parameter `str2`, treating upper-case and lower-case @@ -202,6 +272,10 @@ public isolated function equalsIgnoreCaseAscii(string str1, string str2) returns # # The ASCII white space characters are 0x9...0xD, 0x20. # +# ```ballerina +# string trimedString = " BALLERINA ".trim(); +# ``` +# # + str - the string # + return - parameter `str` with leading or trailing ASCII white space characters removed public isolated function trim(string str) returns string = @java:Method { @@ -211,6 +285,10 @@ public isolated function trim(string str) returns string = @java:Method { # Represents a string as an array of bytes using UTF-8. # +# ```ballerina +# byte[] stringAsBytes = "Hello, World!".toBytes(); +# ``` +# # + str - the string # + return - UTF-8 byte array public isolated function toBytes(string str) returns byte[] = @java:Method { @@ -220,6 +298,11 @@ public isolated function toBytes(string str) returns byte[] = @java:Method { # Constructs a string from its UTF-8 representation in bytes. # +# ```ballerin +# byte[] bytes = [72, 101, 108, 108, 111, 32, 66, 97, 108, 108, 101, 114, 105, 110, 97, 33]; +# string stringValue = check string:fromBytes(bytes); +# ``` +# # + bytes - UTF-8 byte array # + return - parameter `bytes` converted to string or error public isolated function fromBytes(byte[] bytes) returns string|error = @java:Method { @@ -229,6 +312,11 @@ public isolated function fromBytes(byte[] bytes) returns string|error = @java:Me # Converts a string to an array of code points. # +# ```ballerina +# string hello = "Hello, world 🌎 from Ballerina. Tryout Ballerina"; +# int[] charCodePoints = hello.toCodePointInts(); +# ``` +# # + str - the string # + return - an array with a code point for each character of parameter `str` public isolated function toCodePointInts(string str) returns int[] = @java:Method { @@ -237,6 +325,10 @@ public isolated function toCodePointInts(string str) returns int[] = @java:Metho } external; # Converts a single character string to a code point. +# +# ```ballerina +# int charCodePoint = string:toCodePointInt("a"); +# ``` # # + ch - a single character string # + return - the code point of parameter `ch` @@ -249,6 +341,11 @@ public isolated function toCodePointInt(Char ch) returns int = @java:Method { # # An int is a valid code point if it is in the range 0 to 0x10FFFF inclusive, # but not in the range 0xD800 or 0xDFFF inclusive. +# +# ```ballerina +# int[] codePoints = [66,97,108,108,101,114,105,110,97]; +# string stringValue = check string:fromCodePointInts(codePoints); +# ``` # # + codePoints - an array of ints, each specifying a code point # + return - a string with a character for each code point in parameter `codePoints`; or an error @@ -262,6 +359,10 @@ public isolated function fromCodePointInts(int[] codePoints) returns string|erro # # An int is a valid code point if it is in the range 0 to 0x10FFFF inclusive, # but not in the range 0xD800 or 0xDFFF inclusive. +# +# ```ballerina +# string:Char charValue = check string:fromCodePointInt(97); +# ``` # # + codePoint - an int specifying a code point # + return - a single character string whose code point is parameter `codePoint`; or an error @@ -275,6 +376,11 @@ public isolated function fromCodePointInt(int codePoint) returns Char|error = @j # Adds sufficient `padChar` characters at the start of `str` to make its length be `len`. # If the length of `str` is >= `len`, returns `str`. # +# ```ballerina +# // Providing "0" as the custom padding char +# string distanceAsFixedLengthString = "100Km".padStart(10, "0"); +# ``` +# # + str - the string to pad # + len - the length of the string to be returned # + padChar - the character to use for padding `str`; defaults to a space character @@ -287,6 +393,11 @@ public isolated function padStart(string str, int len, Char padChar = " ") retur # Adds padding to the end of a string. # Adds sufficient `padChar` characters to the end of `str` to make its length be `len`. # If the length of `str` is >= `len`, returns `str`. +# +# ```ballerina +# // Providing "!" as the custom padding char +# string quote = "Ballerina for developers".padEnd(30, "!"); +# ``` # # + str - the string to pad # + len - the length of the string to be returned @@ -302,6 +413,10 @@ public isolated function padEnd(string str, int len, Char padChar = " ") returns # Sufficient zero characters are added to `str` to make its length be `len`. # If the length of `str` is >= `len`, returns `str`. # +# ```ballerina +# string paddedString = "-256".padZero(9); +# ``` +# # + str - the string to pad # + len - the length of the string to be returned # + zeroChar - the character to use for the zero; defaults to ASCII zero `0` @@ -313,11 +428,11 @@ public isolated function padZero(string str, int len, Char zeroChar = "0") retur # True if there is a match of `re` against all of `str`. # Use `includesMatch` to test whether `re` matches somewhere in `str`. -public function matches(string str, RegExp 're) returns boolean { +public isolated function matches(string str, RegExp 're) returns boolean { return 're.isFullMatch(str); } # True if there is a match for `re` anywhere in `str` -public function includesMatch(string str, RegExp 're, int startIndex = 0) returns boolean { +public isolated function includesMatch(string str, RegExp 're, int startIndex = 0) returns boolean { return 're.find(str, startIndex) != (); } From 436e66899a5ac128db5aa82c912371b790492be2 Mon Sep 17 00:00:00 2001 From: mohan Date: Fri, 2 Dec 2022 10:08:40 +0530 Subject: [PATCH 267/450] Add minor fix --- langlib/lang.string/src/main/ballerina/string.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index fac8d47375e3..db343861d721 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -298,7 +298,7 @@ public isolated function toBytes(string str) returns byte[] = @java:Method { # Constructs a string from its UTF-8 representation in bytes. # -# ```ballerin +# ```ballerina # byte[] bytes = [72, 101, 108, 108, 111, 32, 66, 97, 108, 108, 101, 114, 105, 110, 97, 33]; # string stringValue = check string:fromBytes(bytes); # ``` From 815ed8c1a1bff501e8660a3bf4c93d0f7a6af776 Mon Sep 17 00:00:00 2001 From: mohan Date: Fri, 2 Dec 2022 12:20:41 +0530 Subject: [PATCH 268/450] Revert "Add initial examples related to string operations" This reverts commit 8db240f2 --- .../lang.string/src/main/ballerina/string.bal | 127 +----------------- 1 file changed, 6 insertions(+), 121 deletions(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index db343861d721..3c28d0f98fab 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -24,12 +24,7 @@ type Char string; public type RegExp regexp:RegExp; # Returns the length of the string. -# -# ```ballerina -# string hello = "Hello, World!"; -# int length = hello.length(); -# ``` -# +# # + str - the string # + return - the number of characters (code points) in parameter `str` public isolated function length(string str) returns int = @java:Method { @@ -40,14 +35,7 @@ public isolated function length(string str) returns int = @java:Method { # Returns an iterator over the string. # # The iterator will yield the substrings of length 1 in order. -# -# ```ballerina -# string greeting = "Hello, World. This is from Ballerina!"; -# object { -# public isolated function next() returns record {|string:Char value;|}?; -# } iterator = greeting.iterator(); -# ``` -# +# # + str - the string to be iterated over # + return - a new iterator object public isolated function iterator(string str) returns object { @@ -59,13 +47,6 @@ public isolated function iterator(string str) returns object { # Concatenates zero or more strings. # -# ```ballerina -# string hostname = "http://worldtimeapi.org"; -# string continent = "Asia"; -# string city = "Colombo"; -# string worldTimeAPIUrl = hostname.concat("/api/timezone/", continent, "/", city); -# -# ``` # + strs - strings to be concatenated # + return - concatenation of all of the parameter `strs`; empty string if parameter `strs` is empty public isolated function concat(string... strs) returns string = @java:Method { @@ -73,13 +54,8 @@ public isolated function concat(string... strs) returns string = @java:Method { name: "concat" } external; -# Returns the unicode code point of a character in a string. +# Returns the code point of a character in a string. # -# ```ballerina -# string hello = "Hello, World!"; -# int codePoint = hello.getCodePoint(3); -# ``` -# # + str - the string # + index - an index in parameter `str` # + return - the Unicode code point of the character at parameter `index` in parameter `str` @@ -90,11 +66,6 @@ public isolated function getCodePoint(string str, int index) returns int = @java # Returns a substring of a string. # -# ```ballerina -# string intro = "Hello, my name is John"; -# string name = intro.substring(18, 22); -# ``` -# # + str - source string. # + startIndex - the starting index, inclusive # + endIndex - the ending index, exclusive @@ -110,10 +81,6 @@ public isolated function substring(string str, int startIndex, int endIndex = st # This orders strings in a consistent and well-defined way, # but the ordering will often not be consistent with cultural expectations # for sorted order. -# -# ```ballerina -# int codePointCompare = "Austria".codePointCompare("Australia"); -# ``` # # + str1 - the first string to be compared # + str2 - the second string to be compared @@ -126,12 +93,6 @@ public isolated function codePointCompare(string str1, string str2) returns int # Joins zero or more strings together with a separator. # -# ```ballerina -# string introString = string:'join(" ", "Ballerina", "is", "a", "statically", "typed,", "concurrent", "programming", "language"); -# -# string student = string:'join(",", "John", "23", "USA", "Computer Science", "Swimmer"); -# ``` -# # + separator - separator string # + strs - strings to be joined # + return - a string consisting of all of parameter `strs` concatenated in order @@ -142,10 +103,7 @@ public isolated function 'join(string separator, string... strs) returns string } external; # Finds the first occurrence of one string in another string. -# ```ballerina -# int? firstIndex = "Newzeland".indexOf("land"); -# ``` -# +# # + str - the string in which to search # + substr - the string to search for # + startIndex - index to start searching from @@ -157,10 +115,6 @@ public isolated function indexOf(string str, string substr, int startIndex = 0) } external; # Finds the last occurrence of one string in another string. -# -# ```ballerina -# int? lastIndex = "There are multiple programming languages. Ballerinalang is unique among them".lastIndexOf("lang"); -# ``` # # + str - the string in which to search # + substr - the string to search for @@ -175,10 +129,6 @@ returns int? = @java:Method { # Tests whether a string includes another string. # -# ```ballerina -# boolean isIncludes = "Hello World! from Ballerina".includes("Bal"); -# ``` -# # + str - the string in which to search # + substr - the string to search for # + startIndex - index to start searching from @@ -191,10 +141,6 @@ public isolated function includes(string str, string substr, int startIndex = 0) # Tests whether a string starts with another string. # -# ```ballerina -# boolean isStarts = "Welcome to Ballerina programming language".includes("Welcome"); -# ``` -# # + str - the string to be tested # + substr - the starting string # + return - true if parameter `str` starts with parameter `substr`; false otherwise @@ -205,10 +151,6 @@ public isolated function startsWith(string str, string substr) returns boolean = # Tests whether a string ends with another string. # -# ```ballerina -# boolean isEnds = "Welcome to Ballerina programming language".includes("language"); -# ``` -# # + str - the string to be tested # + substr - the ending string # + return - true if parameter `str` ends with parameter `substr`; false otherwise @@ -224,10 +166,6 @@ public isolated function endsWith(string str, string substr) returns boolean = @ # Converts occurrences of A-Z to a-z. # # Other characters are left unchanged. -# -# ```ballerina -# string lowerCaseString = "HELLO, World!".toLowerAscii(); -# ``` # # + str - the string to be converted # + return - parameter `str` with any occurrences of A-Z converted to a-z @@ -239,10 +177,6 @@ public isolated function toLowerAscii(string str) returns string = @java:Method # Converts occurrences of a-z to A-Z. # # Other characters are left unchanged. -# -# ```ballerina -# string lowerCaseString = "hello, World!".toUpperAscii(); -# ``` # # + str - the string to be converted # + return - parameter `str` with any occurrences of a-z converted to A-Z @@ -255,10 +189,6 @@ public isolated function toUpperAscii(string str) returns string = @java:Method # # A character in the range a-z is treated the same as the corresponding character in the range A-Z. # -# ```ballerina -# boolean isEquals = "BALLERINA".equalsIgnoreCaseAscii("ballerina"); -# ``` -# # + str1 - the first string to be compared # + str2 - the second string to be compared # + return - true if parameter `str1` is the same as parameter `str2`, treating upper-case and lower-case @@ -272,10 +202,6 @@ public isolated function equalsIgnoreCaseAscii(string str1, string str2) returns # # The ASCII white space characters are 0x9...0xD, 0x20. # -# ```ballerina -# string trimedString = " BALLERINA ".trim(); -# ``` -# # + str - the string # + return - parameter `str` with leading or trailing ASCII white space characters removed public isolated function trim(string str) returns string = @java:Method { @@ -285,10 +211,6 @@ public isolated function trim(string str) returns string = @java:Method { # Represents a string as an array of bytes using UTF-8. # -# ```ballerina -# byte[] stringAsBytes = "Hello, World!".toBytes(); -# ``` -# # + str - the string # + return - UTF-8 byte array public isolated function toBytes(string str) returns byte[] = @java:Method { @@ -298,11 +220,6 @@ public isolated function toBytes(string str) returns byte[] = @java:Method { # Constructs a string from its UTF-8 representation in bytes. # -# ```ballerina -# byte[] bytes = [72, 101, 108, 108, 111, 32, 66, 97, 108, 108, 101, 114, 105, 110, 97, 33]; -# string stringValue = check string:fromBytes(bytes); -# ``` -# # + bytes - UTF-8 byte array # + return - parameter `bytes` converted to string or error public isolated function fromBytes(byte[] bytes) returns string|error = @java:Method { @@ -312,11 +229,6 @@ public isolated function fromBytes(byte[] bytes) returns string|error = @java:Me # Converts a string to an array of code points. # -# ```ballerina -# string hello = "Hello, world 🌎 from Ballerina. Tryout Ballerina"; -# int[] charCodePoints = hello.toCodePointInts(); -# ``` -# # + str - the string # + return - an array with a code point for each character of parameter `str` public isolated function toCodePointInts(string str) returns int[] = @java:Method { @@ -325,10 +237,6 @@ public isolated function toCodePointInts(string str) returns int[] = @java:Metho } external; # Converts a single character string to a code point. -# -# ```ballerina -# int charCodePoint = string:toCodePointInt("a"); -# ``` # # + ch - a single character string # + return - the code point of parameter `ch` @@ -341,11 +249,6 @@ public isolated function toCodePointInt(Char ch) returns int = @java:Method { # # An int is a valid code point if it is in the range 0 to 0x10FFFF inclusive, # but not in the range 0xD800 or 0xDFFF inclusive. -# -# ```ballerina -# int[] codePoints = [66,97,108,108,101,114,105,110,97]; -# string stringValue = check string:fromCodePointInts(codePoints); -# ``` # # + codePoints - an array of ints, each specifying a code point # + return - a string with a character for each code point in parameter `codePoints`; or an error @@ -359,10 +262,6 @@ public isolated function fromCodePointInts(int[] codePoints) returns string|erro # # An int is a valid code point if it is in the range 0 to 0x10FFFF inclusive, # but not in the range 0xD800 or 0xDFFF inclusive. -# -# ```ballerina -# string:Char charValue = check string:fromCodePointInt(97); -# ``` # # + codePoint - an int specifying a code point # + return - a single character string whose code point is parameter `codePoint`; or an error @@ -376,11 +275,6 @@ public isolated function fromCodePointInt(int codePoint) returns Char|error = @j # Adds sufficient `padChar` characters at the start of `str` to make its length be `len`. # If the length of `str` is >= `len`, returns `str`. # -# ```ballerina -# // Providing "0" as the custom padding char -# string distanceAsFixedLengthString = "100Km".padStart(10, "0"); -# ``` -# # + str - the string to pad # + len - the length of the string to be returned # + padChar - the character to use for padding `str`; defaults to a space character @@ -393,11 +287,6 @@ public isolated function padStart(string str, int len, Char padChar = " ") retur # Adds padding to the end of a string. # Adds sufficient `padChar` characters to the end of `str` to make its length be `len`. # If the length of `str` is >= `len`, returns `str`. -# -# ```ballerina -# // Providing "!" as the custom padding char -# string quote = "Ballerina for developers".padEnd(30, "!"); -# ``` # # + str - the string to pad # + len - the length of the string to be returned @@ -413,10 +302,6 @@ public isolated function padEnd(string str, int len, Char padChar = " ") returns # Sufficient zero characters are added to `str` to make its length be `len`. # If the length of `str` is >= `len`, returns `str`. # -# ```ballerina -# string paddedString = "-256".padZero(9); -# ``` -# # + str - the string to pad # + len - the length of the string to be returned # + zeroChar - the character to use for the zero; defaults to ASCII zero `0` @@ -428,11 +313,11 @@ public isolated function padZero(string str, int len, Char zeroChar = "0") retur # True if there is a match of `re` against all of `str`. # Use `includesMatch` to test whether `re` matches somewhere in `str`. -public isolated function matches(string str, RegExp 're) returns boolean { +public function matches(string str, RegExp 're) returns boolean { return 're.isFullMatch(str); } # True if there is a match for `re` anywhere in `str` -public isolated function includesMatch(string str, RegExp 're, int startIndex = 0) returns boolean { +public function includesMatch(string str, RegExp 're, int startIndex = 0) returns boolean { return 're.find(str, startIndex) != (); } From 4c3b6f24e842ef4cdd3433e3c0b0db8eb39c60d8 Mon Sep 17 00:00:00 2001 From: mohan Date: Tue, 13 Dec 2022 18:24:20 +0530 Subject: [PATCH 269/450] Add revamped examples for streams langlib --- .../lang.stream/src/main/ballerina/stream.bal | 49 ++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/langlib/lang.stream/src/main/ballerina/stream.bal b/langlib/lang.stream/src/main/ballerina/stream.bal index f9ba35359565..b498479547e9 100644 --- a/langlib/lang.stream/src/main/ballerina/stream.bal +++ b/langlib/lang.stream/src/main/ballerina/stream.bal @@ -43,6 +43,12 @@ type Type1 any|error; # Selects the members from a stream for which a function returns true. # +# ```ballerina +# stream scoreStream = [45, 60, 75, 30, 90].toStream(); +# stream filtered = scoreStream.filter(score => score > 50); +# filtered.next() ⇒ {"value":60} +# ``` +# # + stm - the stream # + func - a predicate to apply to each member to test whether it should be selected # + return - new stream only containing members of parameter `stm` for which parameter `func` evaluates to true @@ -55,6 +61,11 @@ public isolated function filter(stream stm, @isolatedParam # Returns the next element in the stream wrapped in a record or () if the stream ends. # +# ```ballerina +# stream greetingStream = ["Hello", "Bonjour", "Hola", "Ciao"].toStream(); +# greetingStream.next() ⇒ {"value":"Hello"} +# ``` +# # + stm - The stream # + return - If the stream has elements, return the element wrapped in a record with single field called `value`, # otherwise returns () @@ -76,6 +87,12 @@ public isolated function next(stream stm) returns record { # Applies a function to each member of a stream and returns a stream of the results. # +# ```ballerina +# stream ms = [14.5f, 45.5f, 6.8f, 4f].toStream(); +# stream cms = ms.'map(m => m * 100.0); +# cms.next() ⇒ {"value":1450.0} +# ``` +# # + stm - the stream # + func - a function to apply to each member # + return - new stream containing result of applying parameter `func` to each member of parameter `stm` in order @@ -91,6 +108,11 @@ public isolated function 'map(stream stm, @isolatedParam fu # The combining function takes the combined value so far and a member of the stream, # and returns a new combined value. # +# ```ballerina +# stream scoreStream = [45, 60, 75, 30, 90].toStream(); +# scoreStream.reduce(isolated function (int total, int score) returns int => total + score, 0) ⇒ 300 +# ``` +# # + stm - the stream # + func - combining function # + initial - initial value for the first argument of combining parameter `func` @@ -115,6 +137,15 @@ public isolated function reduce(stream stm, # # The parameter `func` is applied to each member of parameter `stm` stream in order. # +# ```ballerina +# stream scoreStream = [45, 60, 75, 30, 90].toStream(); +# int total = 0; +# scoreStream.forEach(function(int score) { +# total += score; +# }); +# total ⇒ 300 +# ``` +# # + stm - the stream # + func - a function to apply to each member # + return - () if the close completed successfully, otherwise an error @@ -136,6 +167,14 @@ public isolated function forEach(stream stm, # Returns an iterator over a stream. # +# ```ballerina +# stream scoreStream = [45, 60, 75, 30, 90].toStream(); +# object { +# public isolated function next() returns record {|int value;|}?; +# } iterator = scoreStream.iterator(); +# iterator.next() ⇒ {"value":45} +# ``` +# # + stm - the stream # + return - a new iterator object that will iterate over the members of parameter `stm`. public isolated function iterator(stream stm) returns object { @@ -148,8 +187,14 @@ public isolated function iterator(stream stm) returns objec # Closes a stream. # +# ```ballerina +# stream scoreStream = [45, 60, 75, 30, 90].toStream(); +# _ = scoreStream.close(); +# scoreStream.next() ⇒ {"value":45} +# ``` +# # This releases any system resources being used by the stream. -# Closing a stream that has already been closed has no efffect and returns `()`. +# Closing a stream that has already been closed has no effect and returns `()`. # # + stm - the stream to close # + return - () if the close completed successfully, otherwise an error @@ -162,4 +207,4 @@ public isolated function close(stream stm) returns Completi return itrObj.close(); } return; -} +} \ No newline at end of file From 2d6ba66e86c9738f5c7709a5a40fcef4d7355972 Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 14 Dec 2022 15:33:05 +0530 Subject: [PATCH 270/450] Add new line --- langlib/lang.stream/src/main/ballerina/stream.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langlib/lang.stream/src/main/ballerina/stream.bal b/langlib/lang.stream/src/main/ballerina/stream.bal index b498479547e9..0f692e0b69e2 100644 --- a/langlib/lang.stream/src/main/ballerina/stream.bal +++ b/langlib/lang.stream/src/main/ballerina/stream.bal @@ -207,4 +207,4 @@ public isolated function close(stream stm) returns Completi return itrObj.close(); } return; -} \ No newline at end of file +} From 2321a96c39923184e0066018f0d1b7636c4d16fa Mon Sep 17 00:00:00 2001 From: Mohanadarshan V Date: Thu, 15 Dec 2022 12:21:00 +0530 Subject: [PATCH 271/450] Update langlib/lang.stream/src/main/ballerina/stream.bal Co-authored-by: Maryam Ziyad --- langlib/lang.stream/src/main/ballerina/stream.bal | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/langlib/lang.stream/src/main/ballerina/stream.bal b/langlib/lang.stream/src/main/ballerina/stream.bal index 0f692e0b69e2..9a852b0c31bf 100644 --- a/langlib/lang.stream/src/main/ballerina/stream.bal +++ b/langlib/lang.stream/src/main/ballerina/stream.bal @@ -45,8 +45,7 @@ type Type1 any|error; # # ```ballerina # stream scoreStream = [45, 60, 75, 30, 90].toStream(); -# stream filtered = scoreStream.filter(score => score > 50); -# filtered.next() ⇒ {"value":60} +# scoreStream.filter(score => score > 50).next() ⇒ {"value":60} # ``` # # + stm - the stream From 91f85ed0c9e56666f894f6898aa463f822f2af58 Mon Sep 17 00:00:00 2001 From: mohan Date: Thu, 15 Dec 2022 12:43:44 +0530 Subject: [PATCH 272/450] Address review comments --- langlib/lang.stream/src/main/ballerina/stream.bal | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/langlib/lang.stream/src/main/ballerina/stream.bal b/langlib/lang.stream/src/main/ballerina/stream.bal index 9a852b0c31bf..8ac0cf0b477d 100644 --- a/langlib/lang.stream/src/main/ballerina/stream.bal +++ b/langlib/lang.stream/src/main/ballerina/stream.bal @@ -61,8 +61,8 @@ public isolated function filter(stream stm, @isolatedParam # Returns the next element in the stream wrapped in a record or () if the stream ends. # # ```ballerina -# stream greetingStream = ["Hello", "Bonjour", "Hola", "Ciao"].toStream(); -# greetingStream.next() ⇒ {"value":"Hello"} +# stream scoreStream = [45, 60, 75, 30, 90].toStream(); +# scoreStream.next() ⇒ {"value":45} # ``` # # + stm - The stream @@ -189,7 +189,6 @@ public isolated function iterator(stream stm) returns objec # ```ballerina # stream scoreStream = [45, 60, 75, 30, 90].toStream(); # _ = scoreStream.close(); -# scoreStream.next() ⇒ {"value":45} # ``` # # This releases any system resources being used by the stream. From 451230e0e3497c9492829a1e911b16e2cb92e453 Mon Sep 17 00:00:00 2001 From: Thevakumar-Luheerathan Date: Mon, 12 Dec 2022 11:10:59 +0530 Subject: [PATCH 273/450] Add native support for single file --- .../cli/task/RunNativeImageTestTask.java | 3 + .../io/ballerina/cli/utils/NativeUtils.java | 132 +++++++++--------- .../cli/cmd/TestNativeImageCommandTest.java | 27 +++- .../test/runtime/util/TesterinaUtils.java | 7 +- 4 files changed, 100 insertions(+), 69 deletions(-) diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java index dd556cacd7e9..bfc9924a90be 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java @@ -320,6 +320,9 @@ private int runTestSuiteWithNativeImage(Package currentPackage, JBallerinaBacken cmdArgs.add("@" + (nativeConfigPath.resolve("native-image-args.txt"))); nativeArgs.addAll(Lists.of("-cp", classPath)); + if (currentPackage.project().kind() == ProjectKind.SINGLE_FILE_PROJECT) { + packageName = currentPackage.project().sourceRoot().toString().replace(".bal",""); + } // set name and path nativeArgs.add("-H:Name=" + packageName); diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java index cfd44b5d8548..a650a2dc2985 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java @@ -20,9 +20,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import io.ballerina.projects.Module; import io.ballerina.projects.Package; -import io.ballerina.projects.util.ProjectUtils; import io.ballerina.runtime.internal.util.RuntimeUtils; import org.ballerinalang.test.runtime.entity.TestSuite; @@ -60,77 +58,77 @@ public static void createReflectConfig(Path nativeConfigPath, Package currentPac - for (Module module : currentPackage.modules()) { - if (module.testDocumentIds().size() != 0) { - String name = module.moduleName().toString(); - String moduleName = ProjectUtils.getJarFileName(module); - - ReflectConfigClass testInitRefConfClz = new ReflectConfigClass(getQualifiedClassName(org, name, version, - MODULE_INIT_CLASS_NAME)); - - testInitRefConfClz.addReflectConfigClassMethod( - new ReflectConfigClassMethod( - "$moduleInit", - new String[]{"io.ballerina.runtime.internal.scheduling.Strand"} - ) - ); - - testInitRefConfClz.addReflectConfigClassMethod( + for (Map.Entry entry : testSuiteMap.entrySet()) { + String moduleName = entry.getKey(); + TestSuite testSuite = entry.getValue(); + String name = testSuite.getPackageID(); + + ReflectConfigClass testInitRefConfClz = new ReflectConfigClass(getQualifiedClassName(org, name, version, + MODULE_INIT_CLASS_NAME)); + + testInitRefConfClz.addReflectConfigClassMethod( + new ReflectConfigClassMethod( + "$moduleInit", + new String[]{"io.ballerina.runtime.internal.scheduling.Strand"} + ) + ); + + testInitRefConfClz.addReflectConfigClassMethod( + new ReflectConfigClassMethod( + "$moduleStart", + new String[]{"io.ballerina.runtime.internal.scheduling.Strand"} + ) + ); + + testInitRefConfClz.addReflectConfigClassMethod( + new ReflectConfigClassMethod( + "$moduleStop", + new String[]{"io.ballerina.runtime.internal.scheduling.RuntimeRegistry"} + ) + ); + + ReflectConfigClass testConfigurationMapperRefConfClz = new ReflectConfigClass( + getQualifiedClassName(org, name, version, MODULE_CONFIGURATION_MAPPER)); + + testConfigurationMapperRefConfClz.addReflectConfigClassMethod( + new ReflectConfigClassMethod( + "$configureInit", + new String[]{"java.lang.String[]", "java.nio.file.Path[]", "java.lang.String"} + ) + ); + ReflectConfigClass testTestExecuteGeneratedRefConfClz = new ReflectConfigClass( + testSuiteMap.get(moduleName).getTestUtilityFunctions().get("__execute__")); + testTestExecuteGeneratedRefConfClz.addReflectConfigClassMethod( new ReflectConfigClassMethod( - "$moduleStart", - new String[]{"io.ballerina.runtime.internal.scheduling.Strand"} - ) - ); - - testInitRefConfClz.addReflectConfigClassMethod( - new ReflectConfigClassMethod( - "$moduleStop", - new String[]{"io.ballerina.runtime.internal.scheduling.RuntimeRegistry"} + "__execute__", + new String[]{ + "io.ballerina.runtime.internal.scheduling.Strand", + "io.ballerina.runtime.api.values.BString", + "io.ballerina.runtime.api.values.BString", + "io.ballerina.runtime.api.values.BString", + "io.ballerina.runtime.api.values.BString", + "io.ballerina.runtime.api.values.BString", + "io.ballerina.runtime.api.values.BString", + "io.ballerina.runtime.api.values.BString", + "io.ballerina.runtime.api.values.BString", + "io.ballerina.runtime.api.values.BString", + "io.ballerina.runtime.api.values.BString" + } ) ); + if (!testSuiteMap.get(moduleName).getMockFunctionNamesMap().isEmpty()) { + ReflectConfigClass testNameZeroNameRefConfClz = new ReflectConfigClass(getQualifiedClassName( + org, name, version, name.replace(DOT, FILE_NAME_PERIOD_SEPARATOR))); + testNameZeroNameRefConfClz.setQueryAllDeclaredMethods(true); + classList.add(testNameZeroNameRefConfClz); + } - ReflectConfigClass testConfigurationMapperRefConfClz = new ReflectConfigClass( - getQualifiedClassName(org, name, version, MODULE_CONFIGURATION_MAPPER)); + // Add all class values to the array + classList.add(testInitRefConfClz); + classList.add(testConfigurationMapperRefConfClz); + classList.add(testTestExecuteGeneratedRefConfClz); - testConfigurationMapperRefConfClz.addReflectConfigClassMethod( - new ReflectConfigClassMethod( - "$configureInit", - new String[]{"java.lang.String[]", "java.nio.file.Path[]", "java.lang.String"} - ) - ); - ReflectConfigClass testTestExecuteGeneratedRefConfClz = new ReflectConfigClass( - testSuiteMap.get(moduleName).getTestUtilityFunctions().get("__execute__")); - testTestExecuteGeneratedRefConfClz.addReflectConfigClassMethod( - new ReflectConfigClassMethod( - "__execute__", - new String[]{ - "io.ballerina.runtime.internal.scheduling.Strand", - "io.ballerina.runtime.api.values.BString", - "io.ballerina.runtime.api.values.BString", - "io.ballerina.runtime.api.values.BString", - "io.ballerina.runtime.api.values.BString", - "io.ballerina.runtime.api.values.BString", - "io.ballerina.runtime.api.values.BString", - "io.ballerina.runtime.api.values.BString", - "io.ballerina.runtime.api.values.BString", - "io.ballerina.runtime.api.values.BString", - "io.ballerina.runtime.api.values.BString" - } - ) - ); - if (!testSuiteMap.get(moduleName).getMockFunctionNamesMap().isEmpty()) { - ReflectConfigClass testNameZeroNameRefConfClz = new ReflectConfigClass(getQualifiedClassName( - org, name, version, name.replace(DOT, FILE_NAME_PERIOD_SEPARATOR))); - testNameZeroNameRefConfClz.setQueryAllDeclaredMethods(true); - classList.add(testNameZeroNameRefConfClz); - } - - // Add all class values to the array - classList.add(testInitRefConfClz); - classList.add(testConfigurationMapperRefConfClz); - classList.add(testTestExecuteGeneratedRefConfClz); - } } diff --git a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestNativeImageCommandTest.java b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestNativeImageCommandTest.java index d0d20c4b757b..3bf21aea73da 100644 --- a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestNativeImageCommandTest.java +++ b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestNativeImageCommandTest.java @@ -54,10 +54,35 @@ public void testNativeImageTests() throws IOException { Path projectPath = this.testResources.resolve("validProjectWithTests"); System.setProperty(ProjectConstants.USER_DIR, projectPath.toString()); TestCommand testCommand = new TestCommand(projectPath, printStream, printStream, false, true); - // non existing bal file new CommandLine(testCommand).parse(); testCommand.execute(); String buildLog = readOutput(true); Assert.assertTrue(buildLog.contains("1 passing")); } + +// TODO: Fix test cases that are failing due to "Caused by: java.util.zip.ZipException: ZIP file can't be opened as a +// file system because entry "/resources/$anon/./0/openapi-spec.yaml" has a '.' or '..' element in its name" error. + +// @Test(description = "Test a valid ballerina file") +// public void testTestBalFile() throws IOException { +// Path validBalFilePath = this.testResources.resolve("valid-test-bal-file").resolve("sample_tests.bal"); +// System.setProperty(ProjectConstants.USER_DIR, this.testResources.resolve("valid-test-bal-file").toString()); +// TestCommand testCommand = new TestCommand(validBalFilePath, printStream, printStream, false, true); +// new CommandLine(testCommand).parseArgs(validBalFilePath.toString()); +// testCommand.execute(); +// String buildLog = readOutput(true); +// Assert.assertTrue(buildLog.contains("1 passing")); +// } +// +// @Test(description = "Test a valid ballerina file with periods in the file name") +// public void testTestBalFileWithPeriods() throws IOException { +// Path validBalFilePath = this.testResources.resolve("valid-test-bal-file").resolve("sample.tests.bal"); +// +// System.setProperty(ProjectConstants.USER_DIR, this.testResources.resolve("valid-test-bal-file").toString()); +// TestCommand testCommand = new TestCommand(validBalFilePath, printStream, printStream, false, true); +// new CommandLine(testCommand).parseArgs(validBalFilePath.toString()); +// testCommand.execute(); +// String buildLog = readOutput(true); +// Assert.assertTrue(buildLog.contains("1 passing")); +// } } diff --git a/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/TesterinaUtils.java b/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/TesterinaUtils.java index 3e1080481243..b1e0239d353e 100644 --- a/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/TesterinaUtils.java +++ b/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/TesterinaUtils.java @@ -46,6 +46,7 @@ import static io.ballerina.identifier.Utils.encodeNonFunctionIdentifier; import static io.ballerina.runtime.api.constants.RuntimeConstants.BLANG_SRC_FILE_SUFFIX; +import static io.ballerina.runtime.api.constants.RuntimeConstants.FILE_NAME_PERIOD_SEPARATOR; import static io.ballerina.runtime.api.constants.RuntimeConstants.MODULE_INIT_CLASS_NAME; import static io.ballerina.runtime.internal.launch.LaunchUtils.startTrapSignalHandler; import static org.ballerinalang.test.runtime.util.TesterinaConstants.ANON_ORG; @@ -131,10 +132,14 @@ private static void execute(TestSuite suite, ClassLoader classLoader, TestArgume } catch (Throwable e) { throw new BallerinaTestException("failed to load configuration class :" + configClassName); } + String suiteExecuteFilePath = suite.getExecuteFilePath(); + if(suite.getOrgName().equals(ANON_ORG) && suite.getTestPackageID().equals(DOT)) { + suiteExecuteFilePath = suiteExecuteFilePath.replace(DOT, FILE_NAME_PERIOD_SEPARATOR); + } String testExecuteClassName = TesterinaUtils.getQualifiedClassName(suite.getOrgName(), suite.getTestPackageID(), suite.getVersion(), - suite.getExecuteFilePath()); + suiteExecuteFilePath); Class testExecuteClazz; try { testExecuteClazz = classLoader.loadClass(testExecuteClassName); From 20307b108cad1e5f15494b4e658a97f867aa7fd1 Mon Sep 17 00:00:00 2001 From: mindula Date: Mon, 12 Dec 2022 10:41:24 +0530 Subject: [PATCH 274/450] Fix change variable type code action --- .../ChangeVariableTypeCodeAction.java | 11 +++++--- .../ChangeVariableTypeCodeActionTest.java | 1 + .../config/changeVarType5.json | 28 +++++++++++++++++++ .../change-var-type/source/changeVarType2.bal | 6 ++++ 4 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/change-var-type/config/changeVarType5.json create mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/change-var-type/source/changeVarType2.bal diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/changetype/ChangeVariableTypeCodeAction.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/changetype/ChangeVariableTypeCodeAction.java index 5e1f48224390..fa197eec9c3d 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/changetype/ChangeVariableTypeCodeAction.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/changetype/ChangeVariableTypeCodeAction.java @@ -40,8 +40,10 @@ import org.ballerinalang.annotation.JavaSPIService; import org.ballerinalang.langserver.codeaction.CodeActionNodeValidator; import org.ballerinalang.langserver.codeaction.CodeActionUtil; +import org.ballerinalang.langserver.common.ImportsAcceptor; import org.ballerinalang.langserver.common.constants.CommandConstants; import org.ballerinalang.langserver.common.utils.CommonUtil; +import org.ballerinalang.langserver.common.utils.FunctionGenerator; import org.ballerinalang.langserver.common.utils.PositionUtil; import org.ballerinalang.langserver.commons.CodeActionContext; import org.ballerinalang.langserver.commons.codeaction.spi.DiagBasedPositionDetails; @@ -117,17 +119,18 @@ public List getCodeActions(Diagnostic diagnostic, types = CodeActionUtil.getPossibleTypes(foundType.get(), importEdits, context); } for (String type : types) { - if (typeNodeStr.isPresent() && typeNodeStr.get().equals(type)) { + String typeName = FunctionGenerator.processModuleIDsInText(new ImportsAcceptor(context), type, context); + if (typeNodeStr.isPresent() && typeNodeStr.get().equals(typeName)) { // Skip suggesting same type continue; } List edits = new ArrayList<>(); - edits.add(new TextEdit(PositionUtil.toRange(typeNode.get().lineRange()), type)); + edits.add(new TextEdit(PositionUtil.toRange(typeNode.get().lineRange()), typeName)); String commandTitle; if (variableNode.get().kind() == SyntaxKind.CONST_DECLARATION) { - commandTitle = String.format(CommandConstants.CHANGE_CONST_TYPE_TITLE, variableName.get(), type); + commandTitle = String.format(CommandConstants.CHANGE_CONST_TYPE_TITLE, variableName.get(), typeName); } else { - commandTitle = String.format(CommandConstants.CHANGE_VAR_TYPE_TITLE, variableName.get(), type); + commandTitle = String.format(CommandConstants.CHANGE_VAR_TYPE_TITLE, variableName.get(), typeName); } actions.add(CodeActionUtil .createCodeAction(commandTitle, edits, context.fileUri(), CodeActionKind.QuickFix)); diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ChangeVariableTypeCodeActionTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ChangeVariableTypeCodeActionTest.java index 8e711f6d1953..1491bfc85896 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ChangeVariableTypeCodeActionTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ChangeVariableTypeCodeActionTest.java @@ -56,6 +56,7 @@ public Object[][] dataProvider() { {"changeVarType3.json"}, {"changeVarType4.json"}, {"changeVarType3.json"}, + {"changeVarType5.json"}, {"changeVarType_int_to_float.json"}, {"changeVarType_int_to_float_in_constant.json"}, {"changeVarTypeInObjectFields1.json"}, diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/change-var-type/config/changeVarType5.json b/language-server/modules/langserver-core/src/test/resources/codeaction/change-var-type/config/changeVarType5.json new file mode 100644 index 000000000000..03d1ad056bb0 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/change-var-type/config/changeVarType5.json @@ -0,0 +1,28 @@ +{ + "position": { + "line": 4, + "character": 23 + }, + "source": "changeVarType2.bal", + "expected": [ + { + "title": "Change variable 'clientResponse' type to 'module1:Response|anydata'", + "kind": "quickfix", + "edits": [ + { + "range": { + "start": { + "line": 4, + "character": 4 + }, + "end": { + "line": 4, + "character": 5 + } + }, + "newText": "module1:Response|anydata" + } + ] + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/change-var-type/source/changeVarType2.bal b/language-server/modules/langserver-core/src/test/resources/codeaction/change-var-type/source/changeVarType2.bal new file mode 100644 index 000000000000..8ded0cd20a49 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/change-var-type/source/changeVarType2.bal @@ -0,0 +1,6 @@ +import ballerina/module1; + +public function main() returns error? { + module1:Client clientEP = check new("http://example.com"); + x clientResponse = clientEP->get("/"); +} From 6c2b0c8723fe98042df98cc82dfbd3cc6aaf99cd Mon Sep 17 00:00:00 2001 From: Niveathika Date: Thu, 15 Dec 2022 22:07:51 +0530 Subject: [PATCH 275/450] Move pull request build checks against default branch --- .github/workflows/pull_request_full_build.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pull_request_full_build.yml b/.github/workflows/pull_request_full_build.yml index fae38c65849c..de882faaaaee 100644 --- a/.github/workflows/pull_request_full_build.yml +++ b/.github/workflows/pull_request_full_build.yml @@ -72,15 +72,15 @@ jobs: do git clone https://github.com/ballerina-platform/${module_name}.git; \ done - - name: Checkout non-default branch - run: | - for module_name in $(jq -r '.standard_library| .[] | select(.level==${{ matrix.level }}) | .name' extensions.json); \ - do - cd $module_name - git fetch origin - git checkout -t origin/update4 || : - cd .. - done +# - name: Checkout non-default branch +# run: | +# for module_name in $(jq -r '.standard_library| .[] | select(.level==${{ matrix.level }}) | .name' extensions.json); \ +# do +# cd $module_name +# git fetch origin +# git checkout -t origin/update4 || : +# cd .. +# done - name: Update Lang Version in Module run: | From 940f64dd59eb8cb3e76fb98a5ad8dc8a8074e31a Mon Sep 17 00:00:00 2001 From: mohan Date: Fri, 16 Dec 2022 10:31:07 +0530 Subject: [PATCH 276/450] Add fixes for review comments --- langlib/lang.string/src/main/ballerina/string.bal | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index c3b4385e7be6..6a4ae43063d1 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -21,6 +21,7 @@ import ballerina/lang.regexp; @builtinSubtype type Char string; +# Refers to the `RegExp` type defined by lang.regexp module. public type RegExp regexp:RegExp; # Returns the length of the string. @@ -164,7 +165,7 @@ public isolated function indexOf(string str, string substr, int startIndex = 0) # ```ballerina # "Ballerinalang is a unique programming language".lastIndexOf("lang") ⇒ 38 # -# // Search for the last occurrence of a string from a specific index onwards. +# // Search backwards for the last occurrence of a string from a specific index. # "Ballerinalang is a unique programming language".lastIndexOf("lang", 15) ⇒ 9 # ``` # @@ -443,8 +444,8 @@ public isolated function padZero(string str, int len, Char zeroChar = "0") retur # + str - the string # + re - the regular expression # + return - true if there is full match of `re` with `str`, and false otherwise -public isolated function matches(string str, RegExp 're) returns boolean { - return 're.isFullMatch(str); +public function matches(string str, RegExp re) returns boolean { + return re.isFullMatch(str); } # Tests whether there is a match of a regular expression somewhere within a string. @@ -457,6 +458,6 @@ public isolated function matches(string str, RegExp 're) returns boolean { # + str - the string to be matched # + re - the regular expression # + return - true if the is a match of `re` somewhere within `str`, otherwise false -public isolated function includesMatch(string str, RegExp 're, int startIndex = 0) returns boolean { - return 're.find(str, startIndex) != (); +public function includesMatch(string str, RegExp re, int startIndex = 0) returns boolean { + return re.find(str, startIndex) != (); } From 153716efaf750c480cffd9da6ce99add77de7f73 Mon Sep 17 00:00:00 2001 From: Hinduja Date: Fri, 16 Dec 2022 10:54:48 +0530 Subject: [PATCH 277/450] Fix test failures --- .../main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java index d05b2d8e9623..020688558cb9 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java @@ -2682,7 +2682,7 @@ private void generateListConstructorExpr(BLangListConstructorExpr listConstructo } } - if (listConstructorExprType.tag == TypeTags.TUPLE) { + if (referredType.tag == TypeTags.TUPLE) { setScopeAndEmit( new BIRNonTerminator.NewArray(listConstructorExpr.pos, listConstructorExprType, toVarRef, typedescOp, sizeOp, initialValues)); From 97ca46cc5f5aa9d7fc4ce9705272833ea61bcf58 Mon Sep 17 00:00:00 2001 From: suleka96 Date: Fri, 16 Dec 2022 14:26:02 +0530 Subject: [PATCH 278/450] Resolve conflicts --- .../lang.regexp/src/main/ballerina/regexp.bal | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/langlib/lang.regexp/src/main/ballerina/regexp.bal b/langlib/lang.regexp/src/main/ballerina/regexp.bal index a507d36fd1ff..f9aef6c6784f 100644 --- a/langlib/lang.regexp/src/main/ballerina/regexp.bal +++ b/langlib/lang.regexp/src/main/ballerina/regexp.bal @@ -53,6 +53,16 @@ type GroupsArrayType GroupsAsSpanArrayType[]; # Returns the first match of a regular expression within a string. # +# ```ballerina +#var sampleRegex = re `World`; +# +#sampleRegex.find("Not A Match") is () ⇒ true +# +#sampleRegex.find("Hello World") is regexp:Span ⇒ true +# +#sampleRegex.find("Hello World", 7) is regexp:Span ⇒ true +# ``` +# # + re - the regular expression # + str - the string in which to look for a match of `re` # + startIndex - the index within `str` at which to start looking for a match @@ -77,6 +87,16 @@ isolated function findAllImpl(RegExp reExp, string str, int startIndex = 0) retu # Returns the `Groups` for the first match of a regular expression within a string. # +# ```ballerina +#var sampleRegex = re `GFG`; +# +#sampleRegex.findGroups("Not A Match") is () ⇒ true +# +#rsampleRegex.findGroups("GFGFGFGFGFGFGFGFGFG") is regexp:Groups ⇒ true +# +#sampleRegex.findGroups("GFGFGFGFGFGFGFGFGFG", 7) is regexp:Groups ⇒ true +# ``` +# # + re - the regular expression # + str - the string in which to look for a match of `re` # + startIndex - the index within `str` at which to start looking for a match @@ -97,6 +117,16 @@ isolated function findGroupsImpl(RegExp reExp, string str, int startIndex = 0) r # After one match is found, it looks for the next match starting where the previous # match ended, so the list of matches will be non-overlapping. # +# ```ballerina +#var sampleRegex = re `GFG`; +# +#sampleRegex.findAll("Not A Match").length() ⇒ 0 +# +#sampleRegex.findAll("GFGFGFGFGFGFGFGFGFG").length() ⇒ 5 +# +#sampleRegex.findAll("GFGFGFGFGFGFGFGFGFG", 7).length() ⇒ true +# ``` +# # + re - the regular expression # + str - the string in which to look for matches of `re` # + startIndex - the index within `str` at which to start looking for matches @@ -116,6 +146,16 @@ public isolated function findAll(RegExp re, string str, int startIndex = 0) retu # After one match is found, it looks for the next match starting where the previous # match ended, so the list of matches will be non-overlapping. # +# ```ballerina +#var sampleRegex = re `(GFG)(FGF)`; +# +#sampleRegex.findAllGroups("Not A Match").length() ⇒ 0 +# +#sampleRegex.findAllGroups("GFGFGFGFGFGFGFGFGF").length() ⇒ 3 +# +#sampleRegex.findAllGroups("GFGFGFGFGFGFGFGFGF", 7) ⇒ 1 +# ``` +# # + re - the regular expression # + str - the string in which to look for matches of `re` # + startIndex - the index within `str` at which to start looking for matches @@ -154,6 +194,14 @@ isolated function findAllGroupsImpl(RegExp reExp, string str, int startIndex = 0 # Tests whether there is a match of a regular expression at a specific index in the string. # +# ```ballerina +# var sampleRegex = re `World`; +# +#sampleRegex.matchAt("Hello World") is () ⇒ true +# +#sampleRegex.matchAt("Hello World", 6) is regexp:Span ⇒ true +# ``` +# # + re - the regular expression # + str - the string in which to look for a match of `re` # + startIndex - the index within `str` at which to look for a match; defaults to zero @@ -174,6 +222,14 @@ isolated function matchAtImpl(RegExp reExp, string str, int startIndex = 0) retu # Returns the `Groups` of the match of a regular expression at a specific index in the string. # +# ```ballerina +#var sampleRegex = re `([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])?`; +# +#sampleRegex.matchGroupsAt("time: 14:35:59") is () ⇒ true +# +#sampleRegex.matchGroupsAt("time: 14:35:59", 6) is regexp:Groups ⇒ true +# ``` +# # + re - the regular expression # + str - the string in which to look for a match of `re` # + startIndex - the index within `str` at which to look for a match; defaults to zero @@ -203,6 +259,14 @@ isolated function matchGroupsAtImpl(RegExp reExp, string str, int startIndex = 0 # A match of a regular expression in a string is a full match if it # starts at index 0 and ends at index `n`, where `n` is the length of the string. # +# ```ballerina +#var sampleRegex = re `A|Th.*ch|^`; +# +#sampleRegex.isFullMatch("This is a Match") ⇒ true +# +#sampleRegex.isFullMatch("Not a complete Match") ⇒ false +# ``` +# # + re - the regular expression # + str - the string # + return - true if there is full match of `re` with `str`, and false otherwise @@ -219,6 +283,14 @@ isolated function isFullMatchImpl(RegExp reExp, string str) returns boolean = @j # A match of the regular expression in a string is a full match if it # starts at index 0 and ends at index `n`, where `n` is the length of the string. # +# ```ballerina +#var sampleRegex = re `([0-9]+)×([0-9]+)`; +# +#sampleRegex.fullMatchGroups("test: 1440×900") is () ⇒ true +# +#sampleRegex.fullMatchGroups("1440×900") is regexp:Groups ⇒ true +# ``` +# # + re - the regular expression # + str - the string in which to look for a match of `re` # + return - a `Groups` list describing the match, or nil if there is not a full match; the @@ -238,6 +310,16 @@ public type Replacement ReplacerFunction|string; # Replaces the first match of a regular expression. # +# ```ballerina +#var sampleRegex = re `0+`; +# +#sampleRegex.replace("10010011", "*") ⇒ 1*10011 +# +#sampleRegex.replace("10010011", "*", 4) ⇒ 1001*11 +# +#sampleRegex.replace("122111", "*") ⇒ 122111 +# ``` +# # + re - the regular expression # + str - the string in which to perform the replacements # + replacement - a `Replacement` that gives the replacement for the match @@ -264,6 +346,16 @@ public isolated function replace(RegExp re, string str, Replacement replacement, # After one match is found, it looks for the next match starting where the previous # match ended, so the matches will be non-overlapping. # +# ```ballerina +#var sampleRegex = re `0+`; +# +#sampleRegex.replaceAll("10010011", "*") ⇒ 1*1*11 +# +#sampleRegex.replaceAll("10010011", "*", 4) ⇒ 1001*11 +# +#sampleRegex.replaceAll("122111", "*") ⇒ 122111 +# ``` +# # + re - the regular expression # + str - the string in which to perform the replacements # + replacement - a `Replacement` that gives the replacement for each match @@ -320,6 +412,14 @@ isolated function getReplacementString(Groups groups, Replacement replacement) r # between matches, or after the last match. If there are no matches, then # `[str]` will be returned. # +# ```ballerina +#var sampleRegex = re `,`; +# +#sampleRegex.split("Not Valid").length() ⇒ 0 +# +#sampleRegex.split("abc,cde,efg") ⇒ ["abc", "cde", "efg"] +# ``` +# # + re - the regular expression that specifies the separator # + str - the string to be split # + return - a list of substrings of `str` separated by matches of `re` @@ -331,6 +431,12 @@ public isolated function split(RegExp re, string str) returns string[] = @java:M # Constructs a regular expression from a string. # The syntax of the regular expression is the same as accepted by the `re` tagged data template expression. # +# ```ballerina +#regexp:fromString("AB+C*D{1,4}") ⇒ re `AB+C*D{1,4}` +# +#regexp:fromString("AB+^*") is error ⇒ true +# ``` +# # + str - the string representation of a regular expression # + return - the regular expression, or an error value if `str` is not a valid regular expression public isolated function fromString(string str) returns RegExp|error = @java:Method { From 71955c603ca0ddb1bebdc3ede41e48e4e6ee831a Mon Sep 17 00:00:00 2001 From: suleka96 Date: Fri, 16 Dec 2022 16:17:51 +0530 Subject: [PATCH 279/450] Resolve conflicts --- langlib/lang.string/src/main/ballerina/string.bal | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index 3c712f3f62ff..99ac723eb410 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -317,6 +317,11 @@ public type RegExp regexp:RegExp; # starts at index 0 and ends at index `n`, where `n` is the length of the string. # This is equivalent to `regex:isFullMatch(re, str)`. # +# ```ballerina +#string sampleString = "This is a Match"; +#sampleString.matches(re `A|Th.*ch|^`) ⇒ true +# ``` +# # + str - the string # + re - the regular expression # + return - true if there is full match of `re` with `str`, and false otherwise @@ -327,6 +332,11 @@ public function matches(string str, RegExp re) returns boolean { # Tests whether there is a match of a regular expression somewhere within a string. # This is equivalent to `regexp:find(re, str, startIndex) != ()`. # +# ```ballerina +#string sampleString = "Will Match Somewhere"; +#sampleString.includesMatch(re `A|Th.*ch|^`) ⇒ true +# ``` +# # + str - the string to be matched # + re - the regular expression # + return - true if the is a match of `re` somewhere within `str`, otherwise false From bde0415c3d1b905afa0d586cf2f020833af71d69 Mon Sep 17 00:00:00 2001 From: Nipuna Ranasinghe Date: Fri, 16 Dec 2022 20:52:33 +0530 Subject: [PATCH 280/450] Increase variable request timeout and add info logs for monitoring --- .../test/utils/client/DAPClientConnector.java | 2 +- .../test/utils/client/DAPRequestManager.java | 24 ++++++++++++------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/tests/jballerina-debugger-integration-test/src/main/java/org/ballerinalang/debugger/test/utils/client/DAPClientConnector.java b/tests/jballerina-debugger-integration-test/src/main/java/org/ballerinalang/debugger/test/utils/client/DAPClientConnector.java index 0b31666aa049..f7bee198b1ca 100644 --- a/tests/jballerina-debugger-integration-test/src/main/java/org/ballerinalang/debugger/test/utils/client/DAPClientConnector.java +++ b/tests/jballerina-debugger-integration-test/src/main/java/org/ballerinalang/debugger/test/utils/client/DAPClientConnector.java @@ -142,7 +142,7 @@ public void createConnection() { debugServer.initialize(initParams).thenApply(res -> { initializeResult = res; LOGGER.info("initialize response received from the debug server."); - requestManager = new DAPRequestManager(this, debugClient, debugServer, initializeResult); + requestManager = new DAPRequestManager(this, debugServer); debugClient.connect(requestManager); myConnectionState = ConnectionState.CONNECTED; return res; diff --git a/tests/jballerina-debugger-integration-test/src/main/java/org/ballerinalang/debugger/test/utils/client/DAPRequestManager.java b/tests/jballerina-debugger-integration-test/src/main/java/org/ballerinalang/debugger/test/utils/client/DAPRequestManager.java index f5df88b1f8df..2e1e085c9b12 100644 --- a/tests/jballerina-debugger-integration-test/src/main/java/org/ballerinalang/debugger/test/utils/client/DAPRequestManager.java +++ b/tests/jballerina-debugger-integration-test/src/main/java/org/ballerinalang/debugger/test/utils/client/DAPRequestManager.java @@ -16,7 +16,6 @@ package org.ballerinalang.debugger.test.utils.client; import org.eclipse.lsp4j.debug.BreakpointEventArguments; -import org.eclipse.lsp4j.debug.Capabilities; import org.eclipse.lsp4j.debug.CapabilitiesEventArguments; import org.eclipse.lsp4j.debug.CompletionsArguments; import org.eclipse.lsp4j.debug.CompletionsResponse; @@ -52,7 +51,11 @@ import org.eclipse.lsp4j.debug.VariablesArguments; import org.eclipse.lsp4j.debug.VariablesResponse; import org.eclipse.lsp4j.debug.services.IDebugProtocolServer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.time.Duration; +import java.time.Instant; import java.util.Map; import java.util.Objects; import java.util.concurrent.CompletableFuture; @@ -68,16 +71,13 @@ public class DAPRequestManager { private boolean didRunInIntegratedTerminal; private boolean isProjectBasedTest; - public DAPRequestManager(DAPClientConnector clientConnector, DAPClient client, IDebugProtocolServer server, - Capabilities serverCapabilities) { + private static final Logger LOGGER = LoggerFactory.getLogger(DAPRequestManager.class); + + public DAPRequestManager(DAPClientConnector clientConnector, IDebugProtocolServer server) { this.clientConnector = clientConnector; this.server = server; } - public DAPClientConnector getClientConnector() { - return clientConnector; - } - // ------------------------------- Client to Server --------------------------------------------// public SetBreakpointsResponse setBreakpoints(SetBreakpointsArguments args) throws Exception { @@ -190,8 +190,14 @@ public VariablesResponse variables(VariablesArguments args) throws Exception { public VariablesResponse variables(VariablesArguments args, long timeoutMillis) throws Exception { if (checkStatus()) { + Instant start = Instant.now(); CompletableFuture resp = server.variables(args); - return resp.get(timeoutMillis, TimeUnit.MILLISECONDS); + VariablesResponse variablesResponse = resp.get(timeoutMillis, TimeUnit.MILLISECONDS); + Instant end = Instant.now(); + // Todo - remove after monitoring if the debugger integration tests are failing due to averagely high + // variable response times or, due to sudden spikes (potential concurrency issues?) + LOGGER.info(String.format("debug variables request took %s ms", Duration.between(start, end).toMillis())); + return variablesResponse; } else { throw new IllegalStateException("DAP request manager is not active"); } @@ -375,7 +381,7 @@ private enum DefaultTimeouts { THREADS(2000), STACK_TRACE(7000), SCOPES(2000), - VARIABLES(20000), + VARIABLES(30000), EVALUATE(15000), COMPLETIONS(10000), STEP_OVER(5000), From d8f5306b359e377f192e866966ab9f03d3483811 Mon Sep 17 00:00:00 2001 From: mindula Date: Mon, 24 Oct 2022 13:03:25 +0530 Subject: [PATCH 281/450] Add missing completion items in conditional expressions --- .../ExtractToFunctionCodeAction.java | 34 +++++++++++++++---- .../ExtractToFunctionCodeActionTest.java | 1 + 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToFunctionCodeAction.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToFunctionCodeAction.java index 5a043249f27e..6f8949ec8be9 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToFunctionCodeAction.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToFunctionCodeAction.java @@ -163,7 +163,8 @@ private List getCodeActionsForStatements(CodeActionContext context, return Collections.emptyList(); } - Optional argLists = getArgLists(context, argsSymbolsForExtractFunction.get()); + Optional argLists = getArgLists(context, argsSymbolsForExtractFunction.get(), + matchedCodeActionNode); if (argLists.isEmpty()) { return Collections.emptyList(); } @@ -361,7 +362,8 @@ private List getCodeActionsForExpressions(CodeActionContext context, return Collections.emptyList(); } - Optional argLists = getArgLists(context, varAndParamSymbolsWithinRange.get()); + Optional argLists = getArgLists(context, varAndParamSymbolsWithinRange.get(), + matchedCodeActionNode); if (argLists.isEmpty()) { return Collections.emptyList(); @@ -457,7 +459,8 @@ private Optional> getVarAndParamSymbolsWithinRangeForExprs(LineRang .collect(Collectors.toList())); } - private Optional getArgLists(CodeActionContext context, List symbolsList) { + private Optional getArgLists(CodeActionContext context, List symbolsList, + NonTerminalNode node) { List argsForExtractFunction = new ArrayList<>(); List argsForReplaceFunctionCall = new ArrayList<>(); @@ -469,12 +472,20 @@ private Optional getArgLists(CodeActionContext context, List possibleType = Optional.empty(); if (symbol.kind() == SymbolKind.VARIABLE) { - possibleType = CodeActionUtil - .getPossibleType(((VariableSymbol) symbol).typeDescriptor(), new ArrayList<>(), context); + Optional typeSymbol = getTypeSymbol(context, ((VariableSymbol) symbol).typeDescriptor(), + node); + if (typeSymbol.isEmpty()) { + return Optional.empty(); + } + possibleType = CodeActionUtil.getPossibleType(typeSymbol.get(), new ArrayList<>(), context); } else if (symbol.kind() == SymbolKind.PARAMETER) { - possibleType = CodeActionUtil - .getPossibleType(((ParameterSymbol) symbol).typeDescriptor(), new ArrayList<>(), context); + Optional typeSymbol = getTypeSymbol(context, ((ParameterSymbol) symbol).typeDescriptor(), + node); + if (typeSymbol.isEmpty()) { + return Optional.empty(); + } + possibleType = CodeActionUtil.getPossibleType(typeSymbol.get(), new ArrayList<>(), context); } if (possibleType.isEmpty()) { return Optional.empty(); @@ -489,6 +500,15 @@ private Optional getArgLists(CodeActionContext context, List getTypeSymbol(CodeActionContext context, TypeSymbol typeSymbol, + NonTerminalNode node) { + if (typeSymbol.typeKind() == TypeDescKind.UNION) { + return Optional.of(context.currentSemanticModel().flatMap(semanticModel -> + semanticModel.typeOf(node.children().get(0)).flatMap(SymbolUtil::getTypeDescriptor)).get()); + } + return Optional.of(typeSymbol); + } + private Node findEnclosingModulePartNode(NonTerminalNode node) { Node reference = node; diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToFunctionCodeActionTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToFunctionCodeActionTest.java index 1925c11e1fa4..53ecc9a80518 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToFunctionCodeActionTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToFunctionCodeActionTest.java @@ -138,6 +138,7 @@ public Object[][] dataProvider() { // {"extract_to_function_exprs_object_constructor.json"}, // todo support later {"extract_to_function_exprs_error_constructor.json"}, {"extract_to_function_exprs_within_isolated_function.json"}, + {"extract_to_function_exprs_conditional_expr.json"}, // expressions by position {"extract_to_function_exprs_position_numeric_literal_cur_after_literal.json"}, From 88c10d8df849f58bee127c7d74468718e3744908 Mon Sep 17 00:00:00 2001 From: mindula Date: Mon, 24 Oct 2022 13:04:16 +0530 Subject: [PATCH 282/450] Add unit tests --- ...ct_to_function_exprs_conditional_expr.json | 49 +++++ ...act_to_function_exprs_conditional_expr.bal | 8 + .../config/field_access_ctx_config54.json | 190 ++++++++++++++++++ .../source/field_access_ctx_source54.bal | 8 + 4 files changed, 255 insertions(+) create mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/config/extract_to_function_exprs_conditional_expr.json create mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/source/extract_to_function_exprs_conditional_expr.bal create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config54.json create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/source/field_access_ctx_source54.bal diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/config/extract_to_function_exprs_conditional_expr.json b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/config/extract_to_function_exprs_conditional_expr.json new file mode 100644 index 000000000000..9c6203bc807d --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/config/extract_to_function_exprs_conditional_expr.json @@ -0,0 +1,49 @@ +{ + "range": { + "start": { + "line": 6, + "character": 32 + }, + "end": { + "line": 6, + "character": 47 + } + }, + "source": "extract_to_function_exprs_conditional_expr.bal", + "description": "Extract to function for expressions, conditional expression", + "expected": [ + { + "title": "Extract to function", + "kind": "refactor.extract", + "edits": [ + { + "range": { + "start": { + "line": 7, + "character": 1 + }, + "end": { + "line": 7, + "character": 1 + } + }, + "newText": "\n\nfunction extracted(json var1) returns string {\n return var1.toString();\n}\n" + }, + { + "range": { + "start": { + "line": 6, + "character": 32 + }, + "end": { + "line": 6, + "character": 47 + } + }, + "newText": "extracted(var1)" + } + ], + "resolvable": false + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/source/extract_to_function_exprs_conditional_expr.bal b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/source/extract_to_function_exprs_conditional_expr.bal new file mode 100644 index 000000000000..93b32c9dcc34 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-function/source/extract_to_function_exprs_conditional_expr.bal @@ -0,0 +1,8 @@ +type RecordType record { + json|error fieldName; +}; + +function testFunction(RecordType rec) { + json|error var1 = rec.fieldName; + string var2 = var1 is json? var1.toString() : ""; +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config54.json b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config54.json new file mode 100644 index 000000000000..bc19b2029ce9 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/config/field_access_ctx_config54.json @@ -0,0 +1,190 @@ +{ + "position": { + "line": 6, + "character": 37 + }, + "source": "field_access_expression_context/source/field_access_ctx_source54.bal", + "items": [ + { + "label": "cloneWithType(typedesc t)", + "kind": "Function", + "detail": "t|error", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _ballerina/lang.value:0.0.0_ \n \nConstructs a value with a specified type by cloning another value.\n\nWhen parameter `v` is a structural value, the inherent type of the value to be constructed\ncomes from parameter `t`. When parameter `t` is a union, it must be possible to determine which\nmember of the union to use for the inherent type by following the same rules\nthat are used by list constructor expressions and mapping constructor expressions\nwith the contextually expected type. If not, then an error is returned.\nThe `cloneWithType` operation is recursively applied to each member of parameter `v` using\nthe type descriptor that the inherent type requires for that member.\n\nLike the Clone abstract operation, this does a deep copy, but differs in\nthe following respects:\n- the inherent type of any structural values constructed comes from the specified\ntype descriptor rather than the value being constructed\n- the read-only bit of values and fields comes from the specified type descriptor\n- the graph structure of `v` is not preserved; the result will always be a tree;\nan error will be returned if `v` has cycles\n- immutable structural values are copied rather being returned as is; all\nstructural values in the result will be mutable.\n- numeric values can be converted using the NumericConvert abstract operation\n- if a record type descriptor specifies default values, these will be used\nto supply any missing members\n \n**Params** \n- `typedesc` t: the type for the cloned to be constructed(Defaultable) \n \n**Return** `t|error` \n- a new value that belongs to parameter `t`, or an error if this cannot be done \n \n" + } + }, + "sortText": "CD", + "filterText": "cloneWithType", + "insertText": "cloneWithType(${1})", + "insertTextFormat": "Snippet", + "command": { + "title": "editor.action.triggerParameterHints", + "command": "editor.action.triggerParameterHints" + } + }, + { + "label": "cloneReadOnly()", + "kind": "Function", + "detail": "value:CloneableType & readonly", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _ballerina/lang.value:0.0.0_ \n \nReturns a clone of a value that is read-only, i.e., immutable.\n\nIt corresponds to the ImmutableClone(v) abstract operation,\ndefined in the Ballerina Language Specification.\n \n \n \n**Return** `value:CloneableType & readonly` \n- immutable clone of parameter `v` \n \n" + } + }, + "sortText": "CD", + "filterText": "cloneReadOnly", + "insertText": "cloneReadOnly()", + "insertTextFormat": "Snippet" + }, + { + "label": "toBalString()", + "kind": "Function", + "detail": "string", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _ballerina/lang.value:0.0.0_ \n \nConverts a value to a string that describes the value in Ballerina syntax.\n\nIf parameter `v` is anydata and does not have cycles, then the result will\nconform to the grammar for a Ballerina expression and when evaluated\nwill result in a value that is == to parameter `v`.\n\nThe details of the conversion are specified by the ToString abstract operation\ndefined in the Ballerina Language Specification, using the expression style.\n \n \n \n**Return** `string` \n- a string resulting from the conversion \n \n" + } + }, + "sortText": "AD", + "filterText": "toBalString", + "insertText": "toBalString()", + "insertTextFormat": "Snippet" + }, + { + "label": "toJson()", + "kind": "Function", + "detail": "json", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _ballerina/lang.value:0.0.0_ \n \nConverts a value of type `anydata` to `json`.\n\nThis does a deep copy of parameter `v` converting values that do\nnot belong to json into values that do.\nA value of type `xml` is converted into a string as if\nby the `toString` function.\nA value of type `table` is converted into a list of\nmappings one for each row.\nThe inherent type of arrays in the return value will be\n`json[]` and of mappings will be `map`.\nA new copy is made of all structural values, including\nimmutable values.\nThis panics if parameter `v` has cycles.\n \n \n \n**Return** `json` \n- representation of `v` as value of type json \n \n" + } + }, + "sortText": "CD", + "filterText": "toJson", + "insertText": "toJson()", + "insertTextFormat": "Snippet" + }, + { + "label": "isReadOnly()", + "kind": "Function", + "detail": "boolean", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _ballerina/lang.value:0.0.0_ \n \nTests whether a value is read-only, i.e., immutable.\n\nReturns true if read-only, false otherwise.\n \n \n \n**Return** `boolean` \n- true if read-only, false otherwise \n \n" + } + }, + "sortText": "CD", + "filterText": "isReadOnly", + "insertText": "isReadOnly()", + "insertTextFormat": "Snippet" + }, + { + "label": "fromJsonWithType(typedesc t)", + "kind": "Function", + "detail": "t|error", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _ballerina/lang.value:0.0.0_ \n \nConverts a value of type json to a user-specified type.\n\nThis works the same as function `cloneWithType`,\nexcept that it also does the inverse of the conversions done by `toJson`.\n \n**Params** \n- `typedesc` t: type to convert to(Defaultable) \n \n**Return** `t|error` \n- value belonging to type parameter `t` or error if this cannot be done \n \n" + } + }, + "sortText": "CD", + "filterText": "fromJsonWithType", + "insertText": "fromJsonWithType(${1})", + "insertTextFormat": "Snippet", + "command": { + "title": "editor.action.triggerParameterHints", + "command": "editor.action.triggerParameterHints" + } + }, + { + "label": "mergeJson(json j2)", + "kind": "Function", + "detail": "json|error", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _ballerina/lang.value:0.0.0_ \n \nMerges two `json` values.\n\nThe merge of parameter `j1` with parameter `j2` is defined as follows:\n- if parameter `j1` is `()`, then the result is parameter `j2`\n- if parameter `j2` is `()`, then the result is parameter `j1`\n- if parameter `j1` is a mapping and parameter `j2` is a mapping, then for each entry [k, j] in parameter `j2`, set `j1[k]` to the merge of `j1[k]` with `j`\n- if `j1[k]` is undefined, then set `j1[k]` to `j`\n- if any merge fails, then the merge of parameter `j1` with parameter `j2` fails\n- otherwise, the result is parameter `j1`.\n- otherwise, the merge fails\nIf the merge fails, then parameter `j1` is unchanged.\n \n**Params** \n- `json` j2: json value \n \n**Return** `json|error` \n- the merge of parameter `j1` with parameter `j2` or an error if the merge fails \n \n" + } + }, + "sortText": "CD", + "filterText": "mergeJson", + "insertText": "mergeJson(${1})", + "insertTextFormat": "Snippet", + "command": { + "title": "editor.action.triggerParameterHints", + "command": "editor.action.triggerParameterHints" + } + }, + { + "label": "clone()", + "kind": "Function", + "detail": "value:CloneableType", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _ballerina/lang.value:0.0.0_ \n \nReturns a clone of a value.\n\nA clone is a deep copy that does not copy immutable subtrees.\nA clone can therefore safely be used concurrently with the original.\nIt corresponds to the Clone(v) abstract operation,\ndefined in the Ballerina Language Specification.\n \n \n \n**Return** `value:CloneableType` \n- clone of parameter `v` \n \n" + } + }, + "sortText": "CD", + "filterText": "clone", + "insertText": "clone()", + "insertTextFormat": "Snippet" + }, + { + "label": "ensureType(typedesc t)", + "kind": "Function", + "detail": "t|error", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _ballerina/lang.value:0.0.0_ \n \nSafely casts a value to a type.\n\nThis casts a value to a type in the same way as a type cast expression,\nbut returns an error if the cast cannot be done, rather than panicking.\n \n**Params** \n- `typedesc` t: a typedesc for the type to which to cast it(Defaultable) \n \n**Return** `t|error` \n- `v` cast to the type described by parameter `t`, or an error, if the cast cannot be done \n \n" + } + }, + "sortText": "CD", + "filterText": "ensureType", + "insertText": "ensureType(${1})", + "insertTextFormat": "Snippet", + "command": { + "title": "editor.action.triggerParameterHints", + "command": "editor.action.triggerParameterHints" + } + }, + { + "label": "toString()", + "kind": "Function", + "detail": "string", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _ballerina/lang.value:0.0.0_ \n \nPerforms a direct conversion of a value to a string.\n\nThe conversion is direct in the sense that when applied to a value that is already\na string it leaves the value unchanged.\n\nThe details of the conversion are specified by the ToString abstract operation\ndefined in the Ballerina Language Specification, using the direct style.\n \n \n \n**Return** `string` \n- a string resulting from the conversion \n \n" + } + }, + "sortText": "AD", + "filterText": "toString", + "insertText": "toString()", + "insertTextFormat": "Snippet" + }, + { + "label": "toJsonString()", + "kind": "Function", + "detail": "string", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _ballerina/lang.value:0.0.0_ \n \nReturns the string that represents a anydata value in JSON format.\n\nparameter `v` is first converted to `json` as if by the function `toJson`.\n \n \n \n**Return** `string` \n- string representation of parameter `v` converted to `json` \n \n" + } + }, + "sortText": "AD", + "filterText": "toJsonString", + "insertText": "toJsonString()", + "insertTextFormat": "Snippet" + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/source/field_access_ctx_source54.bal b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/source/field_access_ctx_source54.bal new file mode 100644 index 000000000000..eda6408e68a1 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/field_access_expression_context/source/field_access_ctx_source54.bal @@ -0,0 +1,8 @@ +type RecordType record { + json|error fieldName; +}; + +function testFunction(RecordType rec) { + json|error var1 = rec.fieldName; + string var2 = var1 is json? var1. : ""; +} From ad6e15e72c2c96941727be1a23876af7b4da0fd1 Mon Sep 17 00:00:00 2001 From: mindula Date: Tue, 8 Nov 2022 10:33:15 +0530 Subject: [PATCH 283/450] Address review suggestions --- .../codeaction/providers/ExtractToFunctionCodeAction.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToFunctionCodeAction.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToFunctionCodeAction.java index 6f8949ec8be9..8483694ec3a4 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToFunctionCodeAction.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToFunctionCodeAction.java @@ -502,9 +502,10 @@ private Optional getArgLists(CodeActionContext context, List getTypeSymbol(CodeActionContext context, TypeSymbol typeSymbol, NonTerminalNode node) { + // If the type symbol kind is union, return the narrowed type using typeOf() for the particular node. if (typeSymbol.typeKind() == TypeDescKind.UNION) { - return Optional.of(context.currentSemanticModel().flatMap(semanticModel -> - semanticModel.typeOf(node.children().get(0)).flatMap(SymbolUtil::getTypeDescriptor)).get()); + return context.currentSemanticModel().flatMap(semanticModel -> + semanticModel.typeOf(node.children().get(0)).flatMap(SymbolUtil::getTypeDescriptor)); } return Optional.of(typeSymbol); } From 1b926ea18b8725e427ee0f03c8e99d2b0cd9d599 Mon Sep 17 00:00:00 2001 From: mindula Date: Tue, 29 Nov 2022 14:43:44 +0530 Subject: [PATCH 284/450] Fix extract to function code action --- .../ExtractToFunctionCodeAction.java | 88 ++++++++++++------- 1 file changed, 58 insertions(+), 30 deletions(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToFunctionCodeAction.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToFunctionCodeAction.java index 8483694ec3a4..747c6df29540 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToFunctionCodeAction.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToFunctionCodeAction.java @@ -16,7 +16,6 @@ package org.ballerinalang.langserver.codeaction.providers; import io.ballerina.compiler.api.SemanticModel; -import io.ballerina.compiler.api.symbols.ParameterSymbol; import io.ballerina.compiler.api.symbols.Symbol; import io.ballerina.compiler.api.symbols.SymbolKind; import io.ballerina.compiler.api.symbols.TypeDescKind; @@ -27,7 +26,9 @@ import io.ballerina.compiler.syntax.tree.CompoundAssignmentStatementNode; import io.ballerina.compiler.syntax.tree.FieldAccessExpressionNode; import io.ballerina.compiler.syntax.tree.Node; +import io.ballerina.compiler.syntax.tree.NodeVisitor; import io.ballerina.compiler.syntax.tree.NonTerminalNode; +import io.ballerina.compiler.syntax.tree.SimpleNameReferenceNode; import io.ballerina.compiler.syntax.tree.SyntaxKind; import io.ballerina.tools.diagnostics.Location; import io.ballerina.tools.text.LineRange; @@ -59,7 +60,9 @@ import java.util.Collections; import java.util.Comparator; import java.util.HashSet; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -460,37 +463,40 @@ private Optional> getVarAndParamSymbolsWithinRangeForExprs(LineRang } private Optional getArgLists(CodeActionContext context, List symbolsList, - NonTerminalNode node) { + NonTerminalNode matchedCodeActionNode) { List argsForExtractFunction = new ArrayList<>(); List argsForReplaceFunctionCall = new ArrayList<>(); + List symbolNamesList = new ArrayList<>(); for (Symbol symbol : symbolsList) { if (symbol.getName().isEmpty()) { return Optional.empty(); } - argsForReplaceFunctionCall.add(symbol.getName().get()); - - Optional possibleType = Optional.empty(); - if (symbol.kind() == SymbolKind.VARIABLE) { - Optional typeSymbol = getTypeSymbol(context, ((VariableSymbol) symbol).typeDescriptor(), - node); - if (typeSymbol.isEmpty()) { - return Optional.empty(); - } - possibleType = CodeActionUtil.getPossibleType(typeSymbol.get(), new ArrayList<>(), context); + symbolNamesList.add(symbol.getName().get()); + } - } else if (symbol.kind() == SymbolKind.PARAMETER) { - Optional typeSymbol = getTypeSymbol(context, ((ParameterSymbol) symbol).typeDescriptor(), - node); - if (typeSymbol.isEmpty()) { - return Optional.empty(); - } - possibleType = CodeActionUtil.getPossibleType(typeSymbol.get(), new ArrayList<>(), context); + ExtractToFunctionTypeFinder typeFinder = new ExtractToFunctionTypeFinder(symbolNamesList); + typeFinder.findType(matchedCodeActionNode); + Map symbolTypes = typeFinder.getSymbolTypes(); + List sortedSymbolNames = new ArrayList<>(); + + for (Map.Entry entry : symbolTypes.entrySet()) { + sortedSymbolNames.add(entry.getKey()); + sortedSymbolNames.sort(Comparator.comparing(symbolNamesList::indexOf)); + } + + for (String symbolName : sortedSymbolNames) { + Optional typeSymbol = context.currentSemanticModel().get().typeOf(symbolTypes.get(symbolName)); + if (typeSymbol.isEmpty()) { + return Optional.empty(); } + Optional possibleType = + CodeActionUtil.getPossibleType(typeSymbol.get(), new ArrayList<>(), context); if (possibleType.isEmpty()) { return Optional.empty(); } - argsForExtractFunction.add(String.format("%s %s", possibleType.get(), symbol.getName().get())); + argsForExtractFunction.add(String.format("%s %s", possibleType.get(), symbolName)); + argsForReplaceFunctionCall.add(symbolName); } ArgListsHolder argListsHolder = new ArgListsHolder(); @@ -500,16 +506,6 @@ private Optional getArgLists(CodeActionContext context, List getTypeSymbol(CodeActionContext context, TypeSymbol typeSymbol, - NonTerminalNode node) { - // If the type symbol kind is union, return the narrowed type using typeOf() for the particular node. - if (typeSymbol.typeKind() == TypeDescKind.UNION) { - return context.currentSemanticModel().flatMap(semanticModel -> - semanticModel.typeOf(node.children().get(0)).flatMap(SymbolUtil::getTypeDescriptor)); - } - return Optional.of(typeSymbol); - } - private Node findEnclosingModulePartNode(NonTerminalNode node) { Node reference = node; @@ -630,4 +626,36 @@ private static class ArgListsHolder { private List extractFunctionArgs; private List replaceFunctionCallArgs; } + + static class ExtractToFunctionTypeFinder extends NodeVisitor { + List symbolNamesList; + Map nodeList = new LinkedHashMap<>(); + + public ExtractToFunctionTypeFinder(List symbolNamesList) { + this.symbolNamesList = symbolNamesList; + } + + public Map getSymbolTypes() { + return nodeList; + } + + public void findType(NonTerminalNode matchedCodeActionNode) { + if (matchedCodeActionNode.kind() == SyntaxKind.LIST) { + for (Node node : matchedCodeActionNode.children()) { + node.accept(this); + } + } else { + matchedCodeActionNode.accept(this); + } + } + + @Override + public void visit(SimpleNameReferenceNode simpleNameReferenceNode) { + for (String symbolName: symbolNamesList) { + if (!nodeList.containsKey(symbolName) && symbolName.equals(simpleNameReferenceNode.name().text())) { + nodeList.put(symbolName, simpleNameReferenceNode); + } + } + } + } } From 44178f5387a821fae8560889dbf8e023c3b8e2bf Mon Sep 17 00:00:00 2001 From: mindula Date: Thu, 15 Dec 2022 10:26:56 +0530 Subject: [PATCH 285/450] Address review suggestions --- .../providers/ExtractToFunctionCodeAction.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToFunctionCodeAction.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToFunctionCodeAction.java index 747c6df29540..fa991a3e71e6 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToFunctionCodeAction.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToFunctionCodeAction.java @@ -298,7 +298,7 @@ private Range getRangeAfterHighlightedRange(CodeActionContext context, Node encl * This method finds the visible variable and parameter symbols which are referred inside the selected range for * getCodeActionsForStatements scenario. */ - private Optional> getVarAndParamSymbolsWithinRangeForStmts(CodeActionContext context, + private Optional> getVarAndParamSymbolsWithinRangeForStmts(CodeActionContext context, Node enclosingNode) { List argsSymbolsForExtractFunction = new ArrayList<>(); List visibleSymbols = getVisibleSymbols(context, context.range().getStart()); @@ -418,9 +418,9 @@ private String getReplaceFunctionCall(List varSymbolNames, String functi return isExpr ? funcCall : funcCall + CommonKeys.SEMI_COLON_SYMBOL_KEY; } - private String getFunction(CodeActionContext context, NonTerminalNode matchedNode, boolean newLineEnd, + private String getFunction(CodeActionContext context, NonTerminalNode matchedNode, boolean newLineEnd, TypeSymbol typeSymbol, String functionName, List args) { - String returnsClause = + String returnsClause = String.format("returns %s", FunctionGenerator.getReturnTypeAsString(context, typeSymbol.signature())); String returnStatement; @@ -644,18 +644,16 @@ public void findType(NonTerminalNode matchedCodeActionNode) { for (Node node : matchedCodeActionNode.children()) { node.accept(this); } - } else { - matchedCodeActionNode.accept(this); + return; } + matchedCodeActionNode.accept(this); } @Override public void visit(SimpleNameReferenceNode simpleNameReferenceNode) { - for (String symbolName: symbolNamesList) { - if (!nodeList.containsKey(symbolName) && symbolName.equals(simpleNameReferenceNode.name().text())) { - nodeList.put(symbolName, simpleNameReferenceNode); - } - } + symbolNamesList.stream().filter(symbolName -> !nodeList.containsKey(symbolName) + && symbolName.equals(simpleNameReferenceNode.name().text())).findFirst().ifPresent(symbolName -> + nodeList.put(symbolName, simpleNameReferenceNode)); } } } From 88a416ab42896f938bbbe1978c05c562c4e43dde Mon Sep 17 00:00:00 2001 From: mindula Date: Fri, 16 Dec 2022 20:52:21 +0530 Subject: [PATCH 286/450] Refactor the code --- .../codeaction/providers/ExtractToFunctionCodeAction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToFunctionCodeAction.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToFunctionCodeAction.java index fa991a3e71e6..263b4c6ae8e7 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToFunctionCodeAction.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToFunctionCodeAction.java @@ -482,8 +482,8 @@ private Optional getArgLists(CodeActionContext context, List entry : symbolTypes.entrySet()) { sortedSymbolNames.add(entry.getKey()); - sortedSymbolNames.sort(Comparator.comparing(symbolNamesList::indexOf)); } + sortedSymbolNames.sort(Comparator.comparing(symbolNamesList::indexOf)); for (String symbolName : sortedSymbolNames) { Optional typeSymbol = context.currentSemanticModel().get().typeOf(symbolTypes.get(symbolName)); From 546537badca2f7f805115db7b4d5bb2ae34e8395 Mon Sep 17 00:00:00 2001 From: Nipuna Ranasinghe Date: Sat, 17 Dec 2022 00:56:48 +0530 Subject: [PATCH 287/450] Update evaluation request timeout --- .../debugger/test/utils/DebugTestRunner.java | 4 ++-- .../test/utils/client/DAPRequestManager.java | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/jballerina-debugger-integration-test/src/main/java/org/ballerinalang/debugger/test/utils/DebugTestRunner.java b/tests/jballerina-debugger-integration-test/src/main/java/org/ballerinalang/debugger/test/utils/DebugTestRunner.java index 15dd1278c1da..5c77084cf732 100644 --- a/tests/jballerina-debugger-integration-test/src/main/java/org/ballerinalang/debugger/test/utils/DebugTestRunner.java +++ b/tests/jballerina-debugger-integration-test/src/main/java/org/ballerinalang/debugger/test/utils/DebugTestRunner.java @@ -786,8 +786,8 @@ private Variable evaluateExpression(StoppedEventArguments args, String expr) thr result.setVariablesReference(evaluateResp.getVariablesReference()); return result; } catch (Exception e) { - LOGGER.warn("Error occurred when fetching debug hit variables", e); - throw new BallerinaTestException("Error occurred when fetching debug hit variables", e); + LOGGER.warn("Error occurred when evaluating expression", e); + throw new BallerinaTestException("Error occurred when evaluating expression", e); } } diff --git a/tests/jballerina-debugger-integration-test/src/main/java/org/ballerinalang/debugger/test/utils/client/DAPRequestManager.java b/tests/jballerina-debugger-integration-test/src/main/java/org/ballerinalang/debugger/test/utils/client/DAPRequestManager.java index 2e1e085c9b12..9871aa8ac5f7 100644 --- a/tests/jballerina-debugger-integration-test/src/main/java/org/ballerinalang/debugger/test/utils/client/DAPRequestManager.java +++ b/tests/jballerina-debugger-integration-test/src/main/java/org/ballerinalang/debugger/test/utils/client/DAPRequestManager.java @@ -195,7 +195,7 @@ public VariablesResponse variables(VariablesArguments args, long timeoutMillis) VariablesResponse variablesResponse = resp.get(timeoutMillis, TimeUnit.MILLISECONDS); Instant end = Instant.now(); // Todo - remove after monitoring if the debugger integration tests are failing due to averagely high - // variable response times or, due to sudden spikes (potential concurrency issues?) + // response times or, due to sudden spikes (potential concurrency issues?) LOGGER.info(String.format("debug variables request took %s ms", Duration.between(start, end).toMillis())); return variablesResponse; } else { @@ -209,8 +209,14 @@ public EvaluateResponse evaluate(EvaluateArguments args) throws Exception { public EvaluateResponse evaluate(EvaluateArguments args, long timeoutMillis) throws Exception { if (checkStatus()) { + Instant start = Instant.now(); CompletableFuture resp = server.evaluate(args); - return resp.get(timeoutMillis, TimeUnit.MILLISECONDS); + EvaluateResponse evaluateResponse = resp.get(timeoutMillis, TimeUnit.MILLISECONDS); + Instant end = Instant.now(); + // Todo - remove after monitoring if the debugger integration tests are failing due to averagely high + // response times or, due to sudden spikes (potential concurrency issues?) + LOGGER.info(String.format("evaluation request took %s ms", Duration.between(start, end).toMillis())); + return evaluateResponse; } else { throw new IllegalStateException("DAP request manager is not active"); } @@ -382,7 +388,7 @@ private enum DefaultTimeouts { STACK_TRACE(7000), SCOPES(2000), VARIABLES(30000), - EVALUATE(15000), + EVALUATE(20000), COMPLETIONS(10000), STEP_OVER(5000), STEP_IN(10000), From a8f4eeea3d2bf84d29ce4d5e675ea94c386b52dc Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Thu, 1 Dec 2022 10:18:49 +0530 Subject: [PATCH 288/450] Add examples for the error langlib --- .../lang.error/src/main/ballerina/error.bal | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/langlib/lang.error/src/main/ballerina/error.bal b/langlib/lang.error/src/main/ballerina/error.bal index e90f7503ca00..1981105b6c7f 100644 --- a/langlib/lang.error/src/main/ballerina/error.bal +++ b/langlib/lang.error/src/main/ballerina/error.bal @@ -33,6 +33,11 @@ type DetailType Detail; # Returns the error's message. # +# ```ballerina +# error memberAccessError = error("invalid list member access"); +# string message = memberAccessError.message(); +# ``` +# # + e - the error value # + return - error message public isolated function message(error e) returns string = @java:Method { @@ -42,6 +47,13 @@ public isolated function message(error e) returns string = @java:Method { # Returns the error's cause. # +# ```ballerina +# int index = 35; +# error indexOutOfRangeError = error("index out of range", index = index); +# error memberAccessError = error("invalid list member access", indexOutOfRangeError); +# error? cause = memberAccessError.cause(); +# ``` +# # + e - the error value # + return - error cause public isolated function cause(error e) returns error? = @java:Method { @@ -51,6 +63,26 @@ public isolated function cause(error e) returns error? = @java:Method { # Returns the error's detail record. # +# ```ballerina +# int index = 20; +# +# error err = error("index out of range", index = index); +# // Using `error:detail()` with the `error` type returns an immutable `error:Detail` value. +# error:Detail & readonly errDetail = err.detail(); +# +# IndexOutOfRange indexOutOfRangeErr = error("index out of range", index = index, length = 10); +# // Using `error:detail()` with a user-defined error type returns a value that belongs to the intersection +# // of `readonly` and the detail type used in the error type-descriptor (i.e., `IndexOutOfRangeDetail`). +# IndexOutOfRangeDetail & readonly indexOutOfRangeErrDetail = indexOutOfRangeErr.detail(); +# +# type IndexOutOfRange error; +# +# type IndexOutOfRangeDetail record {| +# int index; +# int length; +# |}; +# ``` +# # The returned value will be immutable. # + e - the error value # + return - error detail value @@ -71,6 +103,11 @@ public type StackFrame readonly & object { # Returns an object representing the stack trace of the error. # +# ```ballerina +# error memberAccessError = error("invalid list member access"); +# error:StackFrame[] stackTrace = memberAccessError.stackTrace(); +# ``` +# # + e - the error value # + return - a new object representing the stack trace of the error value # The first member of the array represents the top of the call stack. @@ -91,6 +128,12 @@ public isolated function stackTrace(error e) returns StackFrame[] { # The details of the conversion are specified by the ToString abstract operation # defined in the Ballerina Language Specification, using the direct style. # +# ```ballerina +# int index = 35; +# error indexOutOfRangeError = error("index out of range", index = index); +# string stringRepr = indexOutOfRangeError.toString(); +# ``` +# # + e - the error to be converted to a string # + return - a string resulting from the conversion public isolated function toString(error e) returns string = @java:Method { @@ -104,6 +147,12 @@ public isolated function toString(error e) returns string = @java:Method { # The details of the conversion are specified by the ToString abstract operation # defined in the Ballerina Language Specification, using the expression style. # +# ```ballerina +# int index = 35; +# error indexOutOfRangeError = error("index out of range", index = index); +# string balStringRepr = indexOutOfRangeError.toBalString(); +# ``` +# # + e - the error to be converted to a string # + return - a string resulting from the conversion public isolated function toBalString(error e) returns string = @java:Method { From 03443aaf4dc56616e1e66917174821ec2cad7800 Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Thu, 1 Dec 2022 12:28:26 +0530 Subject: [PATCH 289/450] Use IO errors instead of member access errors --- .../lang.error/src/main/ballerina/error.bal | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/langlib/lang.error/src/main/ballerina/error.bal b/langlib/lang.error/src/main/ballerina/error.bal index 1981105b6c7f..1926b6e45e30 100644 --- a/langlib/lang.error/src/main/ballerina/error.bal +++ b/langlib/lang.error/src/main/ballerina/error.bal @@ -34,8 +34,8 @@ type DetailType Detail; # Returns the error's message. # # ```ballerina -# error memberAccessError = error("invalid list member access"); -# string message = memberAccessError.message(); +# error ioError = error("IO error"); +# string message = ioError.message(); # ``` # # + e - the error value @@ -48,10 +48,10 @@ public isolated function message(error e) returns string = @java:Method { # Returns the error's cause. # # ```ballerina -# int index = 35; -# error indexOutOfRangeError = error("index out of range", index = index); -# error memberAccessError = error("invalid list member access", indexOutOfRangeError); -# error? cause = memberAccessError.cause(); +# string file = "test.bal"; +# error fileNotFoundError = error("file not found", file = file); +# error ioError = error("IO error", fileNotFoundError); +# error? cause = ioError.cause(); # ``` # # + e - the error value @@ -64,22 +64,22 @@ public isolated function cause(error e) returns error? = @java:Method { # Returns the error's detail record. # # ```ballerina -# int index = 20; +# string file = "test.bal"; # -# error err = error("index out of range", index = index); +# error err = error("file not found", file = file); # // Using `error:detail()` with the `error` type returns an immutable `error:Detail` value. # error:Detail & readonly errDetail = err.detail(); # -# IndexOutOfRange indexOutOfRangeErr = error("index out of range", index = index, length = 10); +# FileNotFoundError fileNotFoundErr = error("file not found", file = file, code = 100); # // Using `error:detail()` with a user-defined error type returns a value that belongs to the intersection -# // of `readonly` and the detail type used in the error type-descriptor (i.e., `IndexOutOfRangeDetail`). -# IndexOutOfRangeDetail & readonly indexOutOfRangeErrDetail = indexOutOfRangeErr.detail(); +# // of `readonly` and the detail type used in the error type-descriptor (i.e., `FileNotFoundDetail`). +# FileNotFoundDetail & readonly fileNotFoundErrDetail = fileNotFoundErr.detail(); # -# type IndexOutOfRange error; +# type FileNotFoundError error; # -# type IndexOutOfRangeDetail record {| -# int index; -# int length; +# type FileNotFoundDetail record {| +# string file; +# int code; # |}; # ``` # @@ -104,8 +104,8 @@ public type StackFrame readonly & object { # Returns an object representing the stack trace of the error. # # ```ballerina -# error memberAccessError = error("invalid list member access"); -# error:StackFrame[] stackTrace = memberAccessError.stackTrace(); +# error ioError = error("IO error"); +# error:StackFrame[] stackTrace = ioError.stackTrace(); # ``` # # + e - the error value @@ -129,9 +129,9 @@ public isolated function stackTrace(error e) returns StackFrame[] { # defined in the Ballerina Language Specification, using the direct style. # # ```ballerina -# int index = 35; -# error indexOutOfRangeError = error("index out of range", index = index); -# string stringRepr = indexOutOfRangeError.toString(); +# string file = "test.bal"; +# error fileNotFoundError = error("file not found", file = file); +# string stringRepr = fileNotFoundError.toString(); # ``` # # + e - the error to be converted to a string @@ -148,9 +148,9 @@ public isolated function toString(error e) returns string = @java:Method { # defined in the Ballerina Language Specification, using the expression style. # # ```ballerina -# int index = 35; -# error indexOutOfRangeError = error("index out of range", index = index); -# string balStringRepr = indexOutOfRangeError.toBalString(); +# string file = "test.bal"; +# error fileNotFoundError = error("file not found", file = file); +# string balStringRepr = fileNotFoundError.toBalString(); # ``` # # + e - the error to be converted to a string From 96754f925fe25eb7efc31e3a496a0b84c0d6b02a Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Wed, 14 Dec 2022 09:57:10 +0530 Subject: [PATCH 290/450] Update error langlib examples --- .../lang.error/src/main/ballerina/error.bal | 39 +++++-------------- 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/langlib/lang.error/src/main/ballerina/error.bal b/langlib/lang.error/src/main/ballerina/error.bal index 1926b6e45e30..fc9b87cdac92 100644 --- a/langlib/lang.error/src/main/ballerina/error.bal +++ b/langlib/lang.error/src/main/ballerina/error.bal @@ -34,8 +34,7 @@ type DetailType Detail; # Returns the error's message. # # ```ballerina -# error ioError = error("IO error"); -# string message = ioError.message(); +# error("IO error").message() ⇒ IO error # ``` # # + e - the error value @@ -48,10 +47,11 @@ public isolated function message(error e) returns string = @java:Method { # Returns the error's cause. # # ```ballerina -# string file = "test.bal"; -# error fileNotFoundError = error("file not found", file = file); +# error fileNotFoundError = error("file not found", file = "test.bal"); +# fileNotFoundError.cause() is () ⇒ true +# # error ioError = error("IO error", fileNotFoundError); -# error? cause = ioError.cause(); +# ioError.cause() ⇒ error("file not found",file="test.bal") # ``` # # + e - the error value @@ -64,23 +64,7 @@ public isolated function cause(error e) returns error? = @java:Method { # Returns the error's detail record. # # ```ballerina -# string file = "test.bal"; -# -# error err = error("file not found", file = file); -# // Using `error:detail()` with the `error` type returns an immutable `error:Detail` value. -# error:Detail & readonly errDetail = err.detail(); -# -# FileNotFoundError fileNotFoundErr = error("file not found", file = file, code = 100); -# // Using `error:detail()` with a user-defined error type returns a value that belongs to the intersection -# // of `readonly` and the detail type used in the error type-descriptor (i.e., `FileNotFoundDetail`). -# FileNotFoundDetail & readonly fileNotFoundErrDetail = fileNotFoundErr.detail(); -# -# type FileNotFoundError error; -# -# type FileNotFoundDetail record {| -# string file; -# int code; -# |}; +# error("file not found", file = "test.bal").detail() ⇒ {"file":"test.bal"} # ``` # # The returned value will be immutable. @@ -104,8 +88,7 @@ public type StackFrame readonly & object { # Returns an object representing the stack trace of the error. # # ```ballerina -# error ioError = error("IO error"); -# error:StackFrame[] stackTrace = ioError.stackTrace(); +# error("IO error").stackTrace() ⇒ [callableName: main fileName: test.bal lineNumber: 5] # ``` # # + e - the error value @@ -129,9 +112,7 @@ public isolated function stackTrace(error e) returns StackFrame[] { # defined in the Ballerina Language Specification, using the direct style. # # ```ballerina -# string file = "test.bal"; -# error fileNotFoundError = error("file not found", file = file); -# string stringRepr = fileNotFoundError.toString(); +# error("invalid salary", value = 0d).toString() ⇒ error("invalid salary",value=0) # ``` # # + e - the error to be converted to a string @@ -148,9 +129,7 @@ public isolated function toString(error e) returns string = @java:Method { # defined in the Ballerina Language Specification, using the expression style. # # ```ballerina -# string file = "test.bal"; -# error fileNotFoundError = error("file not found", file = file); -# string balStringRepr = fileNotFoundError.toBalString(); +# error("invalid salary", value = 0d).toBalString() ⇒ error("invalid salary",value=0d) # ``` # # + e - the error to be converted to a string From c16254040e68aa03c2c084c1bb7a5e247ed8e88e Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Wed, 30 Nov 2022 17:07:32 +0530 Subject: [PATCH 291/450] Add examples for the array langlib --- .../lang.array/src/main/ballerina/array.bal | 289 +++++++++++++++++- 1 file changed, 284 insertions(+), 5 deletions(-) diff --git a/langlib/lang.array/src/main/ballerina/array.bal b/langlib/lang.array/src/main/ballerina/array.bal index 083264f21fbc..e8953d7d9926 100644 --- a/langlib/lang.array/src/main/ballerina/array.bal +++ b/langlib/lang.array/src/main/ballerina/array.bal @@ -37,6 +37,11 @@ type AnydataType anydata; # Returns the number of members of an array. # +# ```ballerina +# string[] greetings = ["Hello", "Bonjour", "Hola", "Ciao"]; +# int length = greetings.length(); +# ``` +# # + arr - the array # + return - number of members in parameter `arr` public isolated function length((any|error)[] arr) returns int = @java:Method { @@ -46,8 +51,16 @@ public isolated function length((any|error)[] arr) returns int = @java:Method { # Returns an iterator over an array. # +# ```ballerina +# int[] evenNumbers = [2, 4, 6, 8]; +# object { +# public isolated function next() returns record {|int value;|}?; +# } iterator = evenNumbers.iterator(); +# record {|int value;|}? next = iterator.next(); +# ``` +# # + arr - the array -# + return - a new iterator object that will iterate over the members of parameter `arr`. +# + return - a new iterator object that will iterate over the members of parameter `arr` public isolated function iterator(Type[] arr) returns object { public isolated function next() returns record {| Type value; @@ -59,6 +72,11 @@ public isolated function iterator(Type[] arr) returns object { # Returns a new array consisting of index and member pairs. # +# ```ballerina +# string[] greetings = ["Hello", "Bonjour", "Hola", "Ciao"]; +# [int, string][] enumeration = greetings.enumerate(); +# ``` +# # + arr - the array # + return - array of index, member pairs public isolated function enumerate(Type[] arr) returns [int, Type][] = @java:Method { @@ -70,6 +88,33 @@ public isolated function enumerate(Type[] arr) returns [int, Type][] = @java:Met # Applies a function to each member of an array and returns an array of the results. # +# ```ballerina +# string[] greetings = ["Hello", "Bonjour", "Hola", "Ciao"]; +# int[] lengths = greetings.'map((greeting) => greeting.length()); +# +# Employee[] employees = [ +# {firstName: "Jo", lastName: "David", id: 2121}, +# {firstName: "Emma", id: 2122}, +# {firstName: "John", lastName: "Doe", id: 2123} +# ]; +# string[] fullNames = +# employees.'map(isolated function (Employee employee) returns string { +# string? lastName = employee.lastName; +# +# if lastName is () { +# return employee.firstName; +# } +# +# return string `${employee.firstName} ${lastName}`; +# }); +# +# type Employee record { +# string firstName; +# string lastName?; +# int id; +# }; +# ``` +# # + arr - the array # + func - a function to apply to each member # + return - new array containing result of applying parameter `func` to each member of parameter `arr` in order @@ -82,6 +127,26 @@ public isolated function 'map(Type[] arr, @isolatedParam function(Type val) retu # # The parameter `func` is applied to each member of parameter `arr` in order. # +# ```ballerina +# Employee[] employees = [ +# {name: "Jo", salary: 1200, id: 2121}, +# {name: "Emma", id: 2122, salary: ()}, +# {name: "John", salary: 1500, id: 2123} +# ]; +# +# employees.forEach(isolated function (Employee employee) { +# if employee.salary == () { +# employee.salary = 1000; +# } +# }); +# +# type Employee record {| +# string name; +# int id; +# decimal? salary; +# |}; +# ``` +# # + arr - the array # + func - a function to apply to each member public isolated function forEach(Type[] arr, @isolatedParam function(Type val) returns () func) returns () = @java:Method { @@ -91,6 +156,27 @@ public isolated function forEach(Type[] arr, @isolatedParam function(Type val) r # Selects the members from an array for which a function returns true. # +# ```ballerina +# string[] greetings = ["Hello", "Bonjour", "Hola", "Ciao"]; +# string[] filteredByLength = greetings.filter((greeting) => greeting.length() > 4); +# +# Employee[] employees = [ +# {name: "Jo", salary: 1200, id: 2121}, +# {name: "Emma", id: 2122, salary: 900}, +# {name: "John", salary: 1500, id: 2123} +# ]; +# Employee[] filteredBySalary = employees.filter(isolated function (Employee employee) returns boolean { +# decimal salary = employee.salary; +# return salary > 1000d && salary < 1500d; +# }); +# +# type Employee record {| +# string name; +# int id; +# decimal salary; +# |}; +# ``` +# # + arr - the array # + func - a predicate to apply to each member to test whether it should be selected # + return - new array only containing members of parameter `arr` for which parameter `func` evaluates to true @@ -104,11 +190,29 @@ public isolated function filter(Type[] arr, @isolatedParam function(Type val) re # The combining function takes the combined value so far and a member of the array, # and returns a new combined value. # -# For example -# ``` -# reduce([1, 2, 3], function (int total, int n) returns int { return total + n; }, 0) +# ```ballerina +# int[] integers = [1, 2, 3]; +# int sum = integers.reduce(isolated function (int total, int next) returns int => total + next, 0); +# +# Employee[] employees = [ +# {name: "Jo", salary: 1200, department: "IT"}, +# {name: "Emma", department: "finance", salary: 900}, +# {name: "John", salary: 1500, department: "IT"} +# ]; +# decimal currentTotalSalary = 10500; +# decimal totalSalaryWithITEmployees = employees.reduce(isolated function (decimal total, Employee employee) returns decimal { +# if employee.department == "IT" { +# return total + employee.salary; +# } +# return total; +# }, currentTotalSalary); +# +# type Employee record {| +# string name; +# string department; +# decimal salary; +# |}; # ``` -# is the same as `sum(1, 2, 3)`. # # + arr - the array # + func - combining function @@ -124,6 +228,27 @@ public isolated function reduce(Type[] arr, @isolatedParam function(Type1 accum, # The parameter `func` is called for each member of parameter `arr` in order unless and until a call returns true. # When the array is empty, returns false. # +# ```ballerina +# int[] numbers = [1, 2, 3, 5]; +# boolean hasEvenNumber = numbers.some((number) => number % 2 == 0); +# +# Employee[] employees = [ +# {name: "Jo", salary: 1200, department: "IT"}, +# {name: "Emma", department: "finance", salary: 900}, +# {name: "John", salary: 1500, department: "IT"} +# ]; +# boolean hasEmployeeWithSalaryInRange = employees.some(isolated function (Employee employee) returns boolean { +# decimal salary = employee.salary; +# return salary > 1200d && salary < 1400d; +# }); +# +# type Employee record {| +# string name; +# string department; +# decimal salary; +# |}; +# ``` +# # + arr - the array # + func - function to apply to each member # + return - true if applying parameter `func` returns true for some member of `arr`; otherwise, false @@ -138,6 +263,16 @@ public isolated function some(Type[] arr, @isolatedParam function(Type val) retu # Returns a subarray using a start index (inclusive) and an end index (exclusive). # +# ```ballerina +# int[] evenNumbers = [2, 4, 6, 8, 10, 12]; +# +# // Slice containing numbers starting from the fourth member to the end of the list. +# int[] slice = evenNumbers.slice(3); +# +# // Slice containing the first four members in the list. +# int[] sliceWithEndIndex = evenNumbers.slice(0, 4); +# ``` +# # + arr - the array # + startIndex - index of first member to include in the slice # + endIndex - index of first member not to include in the slice @@ -152,6 +287,27 @@ public isolated function slice(Type[] arr, int startIndex, int endIndex = arr.le # The parameter `func` is called for each member of `arr` in order unless and until a call returns false. # When the array is empty, returns true. # +# ```ballerina +# int[] numbers = [1, 2, 3, 5]; +# boolean allEvenNumbers = numbers.every((number) => number % 2 == 0); +# +# Employee[] employees = [ +# {name: "Jo", salary: 1200, department: "IT"}, +# {name: "Emma", department: "finance", salary: 900}, +# {name: "John", salary: 1500, department: "IT"} +# ]; +# boolean allEmployeesWithSalaryInRange = employees.every(isolated function (Employee employee) returns boolean { +# decimal salary = employee.salary; +# return salary >= 900d && salary < 2000d; +# }); +# +# type Employee record {| +# string name; +# string department; +# decimal salary; +# |}; +# ``` +# # + arr - the array # + func - function to apply to each member # + return - true if applying parameter func returns true for every member of `arr`; otherwise, false @@ -169,6 +325,11 @@ public isolated function every(Type[] arr, @isolatedParam function(Type val) ret # This removes the member of parameter `arr` with index parameter `index` and returns it. # It panics if there is no such member. # +# ```ballerina +# string[] greetings = ["Hello", "Bonjour", "Hola", "Ciao"]; +# string removedGreeting = greetings.remove(1); +# ``` +# # + arr - the array # + index - index of member to be removed from parameter `arr` # + return - the member of parameter `arr` that was at parameter `index` @@ -180,6 +341,12 @@ public isolated function remove(Type[] arr, int index) returns Type = @java:Meth # Removes all members of an array. # # Panics if any member cannot be removed. +# +# ```ballerina +# string[] greetings = ["Hello", "Bonjour", "Hola", "Ciao"]; +# greetings.removeAll(); +# ``` +# # + arr - the array public isolated function removeAll((any|error)[] arr) returns () = @java:Method { 'class: "org.ballerinalang.langlib.array.RemoveAll", @@ -190,6 +357,11 @@ public isolated function removeAll((any|error)[] arr) returns () = @java:Method # # `setLength(arr, 0)` is equivalent to `removeAll(arr)`. # +# ```ballerina +# string[] greetings = ["Hello", "Bonjour", "Hola", "Ciao"]; +# greetings.setLength(2); +# ``` +# # + arr - the array of which to change the length # + length - new length public isolated function setLength((any|error)[] arr, int length) returns () = @java:Method { @@ -201,6 +373,17 @@ public isolated function setLength((any|error)[] arr, int length) returns () = @ # Returns `()` if not found. # Equality is tested using `==`. # +# ```ballerina +# string[] greetings = ["Hello", "Hola", "Bonjour", "Hola", "Ciao"]; +# +# string newGreeting = "guten tag"; +# // First index of "guten tag" if it exists in the list. +# int? indexOfNewGreeting = greetings.indexOf(newGreeting); +# +# // First index of "Hola" if it exists in the list, after the second member of the list. +# int? indexOfHola = greetings.indexOf("Hola", 2); +# ``` +# # + arr - the array # + val - member to search for # + startIndex - index to start the search from @@ -214,6 +397,18 @@ public isolated function indexOf(AnydataType[] arr, AnydataType val, int startIn # Returns `()` if not found. # Equality is tested using `==`. # +# ```ballerina +# string[] greetings = ["Hello", "Hola", "Bonjour", "Hola", "Ciao", "Hola"]; +# +# string newGreeting = "guten tag"; +# // Last index of "guten tag" if it exists in the list. +# int? indexOfNewGreeting = greetings.lastIndexOf(newGreeting); +# +# // Last index of "Hola" if it exists in the list, searching backward starting from the +# // second to last member of the list. +# int? indexOfHola = greetings.lastIndexOf("Hola", greetings.length() - 2); +# ``` +# # + arr - the array # + val - member to search for # + startIndex - index to start searching backwards from @@ -225,6 +420,11 @@ public isolated function lastIndexOf(AnydataType[] arr, AnydataType val, int sta # Reverses the order of the members of an array. # +# ```ballerina +# int[] evenNumbers = [2, 4, 6, 8, 10]; +# int[] evenNumbersReversed = evenNumbers.reverse(); +# ``` +# # + arr - the array to be reversed # + return - parameter `arr` with its members in reverse order public isolated function reverse(Type[] arr) returns Type[] = @java:Method { @@ -247,6 +447,28 @@ public type OrderedType ()|boolean|int|float|decimal|string|OrderedType[]; # must be specified. # Sorting works the same as with the parameter `sort` clause of query expressions. # +# ```ballerina +# string[] greetings = ["Hello", "Bonjour", "", "Hola", "Ciao"]; +# +# // Sort the list based on Unicode code point order. +# string[] sorted = greetings.sort(); +# +# // Sort the list based on Unicode code point descending order. +# string[] sortedDescending = greetings.sort(array:DESCENDING); +# +# // Sort the list in ascending order based on a specified ordering function: order by length of string. +# string[] sortedUsingProvidedFunction = greetings.sort(key = isolated function (string str) returns int { +# int length = str.length(); +# if length == 0 { +# return int:MAX_VALUE; +# } +# return length; +# }); +# +# // Sort the list in descending order based on a specified ordering function: order by length of string. +# string[] sortedByDescendingLength = greetings.sort(array:DESCENDING, (str) => str.length()); +# ``` +# # + arr - the array to be sorted; # + direction - direction in which to sort # + key - function that returns a key to use to sort the members @@ -265,6 +487,11 @@ public isolated function sort(Type[] arr, SortDirection direction = ASCENDING, # # The array must not be empty. # +# ```ballerina +# int[] evenNumbers = [2, 4, 6, 8, 10]; +# int removedLastMember = evenNumbers.pop(); +# ``` +# # + arr - the array # + return - removed member public isolated function pop(Type[] arr) returns Type = @java:Method { @@ -274,6 +501,17 @@ public isolated function pop(Type[] arr) returns Type = @java:Method { # Adds values to the end of an array. # +# ```ballerina +# int[] evenNumbers = [2]; +# +# // Push multiple members to the end of the list. +# evenNumbers.push(4, 6); +# +# int[] moreEvenNumbers = [8, 10, 12, 14]; +# // Push multiple members to the end of the list using an existing list in a rest argument. +# evenNumbers.push(...moreEvenNumbers); +# ``` +# # + arr - the array # + vals - values to add to the end of the array public isolated function push(Type[] arr, Type... vals) returns () = @java:Method { @@ -289,6 +527,11 @@ public isolated function push(Type[] arr, Type... vals) returns () = @java:Metho # # The array must not be empty. # +# ```ballerina +# int[] evenNumbers = [2, 4, 6, 8, 10]; +# int removedFirstMember = evenNumbers.shift(); +# ``` +# # + arr - the array # + return - the value that was the first member of the array public isolated function shift(Type[] arr) returns Type = @java:Method { @@ -301,6 +544,17 @@ public isolated function shift(Type[] arr) returns Type = @java:Method { # The values newly added to the array will be in the same order # as they are in parameter `vals`. # +# ```ballerina +# int[] evenNumbers = [14]; +# +# // Add multiple members to the start of the list. +# evenNumbers.unshift(10, 12); +# +# int[] moreEvenNumbers = [2, 4, 6, 8]; +# // Add multiple members to the start of the list using an existing list in a rest argument. +# evenNumbers.unshift(...moreEvenNumbers); +# ``` +# # + arr - the array # + vals - values to add to the start of the array public isolated function unshift(Type[] arr, Type... vals) returns () = @java:Method { @@ -316,6 +570,11 @@ public isolated function unshift(Type[] arr, Type... vals) returns () = @java:Me # The result will contain only characters `A..Z`, `a..z`, `0..9`, `+`, `/` and `=`. # There will be no whitespace in the returned string. # +# ```ballerina +# byte[] byteArray = [104, 101, 108, 108, 111, 32, 98, 97, 108, 108, 101, 114, 105, 110, 97, 32, 33, 33, 33]; +# string base64Rep = byteArray.toBase64(); +# ``` +# # + arr - the array # + return - Base64 string representation public isolated function toBase64(byte[] arr) returns string = @java:Method { @@ -328,6 +587,11 @@ public isolated function toBase64(byte[] arr) returns string = @java:Method { # parameter `str` must consist of the characters `A..Z`, `a..z`, `0..9`, `+`, `/`, `=` # and whitespace as allowed by a Ballerina Base64Literal. # +# ```ballerina +# string base64Rep = "aGVsbG8gYmFsbGVyaW5hICEhIQ=="; +# byte[] byteArray = check array:fromBase64(base64Rep); +# ``` +# # + str - Base64 string representation # + return - the byte array or error public isolated function fromBase64(string str) returns byte[]|error = @java:Method { @@ -341,6 +605,11 @@ public isolated function fromBase64(string str) returns byte[]|error = @java:Met # The result will contain only characters `0..9`, `a..f`. # There will be no whitespace in the returned string. # +# ```ballerina +# byte[] byteArray = [170, 171, 207, 204, 173, 175, 205, 52, 26, 75, 223, 171, 205, 137, 18, 223]; +# string base16Rep = byteArray.toBase16(); +# ``` +# # + arr - the array # + return - Base16 string representation public isolated function toBase16(byte[] arr) returns string = @java:Method { @@ -353,6 +622,11 @@ public isolated function toBase16(byte[] arr) returns string = @java:Method { # `str` must consist of the characters `0..9`, `A..F`, `a..f` # and whitespace as allowed by a Ballerina Base16Literal. # +# ```ballerina +# string base16Rep = "aaabcfccadafcd341a4bdfabcd8912df"; +# byte[] byteArray = check array:fromBase16(base16Rep); +# ``` +# # + str - Base16 string representation # + return - the byte array or error public isolated function fromBase16(string str) returns byte[]|error = @java:Method { @@ -362,6 +636,11 @@ public isolated function fromBase16(string str) returns byte[]|error = @java:Met # Returns a stream from the given array. # +# ```ballerina +# string[] greetings = ["Hello", "Bonjour", "Hola", "Ciao"]; +# stream greetingsStream = greetings.toStream(); +# ``` +# # + arr - The array from which the stream is created # + return - The stream representation of the array `arr` public isolated function toStream(Type[] arr) returns stream { From fbfb4e5816c6a0aa93c3eb33d315b4b63ae957f5 Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Thu, 8 Dec 2022 14:00:12 +0530 Subject: [PATCH 292/450] Rewrite array examples in a more expression-oriented style --- .../lang.array/src/main/ballerina/array.bal | 262 +++++------------- 1 file changed, 76 insertions(+), 186 deletions(-) diff --git a/langlib/lang.array/src/main/ballerina/array.bal b/langlib/lang.array/src/main/ballerina/array.bal index e8953d7d9926..b58246a7d08e 100644 --- a/langlib/lang.array/src/main/ballerina/array.bal +++ b/langlib/lang.array/src/main/ballerina/array.bal @@ -37,9 +37,8 @@ type AnydataType anydata; # Returns the number of members of an array. # -# ```ballerina -# string[] greetings = ["Hello", "Bonjour", "Hola", "Ciao"]; -# int length = greetings.length(); +# ``` +# [1, 2, 3, 4].length() => 4 # ``` # # + arr - the array @@ -51,12 +50,11 @@ public isolated function length((any|error)[] arr) returns int = @java:Method { # Returns an iterator over an array. # -# ```ballerina -# int[] evenNumbers = [2, 4, 6, 8]; +# ``` # object { # public isolated function next() returns record {|int value;|}?; -# } iterator = evenNumbers.iterator(); -# record {|int value;|}? next = iterator.next(); +# } iterator = [2, 4, 6, 8].iterator(); +# iterator.next() => {"value":2} # ``` # # + arr - the array @@ -72,9 +70,8 @@ public isolated function iterator(Type[] arr) returns object { # Returns a new array consisting of index and member pairs. # -# ```ballerina -# string[] greetings = ["Hello", "Bonjour", "Hola", "Ciao"]; -# [int, string][] enumeration = greetings.enumerate(); +# ``` +# [1, 2, 3, 4].enumerate() => [[0,1],[1,2],[2,3],[3,4]] # ``` # # + arr - the array @@ -88,31 +85,8 @@ public isolated function enumerate(Type[] arr) returns [int, Type][] = @java:Met # Applies a function to each member of an array and returns an array of the results. # -# ```ballerina -# string[] greetings = ["Hello", "Bonjour", "Hola", "Ciao"]; -# int[] lengths = greetings.'map((greeting) => greeting.length()); -# -# Employee[] employees = [ -# {firstName: "Jo", lastName: "David", id: 2121}, -# {firstName: "Emma", id: 2122}, -# {firstName: "John", lastName: "Doe", id: 2123} -# ]; -# string[] fullNames = -# employees.'map(isolated function (Employee employee) returns string { -# string? lastName = employee.lastName; -# -# if lastName is () { -# return employee.firstName; -# } -# -# return string `${employee.firstName} ${lastName}`; -# }); -# -# type Employee record { -# string firstName; -# string lastName?; -# int id; -# }; +# ``` +# [0, 1, 2].map(n => n * 2) => [0,2,4] # ``` # # + arr - the array @@ -127,24 +101,12 @@ public isolated function 'map(Type[] arr, @isolatedParam function(Type val) retu # # The parameter `func` is applied to each member of parameter `arr` in order. # -# ```ballerina -# Employee[] employees = [ -# {name: "Jo", salary: 1200, id: 2121}, -# {name: "Emma", id: 2122, salary: ()}, -# {name: "John", salary: 1500, id: 2123} -# ]; -# -# employees.forEach(isolated function (Employee employee) { -# if employee.salary == () { -# employee.salary = 1000; -# } +# ``` +# string str = ""; +# [0, 1, 2].forEach(function (int i) { +# str += i.toString(); # }); -# -# type Employee record {| -# string name; -# int id; -# decimal? salary; -# |}; +# str => 012 # ``` # # + arr - the array @@ -156,25 +118,8 @@ public isolated function forEach(Type[] arr, @isolatedParam function(Type val) r # Selects the members from an array for which a function returns true. # -# ```ballerina -# string[] greetings = ["Hello", "Bonjour", "Hola", "Ciao"]; -# string[] filteredByLength = greetings.filter((greeting) => greeting.length() > 4); -# -# Employee[] employees = [ -# {name: "Jo", salary: 1200, id: 2121}, -# {name: "Emma", id: 2122, salary: 900}, -# {name: "John", salary: 1500, id: 2123} -# ]; -# Employee[] filteredBySalary = employees.filter(isolated function (Employee employee) returns boolean { -# decimal salary = employee.salary; -# return salary > 1000d && salary < 1500d; -# }); -# -# type Employee record {| -# string name; -# int id; -# decimal salary; -# |}; +# ``` +# [12, 43, 60, 75, 10].filter(n => n > 50) => [60,75] # ``` # # + arr - the array @@ -190,28 +135,8 @@ public isolated function filter(Type[] arr, @isolatedParam function(Type val) re # The combining function takes the combined value so far and a member of the array, # and returns a new combined value. # -# ```ballerina -# int[] integers = [1, 2, 3]; -# int sum = integers.reduce(isolated function (int total, int next) returns int => total + next, 0); -# -# Employee[] employees = [ -# {name: "Jo", salary: 1200, department: "IT"}, -# {name: "Emma", department: "finance", salary: 900}, -# {name: "John", salary: 1500, department: "IT"} -# ]; -# decimal currentTotalSalary = 10500; -# decimal totalSalaryWithITEmployees = employees.reduce(isolated function (decimal total, Employee employee) returns decimal { -# if employee.department == "IT" { -# return total + employee.salary; -# } -# return total; -# }, currentTotalSalary); -# -# type Employee record {| -# string name; -# string department; -# decimal salary; -# |}; +# ``` +# [1, 2, 3].reduce(isolated function (int total, int next) returns int => total + next, 0) => 6 # ``` # # + arr - the array @@ -228,25 +153,8 @@ public isolated function reduce(Type[] arr, @isolatedParam function(Type1 accum, # The parameter `func` is called for each member of parameter `arr` in order unless and until a call returns true. # When the array is empty, returns false. # -# ```ballerina -# int[] numbers = [1, 2, 3, 5]; -# boolean hasEvenNumber = numbers.some((number) => number % 2 == 0); -# -# Employee[] employees = [ -# {name: "Jo", salary: 1200, department: "IT"}, -# {name: "Emma", department: "finance", salary: 900}, -# {name: "John", salary: 1500, department: "IT"} -# ]; -# boolean hasEmployeeWithSalaryInRange = employees.some(isolated function (Employee employee) returns boolean { -# decimal salary = employee.salary; -# return salary > 1200d && salary < 1400d; -# }); -# -# type Employee record {| -# string name; -# string department; -# decimal salary; -# |}; +# ``` +# [1, 2, 3, 5].some(number => number % 2 == 0) => true # ``` # # + arr - the array @@ -263,14 +171,12 @@ public isolated function some(Type[] arr, @isolatedParam function(Type val) retu # Returns a subarray using a start index (inclusive) and an end index (exclusive). # -# ```ballerina -# int[] evenNumbers = [2, 4, 6, 8, 10, 12]; -# +# ``` # // Slice containing numbers starting from the fourth member to the end of the list. -# int[] slice = evenNumbers.slice(3); +# [2, 4, 6, 8, 10, 12].slice(3) => [8,10,12] # # // Slice containing the first four members in the list. -# int[] sliceWithEndIndex = evenNumbers.slice(0, 4); +# [2, 4, 6, 8, 10, 12].slice(0, 4) => [2,4,6,8] # ``` # # + arr - the array @@ -287,25 +193,8 @@ public isolated function slice(Type[] arr, int startIndex, int endIndex = arr.le # The parameter `func` is called for each member of `arr` in order unless and until a call returns false. # When the array is empty, returns true. # -# ```ballerina -# int[] numbers = [1, 2, 3, 5]; -# boolean allEvenNumbers = numbers.every((number) => number % 2 == 0); -# -# Employee[] employees = [ -# {name: "Jo", salary: 1200, department: "IT"}, -# {name: "Emma", department: "finance", salary: 900}, -# {name: "John", salary: 1500, department: "IT"} -# ]; -# boolean allEmployeesWithSalaryInRange = employees.every(isolated function (Employee employee) returns boolean { -# decimal salary = employee.salary; -# return salary >= 900d && salary < 2000d; -# }); -# -# type Employee record {| -# string name; -# string department; -# decimal salary; -# |}; +# ``` +# [1, 2, 3, 5].every(number => number % 2 == 0) => false # ``` # # + arr - the array @@ -325,9 +214,9 @@ public isolated function every(Type[] arr, @isolatedParam function(Type val) ret # This removes the member of parameter `arr` with index parameter `index` and returns it. # It panics if there is no such member. # -# ```ballerina -# string[] greetings = ["Hello", "Bonjour", "Hola", "Ciao"]; -# string removedGreeting = greetings.remove(1); +# ``` +# int[] evenNumbers = [2, 4, 6, 8]; +# evenNumbers.remove(1) => 4 # ``` # # + arr - the array @@ -342,9 +231,10 @@ public isolated function remove(Type[] arr, int index) returns Type = @java:Meth # # Panics if any member cannot be removed. # -# ```ballerina -# string[] greetings = ["Hello", "Bonjour", "Hola", "Ciao"]; -# greetings.removeAll(); +# ``` +# int[] evenNumbers = [2, 4, 6, 8]; +# evenNumbers.removeAll(); +# evenNumbers => [] # ``` # # + arr - the array @@ -357,9 +247,10 @@ public isolated function removeAll((any|error)[] arr) returns () = @java:Method # # `setLength(arr, 0)` is equivalent to `removeAll(arr)`. # -# ```ballerina -# string[] greetings = ["Hello", "Bonjour", "Hola", "Ciao"]; -# greetings.setLength(2); +# ``` +# int[] evenNumbers = [2, 4, 6, 8]; +# evenNumbers.setLength(2); +# evenNumbers => [2,4] # ``` # # + arr - the array of which to change the length @@ -373,15 +264,14 @@ public isolated function setLength((any|error)[] arr, int length) returns () = @ # Returns `()` if not found. # Equality is tested using `==`. # -# ```ballerina +# ``` # string[] greetings = ["Hello", "Hola", "Bonjour", "Hola", "Ciao"]; # -# string newGreeting = "guten tag"; # // First index of "guten tag" if it exists in the list. -# int? indexOfNewGreeting = greetings.indexOf(newGreeting); +# greetings.indexOf("guten tag") => () # # // First index of "Hola" if it exists in the list, after the second member of the list. -# int? indexOfHola = greetings.indexOf("Hola", 2); +# greetings.indexOf("Hola", 2) => 3 # ``` # # + arr - the array @@ -397,16 +287,15 @@ public isolated function indexOf(AnydataType[] arr, AnydataType val, int startIn # Returns `()` if not found. # Equality is tested using `==`. # -# ```ballerina +# ``` # string[] greetings = ["Hello", "Hola", "Bonjour", "Hola", "Ciao", "Hola"]; # -# string newGreeting = "guten tag"; # // Last index of "guten tag" if it exists in the list. -# int? indexOfNewGreeting = greetings.lastIndexOf(newGreeting); +# greetings.lastIndexOf("guten tag") => () # # // Last index of "Hola" if it exists in the list, searching backward starting from the # // second to last member of the list. -# int? indexOfHola = greetings.lastIndexOf("Hola", greetings.length() - 2); +# greetings.lastIndexOf("Hola", greetings.length() - 2) => 3 # ``` # # + arr - the array @@ -420,9 +309,8 @@ public isolated function lastIndexOf(AnydataType[] arr, AnydataType val, int sta # Reverses the order of the members of an array. # -# ```ballerina -# int[] evenNumbers = [2, 4, 6, 8, 10]; -# int[] evenNumbersReversed = evenNumbers.reverse(); +# ``` +# [2, 4, 6, 8, 10].reverse() => [10,8,6,4,2] # ``` # # + arr - the array to be reversed @@ -447,26 +335,26 @@ public type OrderedType ()|boolean|int|float|decimal|string|OrderedType[]; # must be specified. # Sorting works the same as with the parameter `sort` clause of query expressions. # -# ```ballerina +# ``` # string[] greetings = ["Hello", "Bonjour", "", "Hola", "Ciao"]; # # // Sort the list based on Unicode code point order. -# string[] sorted = greetings.sort(); +# greetings.sort() => ["","Bonjour","Ciao","Hello","Hola"] # # // Sort the list based on Unicode code point descending order. -# string[] sortedDescending = greetings.sort(array:DESCENDING); +# greetings.sort(array:DESCENDING) => ["Hola","Hello","Ciao","Bonjour",""] # # // Sort the list in ascending order based on a specified ordering function: order by length of string. -# string[] sortedUsingProvidedFunction = greetings.sort(key = isolated function (string str) returns int { -# int length = str.length(); -# if length == 0 { -# return int:MAX_VALUE; -# } -# return length; -# }); +# greetings.sort(key = isolated function (string str) returns int { +# int length = str.length(); +# if length == 0 { +# return int:MAX_VALUE; +# } +# return length; +# }) => ["Hola","Ciao","Hello","Bonjour",""] # # // Sort the list in descending order based on a specified ordering function: order by length of string. -# string[] sortedByDescendingLength = greetings.sort(array:DESCENDING, (str) => str.length()); +# greetings.sort(array:DESCENDING, (str) => str.length()) => ["Bonjour","Hello","Hola","Ciao",""] # ``` # # + arr - the array to be sorted; @@ -487,9 +375,9 @@ public isolated function sort(Type[] arr, SortDirection direction = ASCENDING, # # The array must not be empty. # -# ```ballerina +# ``` # int[] evenNumbers = [2, 4, 6, 8, 10]; -# int removedLastMember = evenNumbers.pop(); +# evenNumbers.pop() => 10 # ``` # # + arr - the array @@ -501,15 +389,17 @@ public isolated function pop(Type[] arr) returns Type = @java:Method { # Adds values to the end of an array. # -# ```ballerina +# ``` # int[] evenNumbers = [2]; # # // Push multiple members to the end of the list. # evenNumbers.push(4, 6); +# evenNumbers => [2,4,6] # # int[] moreEvenNumbers = [8, 10, 12, 14]; # // Push multiple members to the end of the list using an existing list in a rest argument. # evenNumbers.push(...moreEvenNumbers); +# evenNumbers => [2,4,6,8,10,12,14] # ``` # # + arr - the array @@ -527,9 +417,9 @@ public isolated function push(Type[] arr, Type... vals) returns () = @java:Metho # # The array must not be empty. # -# ```ballerina +# ``` # int[] evenNumbers = [2, 4, 6, 8, 10]; -# int removedFirstMember = evenNumbers.shift(); +# evenNumbers.shift() => 2 # ``` # # + arr - the array @@ -544,15 +434,17 @@ public isolated function shift(Type[] arr) returns Type = @java:Method { # The values newly added to the array will be in the same order # as they are in parameter `vals`. # -# ```ballerina +# ``` # int[] evenNumbers = [14]; # # // Add multiple members to the start of the list. # evenNumbers.unshift(10, 12); +# evenNumbers => [10,12,14] # # int[] moreEvenNumbers = [2, 4, 6, 8]; # // Add multiple members to the start of the list using an existing list in a rest argument. # evenNumbers.unshift(...moreEvenNumbers); +# evenNumbers => [2,4,6,8,10,12,14] # ``` # # + arr - the array @@ -570,9 +462,9 @@ public isolated function unshift(Type[] arr, Type... vals) returns () = @java:Me # The result will contain only characters `A..Z`, `a..z`, `0..9`, `+`, `/` and `=`. # There will be no whitespace in the returned string. # -# ```ballerina +# ``` # byte[] byteArray = [104, 101, 108, 108, 111, 32, 98, 97, 108, 108, 101, 114, 105, 110, 97, 32, 33, 33, 33]; -# string base64Rep = byteArray.toBase64(); +# byteArray.toBase64() => aGVsbG8gYmFsbGVyaW5hICEhIQ== # ``` # # + arr - the array @@ -587,9 +479,8 @@ public isolated function toBase64(byte[] arr) returns string = @java:Method { # parameter `str` must consist of the characters `A..Z`, `a..z`, `0..9`, `+`, `/`, `=` # and whitespace as allowed by a Ballerina Base64Literal. # -# ```ballerina -# string base64Rep = "aGVsbG8gYmFsbGVyaW5hICEhIQ=="; -# byte[] byteArray = check array:fromBase64(base64Rep); +# ``` +# check array:fromBase64("aGVsbG8gYmFsbGVyaW5hICEhIQ==") => [104,101,108,108,111,32,98,97,108,108,101,114,105,110,97,32,33,33,33] # ``` # # + str - Base64 string representation @@ -605,9 +496,9 @@ public isolated function fromBase64(string str) returns byte[]|error = @java:Met # The result will contain only characters `0..9`, `a..f`. # There will be no whitespace in the returned string. # -# ```ballerina +# ``` # byte[] byteArray = [170, 171, 207, 204, 173, 175, 205, 52, 26, 75, 223, 171, 205, 137, 18, 223]; -# string base16Rep = byteArray.toBase16(); +# byteArray.toBase16() => aaabcfccadafcd341a4bdfabcd8912df # ``` # # + arr - the array @@ -622,9 +513,8 @@ public isolated function toBase16(byte[] arr) returns string = @java:Method { # `str` must consist of the characters `0..9`, `A..F`, `a..f` # and whitespace as allowed by a Ballerina Base16Literal. # -# ```ballerina -# string base16Rep = "aaabcfccadafcd341a4bdfabcd8912df"; -# byte[] byteArray = check array:fromBase16(base16Rep); +# ``` +# check array:fromBase16("aaabcfccadafcd341a4bdfabcd8912df") => [170,171,207,204,173,175,205,52,26,75,223,171,205,137,18,223] # ``` # # + str - Base16 string representation @@ -636,9 +526,9 @@ public isolated function fromBase16(string str) returns byte[]|error = @java:Met # Returns a stream from the given array. # -# ```ballerina -# string[] greetings = ["Hello", "Bonjour", "Hola", "Ciao"]; -# stream greetingsStream = greetings.toStream(); +# ``` +# stream greetingsStream = ["Hello", "Bonjour", "Hola", "Ciao"].toStream(); +# greetingsStream.next() => {"value":"Hello"} # ``` # # + arr - The array from which the stream is created From 9d2e42c5c11091b58ac92f97c3bd9591a39d2659 Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Mon, 12 Dec 2022 11:41:17 +0530 Subject: [PATCH 293/450] Use is check for nil result --- langlib/lang.array/src/main/ballerina/array.bal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/langlib/lang.array/src/main/ballerina/array.bal b/langlib/lang.array/src/main/ballerina/array.bal index b58246a7d08e..2d0fa7e161ee 100644 --- a/langlib/lang.array/src/main/ballerina/array.bal +++ b/langlib/lang.array/src/main/ballerina/array.bal @@ -268,7 +268,7 @@ public isolated function setLength((any|error)[] arr, int length) returns () = @ # string[] greetings = ["Hello", "Hola", "Bonjour", "Hola", "Ciao"]; # # // First index of "guten tag" if it exists in the list. -# greetings.indexOf("guten tag") => () +# greetings.indexOf("guten tag") is () => true # # // First index of "Hola" if it exists in the list, after the second member of the list. # greetings.indexOf("Hola", 2) => 3 @@ -291,7 +291,7 @@ public isolated function indexOf(AnydataType[] arr, AnydataType val, int startIn # string[] greetings = ["Hello", "Hola", "Bonjour", "Hola", "Ciao", "Hola"]; # # // Last index of "guten tag" if it exists in the list. -# greetings.lastIndexOf("guten tag") => () +# greetings.lastIndexOf("guten tag") is () => true # # // Last index of "Hola" if it exists in the list, searching backward starting from the # // second to last member of the list. From 969c94b793d9eccfd23bf768b980c82d4822035d Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Tue, 13 Dec 2022 11:45:55 +0530 Subject: [PATCH 294/450] Update examples based on reviews --- .../lang.array/src/main/ballerina/array.bal | 147 +++++++++--------- 1 file changed, 70 insertions(+), 77 deletions(-) diff --git a/langlib/lang.array/src/main/ballerina/array.bal b/langlib/lang.array/src/main/ballerina/array.bal index 2d0fa7e161ee..ebc08750d377 100644 --- a/langlib/lang.array/src/main/ballerina/array.bal +++ b/langlib/lang.array/src/main/ballerina/array.bal @@ -38,7 +38,7 @@ type AnydataType anydata; # Returns the number of members of an array. # # ``` -# [1, 2, 3, 4].length() => 4 +# ["a", "b", "c", "d"].length() ⇒ 4 # ``` # # + arr - the array @@ -54,7 +54,7 @@ public isolated function length((any|error)[] arr) returns int = @java:Method { # object { # public isolated function next() returns record {|int value;|}?; # } iterator = [2, 4, 6, 8].iterator(); -# iterator.next() => {"value":2} +# iterator.next() ⇒ {"value":2} # ``` # # + arr - the array @@ -71,7 +71,7 @@ public isolated function iterator(Type[] arr) returns object { # Returns a new array consisting of index and member pairs. # # ``` -# [1, 2, 3, 4].enumerate() => [[0,1],[1,2],[2,3],[3,4]] +# [1, 2, 3, 4].enumerate() ⇒ [[0,1],[1,2],[2,3],[3,4]] # ``` # # + arr - the array @@ -86,7 +86,8 @@ public isolated function enumerate(Type[] arr) returns [int, Type][] = @java:Met # Applies a function to each member of an array and returns an array of the results. # # ``` -# [0, 1, 2].map(n => n * 2) => [0,2,4] +# int[] numbers = [0, 1, 2]; +# numbers.map(n => n * 2) ⇒ [0,2,4] # ``` # # + arr - the array @@ -102,11 +103,11 @@ public isolated function 'map(Type[] arr, @isolatedParam function(Type val) retu # The parameter `func` is applied to each member of parameter `arr` in order. # # ``` -# string str = ""; -# [0, 1, 2].forEach(function (int i) { -# str += i.toString(); +# int total = 0; +# [1, 2, 3].forEach(function (int i) { +# total += i * 2; # }); -# str => 012 +# total ⇒ 12 # ``` # # + arr - the array @@ -119,7 +120,8 @@ public isolated function forEach(Type[] arr, @isolatedParam function(Type val) r # Selects the members from an array for which a function returns true. # # ``` -# [12, 43, 60, 75, 10].filter(n => n > 50) => [60,75] +# int[] numbers = [12, 43, 60, 75, 10]; +# numbers.filter(n => n > 50) ⇒ [60,75] # ``` # # + arr - the array @@ -136,7 +138,7 @@ public isolated function filter(Type[] arr, @isolatedParam function(Type val) re # and returns a new combined value. # # ``` -# [1, 2, 3].reduce(isolated function (int total, int next) returns int => total + next, 0) => 6 +# [1, 2, 3].reduce(isolated function (int total, int next) returns int => total + next, 0) ⇒ 6 # ``` # # + arr - the array @@ -154,7 +156,8 @@ public isolated function reduce(Type[] arr, @isolatedParam function(Type1 accum, # When the array is empty, returns false. # # ``` -# [1, 2, 3, 5].some(number => number % 2 == 0) => true +# int[] numbers = [1, 2, 3, 5]; +# numbers.some(n => n % 2 == 0) ⇒ true # ``` # # + arr - the array @@ -172,11 +175,11 @@ public isolated function some(Type[] arr, @isolatedParam function(Type val) retu # Returns a subarray using a start index (inclusive) and an end index (exclusive). # # ``` -# // Slice containing numbers starting from the fourth member to the end of the list. -# [2, 4, 6, 8, 10, 12].slice(3) => [8,10,12] +# int[] numbers = [2, 4, 6, 8, 10, 12]; # -# // Slice containing the first four members in the list. -# [2, 4, 6, 8, 10, 12].slice(0, 4) => [2,4,6,8] +# numbers.slice(3) ⇒ [8,10,12] +# +# numbers.slice(0, 4) ⇒ [2,4,6,8] # ``` # # + arr - the array @@ -194,7 +197,8 @@ public isolated function slice(Type[] arr, int startIndex, int endIndex = arr.le # When the array is empty, returns true. # # ``` -# [1, 2, 3, 5].every(number => number % 2 == 0) => false +# int[] numbers = [1, 2, 3, 5]; +# numbers.every(n => n % 2 == 0) ⇒ false # ``` # # + arr - the array @@ -215,8 +219,8 @@ public isolated function every(Type[] arr, @isolatedParam function(Type val) ret # It panics if there is no such member. # # ``` -# int[] evenNumbers = [2, 4, 6, 8]; -# evenNumbers.remove(1) => 4 +# int[] numbers = [2, 4, 6, 8]; +# numbers.remove(1) ⇒ 4 # ``` # # + arr - the array @@ -232,9 +236,9 @@ public isolated function remove(Type[] arr, int index) returns Type = @java:Meth # Panics if any member cannot be removed. # # ``` -# int[] evenNumbers = [2, 4, 6, 8]; -# evenNumbers.removeAll(); -# evenNumbers => [] +# int[] numbers = [2, 4, 6, 8]; +# numbers.removeAll(); +# numbers ⇒ [] # ``` # # + arr - the array @@ -248,9 +252,13 @@ public isolated function removeAll((any|error)[] arr) returns () = @java:Method # `setLength(arr, 0)` is equivalent to `removeAll(arr)`. # # ``` -# int[] evenNumbers = [2, 4, 6, 8]; -# evenNumbers.setLength(2); -# evenNumbers => [2,4] +# int[] numbers = [2, 4, 6, 8]; +# +# numbers.setLength(2); +# numbers ⇒ [2,4] +# +# numbers.setLength(0); +# numbers ⇒ [] # ``` # # + arr - the array of which to change the length @@ -265,13 +273,11 @@ public isolated function setLength((any|error)[] arr, int length) returns () = @ # Equality is tested using `==`. # # ``` -# string[] greetings = ["Hello", "Hola", "Bonjour", "Hola", "Ciao"]; +# string[] strings = ["a", "b", "d", "b", "d"]; # -# // First index of "guten tag" if it exists in the list. -# greetings.indexOf("guten tag") is () => true +# strings.indexOf("e") is () ⇒ true # -# // First index of "Hola" if it exists in the list, after the second member of the list. -# greetings.indexOf("Hola", 2) => 3 +# strings.indexOf("b", 2) ⇒ 3 # ``` # # + arr - the array @@ -288,14 +294,11 @@ public isolated function indexOf(AnydataType[] arr, AnydataType val, int startIn # Equality is tested using `==`. # # ``` -# string[] greetings = ["Hello", "Hola", "Bonjour", "Hola", "Ciao", "Hola"]; +# string[] strings = ["a", "b", "d", "b", "d", "b"]; # -# // Last index of "guten tag" if it exists in the list. -# greetings.lastIndexOf("guten tag") is () => true +# strings.lastIndexOf("e") is () ⇒ true # -# // Last index of "Hola" if it exists in the list, searching backward starting from the -# // second to last member of the list. -# greetings.lastIndexOf("Hola", greetings.length() - 2) => 3 +# strings.lastIndexOf("b", strings.length() - 2) ⇒ 3 # ``` # # + arr - the array @@ -310,7 +313,7 @@ public isolated function lastIndexOf(AnydataType[] arr, AnydataType val, int sta # Reverses the order of the members of an array. # # ``` -# [2, 4, 6, 8, 10].reverse() => [10,8,6,4,2] +# [2, 4, 6, 8, 10].reverse() ⇒ [10,8,6,4,2] # ``` # # + arr - the array to be reversed @@ -336,25 +339,15 @@ public type OrderedType ()|boolean|int|float|decimal|string|OrderedType[]; # Sorting works the same as with the parameter `sort` clause of query expressions. # # ``` -# string[] greetings = ["Hello", "Bonjour", "", "Hola", "Ciao"]; +# string[] strings = ["c", "a", "B"]; # -# // Sort the list based on Unicode code point order. -# greetings.sort() => ["","Bonjour","Ciao","Hello","Hola"] +# strings.sort() ⇒ ["B","a","c"] # -# // Sort the list based on Unicode code point descending order. -# greetings.sort(array:DESCENDING) => ["Hola","Hello","Ciao","Bonjour",""] +# strings.sort("descending") ⇒ ["c","a","B"] # -# // Sort the list in ascending order based on a specified ordering function: order by length of string. -# greetings.sort(key = isolated function (string str) returns int { -# int length = str.length(); -# if length == 0 { -# return int:MAX_VALUE; -# } -# return length; -# }) => ["Hola","Ciao","Hello","Bonjour",""] +# strings.sort(key = string:toLowerAscii) ⇒ ["a","B","c"] # -# // Sort the list in descending order based on a specified ordering function: order by length of string. -# greetings.sort(array:DESCENDING, (str) => str.length()) => ["Bonjour","Hello","Hola","Ciao",""] +# strings.sort("descending", string:toLowerAscii) ⇒ ["c","B","a"] # ``` # # + arr - the array to be sorted; @@ -376,8 +369,8 @@ public isolated function sort(Type[] arr, SortDirection direction = ASCENDING, # The array must not be empty. # # ``` -# int[] evenNumbers = [2, 4, 6, 8, 10]; -# evenNumbers.pop() => 10 +# int[] numbers = [2, 4, 6, 8, 10]; +# numbers.pop() ⇒ 10 # ``` # # + arr - the array @@ -390,16 +383,14 @@ public isolated function pop(Type[] arr) returns Type = @java:Method { # Adds values to the end of an array. # # ``` -# int[] evenNumbers = [2]; +# int[] numbers = [2]; # -# // Push multiple members to the end of the list. -# evenNumbers.push(4, 6); -# evenNumbers => [2,4,6] +# numbers.push(4, 6); +# numbers ⇒ [2,4,6] # -# int[] moreEvenNumbers = [8, 10, 12, 14]; -# // Push multiple members to the end of the list using an existing list in a rest argument. -# evenNumbers.push(...moreEvenNumbers); -# evenNumbers => [2,4,6,8,10,12,14] +# int[] moreNumbers = [8, 10, 12, 14]; +# numbers.push(...moreNumbers); +# numbers ⇒ [2,4,6,8,10,12,14] # ``` # # + arr - the array @@ -418,8 +409,8 @@ public isolated function push(Type[] arr, Type... vals) returns () = @java:Metho # The array must not be empty. # # ``` -# int[] evenNumbers = [2, 4, 6, 8, 10]; -# evenNumbers.shift() => 2 +# int[] numbers = [2, 4, 6, 8, 10]; +# numbers.shift() ⇒ 2 # ``` # # + arr - the array @@ -435,16 +426,14 @@ public isolated function shift(Type[] arr) returns Type = @java:Method { # as they are in parameter `vals`. # # ``` -# int[] evenNumbers = [14]; +# int[] numbers = [14]; # -# // Add multiple members to the start of the list. -# evenNumbers.unshift(10, 12); -# evenNumbers => [10,12,14] +# numbers.unshift(10, 12); +# numbers ⇒ [10,12,14] # -# int[] moreEvenNumbers = [2, 4, 6, 8]; -# // Add multiple members to the start of the list using an existing list in a rest argument. -# evenNumbers.unshift(...moreEvenNumbers); -# evenNumbers => [2,4,6,8,10,12,14] +# int[] moreNumbers = [2, 4, 6, 8]; +# numbers.unshift(...moreNumbers); +# numbers ⇒ [2,4,6,8,10,12,14] # ``` # # + arr - the array @@ -464,7 +453,7 @@ public isolated function unshift(Type[] arr, Type... vals) returns () = @java:Me # # ``` # byte[] byteArray = [104, 101, 108, 108, 111, 32, 98, 97, 108, 108, 101, 114, 105, 110, 97, 32, 33, 33, 33]; -# byteArray.toBase64() => aGVsbG8gYmFsbGVyaW5hICEhIQ== +# byteArray.toBase64() ⇒ aGVsbG8gYmFsbGVyaW5hICEhIQ== # ``` # # + arr - the array @@ -480,7 +469,9 @@ public isolated function toBase64(byte[] arr) returns string = @java:Method { # and whitespace as allowed by a Ballerina Base64Literal. # # ``` -# check array:fromBase64("aGVsbG8gYmFsbGVyaW5hICEhIQ==") => [104,101,108,108,111,32,98,97,108,108,101,114,105,110,97,32,33,33,33] +# check array:fromBase64("aGVsbG8gYmFsbGVyaW5hICEhIQ==") ⇒ [104,101,108,108,111,32,98,97,108,108,101,114,105,110,97,32,33,33,33] +# +# array:fromBase64("aGVsbG8gYmFsbGVyaW5hICEhIQ--") ⇒ error # ``` # # + str - Base64 string representation @@ -498,7 +489,7 @@ public isolated function fromBase64(string str) returns byte[]|error = @java:Met # # ``` # byte[] byteArray = [170, 171, 207, 204, 173, 175, 205, 52, 26, 75, 223, 171, 205, 137, 18, 223]; -# byteArray.toBase16() => aaabcfccadafcd341a4bdfabcd8912df +# byteArray.toBase16() ⇒ aaabcfccadafcd341a4bdfabcd8912df # ``` # # + arr - the array @@ -514,7 +505,9 @@ public isolated function toBase16(byte[] arr) returns string = @java:Method { # and whitespace as allowed by a Ballerina Base16Literal. # # ``` -# check array:fromBase16("aaabcfccadafcd341a4bdfabcd8912df") => [170,171,207,204,173,175,205,52,26,75,223,171,205,137,18,223] +# check array:fromBase16("aaabcfccadafcd341a4bdfabcd8912df") ⇒ [170,171,207,204,173,175,205,52,26,75,223,171,205,137,18,223] +# +# array:fromBase16("aGVsbG8gYmFsbGVyaW5hICEhIQ==") ⇒ error # ``` # # + str - Base16 string representation @@ -527,8 +520,8 @@ public isolated function fromBase16(string str) returns byte[]|error = @java:Met # Returns a stream from the given array. # # ``` -# stream greetingsStream = ["Hello", "Bonjour", "Hola", "Ciao"].toStream(); -# greetingsStream.next() => {"value":"Hello"} +# stream strm = ["a", "b", "c", "d"].toStream(); +# strm.next() ⇒ {"value":"a"} # ``` # # + arr - The array from which the stream is created From 7352b71957e9e601fab50e514d20aa6c228750b6 Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Thu, 15 Dec 2022 01:22:28 +0530 Subject: [PATCH 295/450] Address review suggestions --- .../lang.array/src/main/ballerina/array.bal | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/langlib/lang.array/src/main/ballerina/array.bal b/langlib/lang.array/src/main/ballerina/array.bal index ebc08750d377..680aba2839b9 100644 --- a/langlib/lang.array/src/main/ballerina/array.bal +++ b/langlib/lang.array/src/main/ballerina/array.bal @@ -105,9 +105,9 @@ public isolated function 'map(Type[] arr, @isolatedParam function(Type val) retu # ``` # int total = 0; # [1, 2, 3].forEach(function (int i) { -# total += i * 2; +# total += i; # }); -# total ⇒ 12 +# total ⇒ 6 # ``` # # + arr - the array @@ -180,6 +180,8 @@ public isolated function some(Type[] arr, @isolatedParam function(Type val) retu # numbers.slice(3) ⇒ [8,10,12] # # numbers.slice(0, 4) ⇒ [2,4,6,8] +# +# numbers.slice(0, 10) ⇒ panic # ``` # # + arr - the array @@ -220,7 +222,10 @@ public isolated function every(Type[] arr, @isolatedParam function(Type val) ret # # ``` # int[] numbers = [2, 4, 6, 8]; +# # numbers.remove(1) ⇒ 4 +# +# numbers.remove(7) ⇒ panic # ``` # # + arr - the array @@ -239,6 +244,9 @@ public isolated function remove(Type[] arr, int index) returns Type = @java:Meth # int[] numbers = [2, 4, 6, 8]; # numbers.removeAll(); # numbers ⇒ [] +# +# int[2] values = [1, 2]; +# values.removeAll() ⇒ panic # ``` # # + arr - the array @@ -277,6 +285,8 @@ public isolated function setLength((any|error)[] arr, int length) returns () = @ # # strings.indexOf("e") is () ⇒ true # +# strings.indexOf("b") ⇒ 1 +# # strings.indexOf("b", 2) ⇒ 3 # ``` # @@ -298,6 +308,8 @@ public isolated function indexOf(AnydataType[] arr, AnydataType val, int startIn # # strings.lastIndexOf("e") is () ⇒ true # +# strings.lastIndexOf("b") ⇒ 5 +# # strings.lastIndexOf("b", strings.length() - 2) ⇒ 3 # ``` # @@ -371,6 +383,9 @@ public isolated function sort(Type[] arr, SortDirection direction = ASCENDING, # ``` # int[] numbers = [2, 4, 6, 8, 10]; # numbers.pop() ⇒ 10 +# +# int[] values = []; +# values.pop() ⇒ panic # ``` # # + arr - the array @@ -411,6 +426,9 @@ public isolated function push(Type[] arr, Type... vals) returns () = @java:Metho # ``` # int[] numbers = [2, 4, 6, 8, 10]; # numbers.shift() ⇒ 2 +# +# int[] values = []; +# values.shift() ⇒ panic # ``` # # + arr - the array @@ -452,8 +470,8 @@ public isolated function unshift(Type[] arr, Type... vals) returns () = @java:Me # There will be no whitespace in the returned string. # # ``` -# byte[] byteArray = [104, 101, 108, 108, 111, 32, 98, 97, 108, 108, 101, 114, 105, 110, 97, 32, 33, 33, 33]; -# byteArray.toBase64() ⇒ aGVsbG8gYmFsbGVyaW5hICEhIQ== +# byte[] byteArray = [104, 101, 108, 108, 111, 32, 98, 97]; +# byteArray.toBase64() ⇒ aGVsbG8gYmE= # ``` # # + arr - the array @@ -469,9 +487,9 @@ public isolated function toBase64(byte[] arr) returns string = @java:Method { # and whitespace as allowed by a Ballerina Base64Literal. # # ``` -# check array:fromBase64("aGVsbG8gYmFsbGVyaW5hICEhIQ==") ⇒ [104,101,108,108,111,32,98,97,108,108,101,114,105,110,97,32,33,33,33] +# check array:fromBase64("aGVsbG8gYmE=") ⇒ [104,101,108,108,111,32,98,97] # -# array:fromBase64("aGVsbG8gYmFsbGVyaW5hICEhIQ--") ⇒ error +# array:fromBase64("aGVsbG8gYmE--") ⇒ error # ``` # # + str - Base64 string representation @@ -488,8 +506,8 @@ public isolated function fromBase64(string str) returns byte[]|error = @java:Met # There will be no whitespace in the returned string. # # ``` -# byte[] byteArray = [170, 171, 207, 204, 173, 175, 205, 52, 26, 75, 223, 171, 205, 137, 18, 223]; -# byteArray.toBase16() ⇒ aaabcfccadafcd341a4bdfabcd8912df +# byte[] byteArray = [170, 171, 207, 204, 173, 175, 205]; +# byteArray.toBase16() ⇒ aaabcfccadafcd # ``` # # + arr - the array @@ -505,9 +523,9 @@ public isolated function toBase16(byte[] arr) returns string = @java:Method { # and whitespace as allowed by a Ballerina Base16Literal. # # ``` -# check array:fromBase16("aaabcfccadafcd341a4bdfabcd8912df") ⇒ [170,171,207,204,173,175,205,52,26,75,223,171,205,137,18,223] +# check array:fromBase16("aaabcfccadafcd") ⇒ [170,171,207,204,173,175,205] # -# array:fromBase16("aGVsbG8gYmFsbGVyaW5hICEhIQ==") ⇒ error +# array:fromBase16("aaabcfccadafcd==") ⇒ error # ``` # # + str - Base16 string representation From f032fc76bb84ef81467e983c35d41e295f73e4ad Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Thu, 15 Dec 2022 16:32:47 +0530 Subject: [PATCH 296/450] Add the ballerina tag and remove check --- .../lang.array/src/main/ballerina/array.bal | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/langlib/lang.array/src/main/ballerina/array.bal b/langlib/lang.array/src/main/ballerina/array.bal index 680aba2839b9..57e3fc0c6e09 100644 --- a/langlib/lang.array/src/main/ballerina/array.bal +++ b/langlib/lang.array/src/main/ballerina/array.bal @@ -37,7 +37,7 @@ type AnydataType anydata; # Returns the number of members of an array. # -# ``` +# ```ballerina # ["a", "b", "c", "d"].length() ⇒ 4 # ``` # @@ -50,7 +50,7 @@ public isolated function length((any|error)[] arr) returns int = @java:Method { # Returns an iterator over an array. # -# ``` +# ```ballerina # object { # public isolated function next() returns record {|int value;|}?; # } iterator = [2, 4, 6, 8].iterator(); @@ -70,7 +70,7 @@ public isolated function iterator(Type[] arr) returns object { # Returns a new array consisting of index and member pairs. # -# ``` +# ```ballerina # [1, 2, 3, 4].enumerate() ⇒ [[0,1],[1,2],[2,3],[3,4]] # ``` # @@ -85,7 +85,7 @@ public isolated function enumerate(Type[] arr) returns [int, Type][] = @java:Met # Applies a function to each member of an array and returns an array of the results. # -# ``` +# ```ballerina # int[] numbers = [0, 1, 2]; # numbers.map(n => n * 2) ⇒ [0,2,4] # ``` @@ -102,7 +102,7 @@ public isolated function 'map(Type[] arr, @isolatedParam function(Type val) retu # # The parameter `func` is applied to each member of parameter `arr` in order. # -# ``` +# ```ballerina # int total = 0; # [1, 2, 3].forEach(function (int i) { # total += i; @@ -119,7 +119,7 @@ public isolated function forEach(Type[] arr, @isolatedParam function(Type val) r # Selects the members from an array for which a function returns true. # -# ``` +# ```ballerina # int[] numbers = [12, 43, 60, 75, 10]; # numbers.filter(n => n > 50) ⇒ [60,75] # ``` @@ -137,7 +137,7 @@ public isolated function filter(Type[] arr, @isolatedParam function(Type val) re # The combining function takes the combined value so far and a member of the array, # and returns a new combined value. # -# ``` +# ```ballerina # [1, 2, 3].reduce(isolated function (int total, int next) returns int => total + next, 0) ⇒ 6 # ``` # @@ -155,7 +155,7 @@ public isolated function reduce(Type[] arr, @isolatedParam function(Type1 accum, # The parameter `func` is called for each member of parameter `arr` in order unless and until a call returns true. # When the array is empty, returns false. # -# ``` +# ```ballerina # int[] numbers = [1, 2, 3, 5]; # numbers.some(n => n % 2 == 0) ⇒ true # ``` @@ -174,7 +174,7 @@ public isolated function some(Type[] arr, @isolatedParam function(Type val) retu # Returns a subarray using a start index (inclusive) and an end index (exclusive). # -# ``` +# ```ballerina # int[] numbers = [2, 4, 6, 8, 10, 12]; # # numbers.slice(3) ⇒ [8,10,12] @@ -198,7 +198,7 @@ public isolated function slice(Type[] arr, int startIndex, int endIndex = arr.le # The parameter `func` is called for each member of `arr` in order unless and until a call returns false. # When the array is empty, returns true. # -# ``` +# ```ballerina # int[] numbers = [1, 2, 3, 5]; # numbers.every(n => n % 2 == 0) ⇒ false # ``` @@ -220,7 +220,7 @@ public isolated function every(Type[] arr, @isolatedParam function(Type val) ret # This removes the member of parameter `arr` with index parameter `index` and returns it. # It panics if there is no such member. # -# ``` +# ```ballerina # int[] numbers = [2, 4, 6, 8]; # # numbers.remove(1) ⇒ 4 @@ -240,7 +240,7 @@ public isolated function remove(Type[] arr, int index) returns Type = @java:Meth # # Panics if any member cannot be removed. # -# ``` +# ```ballerina # int[] numbers = [2, 4, 6, 8]; # numbers.removeAll(); # numbers ⇒ [] @@ -259,7 +259,7 @@ public isolated function removeAll((any|error)[] arr) returns () = @java:Method # # `setLength(arr, 0)` is equivalent to `removeAll(arr)`. # -# ``` +# ```ballerina # int[] numbers = [2, 4, 6, 8]; # # numbers.setLength(2); @@ -280,7 +280,7 @@ public isolated function setLength((any|error)[] arr, int length) returns () = @ # Returns `()` if not found. # Equality is tested using `==`. # -# ``` +# ```ballerina # string[] strings = ["a", "b", "d", "b", "d"]; # # strings.indexOf("e") is () ⇒ true @@ -303,7 +303,7 @@ public isolated function indexOf(AnydataType[] arr, AnydataType val, int startIn # Returns `()` if not found. # Equality is tested using `==`. # -# ``` +# ```ballerina # string[] strings = ["a", "b", "d", "b", "d", "b"]; # # strings.lastIndexOf("e") is () ⇒ true @@ -324,7 +324,7 @@ public isolated function lastIndexOf(AnydataType[] arr, AnydataType val, int sta # Reverses the order of the members of an array. # -# ``` +# ```ballerina # [2, 4, 6, 8, 10].reverse() ⇒ [10,8,6,4,2] # ``` # @@ -350,7 +350,7 @@ public type OrderedType ()|boolean|int|float|decimal|string|OrderedType[]; # must be specified. # Sorting works the same as with the parameter `sort` clause of query expressions. # -# ``` +# ```ballerina # string[] strings = ["c", "a", "B"]; # # strings.sort() ⇒ ["B","a","c"] @@ -380,7 +380,7 @@ public isolated function sort(Type[] arr, SortDirection direction = ASCENDING, # # The array must not be empty. # -# ``` +# ```ballerina # int[] numbers = [2, 4, 6, 8, 10]; # numbers.pop() ⇒ 10 # @@ -397,7 +397,7 @@ public isolated function pop(Type[] arr) returns Type = @java:Method { # Adds values to the end of an array. # -# ``` +# ```ballerina # int[] numbers = [2]; # # numbers.push(4, 6); @@ -423,7 +423,7 @@ public isolated function push(Type[] arr, Type... vals) returns () = @java:Metho # # The array must not be empty. # -# ``` +# ```ballerina # int[] numbers = [2, 4, 6, 8, 10]; # numbers.shift() ⇒ 2 # @@ -443,7 +443,7 @@ public isolated function shift(Type[] arr) returns Type = @java:Method { # The values newly added to the array will be in the same order # as they are in parameter `vals`. # -# ``` +# ```ballerina # int[] numbers = [14]; # # numbers.unshift(10, 12); @@ -469,7 +469,7 @@ public isolated function unshift(Type[] arr, Type... vals) returns () = @java:Me # The result will contain only characters `A..Z`, `a..z`, `0..9`, `+`, `/` and `=`. # There will be no whitespace in the returned string. # -# ``` +# ```ballerina # byte[] byteArray = [104, 101, 108, 108, 111, 32, 98, 97]; # byteArray.toBase64() ⇒ aGVsbG8gYmE= # ``` @@ -486,8 +486,8 @@ public isolated function toBase64(byte[] arr) returns string = @java:Method { # parameter `str` must consist of the characters `A..Z`, `a..z`, `0..9`, `+`, `/`, `=` # and whitespace as allowed by a Ballerina Base64Literal. # -# ``` -# check array:fromBase64("aGVsbG8gYmE=") ⇒ [104,101,108,108,111,32,98,97] +# ```ballerina +# array:fromBase64("aGVsbG8gYmE=") ⇒ [104,101,108,108,111,32,98,97] # # array:fromBase64("aGVsbG8gYmE--") ⇒ error # ``` @@ -505,7 +505,7 @@ public isolated function fromBase64(string str) returns byte[]|error = @java:Met # The result will contain only characters `0..9`, `a..f`. # There will be no whitespace in the returned string. # -# ``` +# ```ballerina # byte[] byteArray = [170, 171, 207, 204, 173, 175, 205]; # byteArray.toBase16() ⇒ aaabcfccadafcd # ``` @@ -522,8 +522,8 @@ public isolated function toBase16(byte[] arr) returns string = @java:Method { # `str` must consist of the characters `0..9`, `A..F`, `a..f` # and whitespace as allowed by a Ballerina Base16Literal. # -# ``` -# check array:fromBase16("aaabcfccadafcd") ⇒ [170,171,207,204,173,175,205] +# ```ballerina +# array:fromBase16("aaabcfccadafcd") ⇒ [170,171,207,204,173,175,205] # # array:fromBase16("aaabcfccadafcd==") ⇒ error # ``` @@ -537,7 +537,7 @@ public isolated function fromBase16(string str) returns byte[]|error = @java:Met # Returns a stream from the given array. # -# ``` +# ```ballerina # stream strm = ["a", "b", "c", "d"].toStream(); # strm.next() ⇒ {"value":"a"} # ``` From 39c81dc3f831fe7417bb665851063c70c504f063 Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Fri, 16 Dec 2022 10:10:37 +0530 Subject: [PATCH 297/450] Fix tests --- .../expected/stdlib/inter_stdlib_config1.json | 6 +++--- .../references/expected/ref_within_stdlib_config1.json | 10 +++++----- .../java/org/ballerinalang/test/error/ErrorTest.java | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/language-server/modules/langserver-core/src/test/resources/definition/expected/stdlib/inter_stdlib_config1.json b/language-server/modules/langserver-core/src/test/resources/definition/expected/stdlib/inter_stdlib_config1.json index 019e976b5056..ffa992ee8021 100644 --- a/language-server/modules/langserver-core/src/test/resources/definition/expected/stdlib/inter_stdlib_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/definition/expected/stdlib/inter_stdlib_config1.json @@ -3,18 +3,18 @@ "file": "repo/bala/ballerina/lang.array/0.0.0/any/modules/lang.array/array.bal" }, "position": { - "line": 56, + "line": 67, "character": 13 }, "result": [ { "range": { "start": { - "line": 55, + "line": 66, "character": 18 }, "end": { - "line": 55, + "line": 66, "character": 29 } }, diff --git a/language-server/modules/langserver-core/src/test/resources/references/expected/ref_within_stdlib_config1.json b/language-server/modules/langserver-core/src/test/resources/references/expected/ref_within_stdlib_config1.json index b1c09405c8de..1486e70cd091 100644 --- a/language-server/modules/langserver-core/src/test/resources/references/expected/ref_within_stdlib_config1.json +++ b/language-server/modules/langserver-core/src/test/resources/references/expected/ref_within_stdlib_config1.json @@ -3,7 +3,7 @@ "file": "repo/bala/ballerina/lang.array/0.0.0/any/modules/lang.array/array.bal" }, "position": { - "line": 55, + "line": 66, "character": 21 }, "result": [ @@ -11,11 +11,11 @@ "uri": "repo/bala/ballerina/lang.array/0.0.0/any/modules/lang.array/array.bal", "range": { "start": { - "line": 56, + "line": 67, "character": 11 }, "end": { - "line": 56, + "line": 67, "character": 22 } } @@ -24,11 +24,11 @@ "uri": "repo/bala/ballerina/lang.array/0.0.0/any/modules/lang.array/array.bal", "range": { "start": { - "line": 55, + "line": 66, "character": 18 }, "end": { - "line": 55, + "line": 66, "character": 29 } } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/error/ErrorTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/error/ErrorTest.java index 54316f43e6cb..5ff96a550b16 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/error/ErrorTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/error/ErrorTest.java @@ -339,7 +339,7 @@ public void testStackTraceInNative() { Assert.assertNotNull(expectedException); String message = expectedException.getMessage(); Assert.assertEquals(message, "error: array index out of range: index: 4, size: 2\n\t" + - "at ballerina.lang.array.0:slice(array.bal:145)\n\t" + + "at ballerina.lang.array.0:slice(array.bal:191)\n\t" + " error_test:testStackTraceInNative(error_test.bal:337)"); } From d519b3b7512014b03f07a083d8668dde6e8aabcf Mon Sep 17 00:00:00 2001 From: Maryam Ziyad Date: Mon, 19 Dec 2022 10:38:30 +0530 Subject: [PATCH 298/450] Improve the reverse example Co-authored-by: Chiran Fernando --- langlib/lang.array/src/main/ballerina/array.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langlib/lang.array/src/main/ballerina/array.bal b/langlib/lang.array/src/main/ballerina/array.bal index 57e3fc0c6e09..83dc7ec3eea0 100644 --- a/langlib/lang.array/src/main/ballerina/array.bal +++ b/langlib/lang.array/src/main/ballerina/array.bal @@ -325,7 +325,7 @@ public isolated function lastIndexOf(AnydataType[] arr, AnydataType val, int sta # Reverses the order of the members of an array. # # ```ballerina -# [2, 4, 6, 8, 10].reverse() ⇒ [10,8,6,4,2] +# [2, 4, 12, 8, 10].reverse() ⇒ [10,8,12,4,2] # ``` # # + arr - the array to be reversed From 9da2d1158788d3bc27ecaa8feb27732b829dcf1c Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Fri, 2 Dec 2022 16:22:30 +0530 Subject: [PATCH 299/450] Add examples for function:call --- .../src/main/ballerina/function.bal | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/langlib/lang.function/src/main/ballerina/function.bal b/langlib/lang.function/src/main/ballerina/function.bal index 65ec56fe305c..91c7df57edb9 100644 --- a/langlib/lang.function/src/main/ballerina/function.bal +++ b/langlib/lang.function/src/main/ballerina/function.bal @@ -21,6 +21,23 @@ import ballerina/jballerina.java; # If the arguments specified in `args` are not of the type required by `func`, # then this will panic. # +# ```ballerina +# function fn = getGreeting; +# // Call `getGreeting` without arguments. +# any|error greeting = function:call(fn); +# +# // Call `getGreeting` with an argument. +# any|error greetingWithName = function:call(fn, "David"); +# +# function getGreeting(string? name = ()) returns string { +# if name is () { +# return "Hello!"; +# } +# +# return string `Hello ${name}!`; +# } +# ``` +# # + func - the function to be called # + args - the arguments to be passed to the function # + return - the return value of the call to the function From 22aaf08e3799b13e4a5f42caf082a5633ebe6d4c Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Fri, 2 Dec 2022 22:42:45 +0530 Subject: [PATCH 300/450] Add an example for future:cancel --- .../lang.future/src/main/ballerina/future.bal | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/langlib/lang.future/src/main/ballerina/future.bal b/langlib/lang.future/src/main/ballerina/future.bal index f364ee28ae9f..95856e8de769 100644 --- a/langlib/lang.future/src/main/ballerina/future.bal +++ b/langlib/lang.future/src/main/ballerina/future.bal @@ -21,6 +21,25 @@ import ballerina/jballerina.java; # This sets the cancellation flag in the strand corresponding to `f`. # Each time that a strand yields, it will check the cancellation flag # and terminate abnormally if the flag is set. +# +# ```ballerina +# int[] sales = [10, 13, 54, 245, 24, 29, 343, 34, 23, 45, 67, 93, 846]; +# future computationFuture = start computeEntryCountForTarget(sales, 500); +# computationFuture.cancel(); +# +# function computeEntryCountForTarget(int[] sales, int target) returns int? { +# int sum = 0; +# foreach [int, int] [index, item] in sales.enumerate() { +# sum += item; +# +# if sum >= target { +# return index + 1; +# } +# } +# return (); +# } +# ``` +# # + f - the future to be cancelled public isolated function cancel(future f) returns () = @java:Method { 'class: "org.ballerinalang.langlib.future.Cancel", From 2577a8c0b89d3b66f5a4a5a18583527dcf47ee1f Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Wed, 14 Dec 2022 10:58:38 +0530 Subject: [PATCH 301/450] Update examples --- .../src/main/ballerina/function.bal | 15 ++++----------- .../lang.future/src/main/ballerina/future.bal | 17 ++--------------- 2 files changed, 6 insertions(+), 26 deletions(-) diff --git a/langlib/lang.function/src/main/ballerina/function.bal b/langlib/lang.function/src/main/ballerina/function.bal index 91c7df57edb9..7f08f56a3d70 100644 --- a/langlib/lang.function/src/main/ballerina/function.bal +++ b/langlib/lang.function/src/main/ballerina/function.bal @@ -22,20 +22,13 @@ import ballerina/jballerina.java; # then this will panic. # # ```ballerina -# function fn = getGreeting; -# // Call `getGreeting` without arguments. -# any|error greeting = function:call(fn); +# function getGreeting(string? name = ()) returns string => name is () ? "Hello" : string `Hello ${name}!`; # -# // Call `getGreeting` with an argument. -# any|error greetingWithName = function:call(fn, "David"); +# function:call(getGreeting) ⇒ Hello # -# function getGreeting(string? name = ()) returns string { -# if name is () { -# return "Hello!"; -# } +# function:call(getGreeting, "David") ⇒ Hello David! # -# return string `Hello ${name}!`; -# } +# function:call(getGreeting, 1) ⇒ panic # ``` # # + func - the function to be called diff --git a/langlib/lang.future/src/main/ballerina/future.bal b/langlib/lang.future/src/main/ballerina/future.bal index 95856e8de769..24069546f5dd 100644 --- a/langlib/lang.future/src/main/ballerina/future.bal +++ b/langlib/lang.future/src/main/ballerina/future.bal @@ -23,21 +23,8 @@ import ballerina/jballerina.java; # and terminate abnormally if the flag is set. # # ```ballerina -# int[] sales = [10, 13, 54, 245, 24, 29, 343, 34, 23, 45, 67, 93, 846]; -# future computationFuture = start computeEntryCountForTarget(sales, 500); -# computationFuture.cancel(); -# -# function computeEntryCountForTarget(int[] sales, int target) returns int? { -# int sum = 0; -# foreach [int, int] [index, item] in sales.enumerate() { -# sum += item; -# -# if sum >= target { -# return index + 1; -# } -# } -# return (); -# } +# future sumFuture = start int:sum(10, 13, 54, 245, 24, 29, 343, 34); +# sumFuture.cancel(); # ``` # # + f - the future to be cancelled From ff611e4b89dc92366cff75606cf7d96ee71128da Mon Sep 17 00:00:00 2001 From: azinneera Date: Tue, 13 Dec 2022 23:17:44 +0530 Subject: [PATCH 302/450] Introduce attribute unresolved to nodes in the raw graph --- .../build-project-with-dump-raw-graphs.txt | 4 +- ...raph-for-bal-file-with-dump-raw-graphs.txt | 4 +- .../graph-for-bal-project-missing-dir-dep.txt | 3 +- ...raph-for-bal-project-missing-trans-dep.txt | 2 +- ...h-for-bal-project-with-dump-raw-graphs.txt | 4 +- .../projects/internal/DotGraphs.java | 62 +++++++++++++++---- .../PackageDependencyGraphBuilder.java | 4 ++ .../projects/internal/ResolutionEngine.java | 46 ++++++++++++-- .../io/ballerina/projects/DotGraphsTests.java | 3 +- 9 files changed, 106 insertions(+), 26 deletions(-) diff --git a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/unix/build-project-with-dump-raw-graphs.txt b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/unix/build-project-with-dump-raw-graphs.txt index d3849e98d72f..57493eedfe3b 100644 --- a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/unix/build-project-with-dump-raw-graphs.txt +++ b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/unix/build-project-with-dump-raw-graphs.txt @@ -7,7 +7,7 @@ digraph "Initial" { node [shape=record] "foo/package_a" [label="<0.1.0> foo/package_a:0.1.0"]; "foo/package_b" [label="<0.1.0> foo/package_b:0.1.0"]; - "foo/package_c" [label="<0.1.0> foo/package_c:0.1.0"]; + "foo/package_c" [unresolved="true",color="grey",label="<0.1.0> foo/package_c:0.1.0"]; // Edges "foo/package_a":"0.1.0" -> "foo/package_b":"0.1.0"; @@ -51,7 +51,7 @@ digraph "Initial" { node [shape=record] "foo/package_a" [label="<0.1.0> foo/package_a:0.1.0"]; "foo/package_b" [label="<0.1.0> foo/package_b:0.1.0"]; - "foo/package_c" [label="<0.1.0> foo/package_c:0.1.0"]; + "foo/package_c" [unresolved="true",color="grey",label="<0.1.0> foo/package_c:0.1.0"]; // Edges "foo/package_a":"0.1.0" -> "foo/package_b":"0.1.0"; diff --git a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/unix/graph-for-bal-file-with-dump-raw-graphs.txt b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/unix/graph-for-bal-file-with-dump-raw-graphs.txt index 5d398a2c2a50..8c3527bb12ee 100644 --- a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/unix/graph-for-bal-file-with-dump-raw-graphs.txt +++ b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/unix/graph-for-bal-file-with-dump-raw-graphs.txt @@ -2,7 +2,7 @@ digraph "Initial" { node [shape=record] "$anon/." [label="<0.0.0> $anon/.:0.0.0"]; "foo/package_b" [label="<0.1.0> foo/package_b:0.1.0"]; - "foo/package_c" [label="<0.1.0> foo/package_c:0.1.0"]; + "foo/package_c" [unresolved="true",color="grey",label="<0.1.0> foo/package_c:0.1.0"]; // Edges "$anon/.":"0.0.0" -> "foo/package_b":"0.1.0"; @@ -46,7 +46,7 @@ digraph "Initial" { node [shape=record] "$anon/." [label="<0.0.0> $anon/.:0.0.0"]; "foo/package_b" [label="<0.1.0> foo/package_b:0.1.0"]; - "foo/package_c" [label="<0.1.0> foo/package_c:0.1.0"]; + "foo/package_c" [unresolved="true",color="grey",label="<0.1.0> foo/package_c:0.1.0"]; // Edges "$anon/.":"0.0.0" -> "foo/package_b":"0.1.0"; diff --git a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/unix/graph-for-bal-project-missing-dir-dep.txt b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/unix/graph-for-bal-project-missing-dir-dep.txt index b227834b31e2..ff6e9f66517a 100644 --- a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/unix/graph-for-bal-project-missing-dir-dep.txt +++ b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/unix/graph-for-bal-project-missing-dir-dep.txt @@ -1,7 +1,8 @@ digraph "foo/package_y:0.1.0" { node [shape=record] "foo/package_y" [label="<0.1.0> foo/package_y:0.1.0"]; + "foo/package_z" [unresolved="true",color="grey",label="foo/package_z"]; // Edges - + "foo/package_y":"0.1.0" -> "foo/package_z"; } \ No newline at end of file diff --git a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/unix/graph-for-bal-project-missing-trans-dep.txt b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/unix/graph-for-bal-project-missing-trans-dep.txt index 3a315712eb6b..3a0a33407be7 100644 --- a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/unix/graph-for-bal-project-missing-trans-dep.txt +++ b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/unix/graph-for-bal-project-missing-trans-dep.txt @@ -2,7 +2,7 @@ digraph "foo/package_x:0.1.0" { node [shape=record] "foo/package_x" [label="<0.1.0> foo/package_x:0.1.0"]; "foo/package_y" [label="<0.1.0> foo/package_y:0.1.0"]; - "foo/package_z" [label="<0.1.0> foo/package_z:0.1.0"]; + "foo/package_z" [unresolved="true",color="grey",label="<0.1.0> foo/package_z:0.1.0"]; // Edges "foo/package_x":"0.1.0" -> "foo/package_y":"0.1.0"; diff --git a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/unix/graph-for-bal-project-with-dump-raw-graphs.txt b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/unix/graph-for-bal-project-with-dump-raw-graphs.txt index 21ac0ffacaee..0dd2ff8d166c 100644 --- a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/unix/graph-for-bal-project-with-dump-raw-graphs.txt +++ b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/unix/graph-for-bal-project-with-dump-raw-graphs.txt @@ -2,7 +2,7 @@ digraph "Initial" { node [shape=record] "foo/package_a" [label="<0.1.0> foo/package_a:0.1.0"]; "foo/package_b" [label="<0.1.0> foo/package_b:0.1.0"]; - "foo/package_c" [label="<0.1.0> foo/package_c:0.1.0"]; + "foo/package_c" [unresolved="true",color="grey",label="<0.1.0> foo/package_c:0.1.0"]; // Edges "foo/package_a":"0.1.0" -> "foo/package_b":"0.1.0"; @@ -46,7 +46,7 @@ digraph "Initial" { node [shape=record] "foo/package_a" [label="<0.1.0> foo/package_a:0.1.0"]; "foo/package_b" [label="<0.1.0> foo/package_b:0.1.0"]; - "foo/package_c" [label="<0.1.0> foo/package_c:0.1.0"]; + "foo/package_c" [unresolved="true",color="grey",label="<0.1.0> foo/package_c:0.1.0"]; // Edges "foo/package_a":"0.1.0" -> "foo/package_b":"0.1.0"; diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/DotGraphs.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/DotGraphs.java index a331fa02c9c6..fb2c7fff2c2d 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/DotGraphs.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/DotGraphs.java @@ -28,6 +28,7 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.StringJoiner; @@ -44,17 +45,36 @@ private DotGraphs() { public static String serializeResolvedPackageDependencyGraph( DependencyGraph dependencyGraph) { - return serializeDependencyNodeGraph(toDependencyNodeGraph(dependencyGraph)); + return serializeDependencyNodeGraph(toDependencyNodeGraph(dependencyGraph), Collections.emptyList()); } - public static String serializeDependencyNodeGraph(DependencyGraph dependencyGraph) { - return serializeDependencyNodeGraph(dependencyGraph, getGraphName(dependencyGraph)); + public static String serializeDependencyNodeGraph(DependencyGraph dependencyGraph, + Collection unresolvedNodes) { + return serializeDependencyNodeGraph(dependencyGraph, getGraphName(dependencyGraph), unresolvedNodes); } public static String serializeDependencyNodeGraph(DependencyGraph dependencyGraph, - String graphName) { + Collection unresolvedNodes, + Collection missingDirectDeps) { + return serializeDependencyNodeGraph( + dependencyGraph, getGraphName(dependencyGraph), unresolvedNodes, missingDirectDeps); + } + + public static String serializeDependencyNodeGraph(DependencyGraph dependencyGraph, + String graphName, Collection unresolvedNodes) { + return serializeDependencyNodeGraph(dependencyGraph, graphName, unresolvedNodes, Collections.emptyList()); + } + + public static String serializeDependencyNodeGraph(DependencyGraph dependencyGraph, + String graphName, Collection unresolvedNodes, + Collection missingDirectDeps) { PackageVersionContainer pkgContainer = new PackageVersionContainer<>(); + for (DependencyNode missingDirectDep : missingDirectDeps) { + PackageDescriptor pkgDesc = missingDirectDep.pkgDesc(); + pkgContainer.add(pkgDesc.org(), pkgDesc.name(), pkgDesc.version(), missingDirectDep); + } + for (DependencyNode depNode : dependencyGraph.getNodes()) { PackageDescriptor pkgDesc = depNode.pkgDesc(); if (pkgDesc.isLangLibPackage()) { @@ -70,14 +90,21 @@ public static String serializeDependencyNodeGraph(DependencyGraph visitedNodes = new PackageContainer<>(); - List sortedList = dependencyGraph.toTopologicallySortedList(); + List sortedList = new ArrayList<>(dependencyGraph.toTopologicallySortedList()); + for (DependencyNode missingDirectDep : missingDirectDeps) { + sortedList.add(sortedList.indexOf(dependencyGraph.getRoot()), missingDirectDep); + } + for (int i = sortedList.size() - 1; i >= 0; i--) { DependencyNode depNode = sortedList.get(i); if (depNode.pkgDesc().isLangLibPackage()) { continue; } - - for (DependencyNode directDep : dependencyGraph.getDirectDependencies(depNode)) { + Collection directDependencies = dependencyGraph.getDirectDependencies(depNode); + if (depNode.equals(dependencyGraph.getRoot())) { + directDependencies.addAll(missingDirectDeps); + } + for (DependencyNode directDep : directDependencies) { if (directDep.pkgDesc().isLangLibPackage()) { continue; } @@ -88,7 +115,7 @@ public static String serializeDependencyNodeGraph(DependencyGraph pkgContainer) { + PackageVersionContainer pkgContainer, boolean isUnresolved) { StringJoiner attrs = new StringJoiner(",", getNodeLabel(depNode.pkgDesc()) + " [", "];"); String labelAttr = getNodeLabelAttr(depNode, pkgContainer); if (depNode.scope() == PackageDependencyScope.TEST_ONLY) { @@ -130,6 +157,9 @@ private static String getNodeLine(DependencyNode depNode, } if (depNode.errorNode()) { attrs.add(getErrorNodeLine()); + } else if (isUnresolved) { + attrs.add(getUnresolvedNodeLine()); + attrs.add(addColorLine("grey")); } attrs.add(labelAttr); return attrs.toString(); @@ -142,7 +172,9 @@ private static String getNodeLabelAttr(DependencyNode depNode, List sortedDepNodes = sortVersions(unSortedDepNodes); StringJoiner labelAttr = new StringJoiner(" | ", "label=\"", "\""); for (DependencyNode sortedDepNode : sortedDepNodes) { - labelAttr.add("<" + sortedDepNode.pkgDesc().version() + "> " + sortedDepNode.pkgDesc()); + String version = sortedDepNode.pkgDesc().version() == null ? + "" : "<" + sortedDepNode.pkgDesc().version() + "> "; + labelAttr.add(version + sortedDepNode.pkgDesc()); } return labelAttr.toString(); } @@ -194,6 +226,14 @@ private static String getErrorNodeLine() { return "error=\"true\""; } + private static String getUnresolvedNodeLine() { + return "unresolved=\"true\""; + } + + private static String addColorLine(String color) { + return "color=\"" + color + "\""; + } + private static DependencyGraph toDependencyNodeGraph( DependencyGraph dependencyGraph) { DependencyNode rootNode = toDependencyNode(dependencyGraph.getRoot()); diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageDependencyGraphBuilder.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageDependencyGraphBuilder.java index 28482f29ad77..109194a7624d 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageDependencyGraphBuilder.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/PackageDependencyGraphBuilder.java @@ -203,6 +203,10 @@ public DependencyGraph rawGraph() { return rawGraphBuilder.build(); } + void addUnresolvedDirectDepToRawGraph(DependencyNode unresolvedDirectDep) { + rawGraphBuilder.addDependency(this.rootDepNode, unresolvedDirectDep); + } + private NodeStatus addDependencyInternal(PackageDescriptor dependent, DependencyNode dependencyNode, boolean unresolved) { diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ResolutionEngine.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ResolutionEngine.java index 588052a77639..193892813753 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ResolutionEngine.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ResolutionEngine.java @@ -40,9 +40,11 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.Objects; import java.util.Optional; +import java.util.Set; import java.util.stream.Collectors; /** @@ -60,6 +62,7 @@ public class ResolutionEngine { private final List diagnostics; private String dependencyGraphDump; private DiagnosticResult diagnosticResult; + private Set unresolvedDeps = null; public ResolutionEngine(PackageDescriptor rootPkgDesc, BlendedManifest blendedManifest, @@ -74,7 +77,7 @@ public ResolutionEngine(PackageDescriptor rootPkgDesc, this.graphBuilder = new PackageDependencyGraphBuilder(rootPkgDesc, resolutionOptions); this.diagnostics = new ArrayList<>(); - dependencyGraphDump = ""; + this.dependencyGraphDump = ""; } public DiagnosticResult diagnosticResult() { @@ -168,9 +171,20 @@ private void populateStaticDependencyGraph(Collection directDepe directDependencies.removeAll(errorNodes); Collection pkgMetadataResponses = resolveDirectDependencies(directDependencies); + this.unresolvedDeps = new HashSet<>(); + Set resolvedDeps = new HashSet<>(); for (PackageMetadataResponse resolutionResp : pkgMetadataResponses) { if (resolutionResp.resolutionStatus() == ResolutionResponse.ResolutionStatus.UNRESOLVED) { // TODO Report diagnostics + if (resolutionOptions.dumpRawGraphs() || resolutionOptions.dumpGraph()) { + ResolutionRequest resolutionRequest = resolutionResp.packageLoadRequest(); + DependencyNode dependencyNode = new DependencyNode( + resolutionRequest.packageDescriptor(), + resolutionRequest.scope(), + resolutionRequest.resolutionType()); + unresolvedDeps.add(dependencyNode); + graphBuilder.addUnresolvedDirectDepToRawGraph(dependencyNode); + } continue; } ResolutionRequest resolutionReq = resolutionResp.packageLoadRequest(); @@ -188,8 +202,13 @@ private void populateStaticDependencyGraph(Collection directDepe resolvedPkgDesc.toString())), scope, resolutionType); } + resolvedDeps.add(new DependencyNode(resolvedPkgDesc, scope, resolutionType)); + } + if (resolutionOptions.dumpRawGraphs() || resolutionOptions.dumpGraph()) { + HashSet unresolvedNodes = new HashSet<>(graphBuilder.getAllDependencies()); + unresolvedNodes.removeAll(resolvedDeps); + unresolvedDeps.addAll(unresolvedNodes); } - dumpInitialGraph(); } @@ -309,6 +328,9 @@ private void updateDependencyVersions() { private void addErrorNodesToGraph(List errorNodes) { for (DependencyNode errorNode : errorNodes) { graphBuilder.addErrorNode(errorNode.pkgDesc, errorNode.scope, errorNode.resolutionType); + if (resolutionOptions.dumpGraph() || resolutionOptions.dumpRawGraphs()) { + unresolvedDeps.remove(errorNode); + } } } @@ -433,6 +455,11 @@ private void addNodeToGraph(PackageMetadataResponse resolutionResp) { pkgDesc.toString())), scope, resolvedType); } + + // Remove from the unresolved nodes list for dumping the raw graph + if (resolutionOptions.dumpGraph() || resolutionOptions.dumpRawGraphs()) { + unresolvedDeps.remove(new DependencyNode(pkgDesc, scope, resolvedType)); + } } private DependencyGraph buildFinalDependencyGraph() { @@ -446,7 +473,6 @@ private void dumpInitialGraph() { if (!resolutionOptions.dumpRawGraphs()) { return; } - String serializedGraph = serializeRawGraph("Initial"); dependencyGraphDump += "\n"; dependencyGraphDump += (serializedGraph + "\n"); @@ -467,11 +493,19 @@ private void dumpFinalGraph(DependencyGraph dependencyGraph) { return; } + List unresolvedDirectDeps = new ArrayList<>( + graphBuilder.rawGraph().getDirectDependencies(dependencyGraph.getRoot())); + Collection resolvedDirectDeps = + dependencyGraph.getDirectDependencies(dependencyGraph.getRoot()); + unresolvedDirectDeps.removeAll(resolvedDirectDeps); + String serializedGraph; if (resolutionOptions.dumpRawGraphs()) { - serializedGraph = DotGraphs.serializeDependencyNodeGraph(dependencyGraph, "Final"); + serializedGraph = DotGraphs.serializeDependencyNodeGraph( + dependencyGraph, "Final", this.unresolvedDeps, unresolvedDirectDeps); } else { - serializedGraph = DotGraphs.serializeDependencyNodeGraph(dependencyGraph); + serializedGraph = DotGraphs.serializeDependencyNodeGraph( + dependencyGraph, this.unresolvedDeps, unresolvedDirectDeps); } dependencyGraphDump += "\n"; dependencyGraphDump += (serializedGraph + "\n"); @@ -479,7 +513,7 @@ private void dumpFinalGraph(DependencyGraph dependencyGraph) { private String serializeRawGraph(String graphName) { DependencyGraph initialGraph = graphBuilder.rawGraph(); - return DotGraphs.serializeDependencyNodeGraph(initialGraph, graphName); + return DotGraphs.serializeDependencyNodeGraph(initialGraph, graphName, this.unresolvedDeps); } public String dumpGraphs() { diff --git a/compiler/ballerina-lang/src/test/java/io/ballerina/projects/DotGraphsTests.java b/compiler/ballerina-lang/src/test/java/io/ballerina/projects/DotGraphsTests.java index 01e32f2ba755..47148ca575d6 100644 --- a/compiler/ballerina-lang/src/test/java/io/ballerina/projects/DotGraphsTests.java +++ b/compiler/ballerina-lang/src/test/java/io/ballerina/projects/DotGraphsTests.java @@ -29,6 +29,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.Collection; +import java.util.Collections; import java.util.StringJoiner; /** @@ -47,7 +48,7 @@ public void test() { DependencyGraph expectedGraph = DotGraphUtils.createDependencyNodeGraph(expectedMutableGraph); - String serializedGraph = DotGraphs.serializeDependencyNodeGraph(expectedGraph); + String serializedGraph = DotGraphs.serializeDependencyNodeGraph(expectedGraph, Collections.emptyList()); MutableGraph actualMutableGraph = DotGraphUtils.createGraph(serializedGraph); DependencyGraph actualGraph = DotGraphUtils.createDependencyNodeGraph(actualMutableGraph); From f798369238963101de32e073285ff23fb8ca1329 Mon Sep 17 00:00:00 2001 From: azinneera Date: Wed, 14 Dec 2022 13:55:16 +0530 Subject: [PATCH 303/450] Fix enabling cache generation for TestCommand --- .../src/main/java/io/ballerina/cli/cmd/TestCommand.java | 1 + .../src/test/java/io/ballerina/cli/cmd/BuildCommandTest.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/TestCommand.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/TestCommand.java index 5e373027fbd9..f7f0790cce30 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/TestCommand.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/TestCommand.java @@ -328,6 +328,7 @@ private BuildOptions constructBuildOptions() { .setDumpGraph(dumpGraph) .setDumpRawGraphs(dumpRawGraphs) .setNativeImage(nativeImage) + .setEnableCache(enableCache) .build(); if (targetDir != null) { diff --git a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/BuildCommandTest.java b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/BuildCommandTest.java index c6fcaacd4841..7f6bceffaeb1 100644 --- a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/BuildCommandTest.java +++ b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/BuildCommandTest.java @@ -866,7 +866,7 @@ public void testBirCachedProjectBuildPerformanceAfterTestCommand() { buildCommand.execute(); long secondCodeGenDuration = BuildTime.getInstance().codeGenDuration; - Assert.assertTrue(firstCodeGenDuration > secondCodeGenDuration, + Assert.assertTrue((firstCodeGenDuration / 10) > secondCodeGenDuration, "second code gen duration is greater than the expected value"); } From 36974e7280b4d80437fd989e19e300a31fb2d618 Mon Sep 17 00:00:00 2001 From: azinneera Date: Thu, 15 Dec 2022 13:19:30 +0530 Subject: [PATCH 304/450] Update command graph test outputs for windows --- .../windows/build-project-with-dump-raw-graphs.txt | 4 ++-- .../windows/graph-for-bal-file-with-dump-raw-graphs.txt | 4 ++-- .../windows/graph-for-bal-project-missing-dir-dep.txt | 3 ++- .../windows/graph-for-bal-project-missing-trans-dep.txt | 2 +- .../windows/graph-for-bal-project-with-dump-raw-graphs.txt | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/build-project-with-dump-raw-graphs.txt b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/build-project-with-dump-raw-graphs.txt index 831c5dbfb941..cb2a5b376eae 100644 --- a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/build-project-with-dump-raw-graphs.txt +++ b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/build-project-with-dump-raw-graphs.txt @@ -7,7 +7,7 @@ digraph "Initial" { node [shape=record] "foo/package_a" [label="<0.1.0> foo/package_a:0.1.0"]; "foo/package_b" [label="<0.1.0> foo/package_b:0.1.0"]; - "foo/package_c" [label="<0.1.0> foo/package_c:0.1.0"]; + "foo/package_c" [unresolved="true",color="grey",label="<0.1.0> foo/package_c:0.1.0"]; // Edges "foo/package_a":"0.1.0" -> "foo/package_b":"0.1.0"; @@ -51,7 +51,7 @@ digraph "Initial" { node [shape=record] "foo/package_a" [label="<0.1.0> foo/package_a:0.1.0"]; "foo/package_b" [label="<0.1.0> foo/package_b:0.1.0"]; - "foo/package_c" [label="<0.1.0> foo/package_c:0.1.0"]; + "foo/package_c" [unresolved="true",color="grey",label="<0.1.0> foo/package_c:0.1.0"]; // Edges "foo/package_a":"0.1.0" -> "foo/package_b":"0.1.0"; diff --git a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/graph-for-bal-file-with-dump-raw-graphs.txt b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/graph-for-bal-file-with-dump-raw-graphs.txt index 5d398a2c2a50..8c3527bb12ee 100644 --- a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/graph-for-bal-file-with-dump-raw-graphs.txt +++ b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/graph-for-bal-file-with-dump-raw-graphs.txt @@ -2,7 +2,7 @@ digraph "Initial" { node [shape=record] "$anon/." [label="<0.0.0> $anon/.:0.0.0"]; "foo/package_b" [label="<0.1.0> foo/package_b:0.1.0"]; - "foo/package_c" [label="<0.1.0> foo/package_c:0.1.0"]; + "foo/package_c" [unresolved="true",color="grey",label="<0.1.0> foo/package_c:0.1.0"]; // Edges "$anon/.":"0.0.0" -> "foo/package_b":"0.1.0"; @@ -46,7 +46,7 @@ digraph "Initial" { node [shape=record] "$anon/." [label="<0.0.0> $anon/.:0.0.0"]; "foo/package_b" [label="<0.1.0> foo/package_b:0.1.0"]; - "foo/package_c" [label="<0.1.0> foo/package_c:0.1.0"]; + "foo/package_c" [unresolved="true",color="grey",label="<0.1.0> foo/package_c:0.1.0"]; // Edges "$anon/.":"0.0.0" -> "foo/package_b":"0.1.0"; diff --git a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/graph-for-bal-project-missing-dir-dep.txt b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/graph-for-bal-project-missing-dir-dep.txt index b227834b31e2..ff6e9f66517a 100644 --- a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/graph-for-bal-project-missing-dir-dep.txt +++ b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/graph-for-bal-project-missing-dir-dep.txt @@ -1,7 +1,8 @@ digraph "foo/package_y:0.1.0" { node [shape=record] "foo/package_y" [label="<0.1.0> foo/package_y:0.1.0"]; + "foo/package_z" [unresolved="true",color="grey",label="foo/package_z"]; // Edges - + "foo/package_y":"0.1.0" -> "foo/package_z"; } \ No newline at end of file diff --git a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/graph-for-bal-project-missing-trans-dep.txt b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/graph-for-bal-project-missing-trans-dep.txt index 3a315712eb6b..3a0a33407be7 100644 --- a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/graph-for-bal-project-missing-trans-dep.txt +++ b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/graph-for-bal-project-missing-trans-dep.txt @@ -2,7 +2,7 @@ digraph "foo/package_x:0.1.0" { node [shape=record] "foo/package_x" [label="<0.1.0> foo/package_x:0.1.0"]; "foo/package_y" [label="<0.1.0> foo/package_y:0.1.0"]; - "foo/package_z" [label="<0.1.0> foo/package_z:0.1.0"]; + "foo/package_z" [unresolved="true",color="grey",label="<0.1.0> foo/package_z:0.1.0"]; // Edges "foo/package_x":"0.1.0" -> "foo/package_y":"0.1.0"; diff --git a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/graph-for-bal-project-with-dump-raw-graphs.txt b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/graph-for-bal-project-with-dump-raw-graphs.txt index 21ac0ffacaee..0dd2ff8d166c 100644 --- a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/graph-for-bal-project-with-dump-raw-graphs.txt +++ b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/graph-for-bal-project-with-dump-raw-graphs.txt @@ -2,7 +2,7 @@ digraph "Initial" { node [shape=record] "foo/package_a" [label="<0.1.0> foo/package_a:0.1.0"]; "foo/package_b" [label="<0.1.0> foo/package_b:0.1.0"]; - "foo/package_c" [label="<0.1.0> foo/package_c:0.1.0"]; + "foo/package_c" [unresolved="true",color="grey",label="<0.1.0> foo/package_c:0.1.0"]; // Edges "foo/package_a":"0.1.0" -> "foo/package_b":"0.1.0"; @@ -46,7 +46,7 @@ digraph "Initial" { node [shape=record] "foo/package_a" [label="<0.1.0> foo/package_a:0.1.0"]; "foo/package_b" [label="<0.1.0> foo/package_b:0.1.0"]; - "foo/package_c" [label="<0.1.0> foo/package_c:0.1.0"]; + "foo/package_c" [unresolved="true",color="grey",label="<0.1.0> foo/package_c:0.1.0"]; // Edges "foo/package_a":"0.1.0" -> "foo/package_b":"0.1.0"; From da0b50541ac1d1e0704108af7f05636b08d07bf1 Mon Sep 17 00:00:00 2001 From: sanjana Date: Thu, 1 Dec 2022 14:30:27 +0530 Subject: [PATCH 305/450] Add examples for int langlib functions --- langlib/lang.int/src/main/ballerina/int.bal | 44 +++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/langlib/lang.int/src/main/ballerina/int.bal b/langlib/lang.int/src/main/ballerina/int.bal index 6560c5b743a1..d55ebad82980 100644 --- a/langlib/lang.int/src/main/ballerina/int.bal +++ b/langlib/lang.int/src/main/ballerina/int.bal @@ -81,6 +81,11 @@ public const int UNSIGNED8_MAX_VALUE = 255; # Returns the absolute value of an int value. # +# ```ballerina +# int distance = -25; +# int distance = vectorDisplacement.abs(); +# ``` +# # + n - int value to be operated on # + return - absolute value of parameter `n` public isolated function abs(int n) returns int = @java:Method { @@ -90,6 +95,14 @@ public isolated function abs(int n) returns int = @java:Method { # Returns sum of zero or more int values. # +# ```ballerina +# // Retrieving the total out of the list of integers +# int totalValue = int:sum(10, 20, 30, 40); +# +# int initialScore = 4; +# // Retrieving the total by adding the list of integers with the initial value passed +# int totalScore = initialScore.sum(5, 6, 7); +# ``` # + ns - int values to sum # + return - sum of all of parameter `ns`; 0 if parameter `ns` is empty public isolated function sum(int... ns) returns int = @java:Method { @@ -99,6 +112,14 @@ public isolated function sum(int... ns) returns int = @java:Method { # Returns the maximum of one or more int values. # +# ```ballerina +# // Retrieving the highest value out of the list of integers +# int highestMark = int:max(50, 20, 30, 70, 65); +# +# int initialScore = 5; +# // Retrieving the maximum integer out of the list of integers including `initialScore` +# int highestScore = initialScore.max(4, 8, 9); +# ``` # + n - first int value # + ns - other int values # + return - maximum value of value of parameter `n` and all of parameter `ns` @@ -109,6 +130,15 @@ public isolated function max(int n, int... ns) returns int = @java:Method { # Returns the minimum of one or more int values. # +# ```ballerina +# // Retrieving the lowest value out of the list of integers +# int lowerstMark = int:min(45, 25, 30, 75, 50); +# +# // Retrieving the minimum value out of the list of integers +# int startingScore = 10; +# int lowerstScore = startingScore.min(10, 25, 2, 8, 17); +# ``` +# # + n - first int value # + ns - other int values # + return - minimum value of parameter `n` and all of parameter `ns` @@ -123,6 +153,10 @@ public isolated function min(int n, int... ns) returns int = @java:Method { # The first character may be `+` or `-`. # This is the inverse of function ``value:toString`` applied to an `int`. # +# ```ballerina +# int number = check int:fromString("56"); +# ``` +# # + s - string representation of a integer value # + return - int representation of the argument or error public isolated function fromString(string s) returns int|error = @java:Method { @@ -136,6 +170,11 @@ public isolated function fromString(string s) returns int|error = @java:Method { # Negative numbers will have a `-` prefix. No sign for # non-negative numbers. # +# ```ballerina +# int number = 25; +# string hexNumber = number.toHexString(); +# ``` +# # + n - int value # + return - hexadecimal string representation of int value public isolated function toHexString(int n) returns string = @java:Method { @@ -150,6 +189,11 @@ public isolated function toHexString(int n) returns string = @java:Method { # No `0x` or `0X` prefix is allowed. # Returns an error if the parameter `s` is not in an allowed format. # +# ```ballerina +# string hexStr = "1A6F"; +# int number = check int:fromHexString(hexStr); +# ``` +# # + s - hexadecimal string representation of int value # + return - int value or error public isolated function fromHexString(string s) returns int|error = @java:Method { From 4a527eeb360764d762f01ceaf0ceffeb960d7633 Mon Sep 17 00:00:00 2001 From: sanjana Date: Mon, 5 Dec 2022 17:55:35 +0530 Subject: [PATCH 306/450] Update example docs of int langlib --- langlib/lang.int/src/main/ballerina/int.bal | 33 ++++++++++++++------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/langlib/lang.int/src/main/ballerina/int.bal b/langlib/lang.int/src/main/ballerina/int.bal index d55ebad82980..302188c64c94 100644 --- a/langlib/lang.int/src/main/ballerina/int.bal +++ b/langlib/lang.int/src/main/ballerina/int.bal @@ -82,8 +82,8 @@ public const int UNSIGNED8_MAX_VALUE = 255; # Returns the absolute value of an int value. # # ```ballerina -# int distance = -25; -# int distance = vectorDisplacement.abs(); +# int velocity = -25; +# int speed = velocity.abs(); # ``` # # + n - int value to be operated on @@ -96,11 +96,15 @@ public isolated function abs(int n) returns int = @java:Method { # Returns sum of zero or more int values. # # ```ballerina -# // Retrieving the total out of the list of integers +# // Compute the sum of multiple integers. # int totalValue = int:sum(10, 20, 30, 40); # +# // Compute the sum of the members in an array of integers. +# int[] marks = [50, 65, 78, 95]; +# int total = int:sum(...marks); +# +# // Compute the sum using the method call expression with an int variable. # int initialScore = 4; -# // Retrieving the total by adding the list of integers with the initial value passed # int totalScore = initialScore.sum(5, 6, 7); # ``` # + ns - int values to sum @@ -113,11 +117,15 @@ public isolated function sum(int... ns) returns int = @java:Method { # Returns the maximum of one or more int values. # # ```ballerina -# // Retrieving the highest value out of the list of integers +# // Get the maximum value out of the list of integers. # int highestMark = int:max(50, 20, 30, 70, 65); # +# // Get the maximum value out of the members in an array of integers. +# int[] marks = [25, 50, 70, 80, 94]; +# int highestMark = int:max(...marks); +# +# // Get the maximum value using the method call expression with an int variable. # int initialScore = 5; -# // Retrieving the maximum integer out of the list of integers including `initialScore` # int highestScore = initialScore.max(4, 8, 9); # ``` # + n - first int value @@ -131,10 +139,14 @@ public isolated function max(int n, int... ns) returns int = @java:Method { # Returns the minimum of one or more int values. # # ```ballerina -# // Retrieving the lowest value out of the list of integers +# // Get the minimum value out of the list of integers. # int lowerstMark = int:min(45, 25, 30, 75, 50); # -# // Retrieving the minimum value out of the list of integers +# // Get the minimum value out of the members in an array of integers. +# int[] marks = [23, 48, 59, 28, 47, 86]; +# int lowerstMark = int:min(...marks); +# +# // Get the minimum value out of the list of integers using method call expression. # int startingScore = 10; # int lowerstScore = startingScore.min(10, 25, 2, 8, 17); # ``` @@ -154,7 +166,8 @@ public isolated function min(int n, int... ns) returns int = @java:Method { # This is the inverse of function ``value:toString`` applied to an `int`. # # ```ballerina -# int number = check int:fromString("56"); +# string numericStr = "56"; +# int number = check int:fromString(numericStr); # ``` # # + s - string representation of a integer value @@ -172,7 +185,7 @@ public isolated function fromString(string s) returns int|error = @java:Method { # # ```ballerina # int number = 25; -# string hexNumber = number.toHexString(); +# string hexStringRepr = number.toHexString(); # ``` # # + n - int value From 4493ca15a517c0f8509133a2b969e42fb14351a1 Mon Sep 17 00:00:00 2001 From: sanjana Date: Mon, 5 Dec 2022 08:13:23 +0530 Subject: [PATCH 307/450] Address review suggestions --- langlib/lang.int/src/main/ballerina/int.bal | 26 ++++++--------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/langlib/lang.int/src/main/ballerina/int.bal b/langlib/lang.int/src/main/ballerina/int.bal index 302188c64c94..c8ab83dce6b5 100644 --- a/langlib/lang.int/src/main/ballerina/int.bal +++ b/langlib/lang.int/src/main/ballerina/int.bal @@ -96,14 +96,10 @@ public isolated function abs(int n) returns int = @java:Method { # Returns sum of zero or more int values. # # ```ballerina -# // Compute the sum of multiple integers. +# // Retrieve the sum of multiple integers. # int totalValue = int:sum(10, 20, 30, 40); # -# // Compute the sum of the members in an array of integers. -# int[] marks = [50, 65, 78, 95]; -# int total = int:sum(...marks); -# -# // Compute the sum using the method call expression with an int variable. +# // Retrieve the sum using the method call expression. # int initialScore = 4; # int totalScore = initialScore.sum(5, 6, 7); # ``` @@ -117,14 +113,10 @@ public isolated function sum(int... ns) returns int = @java:Method { # Returns the maximum of one or more int values. # # ```ballerina -# // Get the maximum value out of the list of integers. +# // Retrieve the maximum value out of the list of integers. # int highestMark = int:max(50, 20, 30, 70, 65); # -# // Get the maximum value out of the members in an array of integers. -# int[] marks = [25, 50, 70, 80, 94]; -# int highestMark = int:max(...marks); -# -# // Get the maximum value using the method call expression with an int variable. +# // Retrieve the maximum value out of the list of integers using method call expression. # int initialScore = 5; # int highestScore = initialScore.max(4, 8, 9); # ``` @@ -139,14 +131,10 @@ public isolated function max(int n, int... ns) returns int = @java:Method { # Returns the minimum of one or more int values. # # ```ballerina -# // Get the minimum value out of the list of integers. +# // Retrieve the minimum value out of the list of integers. # int lowerstMark = int:min(45, 25, 30, 75, 50); # -# // Get the minimum value out of the members in an array of integers. -# int[] marks = [23, 48, 59, 28, 47, 86]; -# int lowerstMark = int:min(...marks); -# -# // Get the minimum value out of the list of integers using method call expression. +# // Retrieve the minimum value out of the list of integers using method call expression. # int startingScore = 10; # int lowerstScore = startingScore.min(10, 25, 2, 8, 17); # ``` @@ -185,7 +173,7 @@ public isolated function fromString(string s) returns int|error = @java:Method { # # ```ballerina # int number = 25; -# string hexStringRepr = number.toHexString(); +# string hexNumber = number.toHexString(); # ``` # # + n - int value From 27a7f9aca34a392b5c8827a739d7cb0eb352b663 Mon Sep 17 00:00:00 2001 From: sanjana Date: Tue, 6 Dec 2022 14:33:51 +0530 Subject: [PATCH 308/450] Fix failing junit test --- .../test-src/object/object_field_initializer_with_check.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/object/object_field_initializer_with_check.bal b/tests/jballerina-unit-test/src/test/resources/test-src/object/object_field_initializer_with_check.bal index 8a9f8e118ea8..bb049f7232a4 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/object/object_field_initializer_with_check.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/object/object_field_initializer_with_check.bal @@ -84,7 +84,7 @@ function testCheckInObjectFieldInitializer2() { assertEquality("'string' value 'invalid' cannot be converted to 'int'", checkpanic e.detail()["message"]); error:StackFrame[] callStack = e.stackTrace(); int callStackLength = callStack.length(); - assertEquality("callableName: fromString moduleName: ballerina.lang.int.0 fileName: int.bal lineNumber: 128", + assertEquality("callableName: fromString moduleName: ballerina.lang.int.0 fileName: int.bal lineNumber: 163", callStack[callStackLength - 2].toString()); } From 0777166b8fa7fc10bb63059db5a45907762f7d10 Mon Sep 17 00:00:00 2001 From: azinneera Date: Wed, 14 Dec 2022 14:34:24 +0530 Subject: [PATCH 309/450] Avoid creating the bir if code gen phase has errors --- .../io/ballerina/projects/ModuleContext.java | 5 +++++ .../projects/test/TestBirAndJarCache.java | 17 +++++++++++++++++ .../Ballerina.toml | 8 ++++++++ .../project_with_nonexisting_interop/main.bal | 9 +++++++++ 4 files changed, 39 insertions(+) create mode 100644 project-api/project-api-test/src/test/resources/project_with_nonexisting_interop/Ballerina.toml create mode 100644 project-api/project-api-test/src/test/resources/project_with_nonexisting_interop/main.bal diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleContext.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleContext.java index 811a9bd7da2a..7df7827cee86 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleContext.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ModuleContext.java @@ -476,6 +476,11 @@ static void generateCodeInternal(ModuleContext moduleContext, // Generate and write the thin JAR to the file system compilerBackend.performCodeGen(moduleContext, moduleContext.compilationCache); + // Skip bir caching if jar generation is not successful + if (Diagnostics.hasErrors(moduleContext.diagnostics())) { + return; + } + if (birContent == null) { return; } diff --git a/project-api/project-api-test/src/test/java/io/ballerina/projects/test/TestBirAndJarCache.java b/project-api/project-api-test/src/test/java/io/ballerina/projects/test/TestBirAndJarCache.java index 0d621ff8a3b5..7da57ad0f946 100644 --- a/project-api/project-api-test/src/test/java/io/ballerina/projects/test/TestBirAndJarCache.java +++ b/project-api/project-api-test/src/test/java/io/ballerina/projects/test/TestBirAndJarCache.java @@ -31,6 +31,7 @@ import io.ballerina.projects.Project; import io.ballerina.projects.ProjectEnvironmentBuilder; import io.ballerina.projects.directory.BuildProject; +import io.ballerina.projects.internal.model.Target; import io.ballerina.projects.repos.FileSystemCache; import io.ballerina.projects.util.ProjectConstants; import org.testng.Assert; @@ -105,6 +106,22 @@ public void testBirAndJarCaching() throws IOException { } } + @Test + public void testCachingWhenCodeGenHasErrors() throws IOException { + Path projectPath = RESOURCE_DIRECTORY.resolve("project_with_nonexisting_interop"); + BuildProject buildProject = TestUtils.loadBuildProject(projectPath); + PackageCompilation compilation = buildProject.currentPackage().getCompilation(); + Assert.assertFalse(compilation.diagnosticResult().hasErrors(), + TestUtils.getDiagnosticsAsString(compilation.diagnosticResult())); + + JBallerinaBackend jBallerinaBackend = JBallerinaBackend.from(compilation, JvmTarget.JAVA_11); + Assert.assertEquals(jBallerinaBackend.diagnosticResult().errorCount(), 1, + TestUtils.getDiagnosticsAsString(jBallerinaBackend.diagnosticResult())); + Path cacheDir = new Target(buildProject.targetDir()).cachesPath(); + Assert.assertFalse(Files.exists(cacheDir.resolve(ProjectConstants.REPO_BIR_CACHE_NAME))); + Assert.assertFalse(Files.exists(cacheDir.resolve(jBallerinaBackend.targetPlatform().code()))); + } + /** * An instance of {@code CompilationCacheFactory} used for testing purposes. */ diff --git a/project-api/project-api-test/src/test/resources/project_with_nonexisting_interop/Ballerina.toml b/project-api/project-api-test/src/test/resources/project_with_nonexisting_interop/Ballerina.toml new file mode 100644 index 000000000000..d415f79c3320 --- /dev/null +++ b/project-api/project-api-test/src/test/resources/project_with_nonexisting_interop/Ballerina.toml @@ -0,0 +1,8 @@ +[package] +org = "asmaj" +name = "nonexisting_interop" +version = "0.1.0" +distribution = "2201.3.0" + +[build-options] +observabilityIncluded = false diff --git a/project-api/project-api-test/src/test/resources/project_with_nonexisting_interop/main.bal b/project-api/project-api-test/src/test/resources/project_with_nonexisting_interop/main.bal new file mode 100644 index 000000000000..638f343727d5 --- /dev/null +++ b/project-api/project-api-test/src/test/resources/project_with_nonexisting_interop/main.bal @@ -0,0 +1,9 @@ +import ballerina/jballerina.java; + +public function main() { +} + +function builderWithStudentList(handle list, int index) returns handle = @java:Constructor { + 'class: "a.b.c.Builder", + paramTypes: [{'class: "a.b.c.Student", dimensions:2}, "int"] +} external; From 4a164b3473f53d957fbafab8887288c4914c1ee1 Mon Sep 17 00:00:00 2001 From: sanjana Date: Thu, 8 Dec 2022 08:18:09 +0530 Subject: [PATCH 310/450] Fix failing junit test case --- .../test-src/object/object_field_initializer_with_check.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/object/object_field_initializer_with_check.bal b/tests/jballerina-unit-test/src/test/resources/test-src/object/object_field_initializer_with_check.bal index bb049f7232a4..dc8e8f5c21d3 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/object/object_field_initializer_with_check.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/object/object_field_initializer_with_check.bal @@ -84,7 +84,7 @@ function testCheckInObjectFieldInitializer2() { assertEquality("'string' value 'invalid' cannot be converted to 'int'", checkpanic e.detail()["message"]); error:StackFrame[] callStack = e.stackTrace(); int callStackLength = callStack.length(); - assertEquality("callableName: fromString moduleName: ballerina.lang.int.0 fileName: int.bal lineNumber: 163", + assertEquality("callableName: fromString moduleName: ballerina.lang.int.0 fileName: int.bal lineNumber: 175", callStack[callStackLength - 2].toString()); } From 6950951fd6d2dfe67601ae63b562d888d06b02f8 Mon Sep 17 00:00:00 2001 From: sanjana Date: Thu, 8 Dec 2022 08:25:52 +0530 Subject: [PATCH 311/450] Update failing test case in ForeachErrorHandlingTests --- .../test/statements/foreach/ForeachErrorHandlingTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachErrorHandlingTests.java b/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachErrorHandlingTests.java index bf7e3a952f7f..bbd42c53641d 100644 --- a/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachErrorHandlingTests.java +++ b/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachErrorHandlingTests.java @@ -53,7 +53,7 @@ public void testArrayForeachAndTrap() { @Test(expectedExceptions = BLangRuntimeException.class, expectedExceptionsMessageRegExp = "error: \\{ballerina/lang.int\\}NumberParsingError \\{\"message\":\"'string' value 'waruna' cannot be " + "converted to 'int'\"\\}\n" + - "\tat ballerina.lang.int.0:fromString\\(int.bal:128\\)\n" + + "\tat ballerina.lang.int.0:fromString\\(int.bal:175\\)\n" + "\t foreach_error_handling:\\$lambda\\$_0\\(foreach_error_handling.bal:41\\)") public void testArrayForeachAndPanic() { BRunUtil.invoke(program, "testArrayForeachAndPanic"); From d490c0801c7e73e141ed446db85765cf77dbf7e7 Mon Sep 17 00:00:00 2001 From: sanjana Date: Thu, 15 Dec 2022 13:59:54 +0530 Subject: [PATCH 312/450] Update int langlib examples --- langlib/lang.int/src/main/ballerina/int.bal | 38 +++++++-------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/langlib/lang.int/src/main/ballerina/int.bal b/langlib/lang.int/src/main/ballerina/int.bal index c8ab83dce6b5..bf09000bde81 100644 --- a/langlib/lang.int/src/main/ballerina/int.bal +++ b/langlib/lang.int/src/main/ballerina/int.bal @@ -82,8 +82,8 @@ public const int UNSIGNED8_MAX_VALUE = 255; # Returns the absolute value of an int value. # # ```ballerina -# int velocity = -25; -# int speed = velocity.abs(); +# (-25).abs() ⇒ 25 +# int:abs(-30) ⇒ 30 # ``` # # + n - int value to be operated on @@ -96,13 +96,12 @@ public isolated function abs(int n) returns int = @java:Method { # Returns sum of zero or more int values. # # ```ballerina -# // Retrieve the sum of multiple integers. -# int totalValue = int:sum(10, 20, 30, 40); -# -# // Retrieve the sum using the method call expression. -# int initialScore = 4; -# int totalScore = initialScore.sum(5, 6, 7); +# int:sum(10, 20, 30, 40) ⇒ 100 +# +# int[] marks = [50, 65, 78, 95]; +# int total = int:sum(...marks) ⇒ 288 # ``` +# # + ns - int values to sum # + return - sum of all of parameter `ns`; 0 if parameter `ns` is empty public isolated function sum(int... ns) returns int = @java:Method { @@ -113,12 +112,7 @@ public isolated function sum(int... ns) returns int = @java:Method { # Returns the maximum of one or more int values. # # ```ballerina -# // Retrieve the maximum value out of the list of integers. -# int highestMark = int:max(50, 20, 30, 70, 65); -# -# // Retrieve the maximum value out of the list of integers using method call expression. -# int initialScore = 5; -# int highestScore = initialScore.max(4, 8, 9); +# int:max(50, 20, 30, 70, 65) ⇒ 70 # ``` # + n - first int value # + ns - other int values @@ -131,12 +125,7 @@ public isolated function max(int n, int... ns) returns int = @java:Method { # Returns the minimum of one or more int values. # # ```ballerina -# // Retrieve the minimum value out of the list of integers. -# int lowerstMark = int:min(45, 25, 30, 75, 50); -# -# // Retrieve the minimum value out of the list of integers using method call expression. -# int startingScore = 10; -# int lowerstScore = startingScore.min(10, 25, 2, 8, 17); +# int:min(45, 25, 30, 75, 50) ⇒ 25 # ``` # # + n - first int value @@ -154,8 +143,7 @@ public isolated function min(int n, int... ns) returns int = @java:Method { # This is the inverse of function ``value:toString`` applied to an `int`. # # ```ballerina -# string numericStr = "56"; -# int number = check int:fromString(numericStr); +# check int:fromString("76") ⇒ 76 # ``` # # + s - string representation of a integer value @@ -172,8 +160,7 @@ public isolated function fromString(string s) returns int|error = @java:Method { # non-negative numbers. # # ```ballerina -# int number = 25; -# string hexNumber = number.toHexString(); +# 26.toHexString() ⇒ 1a # ``` # # + n - int value @@ -191,8 +178,7 @@ public isolated function toHexString(int n) returns string = @java:Method { # Returns an error if the parameter `s` is not in an allowed format. # # ```ballerina -# string hexStr = "1A6F"; -# int number = check int:fromHexString(hexStr); +# check int:fromHexString("1A6F") ⇒ 6767 # ``` # # + s - hexadecimal string representation of int value From 1b5066678617d405b645d6bf516f7fc505e76527 Mon Sep 17 00:00:00 2001 From: sanjana Date: Mon, 19 Dec 2022 11:33:51 +0530 Subject: [PATCH 313/450] Update abs() langlib example --- langlib/lang.int/src/main/ballerina/int.bal | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/langlib/lang.int/src/main/ballerina/int.bal b/langlib/lang.int/src/main/ballerina/int.bal index bf09000bde81..6244db102317 100644 --- a/langlib/lang.int/src/main/ballerina/int.bal +++ b/langlib/lang.int/src/main/ballerina/int.bal @@ -82,7 +82,9 @@ public const int UNSIGNED8_MAX_VALUE = 255; # Returns the absolute value of an int value. # # ```ballerina -# (-25).abs() ⇒ 25 +# int n = -25; +# n.abs() ⇒ 25 +# # int:abs(-30) ⇒ 30 # ``` # @@ -113,7 +115,11 @@ public isolated function sum(int... ns) returns int = @java:Method { # # ```ballerina # int:max(50, 20, 30, 70, 65) ⇒ 70 +# +# int n = 18; +# n.max(25, 30, 4, 15) ⇒ 30 # ``` +# # + n - first int value # + ns - other int values # + return - maximum value of value of parameter `n` and all of parameter `ns` @@ -126,6 +132,9 @@ public isolated function max(int n, int... ns) returns int = @java:Method { # # ```ballerina # int:min(45, 25, 30, 75, 50) ⇒ 25 +# +# int m = 23; +# m.min(12, 43, 7, 19) ⇒ 7 # ``` # # + n - first int value @@ -143,7 +152,9 @@ public isolated function min(int n, int... ns) returns int = @java:Method { # This is the inverse of function ``value:toString`` applied to an `int`. # # ```ballerina -# check int:fromString("76") ⇒ 76 +# int:fromString("76") ⇒ 76 +# +# int:fromString("abc") ⇒ error # ``` # # + s - string representation of a integer value @@ -178,7 +189,9 @@ public isolated function toHexString(int n) returns string = @java:Method { # Returns an error if the parameter `s` is not in an allowed format. # # ```ballerina -# check int:fromHexString("1A6F") ⇒ 6767 +# int:fromHexString("1A5F") ⇒ 6751 +# +# int:fromHexString("1Y4K") ⇒ error # ``` # # + s - hexadecimal string representation of int value From d16f365400c3c2a56acdef91b3894aae4b3d8c7d Mon Sep 17 00:00:00 2001 From: sanjana Date: Thu, 8 Dec 2022 10:58:51 +0530 Subject: [PATCH 314/450] Add typedesc langlib function example --- langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal b/langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal index 60fb7aed862b..149ff113cb20 100644 --- a/langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal +++ b/langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal @@ -40,6 +40,12 @@ public type TypeId readonly & record {| |}; # Returns the type-ids induced by a typedesc value. +# +# ```ballerina +# type MyError distinct error; +# typedesc:TypeId[]? & readonly typeIds = MyError.typeIds(); +# ``` +# # + t - the typedesc # + primaryOnly - if true, only the primary type-ids will be returned; otherwise, all type-ids will be returned # + return - an array containing the type-ids induced by `t` or nil if `t` is not definite From 8af2c57ff1dd34010747103080314a499e2ae745 Mon Sep 17 00:00:00 2001 From: sanjana Date: Mon, 19 Dec 2022 13:06:37 +0530 Subject: [PATCH 315/450] Add primary only type id langlib example --- .../src/main/ballerina/typedesc_lib.bal | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal b/langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal index 149ff113cb20..d924a68cc633 100644 --- a/langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal +++ b/langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal @@ -42,8 +42,18 @@ public type TypeId readonly & record {| # Returns the type-ids induced by a typedesc value. # # ```ballerina -# type MyError distinct error; -# typedesc:TypeId[]? & readonly typeIds = MyError.typeIds(); +# type Error distinct error; +# type SampleError distinct (Error & error); +# +# typedesc:TypeId[]? & readonly typeIds = SampleError.typeIds(); +# if (typeIds is typedesc:TypeId[]) { +# io:println(typeIds[typeIds.length() - 1]["localId"]) ⇒ Error +# } +# +# typedesc:TypeId[]? & readonly primaryTypeIds = SampleError.typeIds(true); +# if (primaryTypeIds is typedesc:TypeId[]) { +# io:println(primaryTypeIds[primaryTypeIds.length() - 1]["localId"]) ⇒ SampleError +# } # ``` # # + t - the typedesc From d128dbfcfe316453ce66bc653133fced8e2ea89d Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Tue, 8 Nov 2022 12:29:56 +0530 Subject: [PATCH 316/450] Add utility method to update Json object to replace duplicate names --- misc/json-to-record-converter/build.gradle | 2 + .../jsonmapper/JsonToRecordMapper.java | 15 ++- .../jsonmapper/util/ConverterUtils.java | 109 ++++++++++++++++++ .../src/main/java/module-info.java | 1 + .../JsonToRecordConverterService.java | 2 +- 5 files changed, 124 insertions(+), 5 deletions(-) diff --git a/misc/json-to-record-converter/build.gradle b/misc/json-to-record-converter/build.gradle index 27b02dd3ddba..03ccef073bff 100644 --- a/misc/json-to-record-converter/build.gradle +++ b/misc/json-to-record-converter/build.gradle @@ -17,6 +17,7 @@ */ apply from: "$rootDir/gradle/javaProject.gradle" +apply from: "$rootDir/gradle/ballerinaLangLibLoad.gradle" configurations { compile.transitive = false @@ -36,6 +37,7 @@ dependencies { testCompile 'org.testng:testng' testCompile project(':formatter:formatter-core') + testCompile project(':ballerina-lang') } test { diff --git a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java index 9b645c1c1669..7027e49a0da4 100644 --- a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java +++ b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java @@ -53,8 +53,10 @@ import org.ballerinalang.formatter.core.FormattingOptions; import org.javatuples.Pair; +import java.nio.file.Path; import java.util.AbstractMap; import java.util.ArrayList; +import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; @@ -66,8 +68,10 @@ import static io.ballerina.jsonmapper.util.ConverterUtils.extractArrayTypeDescNode; import static io.ballerina.jsonmapper.util.ConverterUtils.extractTypeDescriptorNodes; import static io.ballerina.jsonmapper.util.ConverterUtils.extractUnionTypeDescNode; +import static io.ballerina.jsonmapper.util.ConverterUtils.getExistingTypeNames; import static io.ballerina.jsonmapper.util.ConverterUtils.getNumberOfDimensions; import static io.ballerina.jsonmapper.util.ConverterUtils.getPrimitiveTypeName; +import static io.ballerina.jsonmapper.util.ConverterUtils.modifyJsonObjectWithUpdatedFieldNames; import static io.ballerina.jsonmapper.util.ConverterUtils.sortTypeDescriptorNodes; import static io.ballerina.jsonmapper.util.ListOperationUtils.difference; import static io.ballerina.jsonmapper.util.ListOperationUtils.intersection; @@ -88,7 +92,7 @@ private JsonToRecordMapper() {} * @deprecated * This method returns the Ballerina code for the provided JSON value or the diagnostics. * - *

    Use {@link JsonToRecordMapper#convert(String, String, boolean, boolean, boolean)}} instead. + *

    Use {@link JsonToRecordMapper#convert(String, String, boolean, boolean, boolean, Path)}} instead. * * @param jsonString JSON string of the JSON value to be converted to Ballerina record * @param recordName Name of the generated record @@ -99,7 +103,7 @@ private JsonToRecordMapper() {} @Deprecated public static JsonToRecordResponse convert(String jsonString, String recordName, boolean isRecordTypeDesc, boolean isClosed) { - return convert(jsonString, recordName, isRecordTypeDesc, isClosed, false); + return convert(jsonString, recordName, isRecordTypeDesc, isClosed, false, null); } /** @@ -113,7 +117,8 @@ public static JsonToRecordResponse convert(String jsonString, String recordName, * @return {@link JsonToRecordResponse} Ballerina code block or the Diagnostics */ public static JsonToRecordResponse convert(String jsonString, String recordName, boolean isRecordTypeDesc, - boolean isClosed, boolean forceFormatRecordFields) { + boolean isClosed, boolean forceFormatRecordFields, Path filePath) { + List existingTypeNames = getExistingTypeNames(filePath); Map recordToTypeDescNodes = new LinkedHashMap<>(); Map jsonFieldToElements = new LinkedHashMap<>(); List diagnosticMessages = new ArrayList<>(); @@ -121,8 +126,10 @@ public static JsonToRecordResponse convert(String jsonString, String recordName, try { JsonElement parsedJson = JsonParser.parseString(jsonString); + if (parsedJson.isJsonObject()) { - generateRecords(parsedJson.getAsJsonObject(), null, isClosed, + JsonObject updated = modifyJsonObjectWithUpdatedFieldNames(parsedJson.getAsJsonObject(), existingTypeNames, new HashMap<>()); + generateRecords(updated, null, isClosed, recordToTypeDescNodes, null, jsonFieldToElements, diagnosticMessages); } else if (parsedJson.isJsonArray()) { JsonObject object = new JsonObject(); diff --git a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java index 8a48e05a7944..4c2e7fa26d81 100644 --- a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java +++ b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java @@ -18,7 +18,10 @@ package io.ballerina.jsonmapper.util; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; +import io.ballerina.compiler.api.symbols.Symbol; import io.ballerina.compiler.syntax.tree.AbstractNodeFactory; import io.ballerina.compiler.syntax.tree.ArrayTypeDescriptorNode; import io.ballerina.compiler.syntax.tree.ParenthesisedTypeDescriptorNode; @@ -27,10 +30,20 @@ import io.ballerina.compiler.syntax.tree.Token; import io.ballerina.compiler.syntax.tree.TypeDescriptorNode; import io.ballerina.compiler.syntax.tree.UnionTypeDescriptorNode; +import io.ballerina.projects.Project; +import io.ballerina.projects.ProjectException; +import io.ballerina.projects.directory.BuildProject; +import io.ballerina.projects.directory.SingleFileProject; +import io.ballerina.projects.util.ProjectUtils; +import org.apache.commons.lang3.StringUtils; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Comparator; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -46,6 +59,7 @@ public final class ConverterUtils { private ConverterUtils() {} + private static final String ARRAY_RECORD_SUFFIX = "Item"; private static final String QUOTED_IDENTIFIER_PREFIX = "'"; private static final String ESCAPE_NUMERIC_PATTERN = "\\b\\d.*"; private static final List KEYWORDS = SyntaxInfo.keywords(); @@ -74,6 +88,93 @@ public static String escapeIdentifier(String identifier) { } } + public static List getExistingTypeNames(Path filePath) { + List existingTypeNames = new ArrayList<>(); + if (filePath == null) { + return existingTypeNames; + } + + Project project; + // Check if the provided file is a SingleFileProject + try { + project = SingleFileProject.load(filePath); + List moduleSymbols = + project.currentPackage().getDefaultModule().getCompilation().getSemanticModel().moduleSymbols(); + moduleSymbols.forEach(symbol -> { + if (symbol.getName().isPresent()) { + existingTypeNames.add(symbol.getName().get()); + } + }); + } catch (ProjectException pe) { + // Check if the provided file is a part of BuildProject + Path projectRoot = ProjectUtils.findProjectRoot(filePath); + if (projectRoot != null) { + try { + project = BuildProject.load(projectRoot); + List moduleSymbols = project.currentPackage().module(project.documentId(filePath).moduleId()) + .getCompilation().getSemanticModel().moduleSymbols(); + moduleSymbols.forEach(symbol -> { + if (symbol.getName().isPresent()) { + existingTypeNames.add(symbol.getName().get()); + } + }); + } catch (ProjectException pe1) { + return existingTypeNames; + } + } + } + return existingTypeNames; + } + + public static JsonObject modifyJsonObjectWithUpdatedFieldNames(JsonObject jsonObject, + List existingFieldNames, + Map updatedFieldNames) { + Set> jsonObjectEntries = jsonObject.deepCopy().entrySet(); + for (Map.Entry entry : jsonObjectEntries) { + if (entry.getValue().isJsonObject()) { + JsonObject updatedJsonObject = + modifyJsonObjectWithUpdatedFieldNames(jsonObject.remove(entry.getKey()).getAsJsonObject(), + existingFieldNames, updatedFieldNames); + jsonObject.add(entry.getKey(), updatedJsonObject); + + String fieldName = StringUtils.capitalize(entry.getKey()); + if (existingFieldNames.contains(fieldName)) { + String updatedFieldName = updatedFieldNames.containsKey(fieldName) ? + updatedFieldNames.get(fieldName) : getUpdatedFieldName(fieldName, existingFieldNames); + updatedFieldNames.put(fieldName, updatedFieldName); + JsonElement removedJsonObject = jsonObject.remove(entry.getKey()); + jsonObject.add(fieldName.equals(entry.getKey()) ? updatedFieldName : + StringUtils.uncapitalize(updatedFieldName) , removedJsonObject); + } + + } else if (entry.getValue().isJsonArray()) { + for (JsonElement element : entry.getValue().getAsJsonArray()) { + if (element.isJsonObject()) { + JsonObject updatedJsonObject = + modifyJsonObjectWithUpdatedFieldNames(jsonObject.remove(entry.getKey()).getAsJsonObject(), + existingFieldNames, updatedFieldNames); + jsonObject.add(entry.getKey(), updatedJsonObject); + } + } + String arrayItemFieldName = StringUtils.capitalize(entry.getKey()) + ARRAY_RECORD_SUFFIX; + if (existingFieldNames.contains(arrayItemFieldName)) { + String updatedFieldName = updatedFieldNames.containsKey(arrayItemFieldName) ? + updatedFieldNames.get(arrayItemFieldName) : + getUpdatedFieldName(arrayItemFieldName, existingFieldNames); + String updatedArrayItemFieldName = StringUtils.capitalize(entry.getKey()) + + updatedFieldName.substring(arrayItemFieldName.length()); + updatedFieldNames.put(arrayItemFieldName, updatedArrayItemFieldName + ARRAY_RECORD_SUFFIX); + JsonElement removedJsonArray = jsonObject.remove(entry.getKey()); + jsonObject.add(StringUtils.capitalize(entry.getKey()).equals(entry.getKey()) ? updatedArrayItemFieldName : + StringUtils.uncapitalize(updatedArrayItemFieldName) , removedJsonArray); + } + } + jsonObject.add(entry.getKey(), jsonObject.remove(entry.getKey())); + } + + return jsonObject; + } + /** * This method returns the SyntaxToken corresponding to the JsonPrimitive. * @@ -211,4 +312,12 @@ private static void addIfNotExist(List typeDescNodes, } } } + + private static String getUpdatedFieldName(String fieldName, List existingFieldNames) { + if (!existingFieldNames.contains(fieldName)) { + return fieldName; + } else { + return getUpdatedFieldName(fieldName + "Duplicate", existingFieldNames); + } + } } diff --git a/misc/json-to-record-converter/src/main/java/module-info.java b/misc/json-to-record-converter/src/main/java/module-info.java index 75a8e6d9e3b8..00ac4ad2076d 100644 --- a/misc/json-to-record-converter/src/main/java/module-info.java +++ b/misc/json-to-record-converter/src/main/java/module-info.java @@ -2,6 +2,7 @@ requires com.google.gson; requires io.ballerina.formatter.core; requires io.ballerina.identifier; + requires io.ballerina.lang; requires io.ballerina.parser; requires io.ballerina.tools.api; requires javatuples; diff --git a/misc/ls-extensions/modules/json-to-record-converter/src/main/java/io/ballerina/converters/JsonToRecordConverterService.java b/misc/ls-extensions/modules/json-to-record-converter/src/main/java/io/ballerina/converters/JsonToRecordConverterService.java index 07a9d12e7d09..204deed1aaad 100644 --- a/misc/ls-extensions/modules/json-to-record-converter/src/main/java/io/ballerina/converters/JsonToRecordConverterService.java +++ b/misc/ls-extensions/modules/json-to-record-converter/src/main/java/io/ballerina/converters/JsonToRecordConverterService.java @@ -75,7 +75,7 @@ public CompletableFuture convert(JsonToRecordRequest reque } } else { response = JsonToRecordMapper.convert(jsonString, recordName, isRecordTypeDesc, isClosed, - forceFormatRecordFields); + forceFormatRecordFields, null); } } catch (JsonSyntaxException e) { DiagnosticMessage message = DiagnosticMessage.jsonToRecordConverter100(new String[]{e.getMessage()}); From 9111352c7c9ad44cbf224cb9101f168958fb5f48 Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Tue, 8 Nov 2022 12:31:53 +0530 Subject: [PATCH 317/450] Add testcases to test the implementation --- .../jsonmapper/JsonToRecordMapperTests.java | 145 +++++++++++------- .../project/balProject/Ballerina.toml | 4 + .../resources/project/balProject/main.bal | 19 +++ .../project/balProject/modules/util/Module.md | 6 + .../balProject/modules/util/resources/.keep | 0 .../modules/util/tests/lib_test.bal | 34 ++++ .../project/balProject/modules/util/util.bal | 16 ++ .../resources/project/balProject/records.bal | 3 + .../singleFileProject/InvalidBalFile.txt | 19 +++ .../singleFileProject/SingleBalFile.bal | 19 +++ 10 files changed, 206 insertions(+), 59 deletions(-) create mode 100644 misc/json-to-record-converter/src/test/resources/project/balProject/Ballerina.toml create mode 100644 misc/json-to-record-converter/src/test/resources/project/balProject/main.bal create mode 100644 misc/json-to-record-converter/src/test/resources/project/balProject/modules/util/Module.md create mode 100644 misc/json-to-record-converter/src/test/resources/project/balProject/modules/util/resources/.keep create mode 100644 misc/json-to-record-converter/src/test/resources/project/balProject/modules/util/tests/lib_test.bal create mode 100644 misc/json-to-record-converter/src/test/resources/project/balProject/modules/util/util.bal create mode 100644 misc/json-to-record-converter/src/test/resources/project/balProject/records.bal create mode 100644 misc/json-to-record-converter/src/test/resources/project/singleFileProject/InvalidBalFile.txt create mode 100644 misc/json-to-record-converter/src/test/resources/project/singleFileProject/SingleBalFile.bal diff --git a/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java b/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java index 8e99f22fd353..bef4865a78dd 100644 --- a/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java +++ b/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java @@ -37,29 +37,32 @@ public class JsonToRecordMapperTests { private static final Path RES_DIR = Paths.get("src/test/resources/").toAbsolutePath(); + private static final String BAL_DIR_NAME = "ballerina"; + private static final String JSON_DIR_NAME = "json"; + private static final String PROJECT_DIR_NAME = "project"; - private final Path sample0Json = RES_DIR.resolve("json") + private final Path sample0Json = RES_DIR.resolve(JSON_DIR_NAME) .resolve("sample_0.json"); - private final Path sample0Bal = RES_DIR.resolve("ballerina") + private final Path sample0Bal = RES_DIR.resolve(BAL_DIR_NAME) .resolve("sample_0.bal"); - private final Path sample1Json = RES_DIR.resolve("json") + private final Path sample1Json = RES_DIR.resolve(JSON_DIR_NAME) .resolve("sample_1.json"); - private final Path sample1Bal = RES_DIR.resolve("ballerina") + private final Path sample1Bal = RES_DIR.resolve(BAL_DIR_NAME) .resolve("sample_1.bal"); - private final Path sample2Json = RES_DIR.resolve("json") + private final Path sample2Json = RES_DIR.resolve(JSON_DIR_NAME) .resolve("sample_2.json"); - private final Path sample2Bal = RES_DIR.resolve("ballerina") + private final Path sample2Bal = RES_DIR.resolve(BAL_DIR_NAME) .resolve("sample_2.bal"); - private final Path sample2TypeDescBal = RES_DIR.resolve("ballerina") + private final Path sample2TypeDescBal = RES_DIR.resolve(BAL_DIR_NAME) .resolve("sample_2_type_desc.bal"); - private final Path sample3Json = RES_DIR.resolve("json") + private final Path sample3Json = RES_DIR.resolve(JSON_DIR_NAME) .resolve("sample_3.json"); - private final Path sample3Bal = RES_DIR.resolve("ballerina") + private final Path sample3Bal = RES_DIR.resolve(BAL_DIR_NAME) .resolve("sample_3.bal"); - private final Path sample3TypeDescBal = RES_DIR.resolve("ballerina") + private final Path sample3TypeDescBal = RES_DIR.resolve(BAL_DIR_NAME) .resolve("sample_3_type_desc.bal"); private final Path sample3PersonBal = RES_DIR.resolve("ballerina") .resolve("sample_3_person.bal"); @@ -68,66 +71,78 @@ public class JsonToRecordMapperTests { private final Path sample3SpecialCharBal = RES_DIR.resolve("ballerina") .resolve("sample_3_special_char.bal"); - private final Path sample4Json = RES_DIR.resolve("json") + private final Path sample4Json = RES_DIR.resolve(JSON_DIR_NAME) .resolve("sample_4.json"); - private final Path sample4Bal = RES_DIR.resolve("ballerina") + private final Path sample4Bal = RES_DIR.resolve(BAL_DIR_NAME) .resolve("sample_4.bal"); - private final Path sample4TypeDescBal = RES_DIR.resolve("ballerina") + private final Path sample4TypeDescBal = RES_DIR.resolve(BAL_DIR_NAME) .resolve("sample_4_type_desc.bal"); - private final Path sample5Json = RES_DIR.resolve("json") + private final Path sample5Json = RES_DIR.resolve(JSON_DIR_NAME) .resolve("sample_5.json"); - private final Path sample5Bal = RES_DIR.resolve("ballerina") + private final Path sample5Bal = RES_DIR.resolve(BAL_DIR_NAME) .resolve("sample_5.bal"); - private final Path sample6Json = RES_DIR.resolve("json") + private final Path sample6Json = RES_DIR.resolve(JSON_DIR_NAME) .resolve("sample_6.json"); - private final Path sample6Bal = RES_DIR.resolve("ballerina") + private final Path sample6Bal = RES_DIR.resolve(BAL_DIR_NAME) .resolve("sample_6.bal"); - private final Path sample6TypeDescBal = RES_DIR.resolve("ballerina") + private final Path sample6TypeDescBal = RES_DIR.resolve(BAL_DIR_NAME) .resolve("sample_6_type_desc.bal"); - private final Path sample7Json = RES_DIR.resolve("json") + private final Path sample7Json = RES_DIR.resolve(JSON_DIR_NAME) .resolve("sample_7.json"); - private final Path sample7Bal = RES_DIR.resolve("ballerina") + private final Path sample7Bal = RES_DIR.resolve(BAL_DIR_NAME) .resolve("sample_7.bal"); - private final Path sample8Json = RES_DIR.resolve("json") + private final Path sample8Json = RES_DIR.resolve(JSON_DIR_NAME) .resolve("sample_8.json"); - private final Path sample8Bal = RES_DIR.resolve("ballerina") + private final Path sample8Bal = RES_DIR.resolve(BAL_DIR_NAME) .resolve("sample_8.bal"); - private final Path sample8TypeDescBal = RES_DIR.resolve("ballerina") + private final Path sample8TypeDescBal = RES_DIR.resolve(BAL_DIR_NAME) .resolve("sample_8_type_desc.bal"); - private final Path sample9Json = RES_DIR.resolve("json") + private final Path sample9Json = RES_DIR.resolve(JSON_DIR_NAME) .resolve("sample_9.json"); - private final Path sample9Bal = RES_DIR.resolve("ballerina") + private final Path sample9Bal = RES_DIR.resolve(BAL_DIR_NAME) .resolve("sample_9.bal"); - private final Path sample9TypeDescBal = RES_DIR.resolve("ballerina") + private final Path sample9TypeDescBal = RES_DIR.resolve(BAL_DIR_NAME) .resolve("sample_9_type_desc.bal"); - private final Path sample10Json = RES_DIR.resolve("json") + private final Path sample10Json = RES_DIR.resolve(JSON_DIR_NAME) .resolve("sample_10.json"); - private final Path sample10Bal = RES_DIR.resolve("ballerina") + private final Path sample10Bal = RES_DIR.resolve(BAL_DIR_NAME) .resolve("sample_10.bal"); - private final Path sample10TypeDescBal = RES_DIR.resolve("ballerina") + private final Path sample10TypeDescBal = RES_DIR.resolve(BAL_DIR_NAME) .resolve("sample_10_type_desc.bal"); - private final Path sample11Json = RES_DIR.resolve("json") + private final Path sample11Json = RES_DIR.resolve(JSON_DIR_NAME) .resolve("sample_11.json"); - private final Path sample11Bal = RES_DIR.resolve("ballerina") + private final Path sample11Bal = RES_DIR.resolve(BAL_DIR_NAME) .resolve("sample_11.bal"); - private final Path sample12Json = RES_DIR.resolve("json") + private final Path sample12Json = RES_DIR.resolve(JSON_DIR_NAME) .resolve("sample_12.json"); - private final Path sample13Json = RES_DIR.resolve("json") + private final Path sample13Json = RES_DIR.resolve(JSON_DIR_NAME) .resolve("sample_13.json"); + private final Path singleBalFile = RES_DIR.resolve(PROJECT_DIR_NAME).resolve("singleFileProject") + .resolve("SingleBalFile.bal"); + + private final Path invalidBalFile = RES_DIR.resolve(PROJECT_DIR_NAME).resolve("singleFileProject") + .resolve("InvalidBalFile.bal"); + + private final Path balProjectFileDefault = RES_DIR.resolve(PROJECT_DIR_NAME).resolve("balProject") + .resolve("main.bal"); + + private final Path balProjectFileUtilModule = RES_DIR.resolve(PROJECT_DIR_NAME).resolve("balProject") + .resolve("modules").resolve("util").resolve("util.bal"); + @Test(description = "Test for primitive and null types") public void testForPrimitiveAndNullTypes() throws IOException { String jsonFileContent = Files.readString(sample0Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample0Bal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -136,7 +151,7 @@ public void testForPrimitiveAndNullTypes() throws IOException { @Test(description = "Test for all number types") public void testForJsonNumberTypes() throws IOException { String jsonFileContent = Files.readString(sample1Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample1Bal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -145,7 +160,7 @@ public void testForJsonNumberTypes() throws IOException { @Test(description = "Test for differencing fields in same JSON object") public void testForDifferencingFields() throws IOException { String jsonFileContent = Files.readString(sample2Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample2Bal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -154,7 +169,7 @@ public void testForDifferencingFields() throws IOException { @Test(description = "Test for differencing fields in same JSON object - inline") public void testForDifferencingFieldsInLine() throws IOException { String jsonFileContent = Files.readString(sample2Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, false, false) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, false, false, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample2TypeDescBal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -163,7 +178,7 @@ public void testForDifferencingFieldsInLine() throws IOException { @Test(description = "Test for differencing field values in same JSON object") public void testForDifferencingFieldValues() throws IOException { String jsonFileContent = Files.readString(sample3Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample3Bal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -172,7 +187,7 @@ public void testForDifferencingFieldValues() throws IOException { @Test(description = "Test for differencing field values in same JSON object - inline") public void testForDifferencingFieldValuesInLIne() throws IOException { String jsonFileContent = Files.readString(sample3Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, false, false) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, false, false, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample3TypeDescBal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -181,7 +196,7 @@ public void testForDifferencingFieldValuesInLIne() throws IOException { @Test(description = "Test for empty and non-empty JSON array") public void testForEmptyNonEmptyJsonArray() throws IOException { String jsonFileContent = Files.readString(sample4Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample4Bal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -190,7 +205,7 @@ public void testForEmptyNonEmptyJsonArray() throws IOException { @Test(description = "Test for empty and non-empty JSON array - inline") public void testForEmptyNonEmptyJsonArrayInLIne() throws IOException { String jsonFileContent = Files.readString(sample4Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, false, false) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, false, false, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample4TypeDescBal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -199,7 +214,7 @@ public void testForEmptyNonEmptyJsonArrayInLIne() throws IOException { @Test(description = "Test for JSON array with values of same and different type") public void testForSameAndDifferentTypeValuesInArray() throws IOException { String jsonFileContent = Files.readString(sample5Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample5Bal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -208,7 +223,7 @@ public void testForSameAndDifferentTypeValuesInArray() throws IOException { @Test(description = "Test for different objects in JSON array") public void testForDifferentObjectsInJsonArray() throws IOException { String jsonFileContent = Files.readString(sample6Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample6Bal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -217,7 +232,7 @@ public void testForDifferentObjectsInJsonArray() throws IOException { @Test(description = "Test for different objects in JSON array - inline") public void testForDifferentObjectsInJsonArrayInLIne() throws IOException { String jsonFileContent = Files.readString(sample6Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, false, false) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, false, false, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample6TypeDescBal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -226,7 +241,7 @@ public void testForDifferentObjectsInJsonArrayInLIne() throws IOException { @Test(description = "Test for multi dimensional JSON array") public void testForMultiDimensionalJsonArray() throws IOException { String jsonFileContent = Files.readString(sample7Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample7Bal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -235,7 +250,7 @@ public void testForMultiDimensionalJsonArray() throws IOException { @Test(description = "Test for complex JSON object") public void testForComplexJsonObject() throws IOException { String jsonFileContent = Files.readString(sample8Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample8Bal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -244,7 +259,7 @@ public void testForComplexJsonObject() throws IOException { @Test(description = "Test for complex JSON object - inline") public void testForComplexJsonObjectInLIne() throws IOException { String jsonFileContent = Files.readString(sample8Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, false, false) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, false, false, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample8TypeDescBal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -253,7 +268,7 @@ public void testForComplexJsonObjectInLIne() throws IOException { @Test(description = "Test for many types in JSON array") public void testForMultipleItemsJsonArray() throws IOException { String jsonFileContent = Files.readString(sample9Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample9Bal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -262,7 +277,7 @@ public void testForMultipleItemsJsonArray() throws IOException { @Test(description = "Test for many types in JSON array - inline") public void testForMultipleItemsJsonArrayInLIne() throws IOException { String jsonFileContent = Files.readString(sample9Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, false, false) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, false, false, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample9TypeDescBal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -271,7 +286,7 @@ public void testForMultipleItemsJsonArrayInLIne() throws IOException { @Test(description = "Test for JSON array of objects") public void testForJsonArrayOfObjects() throws IOException { String jsonFileContent = Files.readString(sample10Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample10Bal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -280,7 +295,7 @@ public void testForJsonArrayOfObjects() throws IOException { @Test(description = "Test for JSON array of objects - inline") public void testForJsonArrayOfObjectsInLIne() throws IOException { String jsonFileContent = Files.readString(sample10Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, false, false) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, false, false, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample10TypeDescBal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -289,7 +304,7 @@ public void testForJsonArrayOfObjectsInLIne() throws IOException { @Test(description = "Test for JSON field names with special characters") public void testForJsonFieldsOfSpecialChars() throws IOException { String jsonFileContent = Files.readString(sample11Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample11Bal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -299,7 +314,7 @@ public void testForJsonFieldsOfSpecialChars() throws IOException { public void testForInvalidJson() throws IOException { String jsonFileContent = Files.readString(sample12Json); List diagnostics = - JsonToRecordMapper.convert(jsonFileContent, "", false, false, false).getDiagnostics(); + JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null).getDiagnostics(); String diagnosticMessage = "Provided JSON is invalid : Unterminated object at line 15 column 8 path $.friend.address.city"; Assert.assertEquals(diagnostics.size(), 1); @@ -310,7 +325,7 @@ public void testForInvalidJson() throws IOException { public void testForSimilarRecordNameAndFieldName() throws IOException { String jsonFileContent = Files.readString(sample13Json); List diagnostics = - JsonToRecordMapper.convert(jsonFileContent, "Person", false, false, false).getDiagnostics(); + JsonToRecordMapper.convert(jsonFileContent, "Person", false, false, false, null).getDiagnostics(); String diagnosticMessage = "Provided record name 'Person' conflicts with the other generated records. " + "Consider providing a different name."; Assert.assertEquals(diagnostics.size(), 1); @@ -348,13 +363,13 @@ public void testForUserDefinedRecordNameWithSpecialChars() throws IOException { public void testChoreoTransPayloads() throws IOException { Map samples = new HashMap<>(); for (int i = 0; i <= 3; i++) { - Path jsonInputPath = RES_DIR.resolve("json").resolve("ChoreoTransPayloads") + Path jsonInputPath = RES_DIR.resolve(JSON_DIR_NAME).resolve("ChoreoTransPayloads") .resolve(String.format("sample_%d_input.json", i)); - Path balInputPath = RES_DIR.resolve("ballerina").resolve("ChoreoTransPayloads") + Path balInputPath = RES_DIR.resolve(BAL_DIR_NAME).resolve("ChoreoTransPayloads") .resolve(String.format("sample_%d_input.bal", i)); - Path jsonOutputPath = RES_DIR.resolve("json").resolve("ChoreoTransPayloads") + Path jsonOutputPath = RES_DIR.resolve(JSON_DIR_NAME).resolve("ChoreoTransPayloads") .resolve(String.format("sample_%d_output.json", i)); - Path balOutputPath = RES_DIR.resolve("ballerina").resolve("ChoreoTransPayloads") + Path balOutputPath = RES_DIR.resolve(BAL_DIR_NAME).resolve("ChoreoTransPayloads") .resolve(String.format("sample_%d_output.bal", i)); samples.put(jsonInputPath, balInputPath); samples.put(jsonOutputPath, balOutputPath); @@ -362,7 +377,7 @@ public void testChoreoTransPayloads() throws IOException { for (Map.Entry sample : samples.entrySet()) { String jsonFileContent = Files.readString(sample.getKey()); JsonToRecordResponse jsonToRecordResponse = - JsonToRecordMapper.convert(jsonFileContent, null, false, false, false); + JsonToRecordMapper.convert(jsonFileContent, null, false, false, false, null); if (jsonToRecordResponse.getCodeBlock() != null) { String generatedCodeBlock = jsonToRecordResponse.getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample.getValue()).replaceAll("\\s+", ""); @@ -374,4 +389,16 @@ public void testChoreoTransPayloads() throws IOException { } } } + + @Test(description = "Test for conflicting record names in single bal file project") + public void testForConflictingRecordNamesInSingleBalFileProject() throws IOException { + String jsonFileContent = Files.readString(sample2Json); + JsonToRecordResponse response = + JsonToRecordMapper.convert(jsonFileContent, "Person", false, false, false, singleBalFile); + System.out.println(response.getCodeBlock()); +// String diagnosticMessage = "Provided record name 'Person' conflicts with the other generated records. " + +// "Consider providing a different name."; +// Assert.assertEquals(diagnostics.size(), 1); +// Assert.assertEquals(diagnostics.get(0).message(), diagnosticMessage); + } } diff --git a/misc/json-to-record-converter/src/test/resources/project/balProject/Ballerina.toml b/misc/json-to-record-converter/src/test/resources/project/balProject/Ballerina.toml new file mode 100644 index 000000000000..8307364dad3f --- /dev/null +++ b/misc/json-to-record-converter/src/test/resources/project/balProject/Ballerina.toml @@ -0,0 +1,4 @@ +[package] +org = "azeemmuzammil" +name = "balProject" +version = "0.1.0" diff --git a/misc/json-to-record-converter/src/test/resources/project/balProject/main.bal b/misc/json-to-record-converter/src/test/resources/project/balProject/main.bal new file mode 100644 index 000000000000..65f570873012 --- /dev/null +++ b/misc/json-to-record-converter/src/test/resources/project/balProject/main.bal @@ -0,0 +1,19 @@ +type Address record { + string city; + string country; + int zip?; + int houseNo?; +}; + +type Friend record { + string firstName; + string lastName; + Address address; +}; + +type NewRecord record { + string firstName; + string lastName; + Address address; + Friend friend; +}; diff --git a/misc/json-to-record-converter/src/test/resources/project/balProject/modules/util/Module.md b/misc/json-to-record-converter/src/test/resources/project/balProject/modules/util/Module.md new file mode 100644 index 000000000000..8a69f51930aa --- /dev/null +++ b/misc/json-to-record-converter/src/test/resources/project/balProject/modules/util/Module.md @@ -0,0 +1,6 @@ +Prints "Hello, World!" with a main function. +[//]: # (above is the module summary) + +# Module Overview +Provides an overview about the module when generating the API documentations. +For example, refer to https://lib.ballerina.io/ballerina/io/latest diff --git a/misc/json-to-record-converter/src/test/resources/project/balProject/modules/util/resources/.keep b/misc/json-to-record-converter/src/test/resources/project/balProject/modules/util/resources/.keep new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/misc/json-to-record-converter/src/test/resources/project/balProject/modules/util/tests/lib_test.bal b/misc/json-to-record-converter/src/test/resources/project/balProject/modules/util/tests/lib_test.bal new file mode 100644 index 000000000000..d97a372d7fdd --- /dev/null +++ b/misc/json-to-record-converter/src/test/resources/project/balProject/modules/util/tests/lib_test.bal @@ -0,0 +1,34 @@ +import ballerina/io; +import ballerina/test; + +// Before Suite Function + +@test:BeforeSuite +function beforeSuiteFunc() { + io:println("I'm the before suite function!"); +} + +// Test function + +@test:Config {} +function testFunction() { + string name = "John"; + string welcomeMsg = hellos(name); + test:assertEquals("Hello, John", welcomeMsg); +} + +// Negative Test function + +@test:Config {} +function negativeTestFunction() { + string name = ""; + string welcomeMsg = hellos(name); + test:assertEquals("Hello, World!", welcomeMsg); +} + +// After Suite Function + +@test:AfterSuite +function afterSuiteFunc() { + io:println("I'm the after suite function!"); +} diff --git a/misc/json-to-record-converter/src/test/resources/project/balProject/modules/util/util.bal b/misc/json-to-record-converter/src/test/resources/project/balProject/modules/util/util.bal new file mode 100644 index 000000000000..5054da0d00a0 --- /dev/null +++ b/misc/json-to-record-converter/src/test/resources/project/balProject/modules/util/util.bal @@ -0,0 +1,16 @@ +# public isolated function hello(string firstName) returns string => firstName; + +# Returns the string `Hello` with the input string name. +# +# + name - name as a string +# + return - "Hello, " with the input string name +function hello(string name) returns string { + if !(name is "") { + return "Hello, " + name; + } + return "Hello, World!"; +} + +type UtilRec record { + string utilMessage; +}; diff --git a/misc/json-to-record-converter/src/test/resources/project/balProject/records.bal b/misc/json-to-record-converter/src/test/resources/project/balProject/records.bal new file mode 100644 index 000000000000..99c69162a9e1 --- /dev/null +++ b/misc/json-to-record-converter/src/test/resources/project/balProject/records.bal @@ -0,0 +1,3 @@ +type Message record { + string messageTitle; +}; diff --git a/misc/json-to-record-converter/src/test/resources/project/singleFileProject/InvalidBalFile.txt b/misc/json-to-record-converter/src/test/resources/project/singleFileProject/InvalidBalFile.txt new file mode 100644 index 000000000000..65f570873012 --- /dev/null +++ b/misc/json-to-record-converter/src/test/resources/project/singleFileProject/InvalidBalFile.txt @@ -0,0 +1,19 @@ +type Address record { + string city; + string country; + int zip?; + int houseNo?; +}; + +type Friend record { + string firstName; + string lastName; + Address address; +}; + +type NewRecord record { + string firstName; + string lastName; + Address address; + Friend friend; +}; diff --git a/misc/json-to-record-converter/src/test/resources/project/singleFileProject/SingleBalFile.bal b/misc/json-to-record-converter/src/test/resources/project/singleFileProject/SingleBalFile.bal new file mode 100644 index 000000000000..65f570873012 --- /dev/null +++ b/misc/json-to-record-converter/src/test/resources/project/singleFileProject/SingleBalFile.bal @@ -0,0 +1,19 @@ +type Address record { + string city; + string country; + int zip?; + int houseNo?; +}; + +type Friend record { + string firstName; + string lastName; + Address address; +}; + +type NewRecord record { + string firstName; + string lastName; + Address address; + Friend friend; +}; From d8c4b87a92f9b43e234a87c7a19ea6f6d2c4d9bb Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Fri, 11 Nov 2022 15:56:50 +0530 Subject: [PATCH 318/450] Add support to generate records without conflicting names --- misc/json-to-record-converter/build.gradle | 1 + .../jsonmapper/JsonToRecordMapper.java | 80 ++++++++++----- .../diagnostic/DiagnosticMessage.java | 12 +++ .../jsonmapper/util/ConverterUtils.java | 98 +++++++++---------- .../singleFileProject/SingleBalFile.bal | 19 ---- .../InvalidBalFile.txt | 0 .../{ => source}/balProject/Ballerina.toml | 0 .../project/{ => source}/balProject/main.bal | 0 .../balProject/modules/util/Module.md | 0 .../balProject/modules/util/resources/.keep | 0 .../modules/util/tests/lib_test.bal | 0 .../balProject/modules/util/util.bal | 0 .../{ => source}/balProject/records.bal | 0 .../singleFileProject/SingleBalFile.bal | 23 +++++ 14 files changed, 134 insertions(+), 99 deletions(-) delete mode 100644 misc/json-to-record-converter/src/test/resources/project/singleFileProject/SingleBalFile.bal rename misc/json-to-record-converter/src/test/resources/project/{singleFileProject => source}/InvalidBalFile.txt (100%) rename misc/json-to-record-converter/src/test/resources/project/{ => source}/balProject/Ballerina.toml (100%) rename misc/json-to-record-converter/src/test/resources/project/{ => source}/balProject/main.bal (100%) rename misc/json-to-record-converter/src/test/resources/project/{ => source}/balProject/modules/util/Module.md (100%) rename misc/json-to-record-converter/src/test/resources/project/{ => source}/balProject/modules/util/resources/.keep (100%) rename misc/json-to-record-converter/src/test/resources/project/{ => source}/balProject/modules/util/tests/lib_test.bal (100%) rename misc/json-to-record-converter/src/test/resources/project/{ => source}/balProject/modules/util/util.bal (100%) rename misc/json-to-record-converter/src/test/resources/project/{ => source}/balProject/records.bal (100%) create mode 100644 misc/json-to-record-converter/src/test/resources/project/source/singleFileProject/SingleBalFile.bal diff --git a/misc/json-to-record-converter/build.gradle b/misc/json-to-record-converter/build.gradle index 03ccef073bff..9895959b120e 100644 --- a/misc/json-to-record-converter/build.gradle +++ b/misc/json-to-record-converter/build.gradle @@ -38,6 +38,7 @@ dependencies { testCompile 'org.testng:testng' testCompile project(':formatter:formatter-core') testCompile project(':ballerina-lang') + testCompile "org.javatuples:javatuples:${project.javaTuples}" } test { diff --git a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java index 7027e49a0da4..04346e26b955 100644 --- a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java +++ b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java @@ -68,10 +68,10 @@ import static io.ballerina.jsonmapper.util.ConverterUtils.extractArrayTypeDescNode; import static io.ballerina.jsonmapper.util.ConverterUtils.extractTypeDescriptorNodes; import static io.ballerina.jsonmapper.util.ConverterUtils.extractUnionTypeDescNode; +import static io.ballerina.jsonmapper.util.ConverterUtils.getAndUpdateFieldNames; import static io.ballerina.jsonmapper.util.ConverterUtils.getExistingTypeNames; import static io.ballerina.jsonmapper.util.ConverterUtils.getNumberOfDimensions; import static io.ballerina.jsonmapper.util.ConverterUtils.getPrimitiveTypeName; -import static io.ballerina.jsonmapper.util.ConverterUtils.modifyJsonObjectWithUpdatedFieldNames; import static io.ballerina.jsonmapper.util.ConverterUtils.sortTypeDescriptorNodes; import static io.ballerina.jsonmapper.util.ListOperationUtils.difference; import static io.ballerina.jsonmapper.util.ListOperationUtils.intersection; @@ -118,25 +118,29 @@ public static JsonToRecordResponse convert(String jsonString, String recordName, */ public static JsonToRecordResponse convert(String jsonString, String recordName, boolean isRecordTypeDesc, boolean isClosed, boolean forceFormatRecordFields, Path filePath) { - List existingTypeNames = getExistingTypeNames(filePath); + List existingFieldNames = getExistingTypeNames(filePath); + Map updatedFieldNames = new HashMap<>(); Map recordToTypeDescNodes = new LinkedHashMap<>(); Map jsonFieldToElements = new LinkedHashMap<>(); List diagnosticMessages = new ArrayList<>(); JsonToRecordResponse response = new JsonToRecordResponse(); + if (existingFieldNames.contains(recordName)) { + DiagnosticMessage message = DiagnosticMessage.jsonToRecordConverter105(new String[]{recordName}); + diagnosticMessages.add(message); + return DiagnosticUtils.getDiagnosticResponse(diagnosticMessages, response); + } try { JsonElement parsedJson = JsonParser.parseString(jsonString); - if (parsedJson.isJsonObject()) { - JsonObject updated = modifyJsonObjectWithUpdatedFieldNames(parsedJson.getAsJsonObject(), existingTypeNames, new HashMap<>()); - generateRecords(updated, null, isClosed, - recordToTypeDescNodes, null, jsonFieldToElements, diagnosticMessages); + generateRecords(parsedJson.getAsJsonObject(), null, isClosed, recordToTypeDescNodes, null, + jsonFieldToElements, existingFieldNames, updatedFieldNames, diagnosticMessages); } else if (parsedJson.isJsonArray()) { JsonObject object = new JsonObject(); object.add(((recordName == null) || recordName.equals("")) ? StringUtils.uncapitalize(NEW_RECORD_NAME) : StringUtils.uncapitalize(recordName), parsedJson); - generateRecords(object, null, isClosed, - recordToTypeDescNodes, null, jsonFieldToElements, diagnosticMessages); + generateRecords(object, null, isClosed, recordToTypeDescNodes, null, jsonFieldToElements, + existingFieldNames, updatedFieldNames, diagnosticMessages); } else { DiagnosticMessage message = DiagnosticMessage.jsonToRecordConverter101(null); diagnosticMessages.add(message); @@ -161,7 +165,8 @@ public static JsonToRecordResponse convert(String jsonString, String recordName, (recordName == null || recordName.equals("")) ? NEW_RECORD_NAME : escapeIdentifier(StringUtils.capitalize(recordName)) : entry.getKey(); - IdentifierToken typeName = AbstractNodeFactory.createIdentifierToken(recordTypeName); + IdentifierToken typeName = AbstractNodeFactory + .createIdentifierToken(escapeIdentifier(recordTypeName)); Token semicolon = AbstractNodeFactory.createToken(SyntaxKind.SEMICOLON_TOKEN); return NodeFactory.createTypeDefinitionNode(null, null, typeKeyWord, typeName, entry.getValue(), semicolon); @@ -195,11 +200,15 @@ public static JsonToRecordResponse convert(String jsonString, String recordName, * @param recordToTypeDescNodes The map of recordNames and the TypeDescriptorNodes already generated * @param moveBefore To move generated TypeDescriptorNode before specified TypeDescriptorNode * @param jsonNodes The map of JSON field names and the JSON nodes for already created TypeDescriptorNodes + * @param existingFieldNames The list of already existing record names in the ModulePartNode + * @param updatedFieldNames The map of updated record names for already existing record names in the ModulePartNode * @param diagnosticMessages The list of diagnostic messages generated by the method */ private static void generateRecords(JsonObject jsonObject, String recordName, boolean isClosed, Map recordToTypeDescNodes, String moveBefore, Map jsonNodes, + List existingFieldNames, + Map updatedFieldNames, List diagnosticMessages) { Token recordKeyWord = AbstractNodeFactory.createToken(SyntaxKind.RECORD_KEYWORD); Token bodyStartDelimiter = AbstractNodeFactory.createToken(isClosed ? SyntaxKind.OPEN_BRACE_PIPE_TOKEN : @@ -222,12 +231,13 @@ private static void generateRecords(JsonObject jsonObject, String recordName, bo .collect(Collectors.toMap(node -> node.fieldName().text(), Function.identity(), (val1, val2) -> val1, LinkedHashMap::new)); Map newRecordFieldToNodes = jsonObject.entrySet().stream() - .map(entry -> (RecordFieldNode) getRecordField(entry, false)) + .map(entry -> + (RecordFieldNode) getRecordField(entry, existingFieldNames, updatedFieldNames, false)) .collect(Collectors.toList()).stream() .collect(Collectors.toMap(node -> node.fieldName().text(), Function.identity(), (val1, val2) -> val1, LinkedHashMap::new)); - updateRecordFields(jsonObject, jsonNodes, diagnosticMessages, - recordFields, previousRecordFieldToNodes, newRecordFieldToNodes); + updateRecordFields(jsonObject, jsonNodes, diagnosticMessages, recordFields, existingFieldNames, + updatedFieldNames, previousRecordFieldToNodes, newRecordFieldToNodes); } else { for (Map.Entry entry : jsonObject.entrySet()) { if (entry.getValue().isJsonObject() || entry.getValue().isJsonArray()) { @@ -235,7 +245,7 @@ private static void generateRecords(JsonObject jsonObject, String recordName, bo null, jsonNodes, diagnosticMessages, false); } jsonNodes.put(entry.getKey(), entry.getValue()); - Node recordField = getRecordField(entry, false); + Node recordField = getRecordField(entry, existingFieldNames, updatedFieldNames, false); recordFields.add(recordField); } } @@ -262,17 +272,20 @@ private static void generateRecords(JsonObject jsonObject, String recordName, bo private static void generateRecordForObjAndArray(JsonElement jsonElement, String elementKey, boolean isClosed, Map recordToTypeDescNodes, String moveBefore, Map jsonNodes, + List existingFieldNames, + Map updatedFieldNames, List diagnosticMessages, boolean arraySuffixAdded) { if (jsonElement.isJsonObject()) { String type = escapeIdentifier(StringUtils.capitalize(elementKey)); - generateRecords(jsonElement.getAsJsonObject(), type, isClosed, - recordToTypeDescNodes, moveBefore, jsonNodes, diagnosticMessages); + String updatedType = getAndUpdateFieldNames(type, false, existingFieldNames, updatedFieldNames); + generateRecords(jsonElement.getAsJsonObject(), updatedType, isClosed, recordToTypeDescNodes, + moveBefore, jsonNodes, existingFieldNames, updatedFieldNames, diagnosticMessages); } else if (jsonElement.isJsonArray()) { for (JsonElement element : jsonElement.getAsJsonArray()) { String arrayElementKey = elementKey + (arraySuffixAdded ? "" : ARRAY_RECORD_SUFFIX); generateRecordForObjAndArray(element, arrayElementKey, isClosed, recordToTypeDescNodes, moveBefore, - jsonNodes, diagnosticMessages, true); + jsonNodes, existingFieldNames, updatedFieldNames, diagnosticMessages, true); } } } @@ -284,11 +297,15 @@ private static void generateRecordForObjAndArray(JsonElement jsonElement, String * @param jsonNodes The map of JSON field names and the JSON nodes for already created TypeDescriptorNodes * @param diagnosticMessages The list of diagnostic messages generated by the method * @param recordFields The list generated record fields + * @param existingFieldNames The list of already existing record names in the ModulePartNode + * @param updatedFieldNames The map of updated record names for already existing record names in the ModulePartNode * @param previousRecordFieldToNodes The list of already generated field nodes * @param newRecordFieldToNodes The list of newly generated field nodes for the same record */ private static void updateRecordFields(JsonObject jsonObject, Map jsonNodes, List diagnosticMessages, List recordFields, + List existingFieldNames, + Map updatedFieldNames, Map previousRecordFieldToNodes, Map newRecordFieldToNodes) { Map> intersectingRecordFields = @@ -334,12 +351,13 @@ private static void updateRecordFields(JsonObject jsonObject, Map escapeIdentifier(elementEntry.getKey()) .equals(jsonField)).findFirst().orElse(null); if (jsonEntry != null) { - Node recordField = getRecordField(jsonEntry, true); + Node recordField = getRecordField(jsonEntry, existingFieldNames, updatedFieldNames, true); recordFields.add(recordField); } else { /* @@ -371,10 +389,14 @@ private static void updateRecordFields(JsonObject jsonObject, Map entry, boolean isOptionalField) { + private static Node getRecordField(Map.Entry entry, List existingFieldNames, + Map updatedFieldNames, + boolean isOptionalField) { Token typeName = AbstractNodeFactory.createToken(SyntaxKind.ANYDATA_KEYWORD); Token questionMarkToken = AbstractNodeFactory.createToken(SyntaxKind.QUESTION_MARK_TOKEN); TypeDescriptorNode fieldTypeName = NodeFactory.createBuiltinSimpleNameReferenceNode(typeName.kind(), typeName); @@ -394,7 +416,8 @@ private static Node getRecordField(Map.Entry entry, boolean } else if (entry.getValue().isJsonObject()) { String elementKey = entry.getKey().trim(); String type = escapeIdentifier(StringUtils.capitalize(elementKey)); - typeName = AbstractNodeFactory.createIdentifierToken(type); + String updatedType = getAndUpdateFieldNames(type, false, existingFieldNames, updatedFieldNames); + typeName = AbstractNodeFactory.createIdentifierToken(updatedType); fieldTypeName = NodeFactory.createBuiltinSimpleNameReferenceNode(typeName.kind(), typeName); recordFieldNode = NodeFactory.createRecordFieldNode(null, null, fieldTypeName, fieldName, @@ -403,7 +426,7 @@ private static Node getRecordField(Map.Entry entry, boolean Map.Entry jsonArrayEntry = new AbstractMap.SimpleEntry<>(entry.getKey(), entry.getValue().getAsJsonArray()); ArrayTypeDescriptorNode arrayTypeName = - getArrayTypeDescriptorNode(jsonArrayEntry); + getArrayTypeDescriptorNode(jsonArrayEntry, existingFieldNames, updatedFieldNames); recordFieldNode = NodeFactory.createRecordFieldNode(null, null, arrayTypeName, fieldName, optionalFieldToken, semicolonToken); @@ -456,9 +479,13 @@ private static TypeDefinitionNode convertToInlineRecord(List * This method generates the record fields for the corresponding JSON fields if it's an array. * * @param entry Map entry of a JSON field name and the corresponding JSON element + * @param existingFieldNames The list of already existing record names in the ModulePartNode + * @param updatedFieldNames The map of updated record names for already existing record names in the ModulePartNode * @return {@link ArrayTypeDescriptorNode} Record field node for the corresponding JSON array field */ - private static ArrayTypeDescriptorNode getArrayTypeDescriptorNode(Map.Entry entry) { + private static ArrayTypeDescriptorNode getArrayTypeDescriptorNode(Map.Entry entry, + List existingFieldNames, + Map updatedFieldNames) { Token openSBracketToken = AbstractNodeFactory.createToken(SyntaxKind.OPEN_BRACKET_TOKEN); Token closeSBracketToken = AbstractNodeFactory.createToken(SyntaxKind.CLOSE_BRACKET_TOKEN); @@ -483,9 +510,10 @@ private static ArrayTypeDescriptorNode getArrayTypeDescriptorNode(Map.Entry arrayEntry = new AbstractMap.SimpleEntry<>(entry.getKey(), element.getAsJsonArray()); TypeDescriptorNode tempTypeNode = - getArrayTypeDescriptorNode(arrayEntry); + getArrayTypeDescriptorNode(arrayEntry, existingFieldNames, updatedFieldNames); if (!typeDescriptorNodes.stream().map(Node::toSourceCode) .collect(Collectors.toList()).contains(tempTypeNode.toSourceCode())) { typeDescriptorNodes.add(tempTypeNode); diff --git a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/diagnostic/DiagnosticMessage.java b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/diagnostic/DiagnosticMessage.java index d2c1c94f51df..597d19d06e07 100644 --- a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/diagnostic/DiagnosticMessage.java +++ b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/diagnostic/DiagnosticMessage.java @@ -96,4 +96,16 @@ public static DiagnosticMessage jsonToRecordConverter104(Object[] args) { "Provided record name conflicts with the other generated records. " + "Consider providing a different name.", DiagnosticSeverity.ERROR, null); } + + public static DiagnosticMessage jsonToRecordConverter105(Object[] args) { + if (args != null) { + return new DiagnosticMessage("JSON_TO_RECORD_CONVERTER_105", + String.format("Provided record name ''%s'' conflicts with already existing records. " + + "Consider providing a different name.", args[0]), DiagnosticSeverity.ERROR, + Arrays.copyOfRange(args, 1, args.length)); + } + return new DiagnosticMessage("JSON_TO_RECORD_CONVERTER_104", + "Provided record name conflicts with already existing records. " + + "Consider providing a different name.", DiagnosticSeverity.ERROR, null); + } } diff --git a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java index 4c2e7fa26d81..7cd203429ef9 100644 --- a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java +++ b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java @@ -18,8 +18,6 @@ package io.ballerina.jsonmapper.util; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import io.ballerina.compiler.api.symbols.Symbol; import io.ballerina.compiler.syntax.tree.AbstractNodeFactory; @@ -35,15 +33,14 @@ import io.ballerina.projects.directory.BuildProject; import io.ballerina.projects.directory.SingleFileProject; import io.ballerina.projects.util.ProjectUtils; -import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; import java.nio.file.Path; import java.util.ArrayList; +import java.util.Arrays; import java.util.Comparator; -import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -88,6 +85,12 @@ public static String escapeIdentifier(String identifier) { } } + /** + * This method returns existing Types on a module/file(for single file projects). + * + * @param filePath FilePath of the/a file in a singleFileProject or module + * @return {@link List} List of already existing Types + */ public static List getExistingTypeNames(Path filePath) { List existingTypeNames = new ArrayList<>(); if (filePath == null) { @@ -126,53 +129,23 @@ public static List getExistingTypeNames(Path filePath) { return existingTypeNames; } - public static JsonObject modifyJsonObjectWithUpdatedFieldNames(JsonObject jsonObject, - List existingFieldNames, - Map updatedFieldNames) { - Set> jsonObjectEntries = jsonObject.deepCopy().entrySet(); - for (Map.Entry entry : jsonObjectEntries) { - if (entry.getValue().isJsonObject()) { - JsonObject updatedJsonObject = - modifyJsonObjectWithUpdatedFieldNames(jsonObject.remove(entry.getKey()).getAsJsonObject(), - existingFieldNames, updatedFieldNames); - jsonObject.add(entry.getKey(), updatedJsonObject); - - String fieldName = StringUtils.capitalize(entry.getKey()); - if (existingFieldNames.contains(fieldName)) { - String updatedFieldName = updatedFieldNames.containsKey(fieldName) ? - updatedFieldNames.get(fieldName) : getUpdatedFieldName(fieldName, existingFieldNames); - updatedFieldNames.put(fieldName, updatedFieldName); - JsonElement removedJsonObject = jsonObject.remove(entry.getKey()); - jsonObject.add(fieldName.equals(entry.getKey()) ? updatedFieldName : - StringUtils.uncapitalize(updatedFieldName) , removedJsonObject); - } - - } else if (entry.getValue().isJsonArray()) { - for (JsonElement element : entry.getValue().getAsJsonArray()) { - if (element.isJsonObject()) { - JsonObject updatedJsonObject = - modifyJsonObjectWithUpdatedFieldNames(jsonObject.remove(entry.getKey()).getAsJsonObject(), - existingFieldNames, updatedFieldNames); - jsonObject.add(entry.getKey(), updatedJsonObject); - } - } - String arrayItemFieldName = StringUtils.capitalize(entry.getKey()) + ARRAY_RECORD_SUFFIX; - if (existingFieldNames.contains(arrayItemFieldName)) { - String updatedFieldName = updatedFieldNames.containsKey(arrayItemFieldName) ? - updatedFieldNames.get(arrayItemFieldName) : - getUpdatedFieldName(arrayItemFieldName, existingFieldNames); - String updatedArrayItemFieldName = StringUtils.capitalize(entry.getKey()) + - updatedFieldName.substring(arrayItemFieldName.length()); - updatedFieldNames.put(arrayItemFieldName, updatedArrayItemFieldName + ARRAY_RECORD_SUFFIX); - JsonElement removedJsonArray = jsonObject.remove(entry.getKey()); - jsonObject.add(StringUtils.capitalize(entry.getKey()).equals(entry.getKey()) ? updatedArrayItemFieldName : - StringUtils.uncapitalize(updatedArrayItemFieldName) , removedJsonArray); - } - } - jsonObject.add(entry.getKey(), jsonObject.remove(entry.getKey())); + /** + * This method returns an alternative fieldName if the given filedName is already exist. + * + * @param fieldName Field name of the JSON Object/Array + * @param isArrayField To denote whether given field is an array or not + * @param existingFieldNames The list of already existing field names + * @param updatedFieldNames The list of updated field names + * @return {@link List} List of already existing Types + */ + public static String getAndUpdateFieldNames(String fieldName, boolean isArrayField, List existingFieldNames, + Map updatedFieldNames) { + String updatedFieldName = getUpdatedFieldName(fieldName, isArrayField, existingFieldNames, updatedFieldNames); + if (!fieldName.equals(updatedFieldName)) { + updatedFieldNames.put(fieldName, updatedFieldName); + return updatedFieldName; } - - return jsonObject; + return fieldName; } /** @@ -313,11 +286,28 @@ private static void addIfNotExist(List typeDescNodes, } } - private static String getUpdatedFieldName(String fieldName, List existingFieldNames) { - if (!existingFieldNames.contains(fieldName)) { + private static String getUpdatedFieldName(String fieldName, boolean isArrayField, List existingFieldNames, + Map updatedFieldNames) { + if (updatedFieldNames.containsKey(fieldName)) { + return updatedFieldNames.get(fieldName); + } + if (!existingFieldNames.contains(fieldName) && !updatedFieldNames.containsValue(fieldName)) { return fieldName; } else { - return getUpdatedFieldName(fieldName + "Duplicate", existingFieldNames); + String extractedFieldName = isArrayField ? + fieldName.substring(0, fieldName.length() - ARRAY_RECORD_SUFFIX.length()) : fieldName; + String[] fieldNameSplit = extractedFieldName.split("_"); + String numericSuffix = fieldNameSplit[fieldNameSplit.length - 1]; // 01 + if (NumberUtils.isParsable(numericSuffix)) { + return getUpdatedFieldName(String.join("_", + Arrays.copyOfRange(fieldNameSplit, 0, fieldNameSplit.length - 1)) + "_" + + String.format("%02d", Integer.parseInt(numericSuffix) + 1) + + (isArrayField ? ARRAY_RECORD_SUFFIX : ""), + isArrayField, existingFieldNames, updatedFieldNames); + } else { + return getUpdatedFieldName(extractedFieldName + "_01" + (isArrayField ? ARRAY_RECORD_SUFFIX : ""), + isArrayField, existingFieldNames, updatedFieldNames); + } } } } diff --git a/misc/json-to-record-converter/src/test/resources/project/singleFileProject/SingleBalFile.bal b/misc/json-to-record-converter/src/test/resources/project/singleFileProject/SingleBalFile.bal deleted file mode 100644 index 65f570873012..000000000000 --- a/misc/json-to-record-converter/src/test/resources/project/singleFileProject/SingleBalFile.bal +++ /dev/null @@ -1,19 +0,0 @@ -type Address record { - string city; - string country; - int zip?; - int houseNo?; -}; - -type Friend record { - string firstName; - string lastName; - Address address; -}; - -type NewRecord record { - string firstName; - string lastName; - Address address; - Friend friend; -}; diff --git a/misc/json-to-record-converter/src/test/resources/project/singleFileProject/InvalidBalFile.txt b/misc/json-to-record-converter/src/test/resources/project/source/InvalidBalFile.txt similarity index 100% rename from misc/json-to-record-converter/src/test/resources/project/singleFileProject/InvalidBalFile.txt rename to misc/json-to-record-converter/src/test/resources/project/source/InvalidBalFile.txt diff --git a/misc/json-to-record-converter/src/test/resources/project/balProject/Ballerina.toml b/misc/json-to-record-converter/src/test/resources/project/source/balProject/Ballerina.toml similarity index 100% rename from misc/json-to-record-converter/src/test/resources/project/balProject/Ballerina.toml rename to misc/json-to-record-converter/src/test/resources/project/source/balProject/Ballerina.toml diff --git a/misc/json-to-record-converter/src/test/resources/project/balProject/main.bal b/misc/json-to-record-converter/src/test/resources/project/source/balProject/main.bal similarity index 100% rename from misc/json-to-record-converter/src/test/resources/project/balProject/main.bal rename to misc/json-to-record-converter/src/test/resources/project/source/balProject/main.bal diff --git a/misc/json-to-record-converter/src/test/resources/project/balProject/modules/util/Module.md b/misc/json-to-record-converter/src/test/resources/project/source/balProject/modules/util/Module.md similarity index 100% rename from misc/json-to-record-converter/src/test/resources/project/balProject/modules/util/Module.md rename to misc/json-to-record-converter/src/test/resources/project/source/balProject/modules/util/Module.md diff --git a/misc/json-to-record-converter/src/test/resources/project/balProject/modules/util/resources/.keep b/misc/json-to-record-converter/src/test/resources/project/source/balProject/modules/util/resources/.keep similarity index 100% rename from misc/json-to-record-converter/src/test/resources/project/balProject/modules/util/resources/.keep rename to misc/json-to-record-converter/src/test/resources/project/source/balProject/modules/util/resources/.keep diff --git a/misc/json-to-record-converter/src/test/resources/project/balProject/modules/util/tests/lib_test.bal b/misc/json-to-record-converter/src/test/resources/project/source/balProject/modules/util/tests/lib_test.bal similarity index 100% rename from misc/json-to-record-converter/src/test/resources/project/balProject/modules/util/tests/lib_test.bal rename to misc/json-to-record-converter/src/test/resources/project/source/balProject/modules/util/tests/lib_test.bal diff --git a/misc/json-to-record-converter/src/test/resources/project/balProject/modules/util/util.bal b/misc/json-to-record-converter/src/test/resources/project/source/balProject/modules/util/util.bal similarity index 100% rename from misc/json-to-record-converter/src/test/resources/project/balProject/modules/util/util.bal rename to misc/json-to-record-converter/src/test/resources/project/source/balProject/modules/util/util.bal diff --git a/misc/json-to-record-converter/src/test/resources/project/balProject/records.bal b/misc/json-to-record-converter/src/test/resources/project/source/balProject/records.bal similarity index 100% rename from misc/json-to-record-converter/src/test/resources/project/balProject/records.bal rename to misc/json-to-record-converter/src/test/resources/project/source/balProject/records.bal diff --git a/misc/json-to-record-converter/src/test/resources/project/source/singleFileProject/SingleBalFile.bal b/misc/json-to-record-converter/src/test/resources/project/source/singleFileProject/SingleBalFile.bal new file mode 100644 index 000000000000..efe2aac93101 --- /dev/null +++ b/misc/json-to-record-converter/src/test/resources/project/source/singleFileProject/SingleBalFile.bal @@ -0,0 +1,23 @@ +type BatterItem record { + string id; + string 'type; + boolean fresh?; +}; + +type Batters record { + (BatterItem|decimal|int|string)[] batter; +}; + +type ToppingItem record { + string id; + string 'type; +}; + +type NewRecord record { + string id; + string 'type; + string name; + decimal ppu; + Batters batters; + (ToppingItem|string|ToppingItem[]|string[])[] topping; +}; From f7c84534159cf3b1f4e81f3b04348471553036e5 Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Fri, 11 Nov 2022 16:01:16 +0530 Subject: [PATCH 319/450] Add testcases to test conflicting record name generation --- .../jsonmapper/JsonToRecordMapperTests.java | 215 +++++++++++++----- .../resources/ballerina/sample_6_closed.bal | 45 ++++ .../ballerina/sample_6_type_desc_closed.bal | 35 +++ .../balProject/sample_bal_project_default.bal | 19 ++ .../balProject/sample_bal_project_util.bal | 45 ++++ .../assert/singleFileProject/sample_10.bal | 26 +++ .../singleFileProject/sample_10_type_desc.bal | 3 + .../assert/singleFileProject/sample_11.bal | 8 + .../assert/singleFileProject/sample_4.bal | 12 + .../singleFileProject/sample_4_type_desc.bal | 4 + .../assert/singleFileProject/sample_8.bal | 124 ++++++++++ .../singleFileProject/sample_9_type_desc.bal | 8 + .../project/source/balProject/main.bal | 14 -- .../source/balProject/modules/util/util.bal | 13 +- .../project/source/balProject/records.bal | 5 +- 15 files changed, 502 insertions(+), 74 deletions(-) create mode 100644 misc/json-to-record-converter/src/test/resources/ballerina/sample_6_closed.bal create mode 100644 misc/json-to-record-converter/src/test/resources/ballerina/sample_6_type_desc_closed.bal create mode 100644 misc/json-to-record-converter/src/test/resources/project/assert/balProject/sample_bal_project_default.bal create mode 100644 misc/json-to-record-converter/src/test/resources/project/assert/balProject/sample_bal_project_util.bal create mode 100644 misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_10.bal create mode 100644 misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_10_type_desc.bal create mode 100644 misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_11.bal create mode 100644 misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_4.bal create mode 100644 misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_4_type_desc.bal create mode 100644 misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_8.bal create mode 100644 misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_9_type_desc.bal diff --git a/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java b/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java index bef4865a78dd..33e47aee5810 100644 --- a/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java +++ b/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java @@ -20,6 +20,7 @@ import io.ballerina.jsonmapper.diagnostic.JsonToRecordMapperDiagnostic; +import org.javatuples.Pair; import org.testng.Assert; import org.testng.annotations.Test; @@ -37,32 +38,34 @@ public class JsonToRecordMapperTests { private static final Path RES_DIR = Paths.get("src/test/resources/").toAbsolutePath(); - private static final String BAL_DIR_NAME = "ballerina"; - private static final String JSON_DIR_NAME = "json"; - private static final String PROJECT_DIR_NAME = "project"; + private static final String BAL_DIR = "ballerina"; + private static final String JSON_DIR = "json"; + private static final String PROJECT_DIR = "project"; + private static final String SOURCE_DIR = "source"; + private static final String ASSERT_DIR = "assert"; - private final Path sample0Json = RES_DIR.resolve(JSON_DIR_NAME) + private final Path sample0Json = RES_DIR.resolve(JSON_DIR) .resolve("sample_0.json"); - private final Path sample0Bal = RES_DIR.resolve(BAL_DIR_NAME) + private final Path sample0Bal = RES_DIR.resolve(BAL_DIR) .resolve("sample_0.bal"); - private final Path sample1Json = RES_DIR.resolve(JSON_DIR_NAME) + private final Path sample1Json = RES_DIR.resolve(JSON_DIR) .resolve("sample_1.json"); - private final Path sample1Bal = RES_DIR.resolve(BAL_DIR_NAME) + private final Path sample1Bal = RES_DIR.resolve(BAL_DIR) .resolve("sample_1.bal"); - private final Path sample2Json = RES_DIR.resolve(JSON_DIR_NAME) + private final Path sample2Json = RES_DIR.resolve(JSON_DIR) .resolve("sample_2.json"); - private final Path sample2Bal = RES_DIR.resolve(BAL_DIR_NAME) + private final Path sample2Bal = RES_DIR.resolve(BAL_DIR) .resolve("sample_2.bal"); - private final Path sample2TypeDescBal = RES_DIR.resolve(BAL_DIR_NAME) + private final Path sample2TypeDescBal = RES_DIR.resolve(BAL_DIR) .resolve("sample_2_type_desc.bal"); - private final Path sample3Json = RES_DIR.resolve(JSON_DIR_NAME) + private final Path sample3Json = RES_DIR.resolve(JSON_DIR) .resolve("sample_3.json"); - private final Path sample3Bal = RES_DIR.resolve(BAL_DIR_NAME) + private final Path sample3Bal = RES_DIR.resolve(BAL_DIR) .resolve("sample_3.bal"); - private final Path sample3TypeDescBal = RES_DIR.resolve(BAL_DIR_NAME) + private final Path sample3TypeDescBal = RES_DIR.resolve(BAL_DIR) .resolve("sample_3_type_desc.bal"); private final Path sample3PersonBal = RES_DIR.resolve("ballerina") .resolve("sample_3_person.bal"); @@ -71,73 +74,81 @@ public class JsonToRecordMapperTests { private final Path sample3SpecialCharBal = RES_DIR.resolve("ballerina") .resolve("sample_3_special_char.bal"); - private final Path sample4Json = RES_DIR.resolve(JSON_DIR_NAME) + private final Path sample4Json = RES_DIR.resolve(JSON_DIR) .resolve("sample_4.json"); - private final Path sample4Bal = RES_DIR.resolve(BAL_DIR_NAME) + private final Path sample4Bal = RES_DIR.resolve(BAL_DIR) .resolve("sample_4.bal"); - private final Path sample4TypeDescBal = RES_DIR.resolve(BAL_DIR_NAME) + private final Path sample4TypeDescBal = RES_DIR.resolve(BAL_DIR) .resolve("sample_4_type_desc.bal"); - private final Path sample5Json = RES_DIR.resolve(JSON_DIR_NAME) + private final Path sample5Json = RES_DIR.resolve(JSON_DIR) .resolve("sample_5.json"); - private final Path sample5Bal = RES_DIR.resolve(BAL_DIR_NAME) + private final Path sample5Bal = RES_DIR.resolve(BAL_DIR) .resolve("sample_5.bal"); - private final Path sample6Json = RES_DIR.resolve(JSON_DIR_NAME) + private final Path sample6Json = RES_DIR.resolve(JSON_DIR) .resolve("sample_6.json"); - private final Path sample6Bal = RES_DIR.resolve(BAL_DIR_NAME) + private final Path sample6Bal = RES_DIR.resolve(BAL_DIR) .resolve("sample_6.bal"); - private final Path sample6TypeDescBal = RES_DIR.resolve(BAL_DIR_NAME) + private final Path sample6TypeDescBal = RES_DIR.resolve(BAL_DIR) .resolve("sample_6_type_desc.bal"); + private final Path sample6ClosedBal = RES_DIR.resolve(BAL_DIR) + .resolve("sample_6_closed.bal"); + private final Path sample6TypeDescClosedBal = RES_DIR.resolve(BAL_DIR) + .resolve("sample_6_type_desc_closed.bal"); - private final Path sample7Json = RES_DIR.resolve(JSON_DIR_NAME) + private final Path sample7Json = RES_DIR.resolve(JSON_DIR) .resolve("sample_7.json"); - private final Path sample7Bal = RES_DIR.resolve(BAL_DIR_NAME) + private final Path sample7Bal = RES_DIR.resolve(BAL_DIR) .resolve("sample_7.bal"); - private final Path sample8Json = RES_DIR.resolve(JSON_DIR_NAME) + private final Path sample8Json = RES_DIR.resolve(JSON_DIR) .resolve("sample_8.json"); - private final Path sample8Bal = RES_DIR.resolve(BAL_DIR_NAME) + private final Path sample8Bal = RES_DIR.resolve(BAL_DIR) .resolve("sample_8.bal"); - private final Path sample8TypeDescBal = RES_DIR.resolve(BAL_DIR_NAME) + private final Path sample8TypeDescBal = RES_DIR.resolve(BAL_DIR) .resolve("sample_8_type_desc.bal"); - private final Path sample9Json = RES_DIR.resolve(JSON_DIR_NAME) + private final Path sample9Json = RES_DIR.resolve(JSON_DIR) .resolve("sample_9.json"); - private final Path sample9Bal = RES_DIR.resolve(BAL_DIR_NAME) + private final Path sample9Bal = RES_DIR.resolve(BAL_DIR) .resolve("sample_9.bal"); - private final Path sample9TypeDescBal = RES_DIR.resolve(BAL_DIR_NAME) + private final Path sample9TypeDescBal = RES_DIR.resolve(BAL_DIR) .resolve("sample_9_type_desc.bal"); - private final Path sample10Json = RES_DIR.resolve(JSON_DIR_NAME) + private final Path sample10Json = RES_DIR.resolve(JSON_DIR) .resolve("sample_10.json"); - private final Path sample10Bal = RES_DIR.resolve(BAL_DIR_NAME) + private final Path sample10Bal = RES_DIR.resolve(BAL_DIR) .resolve("sample_10.bal"); - private final Path sample10TypeDescBal = RES_DIR.resolve(BAL_DIR_NAME) + private final Path sample10TypeDescBal = RES_DIR.resolve(BAL_DIR) .resolve("sample_10_type_desc.bal"); - private final Path sample11Json = RES_DIR.resolve(JSON_DIR_NAME) + private final Path sample11Json = RES_DIR.resolve(JSON_DIR) .resolve("sample_11.json"); - private final Path sample11Bal = RES_DIR.resolve(BAL_DIR_NAME) + private final Path sample11Bal = RES_DIR.resolve(BAL_DIR) .resolve("sample_11.bal"); - private final Path sample12Json = RES_DIR.resolve(JSON_DIR_NAME) + private final Path sample12Json = RES_DIR.resolve(JSON_DIR) .resolve("sample_12.json"); - private final Path sample13Json = RES_DIR.resolve(JSON_DIR_NAME) + private final Path sample13Json = RES_DIR.resolve(JSON_DIR) .resolve("sample_13.json"); - private final Path singleBalFile = RES_DIR.resolve(PROJECT_DIR_NAME).resolve("singleFileProject") - .resolve("SingleBalFile.bal"); + private final Path singleBalFile = RES_DIR.resolve(PROJECT_DIR).resolve(SOURCE_DIR) + .resolve("singleFileProject") .resolve("SingleBalFile.bal"); - private final Path invalidBalFile = RES_DIR.resolve(PROJECT_DIR_NAME).resolve("singleFileProject") - .resolve("InvalidBalFile.bal"); + private final Path invalidBalFile = RES_DIR.resolve(PROJECT_DIR).resolve(SOURCE_DIR) + .resolve("InvalidBalFile.txt"); - private final Path balProjectFileDefault = RES_DIR.resolve(PROJECT_DIR_NAME).resolve("balProject") - .resolve("main.bal"); + private final Path balProjectFileDefaultModule = RES_DIR.resolve(PROJECT_DIR).resolve(SOURCE_DIR) + .resolve("balProject").resolve("main.bal"); + private final Path balProjectFileDefaultModuleAssert = RES_DIR.resolve(PROJECT_DIR).resolve(ASSERT_DIR) + .resolve("balProject").resolve("sample_bal_project_default.bal"); - private final Path balProjectFileUtilModule = RES_DIR.resolve(PROJECT_DIR_NAME).resolve("balProject") - .resolve("modules").resolve("util").resolve("util.bal"); + private final Path balProjectFileUtilModule = RES_DIR.resolve(PROJECT_DIR).resolve(SOURCE_DIR) + .resolve("balProject").resolve("modules").resolve("util").resolve("util.bal"); + private final Path balProjectFileUtilModuleAssert = RES_DIR.resolve(PROJECT_DIR).resolve(ASSERT_DIR) + .resolve("balProject").resolve("sample_bal_project_util.bal"); @Test(description = "Test for primitive and null types") public void testForPrimitiveAndNullTypes() throws IOException { @@ -238,6 +249,33 @@ public void testForDifferentObjectsInJsonArrayInLIne() throws IOException { Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); } + @Test(description = "Test for different objects in JSON array - closed") + public void testForDifferentObjectsInJsonArrayClosed() throws IOException { + String jsonFileContent = Files.readString(sample6Json); + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, true, false, null) + .getCodeBlock().replaceAll("\\s+", ""); + String expectedCodeBlock = Files.readString(sample6ClosedBal).replaceAll("\\s+", ""); + Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); + } + + @Test(description = "Test for different objects in JSON array - inline/closed") + public void testForDifferentObjectsInJsonArrayInLineClosed() throws IOException { + String jsonFileContent = Files.readString(sample6Json); + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, true, false, null) + .getCodeBlock().replaceAll("\\s+", ""); + String expectedCodeBlock = Files.readString(sample6TypeDescClosedBal).replaceAll("\\s+", ""); + Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); + } + + @Test(description = "Test for different objects in JSON array - inline/closed/forceFormatRecField") + public void testForDifferentObjectsInJsonArrayInLineClosedForceFormatRecFields() throws IOException { + String jsonFileContent = Files.readString(sample6Json); + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, true, true, null) + .getCodeBlock(); + String expectedCodeBlock = Files.readString(sample6TypeDescClosedBal); + Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); + } + @Test(description = "Test for multi dimensional JSON array") public void testForMultiDimensionalJsonArray() throws IOException { String jsonFileContent = Files.readString(sample7Json); @@ -363,13 +401,13 @@ public void testForUserDefinedRecordNameWithSpecialChars() throws IOException { public void testChoreoTransPayloads() throws IOException { Map samples = new HashMap<>(); for (int i = 0; i <= 3; i++) { - Path jsonInputPath = RES_DIR.resolve(JSON_DIR_NAME).resolve("ChoreoTransPayloads") + Path jsonInputPath = RES_DIR.resolve(JSON_DIR).resolve("ChoreoTransPayloads") .resolve(String.format("sample_%d_input.json", i)); - Path balInputPath = RES_DIR.resolve(BAL_DIR_NAME).resolve("ChoreoTransPayloads") + Path balInputPath = RES_DIR.resolve(BAL_DIR).resolve("ChoreoTransPayloads") .resolve(String.format("sample_%d_input.bal", i)); - Path jsonOutputPath = RES_DIR.resolve(JSON_DIR_NAME).resolve("ChoreoTransPayloads") + Path jsonOutputPath = RES_DIR.resolve(JSON_DIR).resolve("ChoreoTransPayloads") .resolve(String.format("sample_%d_output.json", i)); - Path balOutputPath = RES_DIR.resolve(BAL_DIR_NAME).resolve("ChoreoTransPayloads") + Path balOutputPath = RES_DIR.resolve(BAL_DIR).resolve("ChoreoTransPayloads") .resolve(String.format("sample_%d_output.bal", i)); samples.put(jsonInputPath, balInputPath); samples.put(jsonOutputPath, balOutputPath); @@ -390,15 +428,82 @@ public void testChoreoTransPayloads() throws IOException { } } + @Test(description = "Test for conflicting record names in invalid bal file") + public void testForConflictingRecordNamesInInvalidBalFile() throws IOException { + String jsonFileContent = Files.readString(sample2Json); + JsonToRecordResponse response = + JsonToRecordMapper.convert(jsonFileContent, null, false, false, false, invalidBalFile); + String generatedCodeBlock = response.getCodeBlock().replaceAll("\\s+", ""); + String expectedCodeBlock = Files.readString(sample2Bal).replaceAll("\\s+", ""); + Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); + } + @Test(description = "Test for conflicting record names in single bal file project") public void testForConflictingRecordNamesInSingleBalFileProject() throws IOException { + Map> existingRecordsToJsonSamples = new HashMap<>() {{ + put("sample_4.bal", new Pair<>(sample4Bal, sample4Json)); + put("sample_8.bal", new Pair<>(sample8Bal,sample8Json)); + put("sample_10.bal", new Pair<>(sample10Bal, sample10Json)); +// put("sample_11.bal", new Pair<>(sample11Bal, sample11Json)); + }}; + Map> existingRecordsToJsonTypeDescSamples = new HashMap<>() {{ + put("sample_4_type_desc.bal", new Pair<>(sample4Bal, sample4Json)); + put("sample_9_type_desc.bal", new Pair<>(sample9Bal, sample9Json)); + put("sample_10_type_desc.bal", new Pair<>(sample10Bal, sample10Json)); + }}; + + for (Map.Entry> entry : existingRecordsToJsonSamples.entrySet()) { + Path jsonFilePath = entry.getValue().getValue1(); + Path balFilePath = RES_DIR.resolve(PROJECT_DIR).resolve(ASSERT_DIR).resolve("singleFileProject") + .resolve(entry.getKey()); + Path balExistingFilePath = entry.getValue().getValue0(); + String jsonFileContent = Files.readString(jsonFilePath); + JsonToRecordResponse jsonToRecordResponse = + JsonToRecordMapper.convert(jsonFileContent, null, false, false, false, balExistingFilePath); + String generatedCodeBlock = jsonToRecordResponse.getCodeBlock().replaceAll("\\s+", ""); + String expectedCodeBlock = Files.readString(balFilePath).replaceAll("\\s+", ""); + Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); + } + for (Map.Entry> entry : existingRecordsToJsonTypeDescSamples.entrySet()) { + Path jsonFilePath = entry.getValue().getValue1(); + Path balFilePath = RES_DIR.resolve(PROJECT_DIR).resolve(ASSERT_DIR).resolve("singleFileProject") + .resolve(entry.getKey()); + Path balExistingFilePath = entry.getValue().getValue0(); + String jsonFileContent = Files.readString(jsonFilePath); + JsonToRecordResponse jsonToRecordResponse = + JsonToRecordMapper.convert(jsonFileContent, null, true, false, false, balExistingFilePath); + String generatedCodeBlock = jsonToRecordResponse.getCodeBlock().replaceAll("\\s+", ""); + String expectedCodeBlock = Files.readString(balFilePath).replaceAll("\\s+", ""); + Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); + } + } + + @Test(description = "Test for conflicting parent record name") + public void testForConflictingParentRecordName() throws IOException { String jsonFileContent = Files.readString(sample2Json); - JsonToRecordResponse response = - JsonToRecordMapper.convert(jsonFileContent, "Person", false, false, false, singleBalFile); - System.out.println(response.getCodeBlock()); -// String diagnosticMessage = "Provided record name 'Person' conflicts with the other generated records. " + -// "Consider providing a different name."; -// Assert.assertEquals(diagnostics.size(), 1); -// Assert.assertEquals(diagnostics.get(0).message(), diagnosticMessage); + List diagnostics = JsonToRecordMapper + .convert(jsonFileContent, "Friend", false, false, false, sample2Bal).getDiagnostics(); + String diagnosticMessage = "Provided record name 'Friend' conflicts with already existing records. " + + "Consider providing a different name."; + Assert.assertEquals(diagnostics.size(), 1); + Assert.assertEquals(diagnostics.get(0).message(), diagnosticMessage); + } + + @Test(description = "Test for conflicting record names in bal project default module") + public void testForConflictingRecordNamesInBalProjectDefault() throws IOException { + String jsonFileContent = Files.readString(sample2Json); + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, null, false, false, false, balProjectFileDefaultModule) + .getCodeBlock().replaceAll("\\s+", ""); + String expectedCodeBlock = Files.readString(balProjectFileDefaultModuleAssert).replaceAll("\\s+", ""); + Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); + } + + @Test(description = "Test for conflicting record names in bal project non-default module") + public void testForConflictingRecordNamesInBalProjectNonDefault() throws IOException { + String jsonFileContent = Files.readString(sample6Json); + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, balProjectFileUtilModule) + .getCodeBlock().replaceAll("\\s+", ""); + String expectedCodeBlock = Files.readString(balProjectFileUtilModuleAssert).replaceAll("\\s+", ""); + Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); } } diff --git a/misc/json-to-record-converter/src/test/resources/ballerina/sample_6_closed.bal b/misc/json-to-record-converter/src/test/resources/ballerina/sample_6_closed.bal new file mode 100644 index 000000000000..8d601365aad9 --- /dev/null +++ b/misc/json-to-record-converter/src/test/resources/ballerina/sample_6_closed.bal @@ -0,0 +1,45 @@ +type SportsItem record {| + string? sport; + string position?; + boolean reserve?; + string game?; + string 'type?; +|}; + +type Author record {| + string name; + string country; + (boolean|int|string)? period; + anydata language?; +|}; + +type BooksItem record {| + string name; + Author author; + int publishedYear?; + decimal price?; +|}; + +type State record {| + string name; + string code; +|}; + +type Address record {| + string number; + string street; + string neighborhood; + string city; + State state; +|}; + +type NewRecord record {| + string name; + string school; + int age; + SportsItem[] sports; + BooksItem[] books; + string year; + boolean honors; + Address address; +|}; diff --git a/misc/json-to-record-converter/src/test/resources/ballerina/sample_6_type_desc_closed.bal b/misc/json-to-record-converter/src/test/resources/ballerina/sample_6_type_desc_closed.bal new file mode 100644 index 000000000000..c83218be6c0e --- /dev/null +++ b/misc/json-to-record-converter/src/test/resources/ballerina/sample_6_type_desc_closed.bal @@ -0,0 +1,35 @@ +type NewRecord record {| + string name; + string school; + int age; + record {| + string? sport; + string position?; + boolean reserve?; + string game?; + string 'type?; + |}[] sports; + record {| + string name; + record {| + string name; + string country; + (boolean|int|string)? period; + anydata language?; + |} author; + int publishedYear?; + decimal price?; + |}[] books; + string year; + boolean honors; + record {| + string number; + string street; + string neighborhood; + string city; + record {| + string name; + string code; + |} state; + |} address; +|}; diff --git a/misc/json-to-record-converter/src/test/resources/project/assert/balProject/sample_bal_project_default.bal b/misc/json-to-record-converter/src/test/resources/project/assert/balProject/sample_bal_project_default.bal new file mode 100644 index 000000000000..27ff625ca065 --- /dev/null +++ b/misc/json-to-record-converter/src/test/resources/project/assert/balProject/sample_bal_project_default.bal @@ -0,0 +1,19 @@ +type Address record { + string city; + string country; + int zip?; + int houseNo?; +}; + +type Friend_01 record { + string firstName; + string lastName; + Address address; +}; + +type NewRecord_01 record { + string firstName; + string lastName; + Address address; + Friend_01 friend; +}; diff --git a/misc/json-to-record-converter/src/test/resources/project/assert/balProject/sample_bal_project_util.bal b/misc/json-to-record-converter/src/test/resources/project/assert/balProject/sample_bal_project_util.bal new file mode 100644 index 000000000000..7599ae8f420d --- /dev/null +++ b/misc/json-to-record-converter/src/test/resources/project/assert/balProject/sample_bal_project_util.bal @@ -0,0 +1,45 @@ +type SportsItem record { + string? sport; + string position?; + boolean reserve?; + string game?; + string 'type?; +}; + +type Author_01 record { + string name; + string country; + (boolean|int|string)? period; + anydata language?; +}; + +type BooksItem record { + string name; + Author_01 author; + int publishedYear?; + decimal price?; +}; + +type State_01 record { + string name; + string code; +}; + +type Address record { + string number; + string street; + string neighborhood; + string city; + State_01 state; +}; + +type NewRecord record { + string name; + string school; + int age; + SportsItem[] sports; + BooksItem[] books; + string year; + boolean honors; + Address address; +}; diff --git a/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_10.bal b/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_10.bal new file mode 100644 index 000000000000..363f54420f6a --- /dev/null +++ b/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_10.bal @@ -0,0 +1,26 @@ +type Batter_01Item record { + string id; + string 'type; +}; + +type Batters_01 record { + Batter_01Item[] batter; +}; + +type Topping_01Item record { + string id; + string 'type; +}; + +type NewRecord_01Item record { + string id; + string 'type; + string name; + decimal ppu; + Batters_01 batters; + Topping_01Item[] topping; +}; + +type NewRecord_01 record { + NewRecord_01Item[] newRecord; +}; diff --git a/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_10_type_desc.bal b/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_10_type_desc.bal new file mode 100644 index 000000000000..98b32969f995 --- /dev/null +++ b/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_10_type_desc.bal @@ -0,0 +1,3 @@ +type NewRecord_01 record { + record {string id; string 'type; string name; decimal ppu; record {record {string id; string 'type;}[] batter;} batters; record {string id; string 'type;}[] topping;}[] newRecord; +}; diff --git a/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_11.bal b/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_11.bal new file mode 100644 index 000000000000..9c2d402177f7 --- /dev/null +++ b/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_11.bal @@ -0,0 +1,8 @@ +type NewRecord record { + string first\ Name; + string last\+Name\?; + string \007; + int ϼ\ \+\-\+; + boolean ōŊĖ; + string house\\Address\+\?; +}; diff --git a/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_4.bal b/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_4.bal new file mode 100644 index 000000000000..38d15ee9f4e5 --- /dev/null +++ b/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_4.bal @@ -0,0 +1,12 @@ +type People_01Item record { + string firstName; + string lastName; + string gender; + int age; + string number; +}; + +type NewRecord_01 record { + People_01Item[] people; + anydata[] addresses; +}; diff --git a/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_4_type_desc.bal b/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_4_type_desc.bal new file mode 100644 index 000000000000..eb7cf59ae6d4 --- /dev/null +++ b/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_4_type_desc.bal @@ -0,0 +1,4 @@ +type NewRecord_01 record { + record {string firstName; string lastName; string gender; int age; string number;}[] people; + anydata[] addresses; +}; diff --git a/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_8.bal b/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_8.bal new file mode 100644 index 000000000000..feb26a4422dd --- /dev/null +++ b/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_8.bal @@ -0,0 +1,124 @@ +type Text_01 record { + string status; + string div; +}; + +type Identifier_01Item record { + string system; + string value; +}; + +type Coding_01Item record { + string code; + string system?; +}; + +type Type_01 record { + Coding_01Item[] coding; +}; + +type Patient_01 record { + string reference; +}; + +type Insurer_01 record { + string reference; +}; + +type Provider_01 record { + string reference; +}; + +type Priority_01 record { + Coding_01Item[] coding; +}; + +type Prescription_01 record { + string reference; +}; + +type Payee_01 record { + Type_01 'type; +}; + +type CareTeam_01Item record { + int sequence; + Provider_01 provider; +}; + +type DiagnosisCodeableConcept_01 record { + Coding_01Item[] coding; +}; + +type Diagnosis_01Item record { + int sequence; + DiagnosisCodeableConcept_01 diagnosisCodeableConcept; +}; + +type Coverage_01 record { + string reference; +}; + +type Insurance_01Item record { + int sequence; + boolean focal; + Coverage_01 coverage; +}; + +type ProductOrService_01 record { + Coding_01Item[] coding; +}; + +type UnitPrice_01 record { + decimal value; + string currency; +}; + +type Net_01 record { + decimal value; + string currency; +}; + +type Quantity_01 record { + int value; +}; + +type Detail_01Item record { + int sequence; + ProductOrService_01 productOrService; + UnitPrice_01 unitPrice; + Net_01 net; + Quantity_01 quantity?; + decimal factor?; +}; + +type Item_01Item record { + int sequence; + int[] careTeamSequence; + ProductOrService_01 productOrService; + string servicedDate; + UnitPrice_01 unitPrice; + Net_01 net; + Detail_01Item[] detail; +}; + +type NewRecord_01 record { + string resourceType; + string id; + Text_01 text; + Identifier_01Item[] identifier; + string status; + Type_01 'type; + string use; + Patient_01 patient; + string created; + Insurer_01 insurer; + Provider_01 provider; + Priority_01 priority; + Prescription_01 prescription; + Payee_01 payee; + CareTeam_01Item[] careTeam; + Diagnosis_01Item[] diagnosis; + Insurance_01Item[] insurance; + Item_01Item[] item; +}; diff --git a/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_9_type_desc.bal b/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_9_type_desc.bal new file mode 100644 index 000000000000..981d01c9583a --- /dev/null +++ b/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_9_type_desc.bal @@ -0,0 +1,8 @@ +type NewRecord_01 record { + string id; + string 'type; + string name; + decimal ppu; + record {(decimal|int|record {string id; string 'type; boolean fresh?;}|string)[] batter;} batters; + (record {string id; string 'type;}|string|record {string id;string 'type;}[]|string[])[] topping; +}; diff --git a/misc/json-to-record-converter/src/test/resources/project/source/balProject/main.bal b/misc/json-to-record-converter/src/test/resources/project/source/balProject/main.bal index 65f570873012..5af259431b96 100644 --- a/misc/json-to-record-converter/src/test/resources/project/source/balProject/main.bal +++ b/misc/json-to-record-converter/src/test/resources/project/source/balProject/main.bal @@ -1,19 +1,5 @@ -type Address record { - string city; - string country; - int zip?; - int houseNo?; -}; - -type Friend record { - string firstName; - string lastName; - Address address; -}; - type NewRecord record { string firstName; string lastName; - Address address; Friend friend; }; diff --git a/misc/json-to-record-converter/src/test/resources/project/source/balProject/modules/util/util.bal b/misc/json-to-record-converter/src/test/resources/project/source/balProject/modules/util/util.bal index 5054da0d00a0..e9ecf47ce629 100644 --- a/misc/json-to-record-converter/src/test/resources/project/source/balProject/modules/util/util.bal +++ b/misc/json-to-record-converter/src/test/resources/project/source/balProject/modules/util/util.bal @@ -4,13 +4,20 @@ # # + name - name as a string # + return - "Hello, " with the input string name -function hello(string name) returns string { +function Author(string name) returns string { if !(name is "") { return "Hello, " + name; } return "Hello, World!"; } -type UtilRec record { - string utilMessage; +type Book record { + string name; + int publishedYear?; + decimal price?; +}; + +type State record { + string name; + string code; }; diff --git a/misc/json-to-record-converter/src/test/resources/project/source/balProject/records.bal b/misc/json-to-record-converter/src/test/resources/project/source/balProject/records.bal index 99c69162a9e1..cac32fb62d8b 100644 --- a/misc/json-to-record-converter/src/test/resources/project/source/balProject/records.bal +++ b/misc/json-to-record-converter/src/test/resources/project/source/balProject/records.bal @@ -1,3 +1,4 @@ -type Message record { - string messageTitle; +type Friend record { + string firstName; + string lastName; }; From 31f8b7de49dabe1fe453308ff383d753009fc35e Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Fri, 11 Nov 2022 16:12:39 +0530 Subject: [PATCH 320/450] Update testcases to test escape backslash in typeName --- .../main/java/io/ballerina/jsonmapper/util/ConverterUtils.java | 2 -- .../java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java | 2 +- .../resources/project/assert/singleFileProject/sample_11.bal | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java index 7cd203429ef9..ccddc3b98c61 100644 --- a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java +++ b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java @@ -75,8 +75,6 @@ public static String escapeIdentifier(String identifier) { identifier = identifier.substring(1); } identifier = unescapeUnicodeCodepoints(identifier); - // TODO: Escape Special Character does not escapes backslashes. - // Refer - https://github.com/ballerina-platform/ballerina-lang/issues/36912 identifier = escapeSpecialCharacters(identifier); if (identifier.matches(ESCAPE_NUMERIC_PATTERN)) { identifier = "\\" + identifier; diff --git a/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java b/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java index 33e47aee5810..0cbdbd266c80 100644 --- a/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java +++ b/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java @@ -444,7 +444,7 @@ public void testForConflictingRecordNamesInSingleBalFileProject() throws IOExcep put("sample_4.bal", new Pair<>(sample4Bal, sample4Json)); put("sample_8.bal", new Pair<>(sample8Bal,sample8Json)); put("sample_10.bal", new Pair<>(sample10Bal, sample10Json)); -// put("sample_11.bal", new Pair<>(sample11Bal, sample11Json)); + put("sample_11.bal", new Pair<>(sample11Bal, sample11Json)); }}; Map> existingRecordsToJsonTypeDescSamples = new HashMap<>() {{ put("sample_4_type_desc.bal", new Pair<>(sample4Bal, sample4Json)); diff --git a/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_11.bal b/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_11.bal index 9c2d402177f7..9c18a08e86ec 100644 --- a/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_11.bal +++ b/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_11.bal @@ -1,4 +1,4 @@ -type NewRecord record { +type NewRecord_01 record { string first\ Name; string last\+Name\?; string \007; From 5bd3bb525024c8d818b32bc341a5743af3255466 Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Fri, 11 Nov 2022 16:52:03 +0530 Subject: [PATCH 321/450] Fix checkstyle bugs --- .../io/ballerina/jsonmapper/JsonToRecordMapper.java | 5 +++-- .../io/ballerina/jsonmapper/util/ConverterUtils.java | 3 ++- .../ballerina/jsonmapper/JsonToRecordMapperTests.java | 10 ++++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java index 04346e26b955..60c60b636d49 100644 --- a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java +++ b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java @@ -163,8 +163,9 @@ public static JsonToRecordResponse convert(String jsonString, String recordName, Token typeKeyWord = AbstractNodeFactory.createToken(SyntaxKind.TYPE_KEYWORD); String recordTypeName = entry.getKey() == null ? (recordName == null || recordName.equals("")) ? - NEW_RECORD_NAME : escapeIdentifier(StringUtils.capitalize(recordName)) : - entry.getKey(); + getAndUpdateFieldNames(NEW_RECORD_NAME, false, + existingFieldNames, updatedFieldNames) + : recordName : entry.getKey(); IdentifierToken typeName = AbstractNodeFactory .createIdentifierToken(escapeIdentifier(recordTypeName)); Token semicolon = AbstractNodeFactory.createToken(SyntaxKind.SEMICOLON_TOKEN); diff --git a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java index ccddc3b98c61..c3d5f5a9b050 100644 --- a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java +++ b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java @@ -112,7 +112,8 @@ public static List getExistingTypeNames(Path filePath) { if (projectRoot != null) { try { project = BuildProject.load(projectRoot); - List moduleSymbols = project.currentPackage().module(project.documentId(filePath).moduleId()) + List moduleSymbols = project.currentPackage() + .module(project.documentId(filePath).moduleId()) .getCompilation().getSemanticModel().moduleSymbols(); moduleSymbols.forEach(symbol -> { if (symbol.getName().isPresent()) { diff --git a/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java b/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java index 0cbdbd266c80..1f061ea9a9a7 100644 --- a/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java +++ b/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java @@ -135,7 +135,7 @@ public class JsonToRecordMapperTests { .resolve("sample_13.json"); private final Path singleBalFile = RES_DIR.resolve(PROJECT_DIR).resolve(SOURCE_DIR) - .resolve("singleFileProject") .resolve("SingleBalFile.bal"); + .resolve("singleFileProject").resolve("SingleBalFile.bal"); private final Path invalidBalFile = RES_DIR.resolve(PROJECT_DIR).resolve(SOURCE_DIR) .resolve("InvalidBalFile.txt"); @@ -442,7 +442,7 @@ public void testForConflictingRecordNamesInInvalidBalFile() throws IOException { public void testForConflictingRecordNamesInSingleBalFileProject() throws IOException { Map> existingRecordsToJsonSamples = new HashMap<>() {{ put("sample_4.bal", new Pair<>(sample4Bal, sample4Json)); - put("sample_8.bal", new Pair<>(sample8Bal,sample8Json)); + put("sample_8.bal", new Pair<>(sample8Bal, sample8Json)); put("sample_10.bal", new Pair<>(sample10Bal, sample10Json)); put("sample_11.bal", new Pair<>(sample11Bal, sample11Json)); }}; @@ -492,7 +492,8 @@ public void testForConflictingParentRecordName() throws IOException { @Test(description = "Test for conflicting record names in bal project default module") public void testForConflictingRecordNamesInBalProjectDefault() throws IOException { String jsonFileContent = Files.readString(sample2Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, null, false, false, false, balProjectFileDefaultModule) + String generatedCodeBlock = JsonToRecordMapper + .convert(jsonFileContent, null, false, false, false, balProjectFileDefaultModule) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(balProjectFileDefaultModuleAssert).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -501,7 +502,8 @@ public void testForConflictingRecordNamesInBalProjectDefault() throws IOExceptio @Test(description = "Test for conflicting record names in bal project non-default module") public void testForConflictingRecordNamesInBalProjectNonDefault() throws IOException { String jsonFileContent = Files.readString(sample6Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, balProjectFileUtilModule) + String generatedCodeBlock = JsonToRecordMapper + .convert(jsonFileContent, "", false, false, false, balProjectFileUtilModule) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(balProjectFileUtilModuleAssert).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); From b0d48dad300d13b0da8313ec015b7036e44acd9a Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Fri, 11 Nov 2022 17:20:17 +0530 Subject: [PATCH 322/450] Update testcases with missing params --- .../java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java b/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java index 1f061ea9a9a7..02ab5b85d8f8 100644 --- a/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java +++ b/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java @@ -373,7 +373,7 @@ public void testForSimilarRecordNameAndFieldName() throws IOException { @Test(description = "Test for JSON with user defined record name") public void testForUserDefinedRecordName() throws IOException { String jsonFileContent = Files.readString(sample3Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "Person", false, false, false) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "Person", false, false, false, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample3PersonBal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -382,7 +382,7 @@ public void testForUserDefinedRecordName() throws IOException { @Test(description = "Test for JSON with user defined record name - inline") public void testForUserDefinedRecordNameInLIne() throws IOException { String jsonFileContent = Files.readString(sample3Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "Person", true, false, false) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "Person", true, false, false, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample3PersonTypeDescBal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); From ba0424086a1df30a09d981749b8d3048f96360f6 Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Sat, 12 Nov 2022 00:32:47 +0530 Subject: [PATCH 323/450] Add info-diagnostics for renaming conflicting record names --- .../ballerina/jsonmapper/JsonToRecordMapper.java | 7 +++++++ .../jsonmapper/diagnostic/DiagnosticMessage.java | 14 +++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java index 60c60b636d49..ff50564d48ea 100644 --- a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java +++ b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java @@ -189,6 +189,13 @@ public static JsonToRecordResponse convert(String jsonString, String recordName, DiagnosticMessage message = DiagnosticMessage.jsonToRecordConverter102(null); diagnosticMessages.add(message); } + if (!updatedFieldNames.isEmpty()) { + updatedFieldNames.forEach((oldFieldName, updateFieldName) -> { + DiagnosticMessage message = + DiagnosticMessage.jsonToRecordConverter106(new String[]{oldFieldName, updateFieldName}); + diagnosticMessages.add(message); + }); + } return DiagnosticUtils.getDiagnosticResponse(diagnosticMessages, response); } diff --git a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/diagnostic/DiagnosticMessage.java b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/diagnostic/DiagnosticMessage.java index 597d19d06e07..4eb1cecd9834 100644 --- a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/diagnostic/DiagnosticMessage.java +++ b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/diagnostic/DiagnosticMessage.java @@ -104,8 +104,20 @@ public static DiagnosticMessage jsonToRecordConverter105(Object[] args) { "Consider providing a different name.", args[0]), DiagnosticSeverity.ERROR, Arrays.copyOfRange(args, 1, args.length)); } - return new DiagnosticMessage("JSON_TO_RECORD_CONVERTER_104", + return new DiagnosticMessage("JSON_TO_RECORD_CONVERTER_105", "Provided record name conflicts with already existing records. " + "Consider providing a different name.", DiagnosticSeverity.ERROR, null); } + + public static DiagnosticMessage jsonToRecordConverter106(Object[] args) { + if (args != null && args.length >= 2) { + return new DiagnosticMessage("JSON_TO_RECORD_CONVERTER_106", + String.format("The record name ''%s'' is renamed as ''%s''. " + + "Consider rename it back to a meaningful name.", args[0], args[1]), DiagnosticSeverity.INFO, + Arrays.copyOfRange(args, 2, args.length)); + } + return new DiagnosticMessage("JSON_TO_RECORD_CONVERTER_106", + "Few of the record names are renamed. " + + "Consider rename it back to a meaningful name.", DiagnosticSeverity.INFO, null); + } } From 43ed1d520ebc8fc78e7779ee51dc772b5aa89cae Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Sat, 12 Nov 2022 00:34:17 +0530 Subject: [PATCH 324/450] Add testcases to test renaming conflicting records diagnostics --- .../jsonmapper/JsonToRecordMapperTests.java | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java b/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java index 02ab5b85d8f8..742873b76abd 100644 --- a/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java +++ b/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java @@ -432,7 +432,7 @@ public void testChoreoTransPayloads() throws IOException { public void testForConflictingRecordNamesInInvalidBalFile() throws IOException { String jsonFileContent = Files.readString(sample2Json); JsonToRecordResponse response = - JsonToRecordMapper.convert(jsonFileContent, null, false, false, false, invalidBalFile); + JsonToRecordMapper.convert(jsonFileContent, null, false, false, false, invalidBalFile.toString()); String generatedCodeBlock = response.getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample2Bal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -456,7 +456,7 @@ public void testForConflictingRecordNamesInSingleBalFileProject() throws IOExcep Path jsonFilePath = entry.getValue().getValue1(); Path balFilePath = RES_DIR.resolve(PROJECT_DIR).resolve(ASSERT_DIR).resolve("singleFileProject") .resolve(entry.getKey()); - Path balExistingFilePath = entry.getValue().getValue0(); + String balExistingFilePath = entry.getValue().getValue0().toString(); String jsonFileContent = Files.readString(jsonFilePath); JsonToRecordResponse jsonToRecordResponse = JsonToRecordMapper.convert(jsonFileContent, null, false, false, false, balExistingFilePath); @@ -468,7 +468,7 @@ public void testForConflictingRecordNamesInSingleBalFileProject() throws IOExcep Path jsonFilePath = entry.getValue().getValue1(); Path balFilePath = RES_DIR.resolve(PROJECT_DIR).resolve(ASSERT_DIR).resolve("singleFileProject") .resolve(entry.getKey()); - Path balExistingFilePath = entry.getValue().getValue0(); + String balExistingFilePath = entry.getValue().getValue0().toString(); String jsonFileContent = Files.readString(jsonFilePath); JsonToRecordResponse jsonToRecordResponse = JsonToRecordMapper.convert(jsonFileContent, null, true, false, false, balExistingFilePath); @@ -482,7 +482,7 @@ public void testForConflictingRecordNamesInSingleBalFileProject() throws IOExcep public void testForConflictingParentRecordName() throws IOException { String jsonFileContent = Files.readString(sample2Json); List diagnostics = JsonToRecordMapper - .convert(jsonFileContent, "Friend", false, false, false, sample2Bal).getDiagnostics(); + .convert(jsonFileContent, "Friend", false, false, false, sample2Bal.toString()).getDiagnostics(); String diagnosticMessage = "Provided record name 'Friend' conflicts with already existing records. " + "Consider providing a different name."; Assert.assertEquals(diagnostics.size(), 1); @@ -493,7 +493,7 @@ public void testForConflictingParentRecordName() throws IOException { public void testForConflictingRecordNamesInBalProjectDefault() throws IOException { String jsonFileContent = Files.readString(sample2Json); String generatedCodeBlock = JsonToRecordMapper - .convert(jsonFileContent, null, false, false, false, balProjectFileDefaultModule) + .convert(jsonFileContent, null, false, false, false, balProjectFileDefaultModule.toString()) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(balProjectFileDefaultModuleAssert).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -503,9 +503,24 @@ public void testForConflictingRecordNamesInBalProjectDefault() throws IOExceptio public void testForConflictingRecordNamesInBalProjectNonDefault() throws IOException { String jsonFileContent = Files.readString(sample6Json); String generatedCodeBlock = JsonToRecordMapper - .convert(jsonFileContent, "", false, false, false, balProjectFileUtilModule) + .convert(jsonFileContent, "", false, false, false, balProjectFileUtilModule.toString()) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(balProjectFileUtilModuleAssert).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); } + + @Test(description = "Test for conflicting record name rename diagnostics") + public void testForConflictingRecordNameRenameDiagnostics() throws IOException { + String jsonFileContent = Files.readString(sample6Json); + List diagnostics = JsonToRecordMapper + .convert(jsonFileContent, "NewRecord", false, false, false, balProjectFileUtilModule.toString()) + .getDiagnostics(); + String diagnosticMessage0 = "The record name 'State' is renamed as 'State_01'. " + + "Consider rename it back to a meaningful name."; + String diagnosticMessage1 = "The record name 'Author' is renamed as 'Author_01'. " + + "Consider rename it back to a meaningful name."; + Assert.assertEquals(diagnostics.size(), 2); + Assert.assertEquals(diagnostics.get(0).message(), diagnosticMessage0); + Assert.assertEquals(diagnostics.get(1).message(), diagnosticMessage1); + } } From a4d8f42e2a4a850805689e190c42c37595970b1f Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Sat, 12 Nov 2022 00:38:10 +0530 Subject: [PATCH 325/450] Update JSON-Bal convert service to include filePath --- .../ballerina/jsonmapper/JsonToRecordMapper.java | 5 ++--- .../jsonmapper/util/ConverterUtils.java | 16 ++++++++++++---- .../json-to-record-converter/build.gradle | 1 + .../converters/JsonToRecordConverterService.java | 3 ++- .../converters/JsonToRecordRequest.java | 12 +++++++++++- 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java index ff50564d48ea..778623e11f53 100644 --- a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java +++ b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java @@ -53,7 +53,6 @@ import org.ballerinalang.formatter.core.FormattingOptions; import org.javatuples.Pair; -import java.nio.file.Path; import java.util.AbstractMap; import java.util.ArrayList; import java.util.HashMap; @@ -92,7 +91,7 @@ private JsonToRecordMapper() {} * @deprecated * This method returns the Ballerina code for the provided JSON value or the diagnostics. * - *

    Use {@link JsonToRecordMapper#convert(String, String, boolean, boolean, boolean, Path)}} instead. + *

    Use {@link JsonToRecordMapper#convert(String, String, boolean, boolean, boolean, String)}} instead. * * @param jsonString JSON string of the JSON value to be converted to Ballerina record * @param recordName Name of the generated record @@ -117,7 +116,7 @@ public static JsonToRecordResponse convert(String jsonString, String recordName, * @return {@link JsonToRecordResponse} Ballerina code block or the Diagnostics */ public static JsonToRecordResponse convert(String jsonString, String recordName, boolean isRecordTypeDesc, - boolean isClosed, boolean forceFormatRecordFields, Path filePath) { + boolean isClosed, boolean forceFormatRecordFields, String filePath) { List existingFieldNames = getExistingTypeNames(filePath); Map updatedFieldNames = new HashMap<>(); Map recordToTypeDescNodes = new LinkedHashMap<>(); diff --git a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java index c3d5f5a9b050..a6cd4d5f2eee 100644 --- a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java +++ b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java @@ -35,6 +35,7 @@ import io.ballerina.projects.util.ProjectUtils; import org.apache.commons.lang3.math.NumberUtils; +import java.nio.file.InvalidPathException; import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; @@ -89,16 +90,23 @@ public static String escapeIdentifier(String identifier) { * @param filePath FilePath of the/a file in a singleFileProject or module * @return {@link List} List of already existing Types */ - public static List getExistingTypeNames(Path filePath) { + public static List getExistingTypeNames(String filePath) { List existingTypeNames = new ArrayList<>(); if (filePath == null) { return existingTypeNames; } + Path filePathResolved; + try { + filePathResolved = Path.of(filePath); + } catch (InvalidPathException e) { + return existingTypeNames; + } + Project project; // Check if the provided file is a SingleFileProject try { - project = SingleFileProject.load(filePath); + project = SingleFileProject.load(filePathResolved); List moduleSymbols = project.currentPackage().getDefaultModule().getCompilation().getSemanticModel().moduleSymbols(); moduleSymbols.forEach(symbol -> { @@ -108,12 +116,12 @@ public static List getExistingTypeNames(Path filePath) { }); } catch (ProjectException pe) { // Check if the provided file is a part of BuildProject - Path projectRoot = ProjectUtils.findProjectRoot(filePath); + Path projectRoot = ProjectUtils.findProjectRoot(filePathResolved); if (projectRoot != null) { try { project = BuildProject.load(projectRoot); List moduleSymbols = project.currentPackage() - .module(project.documentId(filePath).moduleId()) + .module(project.documentId(filePathResolved).moduleId()) .getCompilation().getSemanticModel().moduleSymbols(); moduleSymbols.forEach(symbol -> { if (symbol.getName().isPresent()) { diff --git a/misc/ls-extensions/modules/json-to-record-converter/build.gradle b/misc/ls-extensions/modules/json-to-record-converter/build.gradle index 06da7bbe6c7e..a9a08b309c6e 100644 --- a/misc/ls-extensions/modules/json-to-record-converter/build.gradle +++ b/misc/ls-extensions/modules/json-to-record-converter/build.gradle @@ -17,6 +17,7 @@ */ apply from: "$rootDir/gradle/javaProject.gradle" +apply from: "$rootDir/gradle/ballerinaLangLibLoad.gradle" configurations { compile.transitive = false diff --git a/misc/ls-extensions/modules/json-to-record-converter/src/main/java/io/ballerina/converters/JsonToRecordConverterService.java b/misc/ls-extensions/modules/json-to-record-converter/src/main/java/io/ballerina/converters/JsonToRecordConverterService.java index 204deed1aaad..53f3a3f597b4 100644 --- a/misc/ls-extensions/modules/json-to-record-converter/src/main/java/io/ballerina/converters/JsonToRecordConverterService.java +++ b/misc/ls-extensions/modules/json-to-record-converter/src/main/java/io/ballerina/converters/JsonToRecordConverterService.java @@ -61,6 +61,7 @@ public CompletableFuture convert(JsonToRecordRequest reque boolean isRecordTypeDesc = request.getIsRecordTypeDesc(); boolean isClosed = request.getIsClosed(); boolean forceFormatRecordFields = request.getForceFormatRecordFields(); + String filePath = request.getFilePath(); try { JsonElement parsedJson = JsonParser.parseString(jsonString); @@ -75,7 +76,7 @@ public CompletableFuture convert(JsonToRecordRequest reque } } else { response = JsonToRecordMapper.convert(jsonString, recordName, isRecordTypeDesc, isClosed, - forceFormatRecordFields, null); + forceFormatRecordFields, filePath); } } catch (JsonSyntaxException e) { DiagnosticMessage message = DiagnosticMessage.jsonToRecordConverter100(new String[]{e.getMessage()}); diff --git a/misc/ls-extensions/modules/json-to-record-converter/src/main/java/io/ballerina/converters/JsonToRecordRequest.java b/misc/ls-extensions/modules/json-to-record-converter/src/main/java/io/ballerina/converters/JsonToRecordRequest.java index 1a294ca247b2..f3beb07c66a6 100644 --- a/misc/ls-extensions/modules/json-to-record-converter/src/main/java/io/ballerina/converters/JsonToRecordRequest.java +++ b/misc/ls-extensions/modules/json-to-record-converter/src/main/java/io/ballerina/converters/JsonToRecordRequest.java @@ -29,14 +29,16 @@ public class JsonToRecordRequest { private boolean isRecordTypeDesc; private boolean isClosed; private boolean forceFormatRecordFields; + private String filePath; public JsonToRecordRequest(String jsonString, String recordName, boolean isRecordTypeDesc, boolean isClosed, - boolean forceFormatRecordFields) { + boolean forceFormatRecordFields, String filePath) { this.jsonString = jsonString; this.recordName = recordName; this.isRecordTypeDesc = isRecordTypeDesc; this.isClosed = isClosed; this.forceFormatRecordFields = forceFormatRecordFields; + this.filePath = filePath; } public String getJsonString() { @@ -78,4 +80,12 @@ public boolean getForceFormatRecordFields() { public void setForceFormatRecordFields(boolean forceFormatRecordFields) { this.forceFormatRecordFields = forceFormatRecordFields; } + + public String getFilePath() { + return filePath; + } + + public void setFilePath(String filePath) { + this.filePath = filePath; + } } From 69c7b7b00b1870a7ba835790e1e5f15f9349aeee Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Sat, 12 Nov 2022 00:38:56 +0530 Subject: [PATCH 326/450] Add testcases to test service for conflicting record names --- .../JsonToRecordConverterTests.java | 30 +++++++++++++++---- .../ballerina/sample_10_without_conflict.bal | 26 ++++++++++++++++ 2 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 misc/ls-extensions/modules/json-to-record-converter/src/test/resources/ballerina/sample_10_without_conflict.bal diff --git a/misc/ls-extensions/modules/json-to-record-converter/src/test/java/io/ballerina/converters/JsonToRecordConverterTests.java b/misc/ls-extensions/modules/json-to-record-converter/src/test/java/io/ballerina/converters/JsonToRecordConverterTests.java index a14429f5b427..b0d5187e576e 100644 --- a/misc/ls-extensions/modules/json-to-record-converter/src/test/java/io/ballerina/converters/JsonToRecordConverterTests.java +++ b/misc/ls-extensions/modules/json-to-record-converter/src/test/java/io/ballerina/converters/JsonToRecordConverterTests.java @@ -139,6 +139,8 @@ public class JsonToRecordConverterTests { .resolve("sample_10.bal"); private final Path sample10TypeDescBal = RES_DIR.resolve("ballerina") .resolve("sample_10_type_desc.bal"); + private final Path sample10WithoutConflictBal = RES_DIR.resolve("ballerina") + .resolve("sample_10_without_conflict.bal"); private final Path sample11Json = RES_DIR.resolve("json") .resolve("sample_11.json"); @@ -333,7 +335,7 @@ public void testJSON2RecordService() throws IOException, ExecutionException, Int String jsonString = Files.readString(basicObjectJson); JsonToRecordRequest request = new JsonToRecordRequest(jsonString, null, - false, false, false); + false, false, false, null); CompletableFuture result = serviceEndpoint.request(JsonToRecordService, request); io.ballerina.jsonmapper.JsonToRecordResponse response = (io.ballerina.jsonmapper.JsonToRecordResponse) result.get(); @@ -348,7 +350,7 @@ public void testJSON2RecordServiceNullObjects() throws IOException, ExecutionExc String jsonString = Files.readString(nullObjectJson); JsonToRecordRequest request = new JsonToRecordRequest(jsonString, null, - false, false, false); + false, false, false, null); CompletableFuture result = serviceEndpoint.request(JsonToRecordService, request); io.ballerina.jsonmapper.JsonToRecordResponse response = (io.ballerina.jsonmapper.JsonToRecordResponse) result.get(); @@ -363,7 +365,7 @@ public void testJSON2RecordServiceJSONSchema() throws IOException, ExecutionExce String jsonString = Files.readString(basicSchemaJson); JsonToRecordRequest request = new JsonToRecordRequest(jsonString, null, - false, false, false); + false, false, false, null); CompletableFuture result = serviceEndpoint.request(JsonToRecordService, request); io.ballerina.jsonmapper.JsonToRecordResponse response = (io.ballerina.jsonmapper.JsonToRecordResponse) result.get(); @@ -378,7 +380,7 @@ public void testJSON2RecordServiceInvalidJSONSchema() throws IOException, Execut String jsonString = Files.readString(invalidSchemaJson); JsonToRecordRequest request = new JsonToRecordRequest(jsonString, null, - false, false, false); + false, false, false, null); CompletableFuture result = serviceEndpoint.request(JsonToRecordService, request); io.ballerina.jsonmapper.JsonToRecordResponse response = (io.ballerina.jsonmapper.JsonToRecordResponse) result.get(); @@ -393,7 +395,7 @@ public void testJSON2RecordServiceInvalidJSONObject() throws IOException, Execut String jsonString = Files.readString(invalidJson); JsonToRecordRequest request = new JsonToRecordRequest(jsonString, null, - false, false, false); + false, false, false, null); CompletableFuture result = serviceEndpoint.request(JsonToRecordService, request); io.ballerina.jsonmapper.JsonToRecordResponse response = (io.ballerina.jsonmapper.JsonToRecordResponse) result.get(); @@ -410,7 +412,7 @@ public void testJSON2RecordServiceNullJSON() throws IOException, ExecutionExcept String jsonString = Files.readString(nullJson); JsonToRecordRequest request = new JsonToRecordRequest(jsonString, null, - false, false, false); + false, false, false, null); CompletableFuture result = serviceEndpoint.request(JsonToRecordService, request); io.ballerina.jsonmapper.JsonToRecordResponse response = (io.ballerina.jsonmapper.JsonToRecordResponse) result.get(); @@ -421,6 +423,22 @@ public void testJSON2RecordServiceNullJSON() throws IOException, ExecutionExcept Assert.assertEquals(generatedDiagnosticMessages, expectedCDiagnosticMessages); } + @Test(description = "Test JSON2Record endpoint for conflicting record names") + public void testJSON2RecordServiceConflictingRecNames() throws IOException, ExecutionException, + InterruptedException { + Endpoint serviceEndpoint = TestUtil.initializeLanguageSever(); + String jsonString = Files.readString(sample10Json); + + JsonToRecordRequest request = new JsonToRecordRequest(jsonString, null, + false, false, false, sample10Bal.toString()); + CompletableFuture result = serviceEndpoint.request(JsonToRecordService, request); + io.ballerina.jsonmapper.JsonToRecordResponse response = + (io.ballerina.jsonmapper.JsonToRecordResponse) result.get(); + String generatedCodeBlock = response.getCodeBlock().replaceAll("\\s+", ""); + String expectedCodeBlock = Files.readString(sample10WithoutConflictBal).replaceAll("\\s+", ""); + Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); + } + @Test(description = "Test null and empty array field type extraction") public void testNullAndEmptyArray() throws JsonToRecordConverterException, IOException, FormatterException { String jsonFileContent = Files.readString(sample11Json); diff --git a/misc/ls-extensions/modules/json-to-record-converter/src/test/resources/ballerina/sample_10_without_conflict.bal b/misc/ls-extensions/modules/json-to-record-converter/src/test/resources/ballerina/sample_10_without_conflict.bal new file mode 100644 index 000000000000..ace986727faf --- /dev/null +++ b/misc/ls-extensions/modules/json-to-record-converter/src/test/resources/ballerina/sample_10_without_conflict.bal @@ -0,0 +1,26 @@ +type Batter_01Item record { + string id; + string 'type; +}; + +type Batters_01 record { + Batter_01Item[] batter; +}; + +type Topping_01Item record { + string id; + string 'type; +}; + +type NewRecordItem record { + string id; + string' type; + string name; + decimal ppu; + Batters_01 batters; + Topping_01Item[] topping; +}; + +type NewRecord_01 record { + NewRecordItem[] newRecord; +}; From 470e7fce945c63ef7214d47335a2e644b1940952 Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Mon, 14 Nov 2022 15:19:16 +0530 Subject: [PATCH 327/450] Update logic to access sementic-model through LS-workspace --- misc/json-to-record-converter/build.gradle | 4 +- .../jsonmapper/JsonToRecordMapper.java | 13 ++- .../jsonmapper/util/ConverterUtils.java | 25 ++++-- .../src/main/java/module-info.java | 1 + .../jsonmapper/JsonToRecordMapperTests.java | 81 ++++++++++--------- .../JsonToRecordConverterService.java | 14 +++- .../converters/JsonToRecordRequest.java | 14 ++-- .../src/main/java/module-info.java | 1 + .../JsonToRecordConverterTests.java | 2 +- 9 files changed, 97 insertions(+), 58 deletions(-) diff --git a/misc/json-to-record-converter/build.gradle b/misc/json-to-record-converter/build.gradle index 9895959b120e..f36b671499be 100644 --- a/misc/json-to-record-converter/build.gradle +++ b/misc/json-to-record-converter/build.gradle @@ -28,6 +28,7 @@ dependencies { compileOnly project(':ballerina-parser') compileOnly project(':ballerina-lang') compileOnly project(':formatter:formatter-core') + compileOnly project(':language-server:language-server-commons') implementation project(':ballerina-tools-api') implementation project(':identifier-util') @@ -36,8 +37,9 @@ dependencies { implementation "org.javatuples:javatuples:${project.javaTuples}" testCompile 'org.testng:testng' - testCompile project(':formatter:formatter-core') testCompile project(':ballerina-lang') + testCompile project(':formatter:formatter-core') + testCompile project(':language-server:language-server-commons') testCompile "org.javatuples:javatuples:${project.javaTuples}" } diff --git a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java index 778623e11f53..bd9558fe3eb8 100644 --- a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java +++ b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java @@ -51,6 +51,7 @@ import org.ballerinalang.formatter.core.Formatter; import org.ballerinalang.formatter.core.FormatterException; import org.ballerinalang.formatter.core.FormattingOptions; +import org.ballerinalang.langserver.commons.workspace.WorkspaceManager; import org.javatuples.Pair; import java.util.AbstractMap; @@ -91,7 +92,8 @@ private JsonToRecordMapper() {} * @deprecated * This method returns the Ballerina code for the provided JSON value or the diagnostics. * - *

    Use {@link JsonToRecordMapper#convert(String, String, boolean, boolean, boolean, String)}} instead. + *

    Use {@link JsonToRecordMapper#convert(String, String, boolean, boolean, boolean, String, WorkspaceManager)}} + * instead. * * @param jsonString JSON string of the JSON value to be converted to Ballerina record * @param recordName Name of the generated record @@ -102,7 +104,7 @@ private JsonToRecordMapper() {} @Deprecated public static JsonToRecordResponse convert(String jsonString, String recordName, boolean isRecordTypeDesc, boolean isClosed) { - return convert(jsonString, recordName, isRecordTypeDesc, isClosed, false, null); + return convert(jsonString, recordName, isRecordTypeDesc, isClosed, false, null, null); } /** @@ -113,11 +115,14 @@ public static JsonToRecordResponse convert(String jsonString, String recordName, * @param isRecordTypeDesc To denote final record, a record type descriptor (In line records) * @param isClosed To denote whether the response record is closed or not * @param forceFormatRecordFields To denote whether the inline records to be formatted for multi-line or in-line + * @param filePathUri FilePath URI of the/a file in a singleFileProject or module + * @param workspaceManager Workspace manager instance * @return {@link JsonToRecordResponse} Ballerina code block or the Diagnostics */ public static JsonToRecordResponse convert(String jsonString, String recordName, boolean isRecordTypeDesc, - boolean isClosed, boolean forceFormatRecordFields, String filePath) { - List existingFieldNames = getExistingTypeNames(filePath); + boolean isClosed, boolean forceFormatRecordFields, String filePathUri, + WorkspaceManager workspaceManager) { + List existingFieldNames = getExistingTypeNames(workspaceManager, filePathUri); Map updatedFieldNames = new HashMap<>(); Map recordToTypeDescNodes = new LinkedHashMap<>(); Map jsonFieldToElements = new LinkedHashMap<>(); diff --git a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java index a6cd4d5f2eee..20ddb4ad5c12 100644 --- a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java +++ b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java @@ -34,7 +34,10 @@ import io.ballerina.projects.directory.SingleFileProject; import io.ballerina.projects.util.ProjectUtils; import org.apache.commons.lang3.math.NumberUtils; +import org.ballerinalang.langserver.commons.workspace.WorkspaceManager; +import java.net.URI; +import java.net.URISyntaxException; import java.nio.file.InvalidPathException; import java.nio.file.Path; import java.util.ArrayList; @@ -87,19 +90,31 @@ public static String escapeIdentifier(String identifier) { /** * This method returns existing Types on a module/file(for single file projects). * - * @param filePath FilePath of the/a file in a singleFileProject or module + * @param workspaceManager Workspace manager instance + * @param filePathUri FilePath URI of the/a file in a singleFileProject or module * @return {@link List} List of already existing Types */ - public static List getExistingTypeNames(String filePath) { + public static List getExistingTypeNames(WorkspaceManager workspaceManager, String filePathUri) { List existingTypeNames = new ArrayList<>(); - if (filePath == null) { + if (filePathUri == null) { return existingTypeNames; } Path filePathResolved; try { - filePathResolved = Path.of(filePath); - } catch (InvalidPathException e) { + URI filePathUriResolved = new URI(filePathUri); + filePathResolved = Path.of(filePathUriResolved); + } catch (InvalidPathException | URISyntaxException e) { + return existingTypeNames; + } + + if (workspaceManager != null && workspaceManager.semanticModel(filePathResolved).isPresent()) { + List moduleSymbols = workspaceManager.semanticModel(filePathResolved).get().moduleSymbols(); + moduleSymbols.forEach(symbol -> { + if (symbol.getName().isPresent()) { + existingTypeNames.add(symbol.getName().get()); + } + }); return existingTypeNames; } diff --git a/misc/json-to-record-converter/src/main/java/module-info.java b/misc/json-to-record-converter/src/main/java/module-info.java index 00ac4ad2076d..ef77b46a41e7 100644 --- a/misc/json-to-record-converter/src/main/java/module-info.java +++ b/misc/json-to-record-converter/src/main/java/module-info.java @@ -3,6 +3,7 @@ requires io.ballerina.formatter.core; requires io.ballerina.identifier; requires io.ballerina.lang; + requires io.ballerina.language.server.commons; requires io.ballerina.parser; requires io.ballerina.tools.api; requires javatuples; diff --git a/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java b/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java index 742873b76abd..6748c3ab048b 100644 --- a/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java +++ b/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java @@ -153,7 +153,7 @@ public class JsonToRecordMapperTests { @Test(description = "Test for primitive and null types") public void testForPrimitiveAndNullTypes() throws IOException { String jsonFileContent = Files.readString(sample0Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample0Bal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -162,7 +162,7 @@ public void testForPrimitiveAndNullTypes() throws IOException { @Test(description = "Test for all number types") public void testForJsonNumberTypes() throws IOException { String jsonFileContent = Files.readString(sample1Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample1Bal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -171,7 +171,7 @@ public void testForJsonNumberTypes() throws IOException { @Test(description = "Test for differencing fields in same JSON object") public void testForDifferencingFields() throws IOException { String jsonFileContent = Files.readString(sample2Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample2Bal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -180,7 +180,7 @@ public void testForDifferencingFields() throws IOException { @Test(description = "Test for differencing fields in same JSON object - inline") public void testForDifferencingFieldsInLine() throws IOException { String jsonFileContent = Files.readString(sample2Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, false, false, null) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, false, false, null, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample2TypeDescBal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -189,7 +189,7 @@ public void testForDifferencingFieldsInLine() throws IOException { @Test(description = "Test for differencing field values in same JSON object") public void testForDifferencingFieldValues() throws IOException { String jsonFileContent = Files.readString(sample3Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample3Bal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -198,7 +198,7 @@ public void testForDifferencingFieldValues() throws IOException { @Test(description = "Test for differencing field values in same JSON object - inline") public void testForDifferencingFieldValuesInLIne() throws IOException { String jsonFileContent = Files.readString(sample3Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, false, false, null) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, false, false, null, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample3TypeDescBal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -207,7 +207,7 @@ public void testForDifferencingFieldValuesInLIne() throws IOException { @Test(description = "Test for empty and non-empty JSON array") public void testForEmptyNonEmptyJsonArray() throws IOException { String jsonFileContent = Files.readString(sample4Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample4Bal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -216,7 +216,7 @@ public void testForEmptyNonEmptyJsonArray() throws IOException { @Test(description = "Test for empty and non-empty JSON array - inline") public void testForEmptyNonEmptyJsonArrayInLIne() throws IOException { String jsonFileContent = Files.readString(sample4Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, false, false, null) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, false, false, null, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample4TypeDescBal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -225,7 +225,7 @@ public void testForEmptyNonEmptyJsonArrayInLIne() throws IOException { @Test(description = "Test for JSON array with values of same and different type") public void testForSameAndDifferentTypeValuesInArray() throws IOException { String jsonFileContent = Files.readString(sample5Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample5Bal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -234,7 +234,7 @@ public void testForSameAndDifferentTypeValuesInArray() throws IOException { @Test(description = "Test for different objects in JSON array") public void testForDifferentObjectsInJsonArray() throws IOException { String jsonFileContent = Files.readString(sample6Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample6Bal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -243,7 +243,7 @@ public void testForDifferentObjectsInJsonArray() throws IOException { @Test(description = "Test for different objects in JSON array - inline") public void testForDifferentObjectsInJsonArrayInLIne() throws IOException { String jsonFileContent = Files.readString(sample6Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, false, false, null) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, false, false, null, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample6TypeDescBal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -252,7 +252,7 @@ public void testForDifferentObjectsInJsonArrayInLIne() throws IOException { @Test(description = "Test for different objects in JSON array - closed") public void testForDifferentObjectsInJsonArrayClosed() throws IOException { String jsonFileContent = Files.readString(sample6Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, true, false, null) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, true, false, null, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample6ClosedBal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -261,7 +261,7 @@ public void testForDifferentObjectsInJsonArrayClosed() throws IOException { @Test(description = "Test for different objects in JSON array - inline/closed") public void testForDifferentObjectsInJsonArrayInLineClosed() throws IOException { String jsonFileContent = Files.readString(sample6Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, true, false, null) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, true, false, null, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample6TypeDescClosedBal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -270,7 +270,7 @@ public void testForDifferentObjectsInJsonArrayInLineClosed() throws IOException @Test(description = "Test for different objects in JSON array - inline/closed/forceFormatRecField") public void testForDifferentObjectsInJsonArrayInLineClosedForceFormatRecFields() throws IOException { String jsonFileContent = Files.readString(sample6Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, true, true, null) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, true, true, null, null) .getCodeBlock(); String expectedCodeBlock = Files.readString(sample6TypeDescClosedBal); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -279,7 +279,7 @@ public void testForDifferentObjectsInJsonArrayInLineClosedForceFormatRecFields() @Test(description = "Test for multi dimensional JSON array") public void testForMultiDimensionalJsonArray() throws IOException { String jsonFileContent = Files.readString(sample7Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample7Bal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -288,7 +288,7 @@ public void testForMultiDimensionalJsonArray() throws IOException { @Test(description = "Test for complex JSON object") public void testForComplexJsonObject() throws IOException { String jsonFileContent = Files.readString(sample8Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample8Bal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -297,7 +297,7 @@ public void testForComplexJsonObject() throws IOException { @Test(description = "Test for complex JSON object - inline") public void testForComplexJsonObjectInLIne() throws IOException { String jsonFileContent = Files.readString(sample8Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, false, false, null) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, false, false, null, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample8TypeDescBal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -306,7 +306,7 @@ public void testForComplexJsonObjectInLIne() throws IOException { @Test(description = "Test for many types in JSON array") public void testForMultipleItemsJsonArray() throws IOException { String jsonFileContent = Files.readString(sample9Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample9Bal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -315,7 +315,7 @@ public void testForMultipleItemsJsonArray() throws IOException { @Test(description = "Test for many types in JSON array - inline") public void testForMultipleItemsJsonArrayInLIne() throws IOException { String jsonFileContent = Files.readString(sample9Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, false, false, null) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, false, false, null, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample9TypeDescBal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -324,7 +324,7 @@ public void testForMultipleItemsJsonArrayInLIne() throws IOException { @Test(description = "Test for JSON array of objects") public void testForJsonArrayOfObjects() throws IOException { String jsonFileContent = Files.readString(sample10Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample10Bal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -333,7 +333,7 @@ public void testForJsonArrayOfObjects() throws IOException { @Test(description = "Test for JSON array of objects - inline") public void testForJsonArrayOfObjectsInLIne() throws IOException { String jsonFileContent = Files.readString(sample10Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, false, false, null) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", true, false, false, null, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample10TypeDescBal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -342,7 +342,7 @@ public void testForJsonArrayOfObjectsInLIne() throws IOException { @Test(description = "Test for JSON field names with special characters") public void testForJsonFieldsOfSpecialChars() throws IOException { String jsonFileContent = Files.readString(sample11Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null) + String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample11Bal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -352,7 +352,7 @@ public void testForJsonFieldsOfSpecialChars() throws IOException { public void testForInvalidJson() throws IOException { String jsonFileContent = Files.readString(sample12Json); List diagnostics = - JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null).getDiagnostics(); + JsonToRecordMapper.convert(jsonFileContent, "", false, false, false, null, null).getDiagnostics(); String diagnosticMessage = "Provided JSON is invalid : Unterminated object at line 15 column 8 path $.friend.address.city"; Assert.assertEquals(diagnostics.size(), 1); @@ -363,7 +363,7 @@ public void testForInvalidJson() throws IOException { public void testForSimilarRecordNameAndFieldName() throws IOException { String jsonFileContent = Files.readString(sample13Json); List diagnostics = - JsonToRecordMapper.convert(jsonFileContent, "Person", false, false, false, null).getDiagnostics(); + JsonToRecordMapper.convert(jsonFileContent, "Person", false, false, false, null, null).getDiagnostics(); String diagnosticMessage = "Provided record name 'Person' conflicts with the other generated records. " + "Consider providing a different name."; Assert.assertEquals(diagnostics.size(), 1); @@ -373,7 +373,8 @@ public void testForSimilarRecordNameAndFieldName() throws IOException { @Test(description = "Test for JSON with user defined record name") public void testForUserDefinedRecordName() throws IOException { String jsonFileContent = Files.readString(sample3Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "Person", false, false, false, null) + String generatedCodeBlock = JsonToRecordMapper + .convert(jsonFileContent, "Person", false, false, false, null, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample3PersonBal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -382,7 +383,8 @@ public void testForUserDefinedRecordName() throws IOException { @Test(description = "Test for JSON with user defined record name - inline") public void testForUserDefinedRecordNameInLIne() throws IOException { String jsonFileContent = Files.readString(sample3Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "Person", true, false, false, null) + String generatedCodeBlock = JsonToRecordMapper + .convert(jsonFileContent, "Person", true, false, false, null, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample3PersonTypeDescBal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -415,7 +417,7 @@ public void testChoreoTransPayloads() throws IOException { for (Map.Entry sample : samples.entrySet()) { String jsonFileContent = Files.readString(sample.getKey()); JsonToRecordResponse jsonToRecordResponse = - JsonToRecordMapper.convert(jsonFileContent, null, false, false, false, null); + JsonToRecordMapper.convert(jsonFileContent, null, false, false, false, null, null); if (jsonToRecordResponse.getCodeBlock() != null) { String generatedCodeBlock = jsonToRecordResponse.getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample.getValue()).replaceAll("\\s+", ""); @@ -431,8 +433,8 @@ public void testChoreoTransPayloads() throws IOException { @Test(description = "Test for conflicting record names in invalid bal file") public void testForConflictingRecordNamesInInvalidBalFile() throws IOException { String jsonFileContent = Files.readString(sample2Json); - JsonToRecordResponse response = - JsonToRecordMapper.convert(jsonFileContent, null, false, false, false, invalidBalFile.toString()); + JsonToRecordResponse response = JsonToRecordMapper + .convert(jsonFileContent, null, false, false, false, invalidBalFile.toUri().toString(), null); String generatedCodeBlock = response.getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample2Bal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -456,10 +458,10 @@ public void testForConflictingRecordNamesInSingleBalFileProject() throws IOExcep Path jsonFilePath = entry.getValue().getValue1(); Path balFilePath = RES_DIR.resolve(PROJECT_DIR).resolve(ASSERT_DIR).resolve("singleFileProject") .resolve(entry.getKey()); - String balExistingFilePath = entry.getValue().getValue0().toString(); + String balExistingFilePath = entry.getValue().getValue0().toUri().toString(); String jsonFileContent = Files.readString(jsonFilePath); - JsonToRecordResponse jsonToRecordResponse = - JsonToRecordMapper.convert(jsonFileContent, null, false, false, false, balExistingFilePath); + JsonToRecordResponse jsonToRecordResponse = JsonToRecordMapper + .convert(jsonFileContent, null, false, false, false, balExistingFilePath, null); String generatedCodeBlock = jsonToRecordResponse.getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(balFilePath).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -468,10 +470,10 @@ public void testForConflictingRecordNamesInSingleBalFileProject() throws IOExcep Path jsonFilePath = entry.getValue().getValue1(); Path balFilePath = RES_DIR.resolve(PROJECT_DIR).resolve(ASSERT_DIR).resolve("singleFileProject") .resolve(entry.getKey()); - String balExistingFilePath = entry.getValue().getValue0().toString(); + String balExistingFilePath = entry.getValue().getValue0().toUri().toString(); String jsonFileContent = Files.readString(jsonFilePath); JsonToRecordResponse jsonToRecordResponse = - JsonToRecordMapper.convert(jsonFileContent, null, true, false, false, balExistingFilePath); + JsonToRecordMapper.convert(jsonFileContent, null, true, false, false, balExistingFilePath, null); String generatedCodeBlock = jsonToRecordResponse.getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(balFilePath).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -482,7 +484,8 @@ public void testForConflictingRecordNamesInSingleBalFileProject() throws IOExcep public void testForConflictingParentRecordName() throws IOException { String jsonFileContent = Files.readString(sample2Json); List diagnostics = JsonToRecordMapper - .convert(jsonFileContent, "Friend", false, false, false, sample2Bal.toString()).getDiagnostics(); + .convert(jsonFileContent, "Friend", false, false, false, sample2Bal.toUri().toString(), null) + .getDiagnostics(); String diagnosticMessage = "Provided record name 'Friend' conflicts with already existing records. " + "Consider providing a different name."; Assert.assertEquals(diagnostics.size(), 1); @@ -493,7 +496,8 @@ public void testForConflictingParentRecordName() throws IOException { public void testForConflictingRecordNamesInBalProjectDefault() throws IOException { String jsonFileContent = Files.readString(sample2Json); String generatedCodeBlock = JsonToRecordMapper - .convert(jsonFileContent, null, false, false, false, balProjectFileDefaultModule.toString()) + .convert(jsonFileContent, null, false, false, false, + balProjectFileDefaultModule.toUri().toString(), null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(balProjectFileDefaultModuleAssert).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -503,7 +507,7 @@ public void testForConflictingRecordNamesInBalProjectDefault() throws IOExceptio public void testForConflictingRecordNamesInBalProjectNonDefault() throws IOException { String jsonFileContent = Files.readString(sample6Json); String generatedCodeBlock = JsonToRecordMapper - .convert(jsonFileContent, "", false, false, false, balProjectFileUtilModule.toString()) + .convert(jsonFileContent, "", false, false, false, balProjectFileUtilModule.toUri().toString(), null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(balProjectFileUtilModuleAssert).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); @@ -513,7 +517,8 @@ public void testForConflictingRecordNamesInBalProjectNonDefault() throws IOExcep public void testForConflictingRecordNameRenameDiagnostics() throws IOException { String jsonFileContent = Files.readString(sample6Json); List diagnostics = JsonToRecordMapper - .convert(jsonFileContent, "NewRecord", false, false, false, balProjectFileUtilModule.toString()) + .convert(jsonFileContent, "NewRecord", false, false, false, + balProjectFileUtilModule.toUri().toString(), null) .getDiagnostics(); String diagnosticMessage0 = "The record name 'State' is renamed as 'State_01'. " + "Consider rename it back to a meaningful name."; diff --git a/misc/ls-extensions/modules/json-to-record-converter/src/main/java/io/ballerina/converters/JsonToRecordConverterService.java b/misc/ls-extensions/modules/json-to-record-converter/src/main/java/io/ballerina/converters/JsonToRecordConverterService.java index 53f3a3f597b4..d96487bbba17 100644 --- a/misc/ls-extensions/modules/json-to-record-converter/src/main/java/io/ballerina/converters/JsonToRecordConverterService.java +++ b/misc/ls-extensions/modules/json-to-record-converter/src/main/java/io/ballerina/converters/JsonToRecordConverterService.java @@ -29,8 +29,10 @@ import org.ballerinalang.annotation.JavaSPIService; import org.ballerinalang.formatter.core.FormatterException; import org.ballerinalang.langserver.commons.service.spi.ExtendedLanguageServerService; +import org.ballerinalang.langserver.commons.workspace.WorkspaceManager; import org.eclipse.lsp4j.jsonrpc.services.JsonRequest; import org.eclipse.lsp4j.jsonrpc.services.JsonSegment; +import org.eclipse.lsp4j.services.LanguageServer; import java.io.IOException; import java.util.List; @@ -45,6 +47,13 @@ @JavaSPIService("org.ballerinalang.langserver.commons.service.spi.ExtendedLanguageServerService") @JsonSegment("jsonToRecord") public class JsonToRecordConverterService implements ExtendedLanguageServerService { + private WorkspaceManager workspaceManager; + + @Override + public void init(LanguageServer langServer, WorkspaceManager workspaceManager) { + ExtendedLanguageServerService.super.init(langServer, workspaceManager); + this.workspaceManager = workspaceManager; + } @Override public Class getRemoteInterface() { @@ -61,7 +70,7 @@ public CompletableFuture convert(JsonToRecordRequest reque boolean isRecordTypeDesc = request.getIsRecordTypeDesc(); boolean isClosed = request.getIsClosed(); boolean forceFormatRecordFields = request.getForceFormatRecordFields(); - String filePath = request.getFilePath(); + String filePathUri = request.getFilePathUri(); try { JsonElement parsedJson = JsonParser.parseString(jsonString); @@ -76,7 +85,8 @@ public CompletableFuture convert(JsonToRecordRequest reque } } else { response = JsonToRecordMapper.convert(jsonString, recordName, isRecordTypeDesc, isClosed, - forceFormatRecordFields, filePath); + forceFormatRecordFields, filePathUri, workspaceManager); + } } catch (JsonSyntaxException e) { DiagnosticMessage message = DiagnosticMessage.jsonToRecordConverter100(new String[]{e.getMessage()}); diff --git a/misc/ls-extensions/modules/json-to-record-converter/src/main/java/io/ballerina/converters/JsonToRecordRequest.java b/misc/ls-extensions/modules/json-to-record-converter/src/main/java/io/ballerina/converters/JsonToRecordRequest.java index f3beb07c66a6..64a7e57939cd 100644 --- a/misc/ls-extensions/modules/json-to-record-converter/src/main/java/io/ballerina/converters/JsonToRecordRequest.java +++ b/misc/ls-extensions/modules/json-to-record-converter/src/main/java/io/ballerina/converters/JsonToRecordRequest.java @@ -29,16 +29,16 @@ public class JsonToRecordRequest { private boolean isRecordTypeDesc; private boolean isClosed; private boolean forceFormatRecordFields; - private String filePath; + private String filePathUri; public JsonToRecordRequest(String jsonString, String recordName, boolean isRecordTypeDesc, boolean isClosed, - boolean forceFormatRecordFields, String filePath) { + boolean forceFormatRecordFields, String filePathUri) { this.jsonString = jsonString; this.recordName = recordName; this.isRecordTypeDesc = isRecordTypeDesc; this.isClosed = isClosed; this.forceFormatRecordFields = forceFormatRecordFields; - this.filePath = filePath; + this.filePathUri = filePathUri; } public String getJsonString() { @@ -81,11 +81,11 @@ public void setForceFormatRecordFields(boolean forceFormatRecordFields) { this.forceFormatRecordFields = forceFormatRecordFields; } - public String getFilePath() { - return filePath; + public String getFilePathUri() { + return filePathUri; } - public void setFilePath(String filePath) { - this.filePath = filePath; + public void setFilePathUri(String filePathUri) { + this.filePathUri = filePathUri; } } diff --git a/misc/ls-extensions/modules/json-to-record-converter/src/main/java/module-info.java b/misc/ls-extensions/modules/json-to-record-converter/src/main/java/module-info.java index fbf220362f42..2db7c1c24c37 100644 --- a/misc/ls-extensions/modules/json-to-record-converter/src/main/java/module-info.java +++ b/misc/ls-extensions/modules/json-to-record-converter/src/main/java/module-info.java @@ -19,6 +19,7 @@ requires org.eclipse.lsp4j.jsonrpc; requires swagger.parser.core; requires swagger.parser.v3; + requires org.eclipse.lsp4j; exports io.ballerina.converters; exports io.ballerina.converters.util; diff --git a/misc/ls-extensions/modules/json-to-record-converter/src/test/java/io/ballerina/converters/JsonToRecordConverterTests.java b/misc/ls-extensions/modules/json-to-record-converter/src/test/java/io/ballerina/converters/JsonToRecordConverterTests.java index b0d5187e576e..c61f26df9e6b 100644 --- a/misc/ls-extensions/modules/json-to-record-converter/src/test/java/io/ballerina/converters/JsonToRecordConverterTests.java +++ b/misc/ls-extensions/modules/json-to-record-converter/src/test/java/io/ballerina/converters/JsonToRecordConverterTests.java @@ -430,7 +430,7 @@ public void testJSON2RecordServiceConflictingRecNames() throws IOException, Exec String jsonString = Files.readString(sample10Json); JsonToRecordRequest request = new JsonToRecordRequest(jsonString, null, - false, false, false, sample10Bal.toString()); + false, false, false, sample10Bal.toUri().toString()); CompletableFuture result = serviceEndpoint.request(JsonToRecordService, request); io.ballerina.jsonmapper.JsonToRecordResponse response = (io.ballerina.jsonmapper.JsonToRecordResponse) result.get(); From 55f4a6dd6d530b8b074f465f08c482ea8636d763 Mon Sep 17 00:00:00 2001 From: sanjana Date: Mon, 19 Dec 2022 15:06:56 +0530 Subject: [PATCH 328/450] Add more examples in int langlib --- langlib/lang.int/src/main/ballerina/int.bal | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/langlib/lang.int/src/main/ballerina/int.bal b/langlib/lang.int/src/main/ballerina/int.bal index 6244db102317..8ebe3b92174f 100644 --- a/langlib/lang.int/src/main/ballerina/int.bal +++ b/langlib/lang.int/src/main/ballerina/int.bal @@ -116,6 +116,9 @@ public isolated function sum(int... ns) returns int = @java:Method { # ```ballerina # int:max(50, 20, 30, 70, 65) ⇒ 70 # +# int[] scores = [52, 45, 95, 76]; +# int:max(37, ...scores) ⇒ 95 +# # int n = 18; # n.max(25, 30, 4, 15) ⇒ 30 # ``` @@ -133,6 +136,9 @@ public isolated function max(int n, int... ns) returns int = @java:Method { # ```ballerina # int:min(45, 25, 30, 75, 50) ⇒ 25 # +# int[] points = [21, 12, 48, 14]; +# int:min(50, ...points) ⇒ 12 +# # int m = 23; # m.min(12, 43, 7, 19) ⇒ 7 # ``` From 59bbf850faaed40c85fdd18815d20dae4bc1d08d Mon Sep 17 00:00:00 2001 From: Sasindu Alahakoon Date: Tue, 29 Nov 2022 16:36:16 +0530 Subject: [PATCH 329/450] Add examples for boolean lang library api doc --- langlib/lang.boolean/src/main/ballerina/boolean.bal | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/langlib/lang.boolean/src/main/ballerina/boolean.bal b/langlib/lang.boolean/src/main/ballerina/boolean.bal index e5009ae56b70..998de75bca4f 100644 --- a/langlib/lang.boolean/src/main/ballerina/boolean.bal +++ b/langlib/lang.boolean/src/main/ballerina/boolean.bal @@ -24,6 +24,14 @@ import ballerina/jballerina.java; # and also `1` for true and `0` for `false`. # This is the inverse of function ``value:toString`` applied to a `boolean`. # +# ```ballerina +# boolean:fromString("true") ⇒ true +# +# boolean:fromString("0") ⇒ false +# +# boolean:fromString("01") ⇒ error +# ``` +# # + s - string representing a boolean value # + return - boolean that parameter `s` represents, or an error if there is no such boolean public isolated function fromString(string s) returns boolean|error = @java:Method { From 20d79876feff36f99f692d662e03eedb537b85e7 Mon Sep 17 00:00:00 2001 From: Thevakumar-Luheerathan Date: Mon, 19 Dec 2022 15:12:28 +0530 Subject: [PATCH 330/450] Fix the test case --- .../cli/task/RunNativeImageTestTask.java | 44 ++++++++++++++- .../cli/cmd/TestNativeImageCommandTest.java | 55 +++++++++++-------- .../test/runtime/util/TesterinaUtils.java | 2 +- 3 files changed, 73 insertions(+), 28 deletions(-) diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java index bfc9924a90be..632ce61b94bd 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java @@ -34,6 +34,7 @@ import io.ballerina.projects.ProjectException; import io.ballerina.projects.ProjectKind; import io.ballerina.projects.internal.model.Target; +import io.ballerina.projects.util.ProjectConstants; import org.apache.commons.compress.utils.IOUtils; import org.ballerinalang.test.runtime.entity.ModuleStatus; import org.ballerinalang.test.runtime.entity.TestReport; @@ -43,6 +44,7 @@ import org.wso2.ballerinalang.util.Lists; import java.io.File; +import java.io.FileInputStream; import java.io.FileWriter; import java.io.IOException; import java.io.PrintStream; @@ -57,6 +59,8 @@ import java.util.Map; import java.util.StringJoiner; import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; import static io.ballerina.cli.launcher.LauncherUtils.createLauncherException; import static io.ballerina.cli.utils.NativeUtils.createReflectConfig; @@ -197,7 +201,8 @@ public void execute(Project project) { if (hasTests) { int testResult = 1; try { - testResult = runTestSuiteWithNativeImage(project.currentPackage(), jBallerinaBackend, target); + testResult = runTestSuiteWithNativeImage(project.currentPackage(), jBallerinaBackend, target, + testSuiteMap); if (report || coverage) { for (String moduleName : moduleNamesList) { @@ -238,7 +243,8 @@ public void execute(Project project) { } } - private int runTestSuiteWithNativeImage(Package currentPackage, JBallerinaBackend jBallerinaBackend, Target target) + private int runTestSuiteWithNativeImage(Package currentPackage, JBallerinaBackend jBallerinaBackend, + Target target, Map testSuiteMap) throws IOException, InterruptedException { String packageName = currentPackage.packageName().toString(); String classPath = getClassPath(jBallerinaBackend, currentPackage); @@ -321,7 +327,10 @@ private int runTestSuiteWithNativeImage(Package currentPackage, JBallerinaBacken nativeArgs.addAll(Lists.of("-cp", classPath)); if (currentPackage.project().kind() == ProjectKind.SINGLE_FILE_PROJECT) { - packageName = currentPackage.project().sourceRoot().toString().replace(".bal",""); + String[] splittedArray = currentPackage.project().sourceRoot().toString(). + replace(ProjectConstants.BLANG_SOURCE_EXT, "").split("/"); + packageName = splittedArray[splittedArray.length - 1]; + validateResourcesWithinJar(testSuiteMap, packageName); } // set name and path @@ -373,6 +382,35 @@ private int runTestSuiteWithNativeImage(Package currentPackage, JBallerinaBacken } } + private void validateResourcesWithinJar(Map testSuiteMap, String packageName) + throws IOException { + TestSuite testSuite = testSuiteMap.values().toArray(new TestSuite[0])[0]; + List dependencies = testSuite.getTestExecutionDependencies(); + String jarPath = ""; + for (String dependency : dependencies) { + if (dependency.contains(packageName + ".jar")) { + jarPath = dependency; + } + } + try (ZipInputStream jarInputStream = new ZipInputStream(new FileInputStream(jarPath))) { + ZipEntry entry; + boolean isResourceExist = false; + while ((entry = jarInputStream.getNextEntry()) != null) { + String path = entry.getName(); + if (path.startsWith("resources/")) { + isResourceExist = true; + } + jarInputStream.closeEntry(); + } + jarInputStream.close(); + if (isResourceExist) { + throw createLauncherException("unable to generate native image. this single file project has " + + "resource folder inside"); + } + } + } + + private String getClassPath(JBallerinaBackend jBallerinaBackend, Package currentPackage) { List dependencies = new ArrayList<>(); JarResolver jarResolver = jBallerinaBackend.jarResolver(); diff --git a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestNativeImageCommandTest.java b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestNativeImageCommandTest.java index 3bf21aea73da..27291e389f5b 100644 --- a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestNativeImageCommandTest.java +++ b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestNativeImageCommandTest.java @@ -1,5 +1,6 @@ package io.ballerina.cli.cmd; +import io.ballerina.cli.launcher.BLauncherException; import io.ballerina.projects.ProjectEnvironmentBuilder; import io.ballerina.projects.environment.Environment; import io.ballerina.projects.environment.EnvironmentBuilder; @@ -60,29 +61,35 @@ public void testNativeImageTests() throws IOException { Assert.assertTrue(buildLog.contains("1 passing")); } -// TODO: Fix test cases that are failing due to "Caused by: java.util.zip.ZipException: ZIP file can't be opened as a -// file system because entry "/resources/$anon/./0/openapi-spec.yaml" has a '.' or '..' element in its name" error. -// @Test(description = "Test a valid ballerina file") -// public void testTestBalFile() throws IOException { -// Path validBalFilePath = this.testResources.resolve("valid-test-bal-file").resolve("sample_tests.bal"); -// System.setProperty(ProjectConstants.USER_DIR, this.testResources.resolve("valid-test-bal-file").toString()); -// TestCommand testCommand = new TestCommand(validBalFilePath, printStream, printStream, false, true); -// new CommandLine(testCommand).parseArgs(validBalFilePath.toString()); -// testCommand.execute(); -// String buildLog = readOutput(true); -// Assert.assertTrue(buildLog.contains("1 passing")); -// } -// -// @Test(description = "Test a valid ballerina file with periods in the file name") -// public void testTestBalFileWithPeriods() throws IOException { -// Path validBalFilePath = this.testResources.resolve("valid-test-bal-file").resolve("sample.tests.bal"); -// -// System.setProperty(ProjectConstants.USER_DIR, this.testResources.resolve("valid-test-bal-file").toString()); -// TestCommand testCommand = new TestCommand(validBalFilePath, printStream, printStream, false, true); -// new CommandLine(testCommand).parseArgs(validBalFilePath.toString()); -// testCommand.execute(); -// String buildLog = readOutput(true); -// Assert.assertTrue(buildLog.contains("1 passing")); -// } + //TODO: Change the output once the resource generation plugin is disabled + @Test(description = "Test a valid ballerina file") + public void testTestBalFile() throws IOException { + Path validBalFilePath = this.testResources.resolve("valid-test-bal-file").resolve("sample_tests.bal"); + System.setProperty(ProjectConstants.USER_DIR, this.testResources.resolve("valid-test-bal-file").toString()); + TestCommand testCommand = new TestCommand(validBalFilePath, printStream, printStream, false, true); + new CommandLine(testCommand).parseArgs(validBalFilePath.toString()); + try { + testCommand.execute(); + } catch (BLauncherException e) { + Assert.assertTrue(e.getDetailedMessages().get(0).contains("unable to generate native image. this " + + "single file project has resource folder inside")); + } + } + + //TODO: Change the output once the resource generation plugin is disabled + @Test(description = "Test a valid ballerina file with periods in the file name") + public void testTestBalFileWithPeriods() throws IOException { + Path validBalFilePath = this.testResources.resolve("valid-test-bal-file").resolve("sample.tests.bal"); + + System.setProperty(ProjectConstants.USER_DIR, this.testResources.resolve("valid-test-bal-file").toString()); + TestCommand testCommand = new TestCommand(validBalFilePath, printStream, printStream, false, true); + new CommandLine(testCommand).parseArgs(validBalFilePath.toString()); + try { + testCommand.execute(); + } catch (BLauncherException e) { + Assert.assertTrue(e.getDetailedMessages().get(0).contains("unable to generate native image. this " + + "single file project has resource folder inside")); + } + } } diff --git a/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/TesterinaUtils.java b/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/TesterinaUtils.java index b1e0239d353e..daf7d0daf4d0 100644 --- a/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/TesterinaUtils.java +++ b/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/TesterinaUtils.java @@ -133,7 +133,7 @@ private static void execute(TestSuite suite, ClassLoader classLoader, TestArgume throw new BallerinaTestException("failed to load configuration class :" + configClassName); } String suiteExecuteFilePath = suite.getExecuteFilePath(); - if(suite.getOrgName().equals(ANON_ORG) && suite.getTestPackageID().equals(DOT)) { + if (suite.getOrgName().equals(ANON_ORG) && suite.getTestPackageID().equals(DOT)) { suiteExecuteFilePath = suiteExecuteFilePath.replace(DOT, FILE_NAME_PERIOD_SEPARATOR); } String testExecuteClassName = TesterinaUtils.getQualifiedClassName(suite.getOrgName(), From 6a8f5c235d93c081645db1f4dbe425598b5c9ef5 Mon Sep 17 00:00:00 2001 From: Hinduja Date: Mon, 19 Dec 2022 15:16:04 +0530 Subject: [PATCH 331/450] Address review comments --- .github/workflows/pull_request_full_build.yml | 1 - .github/workflows/pull_request_ubuntu_build.yml | 1 - .github/workflows/pull_request_windows_build.yml | 1 - .../nativeimpl/jvm/runtime/api/tests/TypeReference.java | 2 +- 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/pull_request_full_build.yml b/.github/workflows/pull_request_full_build.yml index c234f66dd88d..de882faaaaee 100644 --- a/.github/workflows/pull_request_full_build.yml +++ b/.github/workflows/pull_request_full_build.yml @@ -4,7 +4,6 @@ on: pull_request: branches: - master - - type-reference-support jobs: build-lang: diff --git a/.github/workflows/pull_request_ubuntu_build.yml b/.github/workflows/pull_request_ubuntu_build.yml index f72d9684f718..1251699bec28 100644 --- a/.github/workflows/pull_request_ubuntu_build.yml +++ b/.github/workflows/pull_request_ubuntu_build.yml @@ -13,7 +13,6 @@ on: - 2201.[0-9]+.x - 2201.[0-9]+.[0-9]+-stage - native-build - - type-reference-support - revert-client-decl-master jobs: diff --git a/.github/workflows/pull_request_windows_build.yml b/.github/workflows/pull_request_windows_build.yml index c0745cd1f9e2..45addbe0669c 100644 --- a/.github/workflows/pull_request_windows_build.yml +++ b/.github/workflows/pull_request_windows_build.yml @@ -13,7 +13,6 @@ on: - 2201.[0-9]+.x - 2201.[0-9]+.[0-9]+-stage - native-build - - type-reference-support - revert-client-decl-master jobs: diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java index 1f403c39c7da..aee8221d1b68 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/nativeimpl/jvm/runtime/api/tests/TypeReference.java @@ -55,7 +55,7 @@ /** * Utility methods used for runtime api @{@link io.ballerina.runtime.internal.types.BTypeReferenceType} testing. * - * @since 2201.3.0 + * @since 2201.4.0 */ public class TypeReference { From 4e332a0100c6f96a0338a23cf8893860ef8573d7 Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Mon, 19 Dec 2022 15:49:01 +0530 Subject: [PATCH 332/450] Resolve merge conflicts --- .../ballerina/jsonmapper/JsonToRecordMapper.java | 10 +++++----- .../jsonmapper/JsonToRecordMapperTests.java | 3 ++- .../assert/singleFileProject/sample_11.bal | 15 ++++++++++++++- .../singleFileProject/sample_9_type_desc.bal | 3 ++- .../balProject/modules/util/tests/lib_test.bal | 6 +++--- 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java index bd9558fe3eb8..a36b27f91c2f 100644 --- a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java +++ b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/JsonToRecordMapper.java @@ -169,9 +169,9 @@ public static JsonToRecordResponse convert(String jsonString, String recordName, (recordName == null || recordName.equals("")) ? getAndUpdateFieldNames(NEW_RECORD_NAME, false, existingFieldNames, updatedFieldNames) - : recordName : entry.getKey(); + : escapeIdentifier(StringUtils.capitalize(recordName)) : entry.getKey(); IdentifierToken typeName = AbstractNodeFactory - .createIdentifierToken(escapeIdentifier(recordTypeName)); + .createIdentifierToken(recordTypeName); Token semicolon = AbstractNodeFactory.createToken(SyntaxKind.SEMICOLON_TOKEN); return NodeFactory.createTypeDefinitionNode(null, null, typeKeyWord, typeName, entry.getValue(), semicolon); @@ -231,7 +231,7 @@ private static void generateRecords(JsonObject jsonObject, String recordName, bo for (Map.Entry entry : jsonObject.entrySet()) { if (entry.getValue().isJsonObject() || entry.getValue().isJsonArray()) { generateRecordForObjAndArray(entry.getValue(), entry.getKey(), isClosed, recordToTypeDescNodes, - recordName, jsonNodes, diagnosticMessages, false); + recordName, jsonNodes, existingFieldNames, updatedFieldNames, diagnosticMessages, false); } jsonNodes.put(entry.getKey(), entry.getValue()); } @@ -254,7 +254,7 @@ private static void generateRecords(JsonObject jsonObject, String recordName, bo for (Map.Entry entry : jsonObject.entrySet()) { if (entry.getValue().isJsonObject() || entry.getValue().isJsonArray()) { generateRecordForObjAndArray(entry.getValue(), entry.getKey(), isClosed, recordToTypeDescNodes, - null, jsonNodes, diagnosticMessages, false); + null, jsonNodes, existingFieldNames, updatedFieldNames, diagnosticMessages, false); } jsonNodes.put(entry.getKey(), entry.getValue()); Node recordField = getRecordField(entry, existingFieldNames, updatedFieldNames, false); @@ -290,7 +290,7 @@ private static void generateRecordForObjAndArray(JsonElement jsonElement, String boolean arraySuffixAdded) { if (jsonElement.isJsonObject()) { String type = escapeIdentifier(StringUtils.capitalize(elementKey)); - String updatedType = getAndUpdateFieldNames(type, false, existingFieldNames, updatedFieldNames); + String updatedType = getAndUpdateFieldNames(type, arraySuffixAdded, existingFieldNames, updatedFieldNames); generateRecords(jsonElement.getAsJsonObject(), updatedType, isClosed, recordToTypeDescNodes, moveBefore, jsonNodes, existingFieldNames, updatedFieldNames, diagnosticMessages); } else if (jsonElement.isJsonArray()) { diff --git a/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java b/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java index 6748c3ab048b..fc77cb56cd4b 100644 --- a/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java +++ b/misc/json-to-record-converter/src/test/java/io/ballerina/jsonmapper/JsonToRecordMapperTests.java @@ -393,7 +393,8 @@ public void testForUserDefinedRecordNameInLIne() throws IOException { @Test(description = "Test for JSON with user defined record name with special chars") public void testForUserDefinedRecordNameWithSpecialChars() throws IOException { String jsonFileContent = Files.readString(sample3Json); - String generatedCodeBlock = JsonToRecordMapper.convert(jsonFileContent, "Special Person", false, false, false) + String generatedCodeBlock = + JsonToRecordMapper.convert(jsonFileContent, "Special Person", false, false, false, null, null) .getCodeBlock().replaceAll("\\s+", ""); String expectedCodeBlock = Files.readString(sample3SpecialCharBal).replaceAll("\\s+", ""); Assert.assertEquals(generatedCodeBlock, expectedCodeBlock); diff --git a/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_11.bal b/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_11.bal index 9c18a08e86ec..bc0c04e15b43 100644 --- a/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_11.bal +++ b/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_11.bal @@ -1,8 +1,21 @@ +type Special\ object_01 record { + string name; + int age; +}; + +type Special\\array\-\?_01Item record { + string date; + int value; + string 'type?; + string[] \2\ favourite\-colors?; +}; + type NewRecord_01 record { string first\ Name; string last\+Name\?; string \007; int ϼ\ \+\-\+; boolean ōŊĖ; - string house\\Address\+\?; + Special\ object_01 special\ object; + (Special\\array\-\?_01Item[]|Special\\array\-\?_01Item[][])[] special\\array\-\?; }; diff --git a/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_9_type_desc.bal b/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_9_type_desc.bal index 981d01c9583a..b316e90db43b 100644 --- a/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_9_type_desc.bal +++ b/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_9_type_desc.bal @@ -4,5 +4,6 @@ type NewRecord_01 record { string name; decimal ppu; record {(decimal|int|record {string id; string 'type; boolean fresh?;}|string)[] batter;} batters; - (record {string id; string 'type;}|string|record {string id;string 'type;}[]|string[])[] topping; + (record {string id; string 'type; string color?;}|string|record {string id; string 'type; string color?;}[]|string[])[] topping; + record {stringid ; string 'type; stringcolor? ;}[][] base; }; diff --git a/misc/json-to-record-converter/src/test/resources/project/source/balProject/modules/util/tests/lib_test.bal b/misc/json-to-record-converter/src/test/resources/project/source/balProject/modules/util/tests/lib_test.bal index d97a372d7fdd..8f6116c819ef 100644 --- a/misc/json-to-record-converter/src/test/resources/project/source/balProject/modules/util/tests/lib_test.bal +++ b/misc/json-to-record-converter/src/test/resources/project/source/balProject/modules/util/tests/lib_test.bal @@ -1,11 +1,11 @@ -import ballerina/io; +// import ballerina/io; import ballerina/test; // Before Suite Function @test:BeforeSuite function beforeSuiteFunc() { - io:println("I'm the before suite function!"); + // io:println("I'm the before suite function!"); } // Test function @@ -30,5 +30,5 @@ function negativeTestFunction() { @test:AfterSuite function afterSuiteFunc() { - io:println("I'm the after suite function!"); + // io:println("I'm the after suite function!"); } From 9992ee9e877249ffe1b7d06d98c0ecfaa6f53280 Mon Sep 17 00:00:00 2001 From: Imesha Sudasingha Date: Mon, 19 Dec 2022 16:32:14 +0530 Subject: [PATCH 333/450] Fix failing tests after syncing upstream --- .../error_constructor_expr_ctx_config12.json | 132 ++++---- .../error_constructor_expr_ctx_config13.json | 281 +++++++++--------- .../error_constructor_expr_ctx_config14.json | 281 +++++++++--------- .../error_constructor_expr_ctx_config15.json | 281 +++++++++--------- .../error_constructor_expr_ctx_config16.json | 281 +++++++++--------- .../error_constructor_expr_ctx_config9.json | 130 ++++---- 6 files changed, 711 insertions(+), 675 deletions(-) diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config12.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config12.json index b1a82501de60..73f7ebfe15c0 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config12.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config12.json @@ -9,7 +9,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -33,7 +33,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -57,7 +57,7 @@ "label": "ballerina/module1", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet", @@ -81,7 +81,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -105,7 +105,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -129,7 +129,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -153,7 +153,7 @@ "label": "map", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "map", "insertTextFormat": "Snippet" }, @@ -161,7 +161,7 @@ "label": "object", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "object", "insertTextFormat": "Snippet" }, @@ -169,7 +169,7 @@ "label": "stream", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "stream", "insertTextFormat": "Snippet" }, @@ -177,7 +177,7 @@ "label": "table", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "table", "insertTextFormat": "Snippet" }, @@ -185,7 +185,7 @@ "label": "transaction", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "transaction", "insertTextFormat": "Snippet" }, @@ -193,7 +193,7 @@ "label": "service", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "service", "insertText": "service", "insertTextFormat": "Snippet" @@ -202,7 +202,7 @@ "label": "new", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "new", "insertText": "new ", "insertTextFormat": "Snippet" @@ -211,7 +211,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -220,7 +220,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -229,7 +229,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -238,7 +238,7 @@ "label": "let", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "let", "insertText": "let", "insertTextFormat": "Snippet" @@ -247,7 +247,7 @@ "label": "typeof", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "typeof", "insertText": "typeof ", "insertTextFormat": "Snippet" @@ -256,7 +256,7 @@ "label": "trap", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "trap", "insertText": "trap", "insertTextFormat": "Snippet" @@ -265,7 +265,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -274,7 +274,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -283,7 +283,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -292,7 +292,7 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" @@ -301,7 +301,7 @@ "label": "check", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "check", "insertText": "check ", "insertTextFormat": "Snippet" @@ -310,7 +310,7 @@ "label": "checkpanic", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "checkpanic", "insertText": "checkpanic ", "insertTextFormat": "Snippet" @@ -319,7 +319,7 @@ "label": "is", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "is", "insertText": "is", "insertTextFormat": "Snippet" @@ -328,7 +328,7 @@ "label": "error constructor", "kind": "Snippet", "detail": "Snippet", - "sortText": "BP", + "sortText": "T", "filterText": "error", "insertText": "error(\"${1}\")", "insertTextFormat": "Snippet" @@ -337,7 +337,7 @@ "label": "object constructor", "kind": "Snippet", "detail": "Snippet", - "sortText": "BP", + "sortText": "T", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -346,7 +346,7 @@ "label": "base16", "kind": "Snippet", "detail": "Snippet", - "sortText": "BP", + "sortText": "T", "filterText": "base16", "insertText": "base16 `${1}`", "insertTextFormat": "Snippet" @@ -355,7 +355,7 @@ "label": "base64", "kind": "Snippet", "detail": "Snippet", - "sortText": "BP", + "sortText": "T", "filterText": "base64", "insertText": "base64 `${1}`", "insertTextFormat": "Snippet" @@ -364,7 +364,7 @@ "label": "from", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "from", "insertText": "from ", "insertTextFormat": "Snippet" @@ -373,7 +373,7 @@ "label": "ce", "kind": "Variable", "detail": "ERR", - "sortText": "BB", + "sortText": "AB", "insertText": "ce", "insertTextFormat": "Snippet" }, @@ -381,7 +381,7 @@ "label": "ERR", "kind": "Event", "detail": "Error", - "sortText": "BL", + "sortText": "AL", "insertText": "ERR", "insertTextFormat": "Snippet" }, @@ -389,7 +389,7 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "BN", + "sortText": "R", "insertText": "Thread", "insertTextFormat": "Snippet" }, @@ -403,7 +403,7 @@ "value": "**Package:** _._ \n \n \n" } }, - "sortText": "BC", + "sortText": "AC", "filterText": "name", "insertText": "name()", "insertTextFormat": "Snippet" @@ -415,7 +415,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "BM", + "sortText": "Q", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -423,7 +423,7 @@ "label": "ErrorData", "kind": "Struct", "detail": "Record", - "sortText": "BM", + "sortText": "Q", "insertText": "ErrorData", "insertTextFormat": "Snippet" }, @@ -431,7 +431,7 @@ "label": "cause = ...", "kind": "Snippet", "detail": "cause = error(\"\")", - "sortText": "AR", + "sortText": "A", "filterText": "cause", "insertText": "cause = ${1:error(\"\")}", "insertTextFormat": "Snippet" @@ -440,7 +440,7 @@ "label": "errID = ...", "kind": "Snippet", "detail": "errID = 0", - "sortText": "AR", + "sortText": "A", "filterText": "errID", "insertText": "errID = ${1:0}", "insertTextFormat": "Snippet" @@ -449,7 +449,7 @@ "label": "start", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "start", "insertText": "start ", "insertTextFormat": "Snippet" @@ -458,7 +458,7 @@ "label": "wait", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "wait", "insertText": "wait ", "insertTextFormat": "Snippet" @@ -467,7 +467,7 @@ "label": "flush", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "flush", "insertText": "flush ", "insertTextFormat": "Snippet" @@ -476,7 +476,7 @@ "label": "from clause", "kind": "Snippet", "detail": "Snippet", - "sortText": "BP", + "sortText": "T", "filterText": "from", "insertText": "from ${1:var} ${2:item} in ${3}", "insertTextFormat": "Snippet" @@ -485,7 +485,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -509,7 +509,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -533,7 +533,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -557,7 +557,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -581,7 +581,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -605,7 +605,7 @@ "label": "re ``", "kind": "Snippet", "detail": "Snippet", - "sortText": "BP", + "sortText": "T", "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" @@ -614,7 +614,7 @@ "label": "decimal", "kind": "TypeParameter", "detail": "Decimal", - "sortText": "BN", + "sortText": "R", "insertText": "decimal", "insertTextFormat": "Snippet" }, @@ -622,7 +622,7 @@ "label": "error", "kind": "Event", "detail": "Error", - "sortText": "BL", + "sortText": "AL", "insertText": "error", "insertTextFormat": "Snippet" }, @@ -630,7 +630,7 @@ "label": "xml", "kind": "TypeParameter", "detail": "Xml", - "sortText": "BN", + "sortText": "R", "insertText": "xml", "insertTextFormat": "Snippet" }, @@ -638,7 +638,7 @@ "label": "boolean", "kind": "TypeParameter", "detail": "Boolean", - "sortText": "BN", + "sortText": "R", "insertText": "boolean", "insertTextFormat": "Snippet" }, @@ -646,7 +646,7 @@ "label": "future", "kind": "TypeParameter", "detail": "Future", - "sortText": "BN", + "sortText": "R", "insertText": "future", "insertTextFormat": "Snippet" }, @@ -654,7 +654,7 @@ "label": "int", "kind": "TypeParameter", "detail": "Int", - "sortText": "BN", + "sortText": "R", "insertText": "int", "insertTextFormat": "Snippet" }, @@ -662,7 +662,7 @@ "label": "float", "kind": "TypeParameter", "detail": "Float", - "sortText": "BN", + "sortText": "R", "insertText": "float", "insertTextFormat": "Snippet" }, @@ -670,7 +670,7 @@ "label": "function", "kind": "TypeParameter", "detail": "Function", - "sortText": "BN", + "sortText": "R", "insertText": "function", "insertTextFormat": "Snippet" }, @@ -678,7 +678,7 @@ "label": "string", "kind": "TypeParameter", "detail": "String", - "sortText": "BN", + "sortText": "R", "insertText": "string", "insertTextFormat": "Snippet" }, @@ -686,7 +686,7 @@ "label": "typedesc", "kind": "TypeParameter", "detail": "Typedesc", - "sortText": "BN", + "sortText": "R", "insertText": "typedesc", "insertTextFormat": "Snippet" }, @@ -694,7 +694,7 @@ "label": "readonly", "kind": "TypeParameter", "detail": "Readonly", - "sortText": "BN", + "sortText": "R", "insertText": "readonly", "insertTextFormat": "Snippet" }, @@ -702,7 +702,7 @@ "label": "handle", "kind": "TypeParameter", "detail": "Handle", - "sortText": "BN", + "sortText": "R", "insertText": "handle", "insertTextFormat": "Snippet" }, @@ -710,7 +710,7 @@ "label": "never", "kind": "TypeParameter", "detail": "Never", - "sortText": "BN", + "sortText": "R", "insertText": "never", "insertTextFormat": "Snippet" }, @@ -718,7 +718,7 @@ "label": "json", "kind": "TypeParameter", "detail": "Json", - "sortText": "BN", + "sortText": "R", "insertText": "json", "insertTextFormat": "Snippet" }, @@ -726,7 +726,7 @@ "label": "anydata", "kind": "TypeParameter", "detail": "Anydata", - "sortText": "BN", + "sortText": "R", "insertText": "anydata", "insertTextFormat": "Snippet" }, @@ -734,7 +734,7 @@ "label": "any", "kind": "TypeParameter", "detail": "Any", - "sortText": "BN", + "sortText": "R", "insertText": "any", "insertTextFormat": "Snippet" }, @@ -742,7 +742,7 @@ "label": "byte", "kind": "TypeParameter", "detail": "Byte", - "sortText": "BN", + "sortText": "R", "insertText": "byte", "insertTextFormat": "Snippet" } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config13.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config13.json index 85797253f78c..4a81463c8f2a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config13.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config13.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -460,62 +388,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "start", "kind": "Keyword", @@ -648,14 +520,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -710,6 +574,151 @@ "sortText": "AB", "insertText": "newError", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "AL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "re ``", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "T", + "filterText": "re ``", + "insertText": "re `${1}`", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config14.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config14.json index 1a71d6214f9b..8a3fbf8a9488 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config14.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config14.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -460,62 +388,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "start", "kind": "Keyword", @@ -648,14 +520,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -736,6 +600,151 @@ "filterText": "detail", "insertText": "detail = ${1:\"\"}", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "AL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "re ``", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "T", + "filterText": "re ``", + "insertText": "re `${1}`", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config15.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config15.json index 0f149c30b3b9..ef9dabb2a0c6 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config15.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config15.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -460,62 +388,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "start", "kind": "Keyword", @@ -648,14 +520,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -736,6 +600,151 @@ "filterText": "detail", "insertText": "detail = ${1:\"\"}", "insertTextFormat": "Snippet" + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "AL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "re ``", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "T", + "filterText": "re ``", + "insertText": "re `${1}`", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config16.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config16.json index f7c5d966a185..9e89f36eab2d 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config16.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config16.json @@ -149,54 +149,6 @@ } ] }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "error", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "int", - "insertTextFormat": "Snippet" - }, { "label": "map", "kind": "Unit", @@ -221,14 +173,6 @@ "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "string", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", @@ -245,22 +189,6 @@ "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", @@ -460,62 +388,6 @@ "insertText": "StrandData", "insertTextFormat": "Snippet" }, - { - "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "readonly", - "insertTextFormat": "Snippet" - }, - { - "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "handle", - "insertTextFormat": "Snippet" - }, - { - "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "never", - "insertTextFormat": "Snippet" - }, - { - "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "json", - "insertTextFormat": "Snippet" - }, - { - "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "anydata", - "insertTextFormat": "Snippet" - }, - { - "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "any", - "insertTextFormat": "Snippet" - }, - { - "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "byte", - "insertTextFormat": "Snippet" - }, { "label": "test/project2", "kind": "Module", @@ -612,14 +484,6 @@ } ] }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "R", - "insertText": "function", - "insertTextFormat": "Snippet" - }, { "label": "ballerina/lang.regexp", "kind": "Module", @@ -702,6 +566,151 @@ "title": "editor.action.triggerParameterHints", "command": "editor.action.triggerParameterHints" } + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "R", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "P", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "R", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "R", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "R", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "R", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "R", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "R", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "R", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "R", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "re ``", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "T", + "filterText": "re ``", + "insertText": "re `${1}`", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "R", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "R", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "R", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "R", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "R", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "R", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "R", + "insertText": "byte", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config9.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config9.json index 409466a4668a..43297e9b55ee 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config9.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/error_constructor_expr_ctx_config9.json @@ -9,7 +9,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -33,7 +33,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -57,7 +57,7 @@ "label": "ballerina/module1", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "module1", "insertText": "module1", "insertTextFormat": "Snippet", @@ -81,7 +81,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -105,7 +105,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -129,7 +129,7 @@ "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -153,7 +153,7 @@ "label": "map", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "map", "insertTextFormat": "Snippet" }, @@ -161,7 +161,7 @@ "label": "object", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "object", "insertTextFormat": "Snippet" }, @@ -169,7 +169,7 @@ "label": "stream", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "stream", "insertTextFormat": "Snippet" }, @@ -177,7 +177,7 @@ "label": "table", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "table", "insertTextFormat": "Snippet" }, @@ -185,7 +185,7 @@ "label": "transaction", "kind": "Unit", "detail": "type", - "sortText": "BR", + "sortText": "R", "insertText": "transaction", "insertTextFormat": "Snippet" }, @@ -193,7 +193,7 @@ "label": "service", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "service", "insertText": "service", "insertTextFormat": "Snippet" @@ -202,7 +202,7 @@ "label": "new", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "new", "insertText": "new ", "insertTextFormat": "Snippet" @@ -211,7 +211,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -220,7 +220,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -229,7 +229,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -238,7 +238,7 @@ "label": "let", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "let", "insertText": "let", "insertTextFormat": "Snippet" @@ -247,7 +247,7 @@ "label": "typeof", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "typeof", "insertText": "typeof ", "insertTextFormat": "Snippet" @@ -256,7 +256,7 @@ "label": "trap", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "trap", "insertText": "trap", "insertTextFormat": "Snippet" @@ -265,7 +265,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -274,7 +274,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -283,7 +283,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -292,7 +292,7 @@ "label": "check", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "check", "insertText": "check ", "insertTextFormat": "Snippet" @@ -301,7 +301,7 @@ "label": "checkpanic", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "checkpanic", "insertText": "checkpanic ", "insertTextFormat": "Snippet" @@ -310,7 +310,7 @@ "label": "is", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "is", "insertText": "is", "insertTextFormat": "Snippet" @@ -319,7 +319,7 @@ "label": "error constructor", "kind": "Snippet", "detail": "Snippet", - "sortText": "BP", + "sortText": "T", "filterText": "error", "insertText": "error(\"${1}\")", "insertTextFormat": "Snippet" @@ -328,7 +328,7 @@ "label": "object constructor", "kind": "Snippet", "detail": "Snippet", - "sortText": "BP", + "sortText": "T", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -337,7 +337,7 @@ "label": "base16", "kind": "Snippet", "detail": "Snippet", - "sortText": "BP", + "sortText": "T", "filterText": "base16", "insertText": "base16 `${1}`", "insertTextFormat": "Snippet" @@ -346,7 +346,7 @@ "label": "base64", "kind": "Snippet", "detail": "Snippet", - "sortText": "BP", + "sortText": "T", "filterText": "base64", "insertText": "base64 `${1}`", "insertTextFormat": "Snippet" @@ -355,7 +355,7 @@ "label": "from", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "from", "insertText": "from ", "insertTextFormat": "Snippet" @@ -367,7 +367,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "BM", + "sortText": "Q", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -375,7 +375,7 @@ "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "BN", + "sortText": "R", "insertText": "Thread", "insertTextFormat": "Snippet" }, @@ -383,7 +383,7 @@ "label": "err1", "kind": "Variable", "detail": "Error1", - "sortText": "BB", + "sortText": "AB", "insertText": "err1", "insertTextFormat": "Snippet" }, @@ -397,7 +397,7 @@ "value": "**Package:** _._ \n \n \n" } }, - "sortText": "BC", + "sortText": "AC", "filterText": "func1", "insertText": "func1()", "insertTextFormat": "Snippet" @@ -406,7 +406,7 @@ "label": "ErrorDesc", "kind": "Struct", "detail": "Record", - "sortText": "BM", + "sortText": "Q", "insertText": "ErrorDesc", "insertTextFormat": "Snippet" }, @@ -414,7 +414,7 @@ "label": "Error1", "kind": "Event", "detail": "Error", - "sortText": "BL", + "sortText": "AL", "insertText": "Error1", "insertTextFormat": "Snippet" }, @@ -422,7 +422,7 @@ "label": "stack = ...", "kind": "Snippet", "detail": "stack = \"\"", - "sortText": "AR", + "sortText": "A", "filterText": "stack", "insertText": "stack = ${1:\"\"}", "insertTextFormat": "Snippet" @@ -431,7 +431,7 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" @@ -440,7 +440,7 @@ "label": "start", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "start", "insertText": "start ", "insertTextFormat": "Snippet" @@ -449,7 +449,7 @@ "label": "wait", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "wait", "insertText": "wait ", "insertTextFormat": "Snippet" @@ -458,7 +458,7 @@ "label": "flush", "kind": "Keyword", "detail": "Keyword", - "sortText": "BQ", + "sortText": "U", "filterText": "flush", "insertText": "flush ", "insertTextFormat": "Snippet" @@ -467,7 +467,7 @@ "label": "from clause", "kind": "Snippet", "detail": "Snippet", - "sortText": "BP", + "sortText": "T", "filterText": "from", "insertText": "from ${1:var} ${2:item} in ${3}", "insertTextFormat": "Snippet" @@ -476,7 +476,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -500,7 +500,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -524,7 +524,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -548,7 +548,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -572,7 +572,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "BR", + "sortText": "R", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -596,7 +596,7 @@ "label": "re ``", "kind": "Snippet", "detail": "Snippet", - "sortText": "BP", + "sortText": "T", "filterText": "re ``", "insertText": "re `${1}`", "insertTextFormat": "Snippet" @@ -605,7 +605,7 @@ "label": "decimal", "kind": "TypeParameter", "detail": "Decimal", - "sortText": "BN", + "sortText": "R", "insertText": "decimal", "insertTextFormat": "Snippet" }, @@ -613,7 +613,7 @@ "label": "error", "kind": "Event", "detail": "Error", - "sortText": "BL", + "sortText": "AL", "insertText": "error", "insertTextFormat": "Snippet" }, @@ -621,7 +621,7 @@ "label": "xml", "kind": "TypeParameter", "detail": "Xml", - "sortText": "BN", + "sortText": "R", "insertText": "xml", "insertTextFormat": "Snippet" }, @@ -629,7 +629,7 @@ "label": "boolean", "kind": "TypeParameter", "detail": "Boolean", - "sortText": "BN", + "sortText": "R", "insertText": "boolean", "insertTextFormat": "Snippet" }, @@ -637,7 +637,7 @@ "label": "future", "kind": "TypeParameter", "detail": "Future", - "sortText": "BN", + "sortText": "R", "insertText": "future", "insertTextFormat": "Snippet" }, @@ -645,7 +645,7 @@ "label": "int", "kind": "TypeParameter", "detail": "Int", - "sortText": "BN", + "sortText": "R", "insertText": "int", "insertTextFormat": "Snippet" }, @@ -653,7 +653,7 @@ "label": "float", "kind": "TypeParameter", "detail": "Float", - "sortText": "BN", + "sortText": "R", "insertText": "float", "insertTextFormat": "Snippet" }, @@ -661,7 +661,7 @@ "label": "function", "kind": "TypeParameter", "detail": "Function", - "sortText": "BN", + "sortText": "R", "insertText": "function", "insertTextFormat": "Snippet" }, @@ -669,7 +669,7 @@ "label": "string", "kind": "TypeParameter", "detail": "String", - "sortText": "BN", + "sortText": "R", "insertText": "string", "insertTextFormat": "Snippet" }, @@ -677,7 +677,7 @@ "label": "typedesc", "kind": "TypeParameter", "detail": "Typedesc", - "sortText": "BN", + "sortText": "R", "insertText": "typedesc", "insertTextFormat": "Snippet" }, @@ -685,7 +685,7 @@ "label": "readonly", "kind": "TypeParameter", "detail": "Readonly", - "sortText": "BN", + "sortText": "R", "insertText": "readonly", "insertTextFormat": "Snippet" }, @@ -693,7 +693,7 @@ "label": "handle", "kind": "TypeParameter", "detail": "Handle", - "sortText": "BN", + "sortText": "R", "insertText": "handle", "insertTextFormat": "Snippet" }, @@ -701,7 +701,7 @@ "label": "never", "kind": "TypeParameter", "detail": "Never", - "sortText": "BN", + "sortText": "R", "insertText": "never", "insertTextFormat": "Snippet" }, @@ -709,7 +709,7 @@ "label": "json", "kind": "TypeParameter", "detail": "Json", - "sortText": "BN", + "sortText": "R", "insertText": "json", "insertTextFormat": "Snippet" }, @@ -717,7 +717,7 @@ "label": "anydata", "kind": "TypeParameter", "detail": "Anydata", - "sortText": "BN", + "sortText": "R", "insertText": "anydata", "insertTextFormat": "Snippet" }, @@ -725,7 +725,7 @@ "label": "any", "kind": "TypeParameter", "detail": "Any", - "sortText": "BN", + "sortText": "R", "insertText": "any", "insertTextFormat": "Snippet" }, @@ -733,7 +733,7 @@ "label": "byte", "kind": "TypeParameter", "detail": "Byte", - "sortText": "BN", + "sortText": "R", "insertText": "byte", "insertTextFormat": "Snippet" } From 3790fa970fa0857033f55ca126e3d677feb4a0a0 Mon Sep 17 00:00:00 2001 From: DamithaSenevirathne Date: Fri, 18 Nov 2022 18:04:53 +0530 Subject: [PATCH 334/450] Add singleton type check --- .../codeaction/providers/changetype/TypeCastCodeAction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/changetype/TypeCastCodeAction.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/changetype/TypeCastCodeAction.java index 83ed2ec0ece0..5072c2559f9f 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/changetype/TypeCastCodeAction.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/changetype/TypeCastCodeAction.java @@ -126,7 +126,7 @@ public List getCodeActions(Diagnostic diagnostic, } String typeName = ""; - if (expectedTypeSymbol.subtypeOf(actualTypeSymbol)) { + if (expectedTypeSymbol.subtypeOf(actualTypeSymbol) && expectedTypeSymbol.typeKind() != TypeDescKind.SINGLETON) { typeName = NameUtil.getModifiedTypeName(context, expectedTypeSymbol); } else if (isNumeric(expectedTypeSymbol)) { Optional numericExpected = findNumericType(expectedTypeSymbol); From 32e06f5c78a32870f36b6d8e5717bbbd9c3a2dc8 Mon Sep 17 00:00:00 2001 From: DamithaSenevirathne Date: Fri, 18 Nov 2022 18:15:22 +0530 Subject: [PATCH 335/450] Add testcases --- .../langserver/codeaction/TypeCastTest.java | 4 +++- .../type-cast/config/type_casts_in_constants.json | 9 +++++++++ .../type-cast/source/type_casts_in_constants.bal | 5 +++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/config/type_casts_in_constants.json create mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/source/type_casts_in_constants.bal diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/TypeCastTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/TypeCastTest.java index 93915e9126f0..4813ee2dbc91 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/TypeCastTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/TypeCastTest.java @@ -85,7 +85,9 @@ public Object[][] dataProvider() { {"type_cast_in_conditional_expr3.json"}, {"type_cast_numeric1.json"}, {"type_cast_in_obj_field_config1.json"}, - {"type_cast_in_obj_field_config2.json"} + {"type_cast_in_obj_field_config2.json"}, + + {"type_casts_in_constants.json"}, }; } diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/config/type_casts_in_constants.json b/language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/config/type_casts_in_constants.json new file mode 100644 index 000000000000..fb92f7656d03 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/config/type_casts_in_constants.json @@ -0,0 +1,9 @@ +{ + "position": { + "line": 3, + "character": 17 + }, + "source": "type_casts_in_constants.bal", + "expected": [ + ] +} \ No newline at end of file diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/source/type_casts_in_constants.bal b/language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/source/type_casts_in_constants.bal new file mode 100644 index 000000000000..db51e680ebbb --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/source/type_casts_in_constants.bal @@ -0,0 +1,5 @@ +const string CONSTANT = "A"; + +public function main() { + CONSTANT a = "1"; +} From 712fcd37c10899b7348095c1812bbb501eedaf80 Mon Sep 17 00:00:00 2001 From: DamithaSenevirathne Date: Fri, 18 Nov 2022 18:16:42 +0530 Subject: [PATCH 336/450] Add new line --- .../codeaction/type-cast/config/type_casts_in_constants.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/config/type_casts_in_constants.json b/language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/config/type_casts_in_constants.json index fb92f7656d03..be3304a844bc 100644 --- a/language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/config/type_casts_in_constants.json +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/config/type_casts_in_constants.json @@ -6,4 +6,4 @@ "source": "type_casts_in_constants.bal", "expected": [ ] -} \ No newline at end of file +} From 6f11c1f4ecad6176df5bd2ed6512048610fa1ad7 Mon Sep 17 00:00:00 2001 From: DamithaSenevirathne Date: Mon, 28 Nov 2022 09:28:54 +0530 Subject: [PATCH 337/450] Address review suggestions --- .../ballerinalang/langserver/codeaction/TypeCastTest.java | 5 ++--- .../{type_casts_in_constants.json => typeCastNegative6.json} | 3 +++ 2 files changed, 5 insertions(+), 3 deletions(-) rename language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/config/{type_casts_in_constants.json => typeCastNegative6.json} (74%) diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/TypeCastTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/TypeCastTest.java index 4813ee2dbc91..af8a06f6cc7e 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/TypeCastTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/TypeCastTest.java @@ -85,9 +85,7 @@ public Object[][] dataProvider() { {"type_cast_in_conditional_expr3.json"}, {"type_cast_numeric1.json"}, {"type_cast_in_obj_field_config1.json"}, - {"type_cast_in_obj_field_config2.json"}, - - {"type_casts_in_constants.json"}, + {"type_cast_in_obj_field_config2.json"} }; } @@ -99,6 +97,7 @@ public Object[][] negativeDataProvider() { {"typeCastNegative3.json"}, {"typeCastNegative4.json"}, {"typeCastNegative5.json"}, + {"typeCastNegative6.json"} }; } } diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/config/type_casts_in_constants.json b/language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/config/typeCastNegative6.json similarity index 74% rename from language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/config/type_casts_in_constants.json rename to language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/config/typeCastNegative6.json index be3304a844bc..20d18516e129 100644 --- a/language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/config/type_casts_in_constants.json +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/type-cast/config/typeCastNegative6.json @@ -5,5 +5,8 @@ }, "source": "type_casts_in_constants.bal", "expected": [ + { + "title": "Add type cast" + } ] } From 17cd4d61b91f614ad1cf6d330607b3c3da18da54 Mon Sep 17 00:00:00 2001 From: sanjana Date: Mon, 19 Dec 2022 18:07:02 +0530 Subject: [PATCH 338/450] Add suggested int langlib examples --- langlib/lang.int/src/main/ballerina/int.bal | 5 ++++- .../test/statements/foreach/ForeachErrorHandlingTests.java | 2 +- .../test-src/object/object_field_initializer_with_check.bal | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/langlib/lang.int/src/main/ballerina/int.bal b/langlib/lang.int/src/main/ballerina/int.bal index 8ebe3b92174f..82f4e3f12905 100644 --- a/langlib/lang.int/src/main/ballerina/int.bal +++ b/langlib/lang.int/src/main/ballerina/int.bal @@ -102,6 +102,9 @@ public isolated function abs(int n) returns int = @java:Method { # # int[] marks = [50, 65, 78, 95]; # int total = int:sum(...marks) ⇒ 288 +# +# int num = 24; +# num.sum(38, 15, 97, 27) ⇒ 201 # ``` # # + ns - int values to sum @@ -197,7 +200,7 @@ public isolated function toHexString(int n) returns string = @java:Method { # ```ballerina # int:fromHexString("1A5F") ⇒ 6751 # -# int:fromHexString("1Y4K") ⇒ error +# int:fromHexString("0xFFFF") ⇒ error # ``` # # + s - hexadecimal string representation of int value diff --git a/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachErrorHandlingTests.java b/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachErrorHandlingTests.java index bbd42c53641d..d57ea61bf111 100644 --- a/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachErrorHandlingTests.java +++ b/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachErrorHandlingTests.java @@ -53,7 +53,7 @@ public void testArrayForeachAndTrap() { @Test(expectedExceptions = BLangRuntimeException.class, expectedExceptionsMessageRegExp = "error: \\{ballerina/lang.int\\}NumberParsingError \\{\"message\":\"'string' value 'waruna' cannot be " + "converted to 'int'\"\\}\n" + - "\tat ballerina.lang.int.0:fromString\\(int.bal:175\\)\n" + + "\tat ballerina.lang.int.0:fromString\\(int.bal:171\\)\n" + "\t foreach_error_handling:\\$lambda\\$_0\\(foreach_error_handling.bal:41\\)") public void testArrayForeachAndPanic() { BRunUtil.invoke(program, "testArrayForeachAndPanic"); diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/object/object_field_initializer_with_check.bal b/tests/jballerina-unit-test/src/test/resources/test-src/object/object_field_initializer_with_check.bal index dc8e8f5c21d3..4e57f86c6967 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/object/object_field_initializer_with_check.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/object/object_field_initializer_with_check.bal @@ -84,7 +84,7 @@ function testCheckInObjectFieldInitializer2() { assertEquality("'string' value 'invalid' cannot be converted to 'int'", checkpanic e.detail()["message"]); error:StackFrame[] callStack = e.stackTrace(); int callStackLength = callStack.length(); - assertEquality("callableName: fromString moduleName: ballerina.lang.int.0 fileName: int.bal lineNumber: 175", + assertEquality("callableName: fromString moduleName: ballerina.lang.int.0 fileName: int.bal lineNumber: 171", callStack[callStackLength - 2].toString()); } From 6a059f916243d2cdbd301168adf3a00c3f93bfe4 Mon Sep 17 00:00:00 2001 From: mohan Date: Mon, 19 Dec 2022 18:43:57 +0530 Subject: [PATCH 339/450] Add fixes for review comments --- .../lang.stream/src/main/ballerina/stream.bal | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/langlib/lang.stream/src/main/ballerina/stream.bal b/langlib/lang.stream/src/main/ballerina/stream.bal index 8ac0cf0b477d..b5b8dab75ca1 100644 --- a/langlib/lang.stream/src/main/ballerina/stream.bal +++ b/langlib/lang.stream/src/main/ballerina/stream.bal @@ -44,8 +44,8 @@ type Type1 any|error; # Selects the members from a stream for which a function returns true. # # ```ballerina -# stream scoreStream = [45, 60, 75, 30, 90].toStream(); -# scoreStream.filter(score => score > 50).next() ⇒ {"value":60} +# stream scores = [45, 60, 75, 30, 90].toStream(); +# scores.filter(score => score > 50).next() ⇒ {"value":60} # ``` # # + stm - the stream @@ -61,8 +61,8 @@ public isolated function filter(stream stm, @isolatedParam # Returns the next element in the stream wrapped in a record or () if the stream ends. # # ```ballerina -# stream scoreStream = [45, 60, 75, 30, 90].toStream(); -# scoreStream.next() ⇒ {"value":45} +# stream scores = [45, 60, 75, 30, 90].toStream(); +# scores.next() ⇒ {"value":45} # ``` # # + stm - The stream @@ -88,7 +88,7 @@ public isolated function next(stream stm) returns record { # # ```ballerina # stream ms = [14.5f, 45.5f, 6.8f, 4f].toStream(); -# stream cms = ms.'map(m => m * 100.0); +# stream cms = ms.map(m => m * 100.0); # cms.next() ⇒ {"value":1450.0} # ``` # @@ -108,8 +108,8 @@ public isolated function 'map(stream stm, @isolatedParam fu # and returns a new combined value. # # ```ballerina -# stream scoreStream = [45, 60, 75, 30, 90].toStream(); -# scoreStream.reduce(isolated function (int total, int score) returns int => total + score, 0) ⇒ 300 +# stream scores = [45, 60, 75, 30, 90].toStream(); +# scores.reduce(isolated function (int total, int score) returns int => total + score, 0) ⇒ 300 # ``` # # + stm - the stream @@ -137,9 +137,9 @@ public isolated function reduce(stream stm, # The parameter `func` is applied to each member of parameter `stm` stream in order. # # ```ballerina -# stream scoreStream = [45, 60, 75, 30, 90].toStream(); +# stream scores = [45, 60, 75, 30, 90].toStream(); # int total = 0; -# scoreStream.forEach(function(int score) { +# scores.forEach(function(int score) { # total += score; # }); # total ⇒ 300 @@ -167,10 +167,10 @@ public isolated function forEach(stream stm, # Returns an iterator over a stream. # # ```ballerina -# stream scoreStream = [45, 60, 75, 30, 90].toStream(); +# stream scores = [45, 60, 75, 30, 90].toStream(); # object { # public isolated function next() returns record {|int value;|}?; -# } iterator = scoreStream.iterator(); +# } iterator = scores.iterator(); # iterator.next() ⇒ {"value":45} # ``` # @@ -186,14 +186,14 @@ public isolated function iterator(stream stm) returns objec # Closes a stream. # -# ```ballerina -# stream scoreStream = [45, 60, 75, 30, 90].toStream(); -# _ = scoreStream.close(); -# ``` -# # This releases any system resources being used by the stream. # Closing a stream that has already been closed has no effect and returns `()`. # +# ```ballerina +# stream scores = [45, 60, 75, 30, 90].toStream(); +# _ = scores.close(); +# ``` +# # + stm - the stream to close # + return - () if the close completed successfully, otherwise an error public isolated function close(stream stm) returns CompletionType? { From 5a1fc9db3ee0836fc8149a6f8a591b15033deb56 Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Mon, 19 Dec 2022 18:55:04 +0530 Subject: [PATCH 340/450] Address review comments --- .../diagnostic/DiagnosticMessage.java | 2 +- .../jsonmapper/util/ConverterUtils.java | 50 +++++++++---------- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/diagnostic/DiagnosticMessage.java b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/diagnostic/DiagnosticMessage.java index 4eb1cecd9834..a790af3eb739 100644 --- a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/diagnostic/DiagnosticMessage.java +++ b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/diagnostic/DiagnosticMessage.java @@ -117,7 +117,7 @@ public static DiagnosticMessage jsonToRecordConverter106(Object[] args) { Arrays.copyOfRange(args, 2, args.length)); } return new DiagnosticMessage("JSON_TO_RECORD_CONVERTER_106", - "Few of the record names are renamed. " + + "Few of the records are renamed. " + "Consider rename it back to a meaningful name.", DiagnosticSeverity.INFO, null); } } diff --git a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java index 20ddb4ad5c12..2106b648f5e8 100644 --- a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java +++ b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java @@ -118,35 +118,33 @@ public static List getExistingTypeNames(WorkspaceManager workspaceManage return existingTypeNames; } - Project project; - // Check if the provided file is a SingleFileProject try { - project = SingleFileProject.load(filePathResolved); - List moduleSymbols = - project.currentPackage().getDefaultModule().getCompilation().getSemanticModel().moduleSymbols(); - moduleSymbols.forEach(symbol -> { - if (symbol.getName().isPresent()) { - existingTypeNames.add(symbol.getName().get()); - } - }); - } catch (ProjectException pe) { - // Check if the provided file is a part of BuildProject + Project project; + List moduleSymbols; Path projectRoot = ProjectUtils.findProjectRoot(filePathResolved); - if (projectRoot != null) { - try { - project = BuildProject.load(projectRoot); - List moduleSymbols = project.currentPackage() - .module(project.documentId(filePathResolved).moduleId()) - .getCompilation().getSemanticModel().moduleSymbols(); - moduleSymbols.forEach(symbol -> { - if (symbol.getName().isPresent()) { - existingTypeNames.add(symbol.getName().get()); - } - }); - } catch (ProjectException pe1) { - return existingTypeNames; - } + if (projectRoot == null) { + // Since the project-root cannot be found, the provided file is considered as SingleFileProject. + project = SingleFileProject.load(filePathResolved); + moduleSymbols = + project.currentPackage().getDefaultModule().getCompilation().getSemanticModel().moduleSymbols(); + moduleSymbols.forEach(symbol -> { + if (symbol.getName().isPresent()) { + existingTypeNames.add(symbol.getName().get()); + } + }); + } else { + project = BuildProject.load(projectRoot); + moduleSymbols = project.currentPackage() + .module(project.documentId(filePathResolved).moduleId()) + .getCompilation().getSemanticModel().moduleSymbols(); + moduleSymbols.forEach(symbol -> { + if (symbol.getName().isPresent()) { + existingTypeNames.add(symbol.getName().get()); + } + }); } + } catch (ProjectException pe) { + return existingTypeNames; } return existingTypeNames; } From cc2dc6ee99337d13940dcc70c8350bfb2028135c Mon Sep 17 00:00:00 2001 From: Mohanadarshan V Date: Mon, 19 Dec 2022 19:04:34 +0530 Subject: [PATCH 341/450] Update langlib/lang.string/src/main/ballerina/string.bal Co-authored-by: Maryam Ziyad --- langlib/lang.string/src/main/ballerina/string.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index 3112233078db..026d3e57bc9e 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -307,7 +307,7 @@ public isolated function toBytes(string str) returns byte[] = @java:Method { # # ```ballerina # string:fromBytes([72, 101, 108, 108, 111, 32, 66, 97, 108, 108, 101, 114, 105, 110, 97, 33]) ⇒ Hello, World! -# string:fromBytes(base64 `lang`) ⇒ error +# string:fromBytes([149, 169, 224]) ⇒ error # ``` # # + bytes - UTF-8 byte array From d117fb6399733ae0ce8e563f43062713be7a53b4 Mon Sep 17 00:00:00 2001 From: Mohanadarshan V Date: Mon, 19 Dec 2022 19:05:05 +0530 Subject: [PATCH 342/450] Update langlib/lang.string/src/main/ballerina/string.bal Co-authored-by: Chiran Fernando --- langlib/lang.string/src/main/ballerina/string.bal | 1 + 1 file changed, 1 insertion(+) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index 026d3e57bc9e..2ce4fed395de 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -88,6 +88,7 @@ public isolated function getCodePoint(string str, int index) returns int = @java # # ```ballerina # "Hello, my name is John".substring(7) ⇒ my name is John + # "Hello, my name is John Anderson".substring(18, 22) ⇒ John # ``` # From f2d76e6e8f35c78e7ff4ec3385f6f97ccf8745d5 Mon Sep 17 00:00:00 2001 From: Mohanadarshan V Date: Mon, 19 Dec 2022 19:05:51 +0530 Subject: [PATCH 343/450] Update langlib/lang.string/src/main/ballerina/string.bal Co-authored-by: Maryam Ziyad --- langlib/lang.string/src/main/ballerina/string.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index 2ce4fed395de..0a4150264be2 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -214,7 +214,7 @@ public isolated function startsWith(string str, string substr) returns boolean = # Tests whether a string ends with another string. # # ```ballerina -# "Welcome to Ballerina programming language".endsWith("language") ⇒ true +# "Welcome to the Ballerina programming language".endsWith("language") ⇒ true # ``` # # + str - the string to be tested From 7c62f3978f2343c7e683ab7e780929cf168b832f Mon Sep 17 00:00:00 2001 From: mohan Date: Mon, 19 Dec 2022 19:08:03 +0530 Subject: [PATCH 344/450] Add fixes for review comments --- langlib/lang.string/src/main/ballerina/string.bal | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index 2ce4fed395de..408741acb50e 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -88,7 +88,7 @@ public isolated function getCodePoint(string str, int index) returns int = @java # # ```ballerina # "Hello, my name is John".substring(7) ⇒ my name is John - +# # "Hello, my name is John Anderson".substring(18, 22) ⇒ John # ``` # @@ -144,7 +144,6 @@ public isolated function 'join(string separator, string... strs) returns string # ```ballerina # "New Zealand".indexOf("land") ⇒ 7 # -# // Search for the first occurrence of a string from a specific index onwards. # "Ballerinalang is a unique programming language".indexOf("lang", 15) ⇒ 38 # ``` # From 9799c06cfb2b2f9e9d4b418116d946e7d8345643 Mon Sep 17 00:00:00 2001 From: mohan Date: Mon, 19 Dec 2022 19:13:07 +0530 Subject: [PATCH 345/450] Add fixes for review comments --- langlib/lang.string/src/main/ballerina/string.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index 2ea40cb833c9..18d6cd79b172 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -280,7 +280,7 @@ public isolated function equalsIgnoreCaseAscii(string str1, string str2) returns # The ASCII white space characters are 0x9...0xD, 0x20. # # ```ballerina -# " BALLERINA ".trim() ⇒ BALLERINA +# " BALLERINA ".trim() ⇒ "BALLERINA" # ``` # # + str - the string From 054da2f42e2cb9450cf985ddef8b58029cc04124 Mon Sep 17 00:00:00 2001 From: mohan Date: Tue, 20 Dec 2022 08:14:16 +0530 Subject: [PATCH 346/450] Add examples for default cases --- langlib/lang.string/src/main/ballerina/string.bal | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index 18d6cd79b172..d7efe4e74bd7 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -307,6 +307,7 @@ public isolated function toBytes(string str) returns byte[] = @java:Method { # # ```ballerina # string:fromBytes([72, 101, 108, 108, 111, 32, 66, 97, 108, 108, 101, 114, 105, 110, 97, 33]) ⇒ Hello, World! +# # string:fromBytes([149, 169, 224]) ⇒ error # ``` # @@ -350,6 +351,8 @@ public isolated function toCodePointInt(Char ch) returns int = @java:Method { # # ```ballerina # string:fromCodePointInts([66, 97, 108, 108, 101, 114, 105, 110, 97]) ⇒ Ballerina +# +# string:fromCodePointInts([1114113, 1114114, 1114115]) ⇒ error # ``` # # + codePoints - an array of ints, each specifying a code point @@ -367,6 +370,8 @@ public isolated function fromCodePointInts(int[] codePoints) returns string|erro # # ```ballerina # string:fromCodePointInt(97) ⇒ a +# +# string:fromCodePointInt(1114113) ⇒ error # ``` # # + codePoint - an int specifying a code point @@ -382,6 +387,8 @@ public isolated function fromCodePointInt(int codePoint) returns Char|error = @j # If the length of `str` is >= `len`, returns `str`. # # ```ballerina +# "100Km".padStart(10, "0") ⇒ " 100Km" +# # "100Km".padStart(10, "0") ⇒ 00000100Km # ``` # @@ -399,6 +406,8 @@ public isolated function padStart(string str, int len, Char padChar = " ") retur # If the length of `str` is >= `len`, returns `str`. # # ```ballerina +# "Ballerina for developers".padEnd(30) ⇒ "Ballerina for developers " +# # "Ballerina for developers".padEnd(30, "!") ⇒ Ballerina for developers!!!!!! # ``` # @@ -418,6 +427,8 @@ public isolated function padEnd(string str, int len, Char padChar = " ") returns # # ```ballerina # "-256".padZero(9) ⇒ -00000256 +# +# "-880".padZero(8, "#") ⇒ -####880 # ``` # # + str - the string to pad From 063c2968e0e259b561e2674928a12c0244f0cd00 Mon Sep 17 00:00:00 2001 From: Sasindu Alahakoon Date: Thu, 1 Dec 2022 12:10:40 +0530 Subject: [PATCH 347/450] Add examples for langlib float functions --- .../lang.float/src/main/ballerina/float.bal | 223 +++++++++++++++++- 1 file changed, 221 insertions(+), 2 deletions(-) diff --git a/langlib/lang.float/src/main/ballerina/float.bal b/langlib/lang.float/src/main/ballerina/float.bal index def863fd5952..743653ce8db9 100644 --- a/langlib/lang.float/src/main/ballerina/float.bal +++ b/langlib/lang.float/src/main/ballerina/float.bal @@ -33,6 +33,13 @@ public const float Infinity = 1.0/0.0; # # Exactly one of isFinite, isInfinite and IsNaN will be true for any float value # +# ```ballerina +# float f = 1.2; +# f.isFinite() ⇒ true +# +# float:Infinity.isFinite() ⇒ false +# ``` +# # + x - the float to be tested # + return - true if parameter `x` is finite, i.e., neither NaN nor +∞ nor -∞ public isolated function isFinite(float x) returns boolean = @java:Method { @@ -44,6 +51,13 @@ public isolated function isFinite(float x) returns boolean = @java:Method { # # Exactly one of isFinite, isInfinite and IsNaN will be true for any float value # +# ```ballerina +# float f = 3.21; +# f.isInfinite() ⇒ false +# +# float:Infinity.isInfinite() ⇒ true +# ``` +# # + x - the float to be tested # + return - true if parameter `x` is either +∞ or -∞ public isolated function isInfinite(float x) returns boolean = @java:Method { @@ -55,6 +69,13 @@ public isolated function isInfinite(float x) returns boolean = @java:Method { # # Exactly one of isFinite, isInfinite and IsNaN will be true for any float value. # +# ```ballerina +# float f = 0.23; +# f.isNaN() ⇒ false +# +# float:NaN.isNaN() ⇒ true +# ``` +# # + x - the float to be tested # + return - true if parameter `x` is NaN public isolated function isNaN(float x) returns boolean = @java:Method { @@ -66,6 +87,18 @@ public isolated function isNaN(float x) returns boolean = @java:Method { # # Result is NaN if any arg is NaN # +# ```ballerina +# float:sum(1.2, 2.3, 3.4) ⇒ 6.9 +# +# float[] scores = [11.1, 22.2, 33.3]; +# float:sum(...scores) ⇒ 66.6 +# +# float f = 21.2; +# f.sum(10.5, 21, 32.4) ⇒ 85.1 +# +# float:sum(float:NaN, 2.3, 3.4) ⇒ NaN +# ``` +# # + xs - float values to sum # + return - sum of all of parameter `xs`, +0.0 if parameter `xs` is empty public isolated function sum(float... xs) returns float = @java:Method { @@ -78,6 +111,20 @@ public isolated function sum(float... xs) returns float = @java:Method { # Result is -∞ if no args # NaN if any arg is NaN # +# ```ballerina +# float:max(1.2, 12.3, 3.4) ⇒ 12.3 +# +# float[] marks = [70.3, 80.5, 98.1, 92.3]; +# float:max(...marks) ⇒ 98.1 +# +# float f = 21.2; +# f.max(40.5, 21, 32.4) ⇒ 40.5 +# +# float:max() ⇒ -Infinity +# +# float:max(1.2, float:NaN, 3.4) ⇒ NaN +# ``` +# # + xs - float values to operate on # + return - maximum value of all of parameter `xs` public isolated function max(float... xs) returns float = @java:Method { @@ -90,6 +137,20 @@ public isolated function max(float... xs) returns float = @java:Method { # Result is +∞ if no args # Result is NaN if any arg is NaN # +# ```ballerina +# float:min(5.2, 2.3, 3.4) ⇒ 2.3 +# +# float[] marks = [90.3, 80.5, 98, 92.3]; +# float:min(...marks) ⇒ 80.5 +# +# float f = 1.2; +# f.min(10.5, 21, 32.4) ⇒ 1.2 +# +# float:min() ⇒ Infinity +# +# float:min(5.2, float:NaN, 3.4) ⇒ NaN +# ``` +# # + xs - float values to operate on # + return - minimum value of all of parameter `xs` public isolated function min(float... xs) returns float = @java:Method { @@ -99,6 +160,11 @@ public isolated function min(float... xs) returns float = @java:Method { # Returns the IEEE absolute value of a float value. # +# ```ballerina +# float f = -3.21; +# f.abs() ⇒ 3.21 +# ``` +# # + x - float value to operate on # + return - absolute value of parameter `x` public isolated function abs(float x) returns float = @java:Method { @@ -113,12 +179,26 @@ public isolated function abs(float x) returns float = @java:Method { # (this is the round-to-nearest rounding mode, which is the default for IEEE and for Ballerina). # A value of `fractionDigits` greater than 0 thus corresponds to the number of digits after the decimal # point being `fractionDigits`; a value of 0 for `fractionDigits` rounds to an integer. -# If `x` is NaN, +0, -0, +∞ or -∞, then the result is `x``. +# If `x` is NaN, +0, -0, +∞ or -∞, then the result is `x`. # When `fractionDigits` is 0, this is # the same as Java Math.rint method, .NET Math.Round method and # IEEE roundToIntegralTiesToEven operation # Note that `x` is the same as `x.round(0)`. # +# ```ballerina +# float f = 3.55; +# f.round() ⇒ 4.0 +# +# float g = 4.55555; +# g.round(3) ⇒ 4.556 +# +# float h = 2.5; +# h.round(0) ⇒ 2.0 +# +# float i = 3.5; +# i.round(0) ⇒ 4.0 +# ``` +# # + x - float value to operate on # + fractionDigits - the number of digits after the decimal point # + return - float value closest to `x` that is an integral multiple of 10 raised to the power of `-fractionDigits` @@ -129,6 +209,11 @@ public isolated function round(float x, int fractionDigits = 0) returns float = # Rounds a float down to the closest integral value. # +# ```ballerina +# float f = 3.51; +# f.floor() ⇒ 3.0 +# ``` +# # + x - float value to operate on # + return - largest (closest to +∞) float value not greater than parameter `x` that is a mathematical integer public isolated function floor(float x) returns float = @java:Method { @@ -138,6 +223,11 @@ public isolated function floor(float x) returns float = @java:Method { # Rounds a float up to the closest integral value. # +# ```ballerina +# float f = 3.51; +# f.ceiling() ⇒ 4.0 +# ``` +# # + x - float value to operate on # + return - smallest (closest to -∞) decimal value not less than parameter `x` that is a mathematical integer public isolated function ceiling(float x) returns float = @java:Method { @@ -149,6 +239,11 @@ public isolated function ceiling(float x) returns float = @java:Method { # # Corresponds to IEEE squareRoot operation. # +# ```ballerina +# float f = 1.96; +# f.sqrt() ⇒ 1.4 +# ``` +# # + x - float value to operate on # + return - square root of parameter `x` public isolated function sqrt(float x) returns float = @java:Method { @@ -160,6 +255,11 @@ public isolated function sqrt(float x) returns float = @java:Method { # # Corresponds to IEEE rootn(x, 3) operation. # +# ```ballerina +# float f = 0.125; +# f.cbrt() ⇒ 0.5 +# ``` +# # + x - float value to operate on # + return - cube root of parameter `x` public isolated function cbrt(float x) returns float = @java:Method { @@ -171,6 +271,11 @@ public isolated function cbrt(float x) returns float = @java:Method { # # Corresponds to IEEE pow(x, y) operation. # +# ```ballerina +# float f = 2.1; +# f.pow(2) ⇒ 4.41 +# ``` +# # + x - base value # + y - the exponent # + return - `x` raised to the power of parameter `y` @@ -183,6 +288,11 @@ public isolated function pow(float x, float y) returns float = @java:Method { # # Corresponds to IEEE log operation. # +# ```ballerina +# float f = 234.56; +# f.log() ⇒ 5.4577114186982865 +# ``` +# # + x - float value to operate on # + return - natural logarithm of parameter `x` public isolated function log(float x) returns float = @java:Method { @@ -194,6 +304,11 @@ public isolated function log(float x) returns float = @java:Method { # # Corresponds to IEEE log10 operation. # +# ```ballerina +# float f = 0.1; +# f.log10() ⇒ -1.0 +# ``` +# # + x - float value to operate on # + return - base 10 logarithm of parameter `x` public isolated function log10(float x) returns float = @java:Method { @@ -205,6 +320,11 @@ public isolated function log10(float x) returns float = @java:Method { # # Corresponds to IEEE exp operation. # +# ```ballerina +# float f = 2.3; +# f.exp() ⇒ 9.974182454814718 +# ``` +# # + x - float value to operate on # + return - Euler's number raised to the power parameter `x` public isolated function exp(float x) returns float = @java:Method { @@ -216,6 +336,11 @@ public isolated function exp(float x) returns float = @java:Method { # # Corresponds to IEEE sin operation. # +# ```ballerina +# float f = 2.3; +# f.sin() ⇒ 0.7457052121767203 +# ``` +# # + x - float value, specifying an angle in radians # + return - the sine of parameter `x` public isolated function sin(float x) returns float = @java:Method { @@ -227,6 +352,11 @@ public isolated function sin(float x) returns float = @java:Method { # # Corresponds to IEEE cos operation. # +# ```ballerina +# float f = 0.7; +# f.cos() ⇒ 0.7648421872844885 +# ``` +# # + x - float value, specifying an angle in radians # + return - the cosine of parameter `x` public isolated function cos(float x) returns float = @java:Method { @@ -238,6 +368,11 @@ public isolated function cos(float x) returns float = @java:Method { # # Corresponds to IEEE tan operation # +# ```ballerina +# float f = 0.2; +# f.tan() ⇒ 0.2027100355086725 +# ``` +# # + x - float value, specifying an angle in radians # + return - the tangent of parameter `x` public isolated function tan(float x) returns float = @java:Method { @@ -249,6 +384,11 @@ public isolated function tan(float x) returns float = @java:Method { # # Corresponds to IEEE acos operation. # +# ```ballerina +# float f = 0.5; +# f.acos() ⇒ 1.0471975511965979 +# ``` +# # + x - float value to operate on # + return - the arccosine of parameter `x` in radians public isolated function acos(float x) returns float = @java:Method { @@ -258,6 +398,11 @@ public isolated function acos(float x) returns float = @java:Method { # Returns the arctangent of a float value. # +# ```ballerina +# float f = 243.25; +# f.atan() ⇒ 1.5666853530369307 +# ``` +# # Corresponds to IEEE atan operation. # # + x - float value to operate on @@ -271,6 +416,11 @@ public isolated function atan(float x) returns float = @java:Method { # # Corresponds to IEEE asin operation. # +# ```ballerina +# float f = 0.5; +# f.asin() ⇒ 0.5235987755982989 +# ``` +# # + x - float value to operate on # + return - the arcsine of parameter `x` in radians public isolated function asin(float x) returns float = @java:Method { @@ -282,6 +432,10 @@ public isolated function asin(float x) returns float = @java:Method { # # Corresponds IEEE atan2(y, x) operation. # +# ```ballerina +# float:atan2(24.21, 12.345) ⇒ 1.0992495979622232 +# ``` +# # + y - the y-coordinate # + x - the x-coordinate # + return - the angle in radians from the positive x-axis to the point @@ -295,6 +449,11 @@ public isolated function atan2(float y, float x) returns float = @java:Method { # # Corresponds to IEEE sinh operation. # +# ```ballerina +# float f = 0.71; +# f.sinh() ⇒ 0.7711735305928927 +# ``` +# # + x - float value to operate on # + return - hyperbolic sine of parameter `x` public isolated function sinh(float x) returns float = @java:Method { @@ -306,6 +465,11 @@ public isolated function sinh(float x) returns float = @java:Method { # # Corresponds to IEEE cosh operation. # +# ```ballerina +# float f = 0.52; +# f.cosh() ⇒ 1.1382740988345403 +# ``` +# # + x - float value to operate on # + return - hyperbolic cosine of parameter `x` public isolated function cosh(float x) returns float = @java:Method { @@ -317,6 +481,11 @@ public isolated function cosh(float x) returns float = @java:Method { # # Corresponds to IEEE tanh operation. # +# ```ballerina +# float f = 0.9; +# f.tanh() ⇒ 0.7162978701990245 +# ``` +# # + x - float value to operate on # + return - hyperbolic tangent of parameter `x` public isolated function tanh(float x) returns float = @java:Method { @@ -334,6 +503,14 @@ public isolated function tanh(float x) returns float = @java:Method { # - a FloatingPointTypeSuffix is not allowed # This is the inverse of function ``value:toString`` applied to an `float`. # +# ```ballerina +# float:fromString("0.2453") ⇒ 0.2453 +# +# float:fromString("-10") ⇒ -10.0 +# +# float:fromString("123f") ⇒ error +# ``` +# # + s - string representation of a float # + return - float value or error public isolated function fromString(string s) returns float|error = @java:Method { @@ -351,6 +528,11 @@ public isolated function fromString(string s) returns float|error = @java:Method # - NaN will be represented by `NaN` # The representation includes `0x` for finite numbers. # +# ```ballerina +# float f = -10.2453; +# f.toHexString() ⇒ -0x1.47d97f62b6ae8p3 +# ``` +# # + x - float value # + return - hexadecimal floating point hex string representation public isolated function toHexString(float x) returns string = @java:Method { @@ -366,6 +548,12 @@ public isolated function toHexString(float x) returns string = @java:Method { # - `NaN` is allowed # - `Infinity` is allowed with an optional leading `+` or `-` sign # +# ```ballerina +# float:fromHexString("0x1.0a3d70a3d70a4p4") ⇒ 16.64 +# +# float:fromHexString("0x1J") ⇒ error +# ``` +# # + s - hexadecimal floating point hex string representation # + return - float value or error public isolated function fromHexString(string s) returns float|error = @java:Method { @@ -375,6 +563,11 @@ public isolated function fromHexString(string s) returns float|error = @java:Met # Returns IEEE 64-bit binary floating point format representation of a float value as an int. # +# ```ballerina +# float f = 4.16; +# f.toBitsInt() ⇒ 4616369762039853220 +# ``` +# # + x - float value # + return - parameter `x` bit pattern as an int public isolated function toBitsInt(float x) returns int = @java:Method { @@ -386,6 +579,10 @@ public isolated function toBitsInt(float x) returns int = @java:Method { # # All bit patterns that IEEE defines to be NaNs will all be mapped to the single float NaN value. # +# ```ballerina +# float:fromBitsInt(4) ⇒ 2.0E-323 +# ``` +# # + x - int value # + return - parameter `x` bit pattern as a float public isolated function fromBitsInt(int x) returns float = @java:Method { @@ -401,6 +598,17 @@ public isolated function fromBitsInt(int x) returns float = @java:Method { # If `fractionDigits` is zero, there will be no decimal point. # Any necessary rounding will use the roundTiesToEven rounding direction. # +# ```ballerina +# float f = 12.456; +# f.toFixedString(2) ⇒ 12.46 +# +# float g = 12.456; +# g.toFixedString(0) ⇒ 12 +# +# float h = 12.456; +# h.toFixedString(-3) ⇒ panic +# ``` +# # + x - float value # + fractionDigits - number of digits following the decimal point; `()` means to use # the minimum number of digits required to accurately represent the value @@ -417,7 +625,7 @@ public isolated function toFixedString(float x, int? fractionDigits) returns str # But if `x` is NaN or infinite, the result will be the same as `value:toString`. # The digit before the decimal point will be zero only if all other digits # are zero. -# This will panic if fractionDigits is less than 0. +# This will panic if `fractionDigits` is less than 0. # If `fractionDigits` is zero, there will be no decimal point. # Any necessary rounding will use the roundTiesToEven rounding direction. # The exponent in the result uses lower-case `e`, followed by a `+` or `-` sign, @@ -425,6 +633,17 @@ public isolated function toFixedString(float x, int? fractionDigits) returns str # to represent the result. If `x` is zero, the exponent is zero. A zero exponent # is represented with a `+` sign. # +# ```ballerina +# float f = 12.456; +# f.toExpString(2) ⇒ 1.25e+1 +# +# float g = 12.456; +# g.toExpString(()) ⇒ 1.2456e+1 +# +# float h = 12.456; +# h.toExpString(-2) ⇒ panic +# ``` +# # + x - float value # + fractionDigits - number of digits following the decimal point; `()` means to use # the minimum number of digits required to accurately represent the value From 95d2cdd1271a70105508fb19e5ba537d2fd85083 Mon Sep 17 00:00:00 2001 From: mohan Date: Tue, 20 Dec 2022 09:26:21 +0530 Subject: [PATCH 348/450] review additional doc comment --- langlib/lang.string/src/main/ballerina/string.bal | 1 - 1 file changed, 1 deletion(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index d7efe4e74bd7..03423e287f29 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -182,7 +182,6 @@ returns int? = @java:Method { # ```ballerina # "Hello World, from Ballerina".includes("Bal") ⇒ true # -# // Check for the occurrence of a string from a specific index onwards. # "Hello World! from Ballerina".includes("Hello", 10) ⇒ false # ``` # From c58f82beaff1f24fca037ef96d7b498087ba5115 Mon Sep 17 00:00:00 2001 From: sanjana Date: Tue, 20 Dec 2022 10:11:40 +0530 Subject: [PATCH 349/450] Update typedesc langlib example --- .../src/main/ballerina/typedesc_lib.bal | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal b/langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal index d924a68cc633..7372abfc8154 100644 --- a/langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal +++ b/langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal @@ -45,15 +45,11 @@ public type TypeId readonly & record {| # type Error distinct error; # type SampleError distinct (Error & error); # -# typedesc:TypeId[]? & readonly typeIds = SampleError.typeIds(); -# if (typeIds is typedesc:TypeId[]) { -# io:println(typeIds[typeIds.length() - 1]["localId"]) ⇒ Error -# } +# typedesc:TypeId[] typeIds = SampleError.typeIds(); +# typeIds[typeIds.length() - 1]["localId"] ⇒ Error # -# typedesc:TypeId[]? & readonly primaryTypeIds = SampleError.typeIds(true); -# if (primaryTypeIds is typedesc:TypeId[]) { -# io:println(primaryTypeIds[primaryTypeIds.length() - 1]["localId"]) ⇒ SampleError -# } +# typedesc:TypeId[] primaryTypeIds = SampleError.typeIds(true); +# primaryTypeIds[primaryTypeIds.length() - 1]["localId"] ⇒ SampleError # ``` # # + t - the typedesc From d7a66b44f2cd985cc7d81acfc985cfc272d11f82 Mon Sep 17 00:00:00 2001 From: sanjana Date: Mon, 12 Dec 2022 10:45:15 +0530 Subject: [PATCH 350/450] Add runtime langlib examples --- .../src/main/ballerina/runtime.bal | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/langlib/lang.runtime/src/main/ballerina/runtime.bal b/langlib/lang.runtime/src/main/ballerina/runtime.bal index 7c39535208fe..87759f4296ed 100644 --- a/langlib/lang.runtime/src/main/ballerina/runtime.bal +++ b/langlib/lang.runtime/src/main/ballerina/runtime.bal @@ -41,6 +41,16 @@ type CallStackElement record {| # The listener becomes a module listener of the module from which this # function is called. # +# ```ballerina +# var 'listener = object { +# public function 'start() returns error? {} +# public function gracefulStop() returns error?{} +# public function immediateStop() returns error? {} +# }; +# +# runtime:registerListener('listener); +# ``` +# # + listener - the listener object to be registered public isolated function registerListener(DynamicListener 'listener) = @java:Method { 'class: "org.ballerinalang.langlib.runtime.Registry" @@ -50,6 +60,17 @@ public isolated function registerListener(DynamicListener 'listener) = @java:Met # # The `listener` ceases to be a module listener of the module from # which this function is called. +# +# ```ballerina +# var 'listener = object { +# public function 'start() returns error? {} +# public function gracefulStop() returns error?{} +# public function immediateStop() returns error? {} +# }; +# +# runtime:registerListener('listener); +# ``` +# # + listener - the listener object to be unregistered public isolated function deregisterListener(DynamicListener 'listener) = @java:Method { 'class: "org.ballerinalang.langlib.runtime.Registry" @@ -57,6 +78,10 @@ public isolated function deregisterListener(DynamicListener 'listener) = @java:M # Halts the current strand for a predefined amount of time. # +# ```ballerina +# runtime:sleep(5); +# ``` +# # + seconds - An amount of time to sleep in seconds public isolated function sleep(decimal seconds) = @java:Method { 'class: "org.ballerinalang.langlib.runtime.Sleep" @@ -75,6 +100,10 @@ public type StackFrame readonly & object { # Returns a stack trace for the current call stack. # +# ```ballerina +# runtime:StackFrame[] stackTrace = runtime:getStackTrace(); +# ``` +# # The first member of the array represents the top of the call stack. # + return - an array representing the current call stack public isolated function getStackTrace() returns StackFrame[] { @@ -102,6 +131,12 @@ public type StopHandler function() returns error?; # that was passed as an argument; the handler functions will be called # after calling `gracefulStop` on all registered listeners, # in reverse order of the corresponding calls to `onGracefulStop`. +# +# ```ballerina +# runtime:StopHandler handler = function() returns error? {}; +# runtime:onGracefulStop(handler); +# ``` +# # + handler - function to be called public isolated function onGracefulStop(StopHandler 'handler) = @java:Method { 'class: "org.ballerinalang.langlib.runtime.Registry" From 69fdbeef040ca22fd7b4ce7c88515dd3a0489a6a Mon Sep 17 00:00:00 2001 From: sanjana Date: Tue, 13 Dec 2022 06:53:22 +0530 Subject: [PATCH 351/450] Reformat code --- .../lang.runtime/src/main/ballerina/runtime.bal | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/langlib/lang.runtime/src/main/ballerina/runtime.bal b/langlib/lang.runtime/src/main/ballerina/runtime.bal index 87759f4296ed..2b32741a3feb 100644 --- a/langlib/lang.runtime/src/main/ballerina/runtime.bal +++ b/langlib/lang.runtime/src/main/ballerina/runtime.bal @@ -42,13 +42,13 @@ type CallStackElement record {| # function is called. # # ```ballerina -# var 'listener = object { +# runtime:DynamicListener ln = object { # public function 'start() returns error? {} -# public function gracefulStop() returns error?{} +# public function gracefulStop() returns error? {} # public function immediateStop() returns error? {} # }; # -# runtime:registerListener('listener); +# runtime:registerListener(ln); # ``` # # + listener - the listener object to be registered @@ -62,13 +62,13 @@ public isolated function registerListener(DynamicListener 'listener) = @java:Met # which this function is called. # # ```ballerina -# var 'listener = object { +# runtime:DynamicListener ln = object { # public function 'start() returns error? {} -# public function gracefulStop() returns error?{} +# public function gracefulStop() returns error? {} # public function immediateStop() returns error? {} # }; # -# runtime:registerListener('listener); +# runtime:deregisterListener(ln); # ``` # # + listener - the listener object to be unregistered @@ -133,8 +133,8 @@ public type StopHandler function() returns error?; # in reverse order of the corresponding calls to `onGracefulStop`. # # ```ballerina -# runtime:StopHandler handler = function() returns error? {}; -# runtime:onGracefulStop(handler); +# runtime:StopHandler stopHandler = function() returns error? {}; +# runtime:onGracefulStop(stopHandler); # ``` # # + handler - function to be called From a189c2bc72a0abb0e82040146055543b6b5b448c Mon Sep 17 00:00:00 2001 From: sanjana Date: Tue, 20 Dec 2022 10:26:37 +0530 Subject: [PATCH 352/450] Reformat runtime langlib examples --- .../src/main/ballerina/runtime.bal | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/langlib/lang.runtime/src/main/ballerina/runtime.bal b/langlib/lang.runtime/src/main/ballerina/runtime.bal index 2b32741a3feb..ffe6047165d5 100644 --- a/langlib/lang.runtime/src/main/ballerina/runtime.bal +++ b/langlib/lang.runtime/src/main/ballerina/runtime.bal @@ -43,9 +43,14 @@ type CallStackElement record {| # # ```ballerina # runtime:DynamicListener ln = object { -# public function 'start() returns error? {} -# public function gracefulStop() returns error? {} -# public function immediateStop() returns error? {} +# public function 'start() returns error? { +# } +# +# public function gracefulStop() returns error? { +# } +# +# public function immediateStop() returns error? { +# } # }; # # runtime:registerListener(ln); @@ -63,9 +68,14 @@ public isolated function registerListener(DynamicListener 'listener) = @java:Met # # ```ballerina # runtime:DynamicListener ln = object { -# public function 'start() returns error? {} -# public function gracefulStop() returns error? {} -# public function immediateStop() returns error? {} +# public function 'start() returns error? { +# } +# +# public function gracefulStop() returns error? { +# } +# +# public function immediateStop() returns error? { +# } # }; # # runtime:deregisterListener(ln); @@ -133,7 +143,7 @@ public type StopHandler function() returns error?; # in reverse order of the corresponding calls to `onGracefulStop`. # # ```ballerina -# runtime:StopHandler stopHandler = function() returns error? {}; +# runtime:StopHandler stopHandler = function() returns error? => (); # runtime:onGracefulStop(stopHandler); # ``` # From 928f513db93dc6ec1cefe69d232b0c176d040a61 Mon Sep 17 00:00:00 2001 From: mohan Date: Tue, 20 Dec 2022 11:10:37 +0530 Subject: [PATCH 353/450] Update examples based on review comments --- langlib/lang.string/src/main/ballerina/string.bal | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index 03423e287f29..da5912efb585 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -279,7 +279,7 @@ public isolated function equalsIgnoreCaseAscii(string str1, string str2) returns # The ASCII white space characters are 0x9...0xD, 0x20. # # ```ballerina -# " BALLERINA ".trim() ⇒ "BALLERINA" +# " Hello World ".trim() + "!" ⇒ Hello World! # ``` # # + str - the string @@ -386,7 +386,7 @@ public isolated function fromCodePointInt(int codePoint) returns Char|error = @j # If the length of `str` is >= `len`, returns `str`. # # ```ballerina -# "100Km".padStart(10, "0") ⇒ " 100Km" +# "100Km".padStart(10, "0") ⇒ 100Km # # "100Km".padStart(10, "0") ⇒ 00000100Km # ``` @@ -405,7 +405,7 @@ public isolated function padStart(string str, int len, Char padChar = " ") retur # If the length of `str` is >= `len`, returns `str`. # # ```ballerina -# "Ballerina for developers".padEnd(30) ⇒ "Ballerina for developers " +# "Ballerina for developers".padEnd(30) ⇒ Ballerina for developers # # "Ballerina for developers".padEnd(30, "!") ⇒ Ballerina for developers!!!!!! # ``` From 26e68ea55b6c6dfc17a80fbb92a8ece2f206b7d5 Mon Sep 17 00:00:00 2001 From: suleka96 Date: Tue, 20 Dec 2022 15:00:21 +0530 Subject: [PATCH 354/450] Refactor code --- .../lang.regexp/src/main/ballerina/regexp.bal | 120 +++++++++--------- .../lang.string/src/main/ballerina/string.bal | 8 +- 2 files changed, 64 insertions(+), 64 deletions(-) diff --git a/langlib/lang.regexp/src/main/ballerina/regexp.bal b/langlib/lang.regexp/src/main/ballerina/regexp.bal index f9aef6c6784f..7b9beacc91ab 100644 --- a/langlib/lang.regexp/src/main/ballerina/regexp.bal +++ b/langlib/lang.regexp/src/main/ballerina/regexp.bal @@ -51,16 +51,38 @@ type GroupsAsSpanArrayType SpanAsTupleType[]; type GroupsArrayType GroupsAsSpanArrayType[]; +# Splits a string into substrings separated by matches of a regular expression. +# This finds the the non-overlapping matches of a regular expression and +# returns a list of substrings of `str` that occur before the first match, +# between matches, or after the last match. If there are no matches, then +# `[str]` will be returned. +# +# ```ballerina +# regexp:RegExp r = re `,`; +# +# r.split("Not Valid") ⇒ ["Not Valid"] +# +# r.split("abc,cde,efg") ⇒ ["abc", "cde", "efg"] +# ``` +# +# + re - the regular expression that specifies the separator +# + str - the string to be split +# + return - a list of substrings of `str` separated by matches of `re` +public isolated function split(RegExp re, string str) returns string[] = @java:Method { + 'class: "org.ballerinalang.langlib.regexp.Split", + name: "split" +} external; + # Returns the first match of a regular expression within a string. # # ```ballerina -#var sampleRegex = re `World`; +# regexp:RegExp r = re `World`; # -#sampleRegex.find("Not A Match") is () ⇒ true +# r.find("Not A Match") is () ⇒ true # -#sampleRegex.find("Hello World") is regexp:Span ⇒ true +# r.find("Hello World") is regexp:Span ⇒ true # -#sampleRegex.find("Hello World", 7) is regexp:Span ⇒ true +# r.find("Hello World", 7) is regexp:Span ⇒ true # ``` # # + re - the regular expression @@ -88,13 +110,13 @@ isolated function findAllImpl(RegExp reExp, string str, int startIndex = 0) retu # Returns the `Groups` for the first match of a regular expression within a string. # # ```ballerina -#var sampleRegex = re `GFG`; +# regexp:RegExp r = re `([bB].tt[a-z]*)`; # -#sampleRegex.findGroups("Not A Match") is () ⇒ true +# r.findGroups("Not A Match") is () ⇒ true # -#rsampleRegex.findGroups("GFGFGFGFGFGFGFGFGFG") is regexp:Groups ⇒ true +# r.findGroups("Butter was bought by Betty but the butter was bitter.") is regexp:Groups ⇒ true # -#sampleRegex.findGroups("GFGFGFGFGFGFGFGFGFG", 7) is regexp:Groups ⇒ true +# r.findGroups("Butter was bought by Betty but the butter was bitter.", 7) is regexp:Groups ⇒ true # ``` # # + re - the regular expression @@ -118,13 +140,13 @@ isolated function findGroupsImpl(RegExp reExp, string str, int startIndex = 0) r # match ended, so the list of matches will be non-overlapping. # # ```ballerina -#var sampleRegex = re `GFG`; +# regexp:RegExp r = re `[bB].tt[a-z]*`; # -#sampleRegex.findAll("Not A Match").length() ⇒ 0 +# r.findAll("Not A Match").length() ⇒ 0 # -#sampleRegex.findAll("GFGFGFGFGFGFGFGFGFG").length() ⇒ 5 +# r.findAll("Butter was bought by Betty but the butter was bitter.").length() ⇒ 4 # -#sampleRegex.findAll("GFGFGFGFGFGFGFGFGFG", 7).length() ⇒ true +# r.findAll("Butter was bought by Betty but the butter was bitter.", 7).length() ⇒ 3 # ``` # # + re - the regular expression @@ -147,13 +169,13 @@ public isolated function findAll(RegExp re, string str, int startIndex = 0) retu # match ended, so the list of matches will be non-overlapping. # # ```ballerina -#var sampleRegex = re `(GFG)(FGF)`; +# regexp:RegExp r = re `([bB].tt[a-z]*)`; # -#sampleRegex.findAllGroups("Not A Match").length() ⇒ 0 +# r.findAllGroups("Not A Match").length() ⇒ 0 # -#sampleRegex.findAllGroups("GFGFGFGFGFGFGFGFGF").length() ⇒ 3 +# r.findAllGroups("Butter was bought by Betty but the butter was bitter.").length() ⇒ 4 # -#sampleRegex.findAllGroups("GFGFGFGFGFGFGFGFGF", 7) ⇒ 1 +# r.findAllGroups("Butter was bought by Betty but the butter was bitter.", 7) ⇒ 3 # ``` # # + re - the regular expression @@ -195,11 +217,11 @@ isolated function findAllGroupsImpl(RegExp reExp, string str, int startIndex = 0 # Tests whether there is a match of a regular expression at a specific index in the string. # # ```ballerina -# var sampleRegex = re `World`; +# regexp:RegExp r = re `World`; # -#sampleRegex.matchAt("Hello World") is () ⇒ true +# r.matchAt("Hello World") is () ⇒ true # -#sampleRegex.matchAt("Hello World", 6) is regexp:Span ⇒ true +# r.matchAt("Hello World", 6) is regexp:Span ⇒ true # ``` # # + re - the regular expression @@ -223,11 +245,11 @@ isolated function matchAtImpl(RegExp reExp, string str, int startIndex = 0) retu # Returns the `Groups` of the match of a regular expression at a specific index in the string. # # ```ballerina -#var sampleRegex = re `([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])?`; +# regexp:RegExp r = re `([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])?`; # -#sampleRegex.matchGroupsAt("time: 14:35:59") is () ⇒ true +# r.matchGroupsAt("time: 14:35:59") is () ⇒ true # -#sampleRegex.matchGroupsAt("time: 14:35:59", 6) is regexp:Groups ⇒ true +# r.matchGroupsAt("time: 14:35:59", 6) is regexp:Groups ⇒ true # ``` # # + re - the regular expression @@ -260,11 +282,11 @@ isolated function matchGroupsAtImpl(RegExp reExp, string str, int startIndex = 0 # starts at index 0 and ends at index `n`, where `n` is the length of the string. # # ```ballerina -#var sampleRegex = re `A|Th.*ch|^`; +# regexp:RegExp r = re `A|Th.*ch|^`; # -#sampleRegex.isFullMatch("This is a Match") ⇒ true +# r.isFullMatch("This is a Match") ⇒ true # -#sampleRegex.isFullMatch("Not a complete Match") ⇒ false +# r.isFullMatch("Not a complete Match") ⇒ false # ``` # # + re - the regular expression @@ -284,11 +306,11 @@ isolated function isFullMatchImpl(RegExp reExp, string str) returns boolean = @j # starts at index 0 and ends at index `n`, where `n` is the length of the string. # # ```ballerina -#var sampleRegex = re `([0-9]+)×([0-9]+)`; +# regexp:RegExp r = re `([0-9]+)×([0-9]+)`; # -#sampleRegex.fullMatchGroups("test: 1440×900") is () ⇒ true +# r.fullMatchGroups("test: 1440×900") is () ⇒ true # -#sampleRegex.fullMatchGroups("1440×900") is regexp:Groups ⇒ true +# r.fullMatchGroups("1440×900") is regexp:Groups ⇒ true # ``` # # + re - the regular expression @@ -311,13 +333,13 @@ public type Replacement ReplacerFunction|string; # Replaces the first match of a regular expression. # # ```ballerina -#var sampleRegex = re `0+`; +# regexp:RegExp r = re `0+`; # -#sampleRegex.replace("10010011", "*") ⇒ 1*10011 +# r.replace("10010011", "*") ⇒ 1*10011 # -#sampleRegex.replace("10010011", "*", 4) ⇒ 1001*11 +# r.replace("10010011", "*", 4) ⇒ 1001*11 # -#sampleRegex.replace("122111", "*") ⇒ 122111 +# r.replace("122111", "*") ⇒ 122111 # ``` # # + re - the regular expression @@ -347,13 +369,13 @@ public isolated function replace(RegExp re, string str, Replacement replacement, # match ended, so the matches will be non-overlapping. # # ```ballerina -#var sampleRegex = re `0+`; +# regexp:RegExp r = re `0+`; # -#sampleRegex.replaceAll("10010011", "*") ⇒ 1*1*11 +# r.replaceAll("10010011", "*") ⇒ 1*1*11 # -#sampleRegex.replaceAll("10010011", "*", 4) ⇒ 1001*11 +# r.replaceAll("10010011", "*", 4) ⇒ 1001*11 # -#sampleRegex.replaceAll("122111", "*") ⇒ 122111 +# r.replaceAll("122111", "*") ⇒ 122111 # ``` # # + re - the regular expression @@ -406,35 +428,13 @@ isolated function getReplacementString(Groups groups, Replacement replacement) r return replacement(groups); } -# Splits a string into substrings separated by matches of a regular expression. -# This finds the the non-overlapping matches of a regular expression and -# returns a list of substrings of `str` that occur before the first match, -# between matches, or after the last match. If there are no matches, then -# `[str]` will be returned. -# -# ```ballerina -#var sampleRegex = re `,`; -# -#sampleRegex.split("Not Valid").length() ⇒ 0 -# -#sampleRegex.split("abc,cde,efg") ⇒ ["abc", "cde", "efg"] -# ``` -# -# + re - the regular expression that specifies the separator -# + str - the string to be split -# + return - a list of substrings of `str` separated by matches of `re` -public isolated function split(RegExp re, string str) returns string[] = @java:Method { - 'class: "org.ballerinalang.langlib.regexp.Split", - name: "split" -} external; - # Constructs a regular expression from a string. # The syntax of the regular expression is the same as accepted by the `re` tagged data template expression. # # ```ballerina -#regexp:fromString("AB+C*D{1,4}") ⇒ re `AB+C*D{1,4}` +# regexp:fromString("AB+C*D{1,4}") ⇒ re `AB+C*D{1,4}` # -#regexp:fromString("AB+^*") is error ⇒ true +# regexp:fromString("AB+^*") ⇒ error # ``` # # + str - the string representation of a regular expression diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index 99ac723eb410..56bbad3e714d 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -318,8 +318,8 @@ public type RegExp regexp:RegExp; # This is equivalent to `regex:isFullMatch(re, str)`. # # ```ballerina -#string sampleString = "This is a Match"; -#sampleString.matches(re `A|Th.*ch|^`) ⇒ true +# string s = "This is a Match"; +# s.matches(re `A|Th.*ch|^`) ⇒ true # ``` # # + str - the string @@ -333,8 +333,8 @@ public function matches(string str, RegExp re) returns boolean { # This is equivalent to `regexp:find(re, str, startIndex) != ()`. # # ```ballerina -#string sampleString = "Will Match Somewhere"; -#sampleString.includesMatch(re `A|Th.*ch|^`) ⇒ true +# string s = "Will Match Somewhere"; +# s.includesMatch(re `A|Th.*ch|^`) ⇒ true # ``` # # + str - the string to be matched From 5710521651bae389b1066adc54d4787f1ec7b403 Mon Sep 17 00:00:00 2001 From: gabilang Date: Tue, 20 Dec 2022 16:58:07 +0530 Subject: [PATCH 355/450] Fix invalid synthetic variable name --- .../java/org/wso2/ballerinalang/compiler/desugar/Desugar.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java index 7dd22704fd82..d72fdb00c012 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java @@ -7245,7 +7245,7 @@ private BLangStatementExpression createStmtExprForNullableBinaryExpr(BLangBinary binaryExpr.lhsExpr = rewriteExpr(binaryExpr.lhsExpr); } - BLangSimpleVariableDef tempVarDef = createVarDef("result", + BLangSimpleVariableDef tempVarDef = createVarDef("$result$", binaryExpr.getBType(), null, binaryExpr.pos); BLangSimpleVarRef tempVarRef = ASTBuilderUtil.createVariableRef(binaryExpr.pos, tempVarDef.var.symbol); blockStmt.addStatement(tempVarDef); From fa00eeabd6729edc073d49ec5aa089f296c4516c Mon Sep 17 00:00:00 2001 From: sanjana Date: Tue, 6 Dec 2022 15:21:48 +0530 Subject: [PATCH 356/450] Add examples in XML langlib functions --- langlib/lang.xml/src/main/ballerina/xml.bal | 79 +++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/langlib/lang.xml/src/main/ballerina/xml.bal b/langlib/lang.xml/src/main/ballerina/xml.bal index 44b9fef98fad..ff9967280a7a 100644 --- a/langlib/lang.xml/src/main/ballerina/xml.bal +++ b/langlib/lang.xml/src/main/ballerina/xml.bal @@ -53,6 +53,11 @@ public type Text xml; # Returns number of xml items in an xml value. # +# ```ballerina +# xml books = xml `BallerinaJava`; +# int length = books.length(); +# ``` +# # + x - xml item # + return - number of xml items in parameter `x` public isolated function length(xml x) returns int = @java:Method { @@ -75,6 +80,14 @@ type XmlType xml; # Returns an iterator over the xml items of an xml sequence. # # # Each item is represented by an xml singleton. +# +# ```ballerina +# xml books = xml `BallerinaJava`; +# object { +# public isolated function next() returns record {|xml value;|}?; +# } iterator = books.iterator(); +# record {|xml value;|}? next = iterator.next(); +# ``` # # + x - xml sequence to iterate over # + return - iterator object @@ -89,6 +102,11 @@ public isolated function iterator(xml x) returns object { # # This differs from `x[i]` in that it panics if # parameter `x` does not have an item with index parameter `i`. +# +# ```ballerina +# xml books = xml `BallerinaJava`; +# xml secondBook = books.get(1); +# ``` # # + x - the xml sequence # + i - the index @@ -99,6 +117,18 @@ public isolated function get(xml x, int i) returns ItemType = @java:Me } external; # Concatenates xml and string values. +# +# ``` +# // Concatanate a set of xml variables +# xml firstBook = xml `Ballerina`; +# xml secondBook = xml `Java`; +# xml thirdBook = xml `Python`; +# xml bookSet = xml:concat(firstBook, secondBook, thirdBook); +# +# // Concatanate an array of xml values +# xml[] subjectList = [xml `English`, xml `Math`, xml `ICT`]; +# xml subjects = xml:concat(...subjectList); +# ``` # # + xs - xml or string items to concatenate # + return - an xml sequence that is the concatenation of all the parameter `xs`; @@ -110,6 +140,11 @@ public isolated function concat((xml|string)... xs) returns xml = @java:Method { # Returns a string giving the expanded name of an xml element. # +# ```ballerina +# xml:Element person = xml `John`; +# string xmlElementName = person.getName(); +# ``` +# # + elem - xml element # + return - element name public isolated function getName(Element elem) returns string = @java:Method { @@ -119,6 +154,10 @@ public isolated function getName(Element elem) returns string = @java:Method { # Changes the name of an XML element. # +# ```ballerina +# xml:Element person = xml `John`; +# person.setName("student"); +# ``` # + elem - xml element # + xName - new expanded name public isolated function setName(Element elem, string xName) = @java:Method { @@ -131,6 +170,11 @@ public isolated function setName(Element elem, string xName) = @java:Method { # This includes namespace attributes. # The keys in the map are the expanded names of the attributes. # +# ```ballerina +# xml:Element person = xml ``; +# map attributes = person.getAttributes(); +# ``` +# # + x - xml element # + return - attributes of parameter `x` public isolated function getAttributes(Element x) returns map = @java:Method { @@ -140,6 +184,11 @@ public isolated function getAttributes(Element x) returns map = @java:Me # Returns the children of an xml element. # +# ```ballerina +# xml:Element bookSet = xml `BallerinaJava`; +# xml books = bookSet.getChildren(); +# ``` +# # + elem - xml element # + return - children of parameter `elem` public isolated function getChildren(Element elem) returns xml = @java:Method { @@ -151,6 +200,12 @@ public isolated function getChildren(Element elem) returns xml = @java:Method { # # This panics if it would result in the element structure # becoming cyclic. +# +# ```ballerina +# xml:Element bookSet = xml `BallerinaJava`; +# xml webDevBooks = xml `HTMLJavascript`; +# bookSet.setChildren(webDevBooks); +# ``` # # + elem - xml element # + children - xml or string to set as children @@ -169,6 +224,11 @@ public isolated function setChildren(Element elem, xml|string children) = @java: # to the order in which the first character of the representation # of the item would occur in the representation of the element in XML syntax. # +# ```ballerina +# xml:Element person = xml `John Doe30`; +# xml details = person.getDescendants(); +# ``` +# # + elem - xml element # + return - descendants of parameter `elem` public isolated function getDescendants(Element elem) returns xml = @java:Method { @@ -188,6 +248,10 @@ public isolated function getDescendants(Element elem) returns xml = @java:Method # * the character data of the concatenation of two xml sequences x1 and x2 is the # concatenation of the character data of x1 and the character data of x2. # +# ```ballerina +# xml book = xml `Ballerina`; +# string bookName = book.data(); +# ``` # + x - the xml value # + return - a string consisting of all the character data of parameter `x` public isolated function data(xml x) returns string = @java:Method { @@ -197,6 +261,11 @@ public isolated function data(xml x) returns string = @java:Method { # Returns the target part of the processing instruction. # +# ```ballerina +# xml:ProcessingInstruction person = xml ``; +# string target = person.getTarget(); +# ``` +# # + x - xml processing instruction item # + return - target part of parameter `x` public isolated function getTarget(ProcessingInstruction x) returns string = @java:Method { @@ -206,6 +275,16 @@ public isolated function getTarget(ProcessingInstruction x) returns string = @ja # Returns the content of a processing instruction or comment item. # +# ```ballerina +# // Get the content of an XML Processing Instruction +# xml:ProcessingInstruction person = xml ``; +# string content = person.getContent(); +# +# // Get the content of an XML comment +# xml:Comment comment = xml ``; +# string commentDetail = comment.getContent(); +# ``` +# # + x - xml item # + return - the content of parameter `x` public isolated function getContent(ProcessingInstruction|Comment x) returns string = @java:Method { From 474df8a15606446074b051c8be842d9aa41242ef Mon Sep 17 00:00:00 2001 From: sanjana Date: Thu, 8 Dec 2022 10:11:06 +0530 Subject: [PATCH 357/450] Add XML langlib function examples --- langlib/lang.xml/src/main/ballerina/xml.bal | 96 +++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/langlib/lang.xml/src/main/ballerina/xml.bal b/langlib/lang.xml/src/main/ballerina/xml.bal index ff9967280a7a..b30f9ae9e0bc 100644 --- a/langlib/lang.xml/src/main/ballerina/xml.bal +++ b/langlib/lang.xml/src/main/ballerina/xml.bal @@ -294,6 +294,13 @@ public isolated function getContent(ProcessingInstruction|Comment x) returns str # Creates a new xml element item. # +# ```ballerina +# string name = "book"; +# map attributes = {title: "Learning Ballerina", author: "Anjana"}; +# xml bookChildren = xml `2022`; +# xml:Element bookElement = xml:createElement(name, attributes, bookChildren); +# ``` +# # + name - the name of the new element # + attributes - the attributes of the new element # + children - the children of the new element @@ -310,6 +317,12 @@ public isolated function createElement(string name, map attributes = {}, # Creates a new xml processing instruction item. # +# ```ballerina +# string target = "url"; +# string content = "example.com"; +# xml:ProcessingInstruction xmlPI = xml:createProcessingInstruction(target, content); +# ``` +# # + target - the target part of the processing instruction to be constructed # + content - the content part of the processing instruction to be constructed # + return - an xml sequence consisting of a processing instruction with parameter `target` as the target @@ -322,6 +335,11 @@ public isolated function createProcessingInstruction(string target, string conte # Creates a new xml comment item. # +# ```ballerina +# string commentContent = "Example comment details"; +# xml:Comment comment = xml:createComment(commentContent); +# ``` +# # + content - the content of the comment to be constructed. # + return - an xml sequence consisting of a comment with parameter `content` as the content public isolated function createComment(string content) returns Comment = @java:Method { @@ -333,6 +351,11 @@ public isolated function createComment(string content) returns Comment = @java:M # # The constructed sequence will be empty when the length of parameter `data` is zero. # +# ```ballerina +# string textData = "Hello world!"; +# xml:Text xmlText = xml:createText(textData); +# ``` +# # + data - the character data of the Text item # + return - an xml sequence that is either empty or consists of one text item public isolated function createText(string data) returns Text = @java:Method { @@ -342,6 +365,11 @@ public isolated function createText(string data) returns Text = @java:Method { # Returns a subsequence of an xml value. # +# ```ballerina +# xml books = xml `HTMLBallerinaPythonCSS`; +# xml programmingBooks = books.slice(1, 3); +# ``` +# # + x - the xml value # + startIndex - start index, inclusive # + endIndex - end index, exclusive @@ -359,6 +387,12 @@ public isolated function slice(xml x, int startIndex, int endIndex = x # the biggest possible chunks (i.e., only elements cause division into multiple chunks) # and a chunk is considered insignificant if the entire chunk is whitespace. # +# ```ballerina +# xml bookDetails = xml ` +# Learning Ballerina`; +# xml essentialBookData = bookDetails.strip(); +# ``` +# # + x - the xml value # + return - `x` with insignificant parts removed public isolated function strip(xml x) returns xml = @java:Method { @@ -371,6 +405,16 @@ public isolated function strip(xml x) returns xml = @java:Method { # If parameter `nm` is `()`, selects all elements; # otherwise, selects only elements whose expanded name is parameter `nm`. # +# ```ballerina +# // Get all the elements present in the given XML dataset. +# xml codingBooks = xml `JSBallerina +# PythonPerl`; +# xml allCodingBooks = codingBooks.elements(); +# +# // Get only the elements which has the given naame. +# xml programmingBooks = codingBooks.elements("programming"); +# ``` +# # + x - the xml value # + nm - the expanded name of the elements to be selected, or `()` for all elements # + return - an xml sequence consisting of all the element items in parameter `x` whose expanded name is parameter `nm`, @@ -385,6 +429,11 @@ public isolated function elements(xml x, string? nm = ()) returns xml = # When parameter `x` is of type `Element`, it is equivalent to function `getChildren`. # This is equivalent to `elements(x).map(getChildren)`. # +# ```ballerina +# xml bookSet = xml `JavaBallerina`; +# xml books = bookSet.children(); +# ``` +# # + x - xml value # + return - xml sequence containing the children of each element x concatenated in order public isolated function children(xml x) returns xml = @java:Method { @@ -396,6 +445,11 @@ public isolated function children(xml x) returns xml = @java:Method { # # This is equivalent to `children(x).elements(nm)`. # +# ```ballerina +# xml bookSet = xml `JavaBallerina`; +# xml bookTitles = bookSet.elementChildren("title"); +# ``` +# # + x - the xml value # + nm - the expanded name of the elements to be selected, or `()` for all elements # + return - an xml sequence consisting of child elements of elements in parameter `x`; if parameter `nm` @@ -412,6 +466,16 @@ public isolated function elementChildren(xml x, string? nm = ()) returns xmlJavaBallerina`; +# +# xml booksWithAuthors = bookSet.'map(function (xml xmlContent) returns xml { +# xml author = xml `Anjana`; +# return xml `${xmlContent.children() + author}`; +# }); +# +# ``` +# # + x - the xml value # + func - a function to apply to each child or `item` # + return - new xml value containing result of applying parameter `func` to each child or `item` @@ -425,6 +489,15 @@ public isolated function 'map(xml x, @isolatedParam function(ItemType # # Each item is represented as a singleton value. # +# ```ballerina +# xml bookSet = xml `JavaBallerina`; +# xml bookTitles = xml ``; +# +# bookSet.forEach(function (xml xmlItem) { +# bookTitles += xmlItem.children(); +# }); +# ``` +# # + x - the xml value # + func - a function to apply to each item in parameter `x` public isolated function forEach(xml x, @isolatedParam function(ItemType item) returns () func) = @java:Method { @@ -436,6 +509,19 @@ public isolated function forEach(xml x, @isolatedParam function(ItemTy # # Each item is represented as a singleton value. # +# ```ballerina +# xml codingBooks = xml `JSBallerina +# PythonPerl`; +# +# xml programmingBooks = codingBooks.filter(function (xml xmlItem) returns boolean { +# if (xmlItem is xml:Element) { +# return ( xmlItem).getName() == "programming"; +# } +# +# return false; +# }); +# ``` +# # + x - xml value # + func - a predicate to apply to each item to test whether it should be selected # + return - new xml sequence containing items in parameter `x` for which function `func` evaluates to true @@ -450,6 +536,11 @@ public isolated function filter(xml x, @isolatedParam function(ItemTyp # This parses the string using the `content` production of the # XML 1.0 Recommendation. # +# ```ballerina +# string bookStr = "BallerinaJava"; +# xml bookXml = check xml:fromString(bookStr); +# ``` +# # + s - a string in XML format # + return - xml value resulting from parsing parameter `s`, or an error public isolated function fromString(string s) returns xml|error = @java:Method { @@ -459,6 +550,11 @@ public isolated function fromString(string s) returns xml|error = @java:Method { # Selects all the items in a sequence that are of type `xml:Text`. # +# ```ballerina +# xml books = xml ` Ballerina Java`; +# xml:Text textContent = books.text(); +# ``` +# # + x - the xml value # + return - an xml sequence consisting of selected text items public isolated function text(xml x) returns Text = @java:Method { From f0dac9d10c92de79bf074968b42be066e0b45d1c Mon Sep 17 00:00:00 2001 From: sanjana Date: Tue, 20 Dec 2022 08:13:02 +0530 Subject: [PATCH 358/450] Add xml langlib example outputs --- langlib/lang.xml/src/main/ballerina/xml.bal | 109 +++++++++----------- 1 file changed, 51 insertions(+), 58 deletions(-) diff --git a/langlib/lang.xml/src/main/ballerina/xml.bal b/langlib/lang.xml/src/main/ballerina/xml.bal index b30f9ae9e0bc..16043f1f1176 100644 --- a/langlib/lang.xml/src/main/ballerina/xml.bal +++ b/langlib/lang.xml/src/main/ballerina/xml.bal @@ -55,7 +55,7 @@ public type Text xml; # # ```ballerina # xml books = xml `BallerinaJava`; -# int length = books.length(); +# books.length() ⇒ 2 # ``` # # + x - xml item @@ -86,7 +86,7 @@ type XmlType xml; # object { # public isolated function next() returns record {|xml value;|}?; # } iterator = books.iterator(); -# record {|xml value;|}? next = iterator.next(); +# iterator.next() ⇒ {"value":`Ballerina`} # ``` # # + x - xml sequence to iterate over @@ -105,7 +105,7 @@ public isolated function iterator(xml x) returns object { # # ```ballerina # xml books = xml `BallerinaJava`; -# xml secondBook = books.get(1); +# books.get(1) ⇒ Java # ``` # # + x - the xml sequence @@ -119,15 +119,13 @@ public isolated function get(xml x, int i) returns ItemType = @java:Me # Concatenates xml and string values. # # ``` -# // Concatanate a set of xml variables -# xml firstBook = xml `Ballerina`; -# xml secondBook = xml `Java`; -# xml thirdBook = xml `Python`; -# xml bookSet = xml:concat(firstBook, secondBook, thirdBook); +# xml bookA = xml `Ballerina`; +# xml bookB = xml `Java`; +# xml bookC = xml `Python`; +# xml:concat(bookA, bookB, bookC) ⇒ BallerinaJavaPython # -# // Concatanate an array of xml values # xml[] subjectList = [xml `English`, xml `Math`, xml `ICT`]; -# xml subjects = xml:concat(...subjectList); +# xml:concat(...subjectList) ⇒ EnglishMathICT # ``` # # + xs - xml or string items to concatenate @@ -141,8 +139,8 @@ public isolated function concat((xml|string)... xs) returns xml = @java:Method { # Returns a string giving the expanded name of an xml element. # # ```ballerina -# xml:Element person = xml `John`; -# string xmlElementName = person.getName(); +# xml:Element p = xml `John`; +# p.getName() ⇒ person # ``` # # + elem - xml element @@ -155,8 +153,8 @@ public isolated function getName(Element elem) returns string = @java:Method { # Changes the name of an XML element. # # ```ballerina -# xml:Element person = xml `John`; -# person.setName("student"); +# xml:Element s = xml `John`; +# s.setName("student"); # ``` # + elem - xml element # + xName - new expanded name @@ -171,8 +169,8 @@ public isolated function setName(Element elem, string xName) = @java:Method { # The keys in the map are the expanded names of the attributes. # # ```ballerina -# xml:Element person = xml ``; -# map attributes = person.getAttributes(); +# xml:Element a = xml ``; +# a.getAttributes() ⇒ {"name":"John","age":"30"} # ``` # # + x - xml element @@ -186,7 +184,7 @@ public isolated function getAttributes(Element x) returns map = @java:Me # # ```ballerina # xml:Element bookSet = xml `BallerinaJava`; -# xml books = bookSet.getChildren(); +# bookSet.getChildren() ⇒ BallerinaJava # ``` # # + elem - xml element @@ -226,7 +224,7 @@ public isolated function setChildren(Element elem, xml|string children) = @java: # # ```ballerina # xml:Element person = xml `John Doe30`; -# xml details = person.getDescendants(); +# person.getDescendants() ⇒ John DoeJohn Doe3030 # ``` # # + elem - xml element @@ -250,7 +248,7 @@ public isolated function getDescendants(Element elem) returns xml = @java:Method # # ```ballerina # xml book = xml `Ballerina`; -# string bookName = book.data(); +# book.data() ⇒ Ballerina # ``` # + x - the xml value # + return - a string consisting of all the character data of parameter `x` @@ -262,8 +260,8 @@ public isolated function data(xml x) returns string = @java:Method { # Returns the target part of the processing instruction. # # ```ballerina -# xml:ProcessingInstruction person = xml ``; -# string target = person.getTarget(); +# xml:ProcessingInstruction p = xml ``; +# p.getTarget() ⇒ person # ``` # # + x - xml processing instruction item @@ -276,13 +274,11 @@ public isolated function getTarget(ProcessingInstruction x) returns string = @ja # Returns the content of a processing instruction or comment item. # # ```ballerina -# // Get the content of an XML Processing Instruction # xml:ProcessingInstruction person = xml ``; -# string content = person.getContent(); +# person.getContent() ⇒ name # -# // Get the content of an XML comment # xml:Comment comment = xml ``; -# string commentDetail = comment.getContent(); +# comment.getContent() ⇒ Example comment # ``` # # + x - xml item @@ -296,9 +292,9 @@ public isolated function getContent(ProcessingInstruction|Comment x) returns str # # ```ballerina # string name = "book"; -# map attributes = {title: "Learning Ballerina", author: "Anjana"}; -# xml bookChildren = xml `2022`; -# xml:Element bookElement = xml:createElement(name, attributes, bookChildren); +# map attributes = {title: "Ballerina", author: "Anjana"}; +# xml contents = xml `2022`; +# xml:createElement(name, attributes, contents) ⇒ 2022 # ``` # # + name - the name of the new element @@ -320,7 +316,7 @@ public isolated function createElement(string name, map attributes = {}, # ```ballerina # string target = "url"; # string content = "example.com"; -# xml:ProcessingInstruction xmlPI = xml:createProcessingInstruction(target, content); +# xml:createProcessingInstruction(target, content) ⇒ # ``` # # + target - the target part of the processing instruction to be constructed @@ -336,8 +332,8 @@ public isolated function createProcessingInstruction(string target, string conte # Creates a new xml comment item. # # ```ballerina -# string commentContent = "Example comment details"; -# xml:Comment comment = xml:createComment(commentContent); +# string commentContent = "Example comment"; +# xml:createComment(commentContent) ⇒ # ``` # # + content - the content of the comment to be constructed. @@ -352,8 +348,8 @@ public isolated function createComment(string content) returns Comment = @java:M # The constructed sequence will be empty when the length of parameter `data` is zero. # # ```ballerina -# string textData = "Hello world!"; -# xml:Text xmlText = xml:createText(textData); +# string textData = "Hello!"; +# xml:createText(textData) ⇒ Hello! # ``` # # + data - the character data of the Text item @@ -367,7 +363,7 @@ public isolated function createText(string data) returns Text = @java:Method { # # ```ballerina # xml books = xml `HTMLBallerinaPythonCSS`; -# xml programmingBooks = books.slice(1, 3); +# books.slice(1, 3) ⇒ BallerinaPython # ``` # # + x - the xml value @@ -390,7 +386,7 @@ public isolated function slice(xml x, int startIndex, int endIndex = x # ```ballerina # xml bookDetails = xml ` # Learning Ballerina`; -# xml essentialBookData = bookDetails.strip(); +# bookDetails.strip() ⇒ Learning Ballerina # ``` # # + x - the xml value @@ -406,10 +402,9 @@ public isolated function strip(xml x) returns xml = @java:Method { # otherwise, selects only elements whose expanded name is parameter `nm`. # # ```ballerina -# // Get all the elements present in the given XML dataset. -# xml codingBooks = xml `JSBallerina -# PythonPerl`; -# xml allCodingBooks = codingBooks.elements(); +# xml codingBooks = xml `Ballerina +# Python`; +# codingBooks.elements() ⇒ BallerinaPython # # // Get only the elements which has the given naame. # xml programmingBooks = codingBooks.elements("programming"); @@ -431,7 +426,7 @@ public isolated function elements(xml x, string? nm = ()) returns xml = # # ```ballerina # xml bookSet = xml `JavaBallerina`; -# xml books = bookSet.children(); +# bookSet.children() ⇒ JavaBallerina # ``` # # + x - xml value @@ -447,7 +442,7 @@ public isolated function children(xml x) returns xml = @java:Method { # # ```ballerina # xml bookSet = xml `JavaBallerina`; -# xml bookTitles = bookSet.elementChildren("title"); +# bookSet.elementChildren("title") ⇒ JavaBallerina # ``` # # + x - the xml value @@ -467,13 +462,10 @@ public isolated function elementChildren(xml x, string? nm = ()) returns xmlJavaBallerina`; -# -# xml booksWithAuthors = bookSet.'map(function (xml xmlContent) returns xml { -# xml author = xml `Anjana`; -# return xml `${xmlContent.children() + author}`; -# }); -# +# xml bookSet = xml `JavaBallerina`; +# bookSet.'map(function (xml xmlContent) returns xml { +# return xml `${xmlContent.children()}`; +# }) ⇒ JavaBallerina # ``` # # + x - the xml value @@ -513,13 +505,13 @@ public isolated function forEach(xml x, @isolatedParam function(ItemTy # xml codingBooks = xml `JSBallerina # PythonPerl`; # -# xml programmingBooks = codingBooks.filter(function (xml xmlItem) returns boolean { -# if (xmlItem is xml:Element) { -# return ( xmlItem).getName() == "programming"; -# } +# codingBooks.filter(function(xml xmlItem) returns boolean { +# if (xmlItem is xml:Element) { +# return (xmlItem).getName() == "code"; +# } # -# return false; -# }); +# return false; +# }) ⇒ BallerinaPython # ``` # # + x - xml value @@ -537,8 +529,9 @@ public isolated function filter(xml x, @isolatedParam function(ItemTyp # XML 1.0 Recommendation. # # ```ballerina -# string bookStr = "BallerinaJava"; -# xml bookXml = check xml:fromString(bookStr); +# xml:fromString(bookStr) ⇒ BallerinaJava +# +# xml:fromString("b") ⇒ error # ``` # # + s - a string in XML format @@ -551,8 +544,8 @@ public isolated function fromString(string s) returns xml|error = @java:Method { # Selects all the items in a sequence that are of type `xml:Text`. # # ```ballerina -# xml books = xml ` Ballerina Java`; -# xml:Text textContent = books.text(); +# xml books = xml `BallerinaJava`; +# books.text() ⇒ BallerinaJava # ``` # # + x - the xml value From 3f8c6ea2b25a7937cee32f7249f36fa422386172 Mon Sep 17 00:00:00 2001 From: hinduja Date: Tue, 20 Dec 2022 17:30:10 +0530 Subject: [PATCH 359/450] Fix final constants failing with null --- .../codegen/split/constants/JvmErrorTypeConstantsGen.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmErrorTypeConstantsGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmErrorTypeConstantsGen.java index 657112005eb3..c02671ce0ce0 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmErrorTypeConstantsGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/constants/JvmErrorTypeConstantsGen.java @@ -36,7 +36,6 @@ import java.util.TreeMap; import static org.objectweb.asm.ClassWriter.COMPUTE_FRAMES; -import static org.objectweb.asm.Opcodes.ACC_FINAL; import static org.objectweb.asm.Opcodes.ACC_PUBLIC; import static org.objectweb.asm.Opcodes.ACC_STATIC; import static org.objectweb.asm.Opcodes.GETSTATIC; @@ -60,7 +59,6 @@ public class JvmErrorTypeConstantsGen { private JvmErrorTypeGen jvmErrorTypeGen; private final ClassWriter cw; private MethodVisitor mv; - private int methodCount; private final List funcNames; private final Map errorTypeVarMap; @@ -112,8 +110,7 @@ private void createBErrorType(MethodVisitor mv, BErrorType errorType, String var } private void visitBErrorField(String varName) { - FieldVisitor fv = cw.visitField(ACC_PUBLIC + ACC_FINAL + ACC_STATIC, varName, - GET_ERROR_TYPE_IMPL, null, null); + FieldVisitor fv = cw.visitField(ACC_PUBLIC + ACC_STATIC, varName, GET_ERROR_TYPE_IMPL, null, null); fv.visitEnd(); } From 7b4dfa608b04064393e46211524556d9850dfddf Mon Sep 17 00:00:00 2001 From: sanjana Date: Tue, 20 Dec 2022 17:24:52 +0530 Subject: [PATCH 360/450] Update xml langlib examples with outputs --- langlib/lang.xml/src/main/ballerina/xml.bal | 24 +++++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/langlib/lang.xml/src/main/ballerina/xml.bal b/langlib/lang.xml/src/main/ballerina/xml.bal index 16043f1f1176..e84acead41ea 100644 --- a/langlib/lang.xml/src/main/ballerina/xml.bal +++ b/langlib/lang.xml/src/main/ballerina/xml.bal @@ -118,12 +118,18 @@ public isolated function get(xml x, int i) returns ItemType = @java:Me # Concatenates xml and string values. # -# ``` +# ```ballerina # xml bookA = xml `Ballerina`; # xml bookB = xml `Java`; # xml bookC = xml `Python`; # xml:concat(bookA, bookB, bookC) ⇒ BallerinaJavaPython # +# bookA.concat(bookB) ⇒ BallerinaJava +# +# bookC.concat("Coding") ⇒ PythonCoding +# +# xml:concat("Hello", "World") ⇒ HelloWorld +# # xml[] subjectList = [xml `English`, xml `Math`, xml `ICT`]; # xml:concat(...subjectList) ⇒ EnglishMathICT # ``` @@ -156,6 +162,7 @@ public isolated function getName(Element elem) returns string = @java:Method { # xml:Element s = xml `John`; # s.setName("student"); # ``` +# # + elem - xml element # + xName - new expanded name public isolated function setName(Element elem, string xName) = @java:Method { @@ -203,6 +210,9 @@ public isolated function getChildren(Element elem) returns xml = @java:Method { # xml:Element bookSet = xml `BallerinaJava`; # xml webDevBooks = xml `HTMLJavascript`; # bookSet.setChildren(webDevBooks); +# +# xml:Element x = xml `John`; +# x.setChildren("Jane"); # ``` # # + elem - xml element @@ -250,6 +260,7 @@ public isolated function getDescendants(Element elem) returns xml = @java:Method # xml book = xml `Ballerina`; # book.data() ⇒ Ballerina # ``` +# # + x - the xml value # + return - a string consisting of all the character data of parameter `x` public isolated function data(xml x) returns string = @java:Method { @@ -482,11 +493,11 @@ public isolated function 'map(xml x, @isolatedParam function(ItemType # Each item is represented as a singleton value. # # ```ballerina -# xml bookSet = xml `JavaBallerina`; +# xml bookSet = xml `JavaBallerina`; # xml bookTitles = xml ``; # # bookSet.forEach(function (xml xmlItem) { -# bookTitles += xmlItem.children(); +# bookTitles += xml `${xmlItem.data()}`; # }); # ``` # @@ -502,11 +513,10 @@ public isolated function forEach(xml x, @isolatedParam function(ItemTy # Each item is represented as a singleton value. # # ```ballerina -# xml codingBooks = xml `JSBallerina -# PythonPerl`; +# xml codingBooks = xml `BallerinaPython`; # # codingBooks.filter(function(xml xmlItem) returns boolean { -# if (xmlItem is xml:Element) { +# if xmlItem is xml:Element { # return (xmlItem).getName() == "code"; # } # @@ -529,7 +539,7 @@ public isolated function filter(xml x, @isolatedParam function(ItemTyp # XML 1.0 Recommendation. # # ```ballerina -# xml:fromString(bookStr) ⇒ BallerinaJava +# xml:fromString("BallerinaJava") ⇒ BallerinaJava # # xml:fromString("b") ⇒ error # ``` From 69128d3dd418a7a5070e58b83db61f160d768e37 Mon Sep 17 00:00:00 2001 From: sanjana Date: Tue, 20 Dec 2022 18:09:55 +0530 Subject: [PATCH 361/450] Update elements method example output in xml langlib --- langlib/lang.xml/src/main/ballerina/xml.bal | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/langlib/lang.xml/src/main/ballerina/xml.bal b/langlib/lang.xml/src/main/ballerina/xml.bal index e84acead41ea..6f3c350b1445 100644 --- a/langlib/lang.xml/src/main/ballerina/xml.bal +++ b/langlib/lang.xml/src/main/ballerina/xml.bal @@ -359,8 +359,7 @@ public isolated function createComment(string content) returns Comment = @java:M # The constructed sequence will be empty when the length of parameter `data` is zero. # # ```ballerina -# string textData = "Hello!"; -# xml:createText(textData) ⇒ Hello! +# xml:createText("Hello!") ⇒ Hello! # ``` # # + data - the character data of the Text item @@ -417,8 +416,7 @@ public isolated function strip(xml x) returns xml = @java:Method { # Python`; # codingBooks.elements() ⇒ BallerinaPython # -# // Get only the elements which has the given naame. -# xml programmingBooks = codingBooks.elements("programming"); +# codingBooks.elements("code") ⇒ BallerinaPython # ``` # # + x - the xml value From b825e34965538f5293ceb78164858908906b7524 Mon Sep 17 00:00:00 2001 From: gabilang Date: Tue, 20 Dec 2022 18:48:54 +0530 Subject: [PATCH 362/450] Add test case with variable name - result --- .../test/expressions/binaryoperations/AddOperationTest.java | 3 ++- .../test-src/expressions/binaryoperations/add-operation.bal | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/binaryoperations/AddOperationTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/binaryoperations/AddOperationTest.java index 4bb3897d40d4..6c9074ff7ffa 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/binaryoperations/AddOperationTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/binaryoperations/AddOperationTest.java @@ -158,7 +158,8 @@ public Object[] dataToTestAdditionWithTypes() { "testStringCharAddition", "testStringXmlSubtypesAddition", "testStringSubtypesAddition", - "testXmlSubtypesAddition" + "testXmlSubtypesAddition", + "testNullableIntAdd" }; } diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/expressions/binaryoperations/add-operation.bal b/tests/jballerina-unit-test/src/test/resources/test-src/expressions/binaryoperations/add-operation.bal index 0ffece3c5a3e..420fa99505bf 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/expressions/binaryoperations/add-operation.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/expressions/binaryoperations/add-operation.bal @@ -529,6 +529,12 @@ function bam() returns int { return 5; } +function testNullableIntAdd() { + int[] result = [1, 2]; + int? val = bar() + result[0]; + assertEquality(val, ()); +} + function assertEquality(any actual, any expected) { if actual is anydata && expected is anydata && actual == expected { return; From 57c2e044340a38b9a339ff102abd93730c3725d4 Mon Sep 17 00:00:00 2001 From: sanjana Date: Tue, 20 Dec 2022 19:23:41 +0530 Subject: [PATCH 363/450] Update rest param arg in int langlib examples --- langlib/lang.int/src/main/ballerina/int.bal | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/langlib/lang.int/src/main/ballerina/int.bal b/langlib/lang.int/src/main/ballerina/int.bal index f8e12064b61b..2fc3eaf4d34e 100644 --- a/langlib/lang.int/src/main/ballerina/int.bal +++ b/langlib/lang.int/src/main/ballerina/int.bal @@ -119,8 +119,8 @@ public isolated function sum(int... ns) returns int = @java:Method { # ```ballerina # int:max(50, 20, 30, 70, 65) ⇒ 70 # -# int[] scores = [52, 45, 95, 76]; -# int:max(37, ...scores) ⇒ 95 +# [int, int, int] scores = [52, 95, 76]; +# int:max(int:max(...scores)) ⇒ 95 # # int n = 18; # n.max(25, 30, 4, 15) ⇒ 30 @@ -139,8 +139,8 @@ public isolated function max(int n, int... ns) returns int = @java:Method { # ```ballerina # int:min(45, 25, 30, 75, 50) ⇒ 25 # -# int[] points = [21, 12, 48, 14]; -# int:min(50, ...points) ⇒ 12 +# [int, int, int, int] points = [21, 12, 48, 14]; +# int:min(...points) ⇒ 12 # # int m = 23; # m.min(12, 43, 7, 19) ⇒ 7 From c0902ce23eeeebb93e244d91a76214f80606fba7 Mon Sep 17 00:00:00 2001 From: mohan Date: Tue, 20 Dec 2022 20:49:15 +0530 Subject: [PATCH 364/450] Fix padStart default case example --- langlib/lang.string/src/main/ballerina/string.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index da5912efb585..9e1019988a7b 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -386,7 +386,7 @@ public isolated function fromCodePointInt(int codePoint) returns Char|error = @j # If the length of `str` is >= `len`, returns `str`. # # ```ballerina -# "100Km".padStart(10, "0") ⇒ 100Km +# "100Km".padStart(10) ⇒ 100Km # # "100Km".padStart(10, "0") ⇒ 00000100Km # ``` From bef81eacf094807ffddb1ce9a5eb594b4b1b8bee Mon Sep 17 00:00:00 2001 From: sanjana Date: Tue, 20 Dec 2022 20:55:36 +0530 Subject: [PATCH 365/450] Add negative int langlib examples --- langlib/lang.int/src/main/ballerina/int.bal | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/langlib/lang.int/src/main/ballerina/int.bal b/langlib/lang.int/src/main/ballerina/int.bal index 2fc3eaf4d34e..52567228c1d3 100644 --- a/langlib/lang.int/src/main/ballerina/int.bal +++ b/langlib/lang.int/src/main/ballerina/int.bal @@ -163,6 +163,8 @@ public isolated function min(int n, int... ns) returns int = @java:Method { # ```ballerina # int:fromString("76") ⇒ 76 # +# int:fromString("-120") ⇒ -120 +# # int:fromString("0xFFFF") ⇒ error # ``` # @@ -181,6 +183,8 @@ public isolated function fromString(string s) returns int|error = @java:Method { # # ```ballerina # 26.toHexString() ⇒ 1a +# +# int:toHexString(-158) ⇒ -9e # ``` # # + n - int value @@ -200,6 +204,8 @@ public isolated function toHexString(int n) returns string = @java:Method { # ```ballerina # int:fromHexString("1A5F") ⇒ 6751 # +# int:fromHexString("-2b4a") ⇒ -11082 +# # int:fromHexString("1Y4K") ⇒ error # ``` # From 6862fecf5da27731e9b72c12f9f7f66e09bce361 Mon Sep 17 00:00:00 2001 From: sanjana Date: Tue, 20 Dec 2022 21:02:49 +0530 Subject: [PATCH 366/450] Update failing test cases --- .../test/statements/foreach/ForeachErrorHandlingTests.java | 2 +- .../test-src/object/object_field_initializer_with_check.bal | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachErrorHandlingTests.java b/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachErrorHandlingTests.java index d57ea61bf111..e7ab1565f55d 100644 --- a/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachErrorHandlingTests.java +++ b/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachErrorHandlingTests.java @@ -53,7 +53,7 @@ public void testArrayForeachAndTrap() { @Test(expectedExceptions = BLangRuntimeException.class, expectedExceptionsMessageRegExp = "error: \\{ballerina/lang.int\\}NumberParsingError \\{\"message\":\"'string' value 'waruna' cannot be " + "converted to 'int'\"\\}\n" + - "\tat ballerina.lang.int.0:fromString\\(int.bal:171\\)\n" + + "\tat ballerina.lang.int.0:fromString\\(int.bal:173\\)\n" + "\t foreach_error_handling:\\$lambda\\$_0\\(foreach_error_handling.bal:41\\)") public void testArrayForeachAndPanic() { BRunUtil.invoke(program, "testArrayForeachAndPanic"); diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/object/object_field_initializer_with_check.bal b/tests/jballerina-unit-test/src/test/resources/test-src/object/object_field_initializer_with_check.bal index 4e57f86c6967..33b2de039e65 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/object/object_field_initializer_with_check.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/object/object_field_initializer_with_check.bal @@ -84,7 +84,7 @@ function testCheckInObjectFieldInitializer2() { assertEquality("'string' value 'invalid' cannot be converted to 'int'", checkpanic e.detail()["message"]); error:StackFrame[] callStack = e.stackTrace(); int callStackLength = callStack.length(); - assertEquality("callableName: fromString moduleName: ballerina.lang.int.0 fileName: int.bal lineNumber: 171", + assertEquality("callableName: fromString moduleName: ballerina.lang.int.0 fileName: int.bal lineNumber: 173", callStack[callStackLength - 2].toString()); } From f917214431f6acb99ccca8cf3fe1f684aaa682a5 Mon Sep 17 00:00:00 2001 From: gabilang Date: Tue, 20 Dec 2022 21:23:33 +0530 Subject: [PATCH 367/450] Fix unit test failure --- .../test-src/expressions/binaryoperations/add-operation.bal | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/expressions/binaryoperations/add-operation.bal b/tests/jballerina-unit-test/src/test/resources/test-src/expressions/binaryoperations/add-operation.bal index 420fa99505bf..0f74013bff79 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/expressions/binaryoperations/add-operation.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/expressions/binaryoperations/add-operation.bal @@ -531,10 +531,14 @@ function bam() returns int { function testNullableIntAdd() { int[] result = [1, 2]; - int? val = bar() + result[0]; + int? val = baz() + result[0]; assertEquality(val, ()); } +function baz() returns int? { + return (); +} + function assertEquality(any actual, any expected) { if actual is anydata && expected is anydata && actual == expected { return; From 0c0e021a6e4f631cf924cdff82704d3514345a25 Mon Sep 17 00:00:00 2001 From: sanjana Date: Tue, 20 Dec 2022 21:23:57 +0530 Subject: [PATCH 368/450] Update runtime langlibe examples --- .../src/main/ballerina/runtime.bal | 27 ++++++------------- .../resources/test-src/runtimelib_test.bal | 6 ++--- .../nativeimpl/functions/RuntimeTest.java | 4 +-- 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/langlib/lang.runtime/src/main/ballerina/runtime.bal b/langlib/lang.runtime/src/main/ballerina/runtime.bal index ffe6047165d5..60c93dc7e8b3 100644 --- a/langlib/lang.runtime/src/main/ballerina/runtime.bal +++ b/langlib/lang.runtime/src/main/ballerina/runtime.bal @@ -43,14 +43,9 @@ type CallStackElement record {| # # ```ballerina # runtime:DynamicListener ln = object { -# public function 'start() returns error? { -# } -# -# public function gracefulStop() returns error? { -# } -# -# public function immediateStop() returns error? { -# } +# public function 'start() returns error? {} +# public function gracefulStop() returns error? {} +# public function immediateStop() returns error? {} # }; # # runtime:registerListener(ln); @@ -68,14 +63,9 @@ public isolated function registerListener(DynamicListener 'listener) = @java:Met # # ```ballerina # runtime:DynamicListener ln = object { -# public function 'start() returns error? { -# } -# -# public function gracefulStop() returns error? { -# } -# -# public function immediateStop() returns error? { -# } +# public function 'start() returns error? {} +# public function gracefulStop() returns error? {} +# public function immediateStop() returns error? {} # }; # # runtime:deregisterListener(ln); @@ -111,7 +101,7 @@ public type StackFrame readonly & object { # Returns a stack trace for the current call stack. # # ```ballerina -# runtime:StackFrame[] stackTrace = runtime:getStackTrace(); +# runtime:getStackTrace(); # ``` # # The first member of the array represents the top of the call stack. @@ -143,8 +133,7 @@ public type StopHandler function() returns error?; # in reverse order of the corresponding calls to `onGracefulStop`. # # ```ballerina -# runtime:StopHandler stopHandler = function() returns error? => (); -# runtime:onGracefulStop(stopHandler); +# runtime:onGracefulStop(function() returns error? {}); # ``` # # + handler - function to be called diff --git a/langlib/langlib-test/src/test/resources/test-src/runtimelib_test.bal b/langlib/langlib-test/src/test/resources/test-src/runtimelib_test.bal index dcf23f88fe4b..e88878a4d84d 100644 --- a/langlib/langlib-test/src/test/resources/test-src/runtimelib_test.bal +++ b/langlib/langlib-test/src/test/resources/test-src/runtimelib_test.bal @@ -21,9 +21,9 @@ function getCallStacktoStringTest() { runtime:StackFrame[] stackFrames = runtime:getStackTrace(); assertEquality(stackFrames.length(), 3); assertEquality("callableName: externGetStackTrace moduleName: ballerina.lang.runtime.0 fileName: runtime.bal " + - "lineNumber: 92", stackFrames[0].toString()); + "lineNumber: 121", stackFrames[0].toString()); assertEquality("callableName: getStackTrace moduleName: ballerina.lang.runtime.0 fileName: runtime.bal " + - "lineNumber: 82", stackFrames[1].toString()); + "lineNumber: 111", stackFrames[1].toString()); assertEquality("callableName: getCallStacktoStringTest fileName: runtimelib_test.bal lineNumber: 21", stackFrames[2].toString()); @@ -36,7 +36,7 @@ function getCallStacktoStringTest() { assertEquality("getStackTrace", callableName); assertEquality("ballerina.lang.runtime.0", moduleName); assertEquality("runtime.bal", fileName); - assertEquality(82, lineNumber); + assertEquality(111, lineNumber); java:StackFrameImpl stackFrame2 = stackFrames[2]; callableName = stackFrame2.callableName; diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/nativeimpl/functions/RuntimeTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/nativeimpl/functions/RuntimeTest.java index e278a1ec60c2..a45e215e62ea 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/nativeimpl/functions/RuntimeTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/nativeimpl/functions/RuntimeTest.java @@ -54,9 +54,9 @@ public void testGetCallStack() { BArray returns = (BArray) val; Assert.assertEquals(returns.size(), 5); Assert.assertEquals(returns.get(0).toString(), "{callableName:externGetStackTrace, moduleName:ballerina.lang" + - ".runtime.0, fileName:runtime.bal, lineNumber:92}"); + ".runtime.0, fileName:runtime.bal, lineNumber:121}"); Assert.assertEquals(returns.get(1).toString(), "{callableName:getStackTrace, moduleName:ballerina.lang" + - ".runtime.0, fileName:runtime.bal, lineNumber:82}"); + ".runtime.0, fileName:runtime.bal, lineNumber:111}"); Assert.assertEquals(returns.get(2).toString(), "{callableName:level2Function, moduleName:null, " + "fileName:runtime-error.bal, lineNumber:12}"); Assert.assertEquals(returns.get(3).toString(), "{callableName:level1Function, moduleName:null, " + From c857d393985333776f00303de8af5ae5204fa32b Mon Sep 17 00:00:00 2001 From: sanjana Date: Tue, 20 Dec 2022 21:29:41 +0530 Subject: [PATCH 369/450] Reformat code in typedesc langlib examples --- langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal | 1 + 1 file changed, 1 insertion(+) diff --git a/langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal b/langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal index 7372abfc8154..9ed9973ede83 100644 --- a/langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal +++ b/langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal @@ -43,6 +43,7 @@ public type TypeId readonly & record {| # # ```ballerina # type Error distinct error; +# # type SampleError distinct (Error & error); # # typedesc:TypeId[] typeIds = SampleError.typeIds(); From 4a1451bb4a043d6e9718bd42e673022e78223dda Mon Sep 17 00:00:00 2001 From: sanjana Date: Tue, 20 Dec 2022 21:41:45 +0530 Subject: [PATCH 370/450] Add panic example in xml langlibs --- langlib/lang.xml/src/main/ballerina/xml.bal | 2 ++ 1 file changed, 2 insertions(+) diff --git a/langlib/lang.xml/src/main/ballerina/xml.bal b/langlib/lang.xml/src/main/ballerina/xml.bal index 6f3c350b1445..e775352da885 100644 --- a/langlib/lang.xml/src/main/ballerina/xml.bal +++ b/langlib/lang.xml/src/main/ballerina/xml.bal @@ -106,6 +106,8 @@ public isolated function iterator(xml x) returns object { # ```ballerina # xml books = xml `BallerinaJava`; # books.get(1) ⇒ Java +# +# books.get(15) ⇒ panic # ``` # # + x - the xml sequence From 8348db48185e6e41ea644ddbd2183124291e9dd2 Mon Sep 17 00:00:00 2001 From: sanjana Date: Tue, 20 Dec 2022 22:52:21 +0530 Subject: [PATCH 371/450] Add var assignment to runtime stacktrace langlib example --- langlib/lang.runtime/src/main/ballerina/runtime.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langlib/lang.runtime/src/main/ballerina/runtime.bal b/langlib/lang.runtime/src/main/ballerina/runtime.bal index 60c93dc7e8b3..8fb39c099199 100644 --- a/langlib/lang.runtime/src/main/ballerina/runtime.bal +++ b/langlib/lang.runtime/src/main/ballerina/runtime.bal @@ -101,7 +101,7 @@ public type StackFrame readonly & object { # Returns a stack trace for the current call stack. # # ```ballerina -# runtime:getStackTrace(); +# runtime:StackFrame[] stackTrace = runtime:getStackTrace(); # ``` # # The first member of the array represents the top of the call stack. From e000e12707071c8e1c69d09b5267ea313e0417fd Mon Sep 17 00:00:00 2001 From: malinthar Date: Wed, 21 Dec 2022 00:08:16 +0530 Subject: [PATCH 372/450] Fix test failure --- .../config/new_expr_ctx_config24.json | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config24.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config24.json index 7fde244e7f1e..1236ab9462e4 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config24.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config24.json @@ -560,7 +560,7 @@ "label": "decimal", "kind": "TypeParameter", "detail": "Decimal", - "sortText": "N", + "sortText": "R", "insertText": "decimal", "insertTextFormat": "Snippet" }, @@ -568,7 +568,7 @@ "label": "error", "kind": "Event", "detail": "Error", - "sortText": "L", + "sortText": "P", "insertText": "error", "insertTextFormat": "Snippet" }, @@ -576,7 +576,7 @@ "label": "xml", "kind": "TypeParameter", "detail": "Xml", - "sortText": "N", + "sortText": "R", "insertText": "xml", "insertTextFormat": "Snippet" }, @@ -584,7 +584,7 @@ "label": "boolean", "kind": "TypeParameter", "detail": "Boolean", - "sortText": "N", + "sortText": "R", "insertText": "boolean", "insertTextFormat": "Snippet" }, @@ -592,7 +592,7 @@ "label": "future", "kind": "TypeParameter", "detail": "Future", - "sortText": "N", + "sortText": "R", "insertText": "future", "insertTextFormat": "Snippet" }, @@ -600,7 +600,7 @@ "label": "int", "kind": "TypeParameter", "detail": "Int", - "sortText": "N", + "sortText": "R", "insertText": "int", "insertTextFormat": "Snippet" }, @@ -608,7 +608,7 @@ "label": "float", "kind": "TypeParameter", "detail": "Float", - "sortText": "N", + "sortText": "R", "insertText": "float", "insertTextFormat": "Snippet" }, @@ -616,7 +616,7 @@ "label": "function", "kind": "TypeParameter", "detail": "Function", - "sortText": "N", + "sortText": "R", "insertText": "function", "insertTextFormat": "Snippet" }, @@ -624,7 +624,7 @@ "label": "string", "kind": "TypeParameter", "detail": "String", - "sortText": "N", + "sortText": "R", "insertText": "string", "insertTextFormat": "Snippet" }, @@ -632,7 +632,7 @@ "label": "typedesc", "kind": "TypeParameter", "detail": "Typedesc", - "sortText": "N", + "sortText": "R", "insertText": "typedesc", "insertTextFormat": "Snippet" }, @@ -640,7 +640,7 @@ "label": "readonly", "kind": "TypeParameter", "detail": "Readonly", - "sortText": "N", + "sortText": "R", "insertText": "readonly", "insertTextFormat": "Snippet" }, @@ -648,7 +648,7 @@ "label": "handle", "kind": "TypeParameter", "detail": "Handle", - "sortText": "N", + "sortText": "R", "insertText": "handle", "insertTextFormat": "Snippet" }, @@ -656,7 +656,7 @@ "label": "never", "kind": "TypeParameter", "detail": "Never", - "sortText": "N", + "sortText": "R", "insertText": "never", "insertTextFormat": "Snippet" }, @@ -664,7 +664,7 @@ "label": "json", "kind": "TypeParameter", "detail": "Json", - "sortText": "N", + "sortText": "R", "insertText": "json", "insertTextFormat": "Snippet" }, @@ -672,7 +672,7 @@ "label": "anydata", "kind": "TypeParameter", "detail": "Anydata", - "sortText": "N", + "sortText": "R", "insertText": "anydata", "insertTextFormat": "Snippet" }, @@ -680,7 +680,7 @@ "label": "any", "kind": "TypeParameter", "detail": "Any", - "sortText": "N", + "sortText": "R", "insertText": "any", "insertTextFormat": "Snippet" }, @@ -688,7 +688,7 @@ "label": "byte", "kind": "TypeParameter", "detail": "Byte", - "sortText": "N", + "sortText": "R", "insertText": "byte", "insertTextFormat": "Snippet" } From ab0b69415bc3ca950e69b4311b92e16398b4beb8 Mon Sep 17 00:00:00 2001 From: Sasindu Alahakoon Date: Fri, 2 Dec 2022 11:12:29 +0530 Subject: [PATCH 373/450] Add langlib examples for decimal --- .../src/main/ballerina/decimal.bal | 94 ++++++++++++++++++- 1 file changed, 92 insertions(+), 2 deletions(-) diff --git a/langlib/lang.decimal/src/main/ballerina/decimal.bal b/langlib/lang.decimal/src/main/ballerina/decimal.bal index d1aa4fab9665..e4d95b566800 100644 --- a/langlib/lang.decimal/src/main/ballerina/decimal.bal +++ b/langlib/lang.decimal/src/main/ballerina/decimal.bal @@ -18,6 +18,19 @@ import ballerina/jballerina.java; # Returns the sum of zero or more decimal values. # +# ```ballerina +# decimal:sum(1.2, 2.3, 3.4) ⇒ 6.9 +# +# decimal[] scores = [11.1, 22.2, 33.3]; +# decimal:sum(...scores) ⇒ 66.6 +# +# [decimal, decimal, decimal] marks = [7.21, 10.32, 9.2]; +# decimal:sum(...marks) ⇒ 26.73 +# +# decimal d = 21.2; +# d.sum(10.5, 21, 32.4) ⇒ 85.1 +# ``` +# # + xs - decimal values to sum # + return - sum of all the parameter `xs`; 0 if parameter `xs` is empty public isolated function sum(decimal... xs) returns decimal = @java:Method { @@ -27,6 +40,19 @@ public isolated function sum(decimal... xs) returns decimal = @java:Method { # Returns the maximum of one or more decimal values. # +# ```ballerina +# decimal:max(1.2, 12.3, 3.4) ⇒ 12.3 +# +# decimal[] marks = [70.3, 80.5, 98.1, 92.3]; +# decimal:max(30.5, ...marks) ⇒ 98.1 +# +# [decimal, decimal, decimal] scores = [7.21, 10.32, 9.2]; +# decimal:max(2.34, ...scores) ⇒ 10.32 +# +# decimal d = 21.2; +# d.max(40.5, 21, 32.4) ⇒ 40.5 +#``` +# # + x - first decimal value # + xs - other decimal values # + return - maximum value of parameter `x` and all the parameter `xs` @@ -37,6 +63,19 @@ public isolated function max(decimal x, decimal... xs) returns decimal = @java:M # Returns the minimum of one or more decimal values. # +# ```ballerina +# decimal:min(5.2, 2.3, 3.4) ⇒ 2.3 +# +# decimal[] marks = [90.3, 80.5, 98, 92.3]; +# decimal:min(82.1, ...marks) ⇒ 80.5 +# +# [decimal, decimal, decimal] scores = [7.21, 10.32, 9.2]; +# decimal:min(12.34, ...scores) ⇒ 7.21 +# +# decimal d = 1.2; +# d.min(10.5, 21, 32.4) ⇒ 1.2 +#``` +# # + x - first decimal value # + xs - other decimal values # + return - minimum value of parameter `x` and all the parameter `xs`. @@ -47,6 +86,11 @@ public isolated function min(decimal x, decimal... xs) returns decimal = @java:M # Returns the IEEE absolute value of a decimal value. # +# ```ballerina +# decimal d = -3.21; +# d.abs() ⇒ 3.21 +# ``` +# # + x - decimal value to operate on # + return - absolute value of parameter `x` public isolated function abs(decimal x) returns decimal = @java:Method { @@ -66,6 +110,20 @@ public isolated function abs(decimal x) returns decimal = @java:Method { # roundToIntegralTiesToEven will return a value with a positive exponent when the operand has a positive exponent. # Note that `x` is the same as `x.round(0)`. # +# ```ballerina +# decimal d = 3.55; +# d.round() ⇒ 4 +# +# decimal e = 4.55555; +# e.round(3) ⇒ 4.556 +# +# decimal g = 2.5; +# g.round(0) ⇒ 2 +# +# decimal h = 3.5; +# h.round(0) ⇒ 4 +# ``` +# # + x - decimal value to operate on # + fractionDigits - the number of digits after the decimal point # + return - closest decimal value to `x` that is an integral multiple of 10 raised to the power of `-fractionDigits` @@ -74,8 +132,22 @@ public isolated function round(decimal x, int fractionDigits = 0) returns decima name: "round" } external; -# IEEE quantize operation. - +# Return a decimal with a specified value and exponent. +# Return a decimal value that has the same value (except for rounding) as the first +# argument, and the same exponent as the second argument. +# This is the IEEE quantize operation. +# +# ```ballerina +# decimal d = 4.1626; +# d.quantize(3.512) ⇒ 4.163 +# +# decimal:quantize(4.1626, 3.512) ⇒ 4.163 +# +# decimal:quantize(4.1624, 3.512) ⇒ 4.162 +# +# decimal:quantize(4.1624, 3.51) ⇒ 4.16 +# ``` +# # + x - decimal value to operate on # + y - decimal value from which to get the quantum # + return - `x` with the quantum of `y` @@ -86,6 +158,11 @@ public isolated function quantize(decimal x, decimal y) returns decimal = @java: # Rounds a decimal down to the closest integral value. # +# ```ballerina +# decimal d = 3.51; +# d.floor() ⇒ 3 +# ``` +# # + x - decimal value to operate on # + return - largest (closest to +∞) decimal value not greater than parameter `x` that is a mathematical integer. public isolated function floor(decimal x) returns decimal = @java:Method { @@ -95,6 +172,11 @@ public isolated function floor(decimal x) returns decimal = @java:Method { # Rounds a decimal up to the closest integral value. # +# ```ballerina +# decimal d = 3.51; +# d.ceiling() ⇒ 4 +# ``` +# # + x - decimal value to operate on # + return - smallest (closest to -∞) decimal value not less than parameter `x` that is a mathematical integer public isolated function ceiling(decimal x) returns decimal = @java:Method { @@ -110,6 +192,14 @@ public isolated function ceiling(decimal x) returns decimal = @java:Method { # - a FloatingPointTypeSuffix is not allowed # This is the inverse of function ``value:toString`` applied to an `decimal`. # +# ```ballerina +# decimal:fromString("0.2453") ⇒ 0.2453 +# +# decimal:fromString("-10") ⇒ -10 +# +# decimal:fromString("123d") ⇒ error +# ``` +# # + s - string representation of a decimal # + return - decimal representation of the argument or error public isolated function fromString(string s) returns decimal|error = @java:Method { From 015f68edf3c173d04f494b82ab8c01e964211d74 Mon Sep 17 00:00:00 2001 From: sanjana Date: Wed, 21 Dec 2022 09:34:03 +0530 Subject: [PATCH 374/450] Reformat code in int langlib examples --- langlib/lang.int/src/main/ballerina/int.bal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/langlib/lang.int/src/main/ballerina/int.bal b/langlib/lang.int/src/main/ballerina/int.bal index 52567228c1d3..7bd92006dce9 100644 --- a/langlib/lang.int/src/main/ballerina/int.bal +++ b/langlib/lang.int/src/main/ballerina/int.bal @@ -101,7 +101,7 @@ public isolated function abs(int n) returns int = @java:Method { # int:sum(10, 20, 30, 40) ⇒ 100 # # int[] marks = [50, 65, 78, 95]; -# int total = int:sum(...marks) ⇒ 288 +# int:sum(...marks) ⇒ 288 # # int num = 24; # num.sum(38, 15, 97, 27) ⇒ 201 @@ -120,7 +120,7 @@ public isolated function sum(int... ns) returns int = @java:Method { # int:max(50, 20, 30, 70, 65) ⇒ 70 # # [int, int, int] scores = [52, 95, 76]; -# int:max(int:max(...scores)) ⇒ 95 +# int:max(...scores) ⇒ 95 # # int n = 18; # n.max(25, 30, 4, 15) ⇒ 30 From 5979367149a40ed3252a55c1b0cef828b78c1ee5 Mon Sep 17 00:00:00 2001 From: malinthar Date: Wed, 21 Dec 2022 00:08:16 +0530 Subject: [PATCH 375/450] Fix test failure --- .../config/new_expr_ctx_config24.json | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config24.json b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config24.json index 7fde244e7f1e..1236ab9462e4 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config24.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/expression_context/config/new_expr_ctx_config24.json @@ -560,7 +560,7 @@ "label": "decimal", "kind": "TypeParameter", "detail": "Decimal", - "sortText": "N", + "sortText": "R", "insertText": "decimal", "insertTextFormat": "Snippet" }, @@ -568,7 +568,7 @@ "label": "error", "kind": "Event", "detail": "Error", - "sortText": "L", + "sortText": "P", "insertText": "error", "insertTextFormat": "Snippet" }, @@ -576,7 +576,7 @@ "label": "xml", "kind": "TypeParameter", "detail": "Xml", - "sortText": "N", + "sortText": "R", "insertText": "xml", "insertTextFormat": "Snippet" }, @@ -584,7 +584,7 @@ "label": "boolean", "kind": "TypeParameter", "detail": "Boolean", - "sortText": "N", + "sortText": "R", "insertText": "boolean", "insertTextFormat": "Snippet" }, @@ -592,7 +592,7 @@ "label": "future", "kind": "TypeParameter", "detail": "Future", - "sortText": "N", + "sortText": "R", "insertText": "future", "insertTextFormat": "Snippet" }, @@ -600,7 +600,7 @@ "label": "int", "kind": "TypeParameter", "detail": "Int", - "sortText": "N", + "sortText": "R", "insertText": "int", "insertTextFormat": "Snippet" }, @@ -608,7 +608,7 @@ "label": "float", "kind": "TypeParameter", "detail": "Float", - "sortText": "N", + "sortText": "R", "insertText": "float", "insertTextFormat": "Snippet" }, @@ -616,7 +616,7 @@ "label": "function", "kind": "TypeParameter", "detail": "Function", - "sortText": "N", + "sortText": "R", "insertText": "function", "insertTextFormat": "Snippet" }, @@ -624,7 +624,7 @@ "label": "string", "kind": "TypeParameter", "detail": "String", - "sortText": "N", + "sortText": "R", "insertText": "string", "insertTextFormat": "Snippet" }, @@ -632,7 +632,7 @@ "label": "typedesc", "kind": "TypeParameter", "detail": "Typedesc", - "sortText": "N", + "sortText": "R", "insertText": "typedesc", "insertTextFormat": "Snippet" }, @@ -640,7 +640,7 @@ "label": "readonly", "kind": "TypeParameter", "detail": "Readonly", - "sortText": "N", + "sortText": "R", "insertText": "readonly", "insertTextFormat": "Snippet" }, @@ -648,7 +648,7 @@ "label": "handle", "kind": "TypeParameter", "detail": "Handle", - "sortText": "N", + "sortText": "R", "insertText": "handle", "insertTextFormat": "Snippet" }, @@ -656,7 +656,7 @@ "label": "never", "kind": "TypeParameter", "detail": "Never", - "sortText": "N", + "sortText": "R", "insertText": "never", "insertTextFormat": "Snippet" }, @@ -664,7 +664,7 @@ "label": "json", "kind": "TypeParameter", "detail": "Json", - "sortText": "N", + "sortText": "R", "insertText": "json", "insertTextFormat": "Snippet" }, @@ -672,7 +672,7 @@ "label": "anydata", "kind": "TypeParameter", "detail": "Anydata", - "sortText": "N", + "sortText": "R", "insertText": "anydata", "insertTextFormat": "Snippet" }, @@ -680,7 +680,7 @@ "label": "any", "kind": "TypeParameter", "detail": "Any", - "sortText": "N", + "sortText": "R", "insertText": "any", "insertTextFormat": "Snippet" }, @@ -688,7 +688,7 @@ "label": "byte", "kind": "TypeParameter", "detail": "Byte", - "sortText": "N", + "sortText": "R", "insertText": "byte", "insertTextFormat": "Snippet" } From 718d9ead09f2601ddf72c1235487ea31793b81a1 Mon Sep 17 00:00:00 2001 From: Thevakumar-Luheerathan Date: Wed, 21 Dec 2022 09:59:09 +0530 Subject: [PATCH 376/450] Address the review --- .../io/ballerina/cli/task/RunNativeImageTestTask.java | 5 ++--- .../io/ballerina/cli/cmd/TestNativeImageCommandTest.java | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java index 632ce61b94bd..78c325960185 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java @@ -402,10 +402,9 @@ private void validateResourcesWithinJar(Map testSuiteMap, Str } jarInputStream.closeEntry(); } - jarInputStream.close(); if (isResourceExist) { - throw createLauncherException("unable to generate native image. this single file project has " + - "resource folder inside"); + throw createLauncherException("native image testing is not supported for standalone " + + "Ballerina files containing resources"); } } } diff --git a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestNativeImageCommandTest.java b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestNativeImageCommandTest.java index 27291e389f5b..8d08e2d136bf 100644 --- a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestNativeImageCommandTest.java +++ b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/TestNativeImageCommandTest.java @@ -72,8 +72,8 @@ public void testTestBalFile() throws IOException { try { testCommand.execute(); } catch (BLauncherException e) { - Assert.assertTrue(e.getDetailedMessages().get(0).contains("unable to generate native image. this " + - "single file project has resource folder inside")); + Assert.assertTrue(e.getDetailedMessages().get(0).contains("native image testing is not supported for " + + "standalone Ballerina files containing resources")); } } @@ -88,8 +88,8 @@ public void testTestBalFileWithPeriods() throws IOException { try { testCommand.execute(); } catch (BLauncherException e) { - Assert.assertTrue(e.getDetailedMessages().get(0).contains("unable to generate native image. this " + - "single file project has resource folder inside")); + Assert.assertTrue(e.getDetailedMessages().get(0).contains("native image testing is not supported for " + + "standalone Ballerina files containing resources")); } } } From 319b7b59d5503957e8b68eb82c3255c232daa29d Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 21 Dec 2022 10:02:57 +0530 Subject: [PATCH 377/450] Update stream close example --- langlib/lang.stream/src/main/ballerina/stream.bal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/langlib/lang.stream/src/main/ballerina/stream.bal b/langlib/lang.stream/src/main/ballerina/stream.bal index b5b8dab75ca1..e14fd4a57d55 100644 --- a/langlib/lang.stream/src/main/ballerina/stream.bal +++ b/langlib/lang.stream/src/main/ballerina/stream.bal @@ -190,8 +190,8 @@ public isolated function iterator(stream stm) returns objec # Closing a stream that has already been closed has no effect and returns `()`. # # ```ballerina -# stream scores = [45, 60, 75, 30, 90].toStream(); -# _ = scores.close(); +# stream strm = new; +# _ = check strm.close(); # ``` # # + stm - the stream to close From 4d600883305ff3cb7df7047599cab478f5390859 Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 21 Dec 2022 10:08:24 +0530 Subject: [PATCH 378/450] Update stream close example --- langlib/lang.stream/src/main/ballerina/stream.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langlib/lang.stream/src/main/ballerina/stream.bal b/langlib/lang.stream/src/main/ballerina/stream.bal index e14fd4a57d55..ac63127b1770 100644 --- a/langlib/lang.stream/src/main/ballerina/stream.bal +++ b/langlib/lang.stream/src/main/ballerina/stream.bal @@ -191,7 +191,7 @@ public isolated function iterator(stream stm) returns objec # # ```ballerina # stream strm = new; -# _ = check strm.close(); +# check strm.close(); # ``` # # + stm - the stream to close From 2055172faf6e306386132bad3b1e0eac878ef5f4 Mon Sep 17 00:00:00 2001 From: Mohanadarshan V Date: Wed, 21 Dec 2022 10:14:00 +0530 Subject: [PATCH 379/450] Update langlib/lang.string/src/main/ballerina/string.bal Co-authored-by: Maryam Ziyad --- langlib/lang.string/src/main/ballerina/string.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index 9e1019988a7b..296dad7b1192 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -59,7 +59,7 @@ public isolated function iterator(string str) returns object { # ```ballerina # "http://worldtimeapi.org".concat("/api/timezone/", "Asia", "/", "Colombo") ⇒ http://worldtimeapi.org/api/timezone/Asia/Colombo # -# // Alternative approach to achieve the same as above. +# // Alternative approach to achieve the same. # string:concat("http://worldtimeapi.org", "/api/timezone/", "Asia", "/", "Colombo") ⇒ http://worldtimeapi.org/api/timezone/Asia/Colombo # ``` # From a96be06e13e48b8e49339b6f5a00a9757787257e Mon Sep 17 00:00:00 2001 From: Sasindu Alahakoon Date: Wed, 21 Dec 2022 10:15:34 +0530 Subject: [PATCH 380/450] Update apidoc examples in decimal langlib --- langlib/lang.decimal/src/main/ballerina/decimal.bal | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/langlib/lang.decimal/src/main/ballerina/decimal.bal b/langlib/lang.decimal/src/main/ballerina/decimal.bal index e4d95b566800..e922425e9e61 100644 --- a/langlib/lang.decimal/src/main/ballerina/decimal.bal +++ b/langlib/lang.decimal/src/main/ballerina/decimal.bal @@ -47,7 +47,7 @@ public isolated function sum(decimal... xs) returns decimal = @java:Method { # decimal:max(30.5, ...marks) ⇒ 98.1 # # [decimal, decimal, decimal] scores = [7.21, 10.32, 9.2]; -# decimal:max(2.34, ...scores) ⇒ 10.32 +# decimal:max(...scores) ⇒ 10.32 # # decimal d = 21.2; # d.max(40.5, 21, 32.4) ⇒ 40.5 @@ -70,7 +70,7 @@ public isolated function max(decimal x, decimal... xs) returns decimal = @java:M # decimal:min(82.1, ...marks) ⇒ 80.5 # # [decimal, decimal, decimal] scores = [7.21, 10.32, 9.2]; -# decimal:min(12.34, ...scores) ⇒ 7.21 +# decimal:min(...scores) ⇒ 7.21 # # decimal d = 1.2; # d.min(10.5, 21, 32.4) ⇒ 1.2 @@ -122,6 +122,9 @@ public isolated function abs(decimal x) returns decimal = @java:Method { # # decimal h = 3.5; # h.round(0) ⇒ 4 +# +# decimal e = 4345.55; +# e.round(-3) ⇒ 4E+3 # ``` # # + x - decimal value to operate on @@ -143,8 +146,6 @@ public isolated function round(decimal x, int fractionDigits = 0) returns decima # # decimal:quantize(4.1626, 3.512) ⇒ 4.163 # -# decimal:quantize(4.1624, 3.512) ⇒ 4.162 -# # decimal:quantize(4.1624, 3.51) ⇒ 4.16 # ``` # From 8bceaabd7a1a2202d2929fee34d1e15e2f2b9b18 Mon Sep 17 00:00:00 2001 From: sanjana Date: Wed, 21 Dec 2022 12:03:31 +0530 Subject: [PATCH 381/450] Address review suggestions in xml langlib examples --- langlib/lang.xml/src/main/ballerina/xml.bal | 102 +++++++++----------- 1 file changed, 48 insertions(+), 54 deletions(-) diff --git a/langlib/lang.xml/src/main/ballerina/xml.bal b/langlib/lang.xml/src/main/ballerina/xml.bal index e775352da885..8cfd6fe00518 100644 --- a/langlib/lang.xml/src/main/ballerina/xml.bal +++ b/langlib/lang.xml/src/main/ballerina/xml.bal @@ -54,8 +54,10 @@ public type Text xml; # Returns number of xml items in an xml value. # # ```ballerina -# xml books = xml `BallerinaJava`; -# books.length() ⇒ 2 +# xml `BallerinaJava`.length() ⇒ 2 +# +# xml `John20 +# adminteacher`.length() ⇒ 3 # ``` # # + x - xml item @@ -82,10 +84,9 @@ type XmlType xml; # # Each item is represented by an xml singleton. # # ```ballerina -# xml books = xml `BallerinaJava`; # object { -# public isolated function next() returns record {|xml value;|}?; -# } iterator = books.iterator(); +# public isolated function next() returns record {|xml value;|}?; +# } iterator = xml `BallerinaJava`.iterator(); # iterator.next() ⇒ {"value":`Ballerina`} # ``` # @@ -123,17 +124,16 @@ public isolated function get(xml x, int i) returns ItemType = @java:Me # ```ballerina # xml bookA = xml `Ballerina`; # xml bookB = xml `Java`; -# xml bookC = xml `Python`; -# xml:concat(bookA, bookB, bookC) ⇒ BallerinaJavaPython +# xml:concat(bookA, bookB, xml `Python`) ⇒ BallerinaJavaPython # # bookA.concat(bookB) ⇒ BallerinaJava # -# bookC.concat("Coding") ⇒ PythonCoding +# bookB.concat("Coding") ⇒ JavaCoding # # xml:concat("Hello", "World") ⇒ HelloWorld # -# xml[] subjectList = [xml `English`, xml `Math`, xml `ICT`]; -# xml:concat(...subjectList) ⇒ EnglishMathICT +# xml[] subjects = [xml `English`, xml `Math`, xml `ICT`]; +# xml:concat(...subjects) ⇒ EnglishMathICT # ``` # # + xs - xml or string items to concatenate @@ -163,6 +163,7 @@ public isolated function getName(Element elem) returns string = @java:Method { # ```ballerina # xml:Element s = xml `John`; # s.setName("student"); +# s ⇒ John # ``` # # + elem - xml element @@ -178,8 +179,8 @@ public isolated function setName(Element elem, string xName) = @java:Method { # The keys in the map are the expanded names of the attributes. # # ```ballerina -# xml:Element a = xml ``; -# a.getAttributes() ⇒ {"name":"John","age":"30"} +# xml:Element a = xml `John`; +# a.getAttributes() ⇒ {"gender":"male","isEmployed":"yes"} # ``` # # + x - xml element @@ -192,8 +193,8 @@ public isolated function getAttributes(Element x) returns map = @java:Me # Returns the children of an xml element. # # ```ballerina -# xml:Element bookSet = xml `BallerinaJava`; -# bookSet.getChildren() ⇒ BallerinaJava +# xml:Element books = xml `BallerinaJava`; +# books.getChildren() ⇒ BallerinaJava # ``` # # + elem - xml element @@ -209,12 +210,14 @@ public isolated function getChildren(Element elem) returns xml = @java:Method { # becoming cyclic. # # ```ballerina -# xml:Element bookSet = xml `BallerinaJava`; -# xml webDevBooks = xml `HTMLJavascript`; -# bookSet.setChildren(webDevBooks); +# xml:Element books = xml `BallerinaJava`; +# xml js = xml `HTMLJavascript`; +# books.setChildren(js); +# books ⇒ HTMLJavascript # # xml:Element x = xml `John`; # x.setChildren("Jane"); +# x ⇒ Jane # ``` # # + elem - xml element @@ -273,8 +276,8 @@ public isolated function data(xml x) returns string = @java:Method { # Returns the target part of the processing instruction. # # ```ballerina -# xml:ProcessingInstruction p = xml ``; -# p.getTarget() ⇒ person +# xml:ProcessingInstruction p = xml ``; +# p.getTarget() ⇒ website # ``` # # + x - xml processing instruction item @@ -287,8 +290,8 @@ public isolated function getTarget(ProcessingInstruction x) returns string = @ja # Returns the content of a processing instruction or comment item. # # ```ballerina -# xml:ProcessingInstruction person = xml ``; -# person.getContent() ⇒ name +# xml:ProcessingInstruction p = xml ``; +# person.getContent() ⇒ ballerina.io # # xml:Comment comment = xml ``; # comment.getContent() ⇒ Example comment @@ -304,10 +307,11 @@ public isolated function getContent(ProcessingInstruction|Comment x) returns str # Creates a new xml element item. # # ```ballerina -# string name = "book"; -# map attributes = {title: "Ballerina", author: "Anjana"}; -# xml contents = xml `2022`; -# xml:createElement(name, attributes, contents) ⇒ 2022 +# xml:createElement( +# "book", +# {title: "Ballerina", author: "Anjana"}, +# xml `2022` +# ) ⇒ 2022 # ``` # # + name - the name of the new element @@ -327,9 +331,7 @@ public isolated function createElement(string name, map attributes = {}, # Creates a new xml processing instruction item. # # ```ballerina -# string target = "url"; -# string content = "example.com"; -# xml:createProcessingInstruction(target, content) ⇒ +# xml:createProcessingInstruction("url", "ballerina.io") ⇒ # ``` # # + target - the target part of the processing instruction to be constructed @@ -345,8 +347,7 @@ public isolated function createProcessingInstruction(string target, string conte # Creates a new xml comment item. # # ```ballerina -# string commentContent = "Example comment"; -# xml:createComment(commentContent) ⇒ +# xml:createComment("Example comment") ⇒ # ``` # # + content - the content of the comment to be constructed. @@ -396,9 +397,9 @@ public isolated function slice(xml x, int startIndex, int endIndex = x # and a chunk is considered insignificant if the entire chunk is whitespace. # # ```ballerina -# xml bookDetails = xml ` +# xml books = xml ` # Learning Ballerina`; -# bookDetails.strip() ⇒ Learning Ballerina +# books.strip() ⇒ Learning Ballerina # ``` # # + x - the xml value @@ -414,11 +415,11 @@ public isolated function strip(xml x) returns xml = @java:Method { # otherwise, selects only elements whose expanded name is parameter `nm`. # # ```ballerina -# xml codingBooks = xml `Ballerina +# xml books = xml `Ballerina # Python`; -# codingBooks.elements() ⇒ BallerinaPython +# books.elements() ⇒ BallerinaPython # -# codingBooks.elements("code") ⇒ BallerinaPython +# books.elements("code") ⇒ BallerinaPython # ``` # # + x - the xml value @@ -436,8 +437,8 @@ public isolated function elements(xml x, string? nm = ()) returns xml = # This is equivalent to `elements(x).map(getChildren)`. # # ```ballerina -# xml bookSet = xml `JavaBallerina`; -# bookSet.children() ⇒ JavaBallerina +# xml books = xml `JavaBallerina`; +# books.children() ⇒ JavaBallerina # ``` # # + x - xml value @@ -452,8 +453,8 @@ public isolated function children(xml x) returns xml = @java:Method { # This is equivalent to `children(x).elements(nm)`. # # ```ballerina -# xml bookSet = xml `JavaBallerina`; -# bookSet.elementChildren("title") ⇒ JavaBallerina +# xml books = xml `JavaBallerina`; +# books.elementChildren("title") ⇒ JavaBallerina # ``` # # + x - the xml value @@ -473,8 +474,8 @@ public isolated function elementChildren(xml x, string? nm = ()) returns xmlJavaBallerina`; -# bookSet.'map(function (xml xmlContent) returns xml { +# xml books = xml `JavaBallerina`; +# books.'map(function (xml xmlContent) returns xml { # return xml `${xmlContent.children()}`; # }) ⇒ JavaBallerina # ``` @@ -493,11 +494,11 @@ public isolated function 'map(xml x, @isolatedParam function(ItemType # Each item is represented as a singleton value. # # ```ballerina -# xml bookSet = xml `JavaBallerina`; -# xml bookTitles = xml ``; +# xml books = xml `JavaBallerina`; +# xml titles = xml ``; # -# bookSet.forEach(function (xml xmlItem) { -# bookTitles += xml `${xmlItem.data()}`; +# books.forEach(function (xml xmlItem) { +# titles += xml `${xmlItem.data()}`; # }); # ``` # @@ -513,15 +514,8 @@ public isolated function forEach(xml x, @isolatedParam function(ItemTy # Each item is represented as a singleton value. # # ```ballerina -# xml codingBooks = xml `BallerinaPython`; -# -# codingBooks.filter(function(xml xmlItem) returns boolean { -# if xmlItem is xml:Element { -# return (xmlItem).getName() == "code"; -# } -# -# return false; -# }) ⇒ BallerinaPython +# xml books = xml `BallerinaPython`; +# books.filter(x => x is xml:Element && x.getName() == "code") ⇒ BallerinaPython # ``` # # + x - xml value From f6d19753b38bfbd2f54f138f2a89db6829cb92a2 Mon Sep 17 00:00:00 2001 From: Fathima Dilhasha Date: Wed, 21 Dec 2022 12:08:20 +0530 Subject: [PATCH 382/450] Clear caches after the Ballerina toml update to get diagnostics --- .../langserver/workspace/BallerinaWorkspaceManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/workspace/BallerinaWorkspaceManager.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/workspace/BallerinaWorkspaceManager.java index 9b4bb328cda9..40a3d49dee55 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/workspace/BallerinaWorkspaceManager.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/workspace/BallerinaWorkspaceManager.java @@ -875,6 +875,7 @@ private void updateBallerinaToml(String content, ProjectPair projectPair, boolea } // Update toml BallerinaToml updatedToml = ballerinaToml.get().modify().withContent(content).apply(); + updatedToml.packageInstance().project().clearCaches(); // Update project instance projectPair.setProject(updatedToml.packageInstance().project()); } finally { From 4c4bf89c9e317d630fa8ba6c6fc900b31f62d454 Mon Sep 17 00:00:00 2001 From: sanjana Date: Wed, 21 Dec 2022 14:54:58 +0530 Subject: [PATCH 383/450] Add output of forEach in xml langlib examples --- langlib/lang.xml/src/main/ballerina/xml.bal | 2 ++ 1 file changed, 2 insertions(+) diff --git a/langlib/lang.xml/src/main/ballerina/xml.bal b/langlib/lang.xml/src/main/ballerina/xml.bal index 8cfd6fe00518..2c3f0a069a76 100644 --- a/langlib/lang.xml/src/main/ballerina/xml.bal +++ b/langlib/lang.xml/src/main/ballerina/xml.bal @@ -500,6 +500,8 @@ public isolated function 'map(xml x, @isolatedParam function(ItemType # books.forEach(function (xml xmlItem) { # titles += xml `${xmlItem.data()}`; # }); +# +# titles ⇒ JavaBallerina # ``` # # + x - the xml value From bf66c784ca8075b5196c58e6602ff8c7f7af7129 Mon Sep 17 00:00:00 2001 From: Thevakumar-Luheerathan Date: Wed, 21 Dec 2022 15:33:46 +0530 Subject: [PATCH 384/450] Address the review --- .../cli/task/RunNativeImageTestTask.java | 161 ++---------------- .../cli/utils/MethodCallReplaceVisitor.java | 67 -------- .../io/ballerina/cli/utils/NativeUtils.java | 19 ++- .../utils/OrigMockFunctionReplaceVisitor.java | 130 -------------- .../TesterinaCompilerPluginUtils.java | 8 +- .../exceptions/CacheGenException.java | 11 -- .../test/runtime/util/TesterinaConstants.java | 1 + 7 files changed, 30 insertions(+), 367 deletions(-) delete mode 100644 cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/MethodCallReplaceVisitor.java delete mode 100644 cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/OrigMockFunctionReplaceVisitor.java delete mode 100644 misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/exceptions/CacheGenException.java diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java index 57ffa5bc6d5f..f482b445d772 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java @@ -19,15 +19,12 @@ package io.ballerina.cli.task; import io.ballerina.cli.utils.BuildTime; -import io.ballerina.cli.utils.MethodCallReplaceVisitor; import io.ballerina.cli.utils.TestUtils; import io.ballerina.projects.JBallerinaBackend; -import io.ballerina.projects.JarLibrary; import io.ballerina.projects.JarResolver; import io.ballerina.projects.JvmTarget; import io.ballerina.projects.Module; import io.ballerina.projects.ModuleDescriptor; -import io.ballerina.projects.ModuleId; import io.ballerina.projects.ModuleName; import io.ballerina.projects.Package; import io.ballerina.projects.PackageCompilation; @@ -87,6 +84,7 @@ import static org.ballerinalang.test.runtime.util.TesterinaConstants.CACHE_DIR; import static org.ballerinalang.test.runtime.util.TesterinaConstants.CLASS_EXTENSION; import static org.ballerinalang.test.runtime.util.TesterinaConstants.DOT; +import static org.ballerinalang.test.runtime.util.TesterinaConstants.DOT_REPLACER; import static org.ballerinalang.test.runtime.util.TesterinaConstants.HYPHEN; import static org.ballerinalang.test.runtime.util.TesterinaConstants.JAR_EXTENSION; import static org.ballerinalang.test.runtime.util.TesterinaConstants.JAVA_11_DIR; @@ -108,15 +106,12 @@ public class RunNativeImageTestTask implements Task { private final PrintStream out; private final PrintStream err; - private final String includesInCoverage; private String groupList; private String disableGroupList; private boolean report; private boolean coverage; - private String coverageReportFormat; private boolean isRerunTestExecution; private String singleExecTests; - private Map coverageModules; private boolean listGroups; TestReport testReport; @@ -137,14 +132,11 @@ public RunNativeImageTestTask(PrintStream out, PrintStream err, boolean rerunTes if (testList != null) { singleExecTests = testList; } - this.includesInCoverage = includes; - this.coverageReportFormat = coverageFormat; - this.coverageModules = modules; this.listGroups = listGroups; } - public static byte[] getModifiedClassBytes(String className, List functionNames, TestSuite suite, + private static byte[] getModifiedClassBytes(String className, List functionNames, TestSuite suite, ClassLoader classLoader) { Class functionToMockClass; try { @@ -165,7 +157,8 @@ public static byte[] getModifiedClassBytes(String className, List functi try { testClass = classLoader.loadClass(testClassName); } catch (Throwable e) { - throw createLauncherException("failed to load class :" + testClassName); + throw createLauncherException("failed to prepare " + testClassName + " for mocking reason:" + + e.getMessage()); } for (Method method2 : testClass.getDeclaredMethods()) { if (method2.getName().equals(desugaredMockFunctionName)) { @@ -186,7 +179,8 @@ public static byte[] getModifiedClassBytes(String className, List functi try { mockFunctionClass = classLoader.loadClass(mockFunctionClassName); } catch (ClassNotFoundException e) { - throw createLauncherException("failed to load class: " + mockFunctionClassName); + throw createLauncherException("failed to prepare " + mockFunctionClassName + + " for mocking reason:" + e.getMessage()); } for (Method method2 : mockFunctionClass.getDeclaredMethods()) { if (method2.getName().equals(mockFunctionName)) { @@ -204,100 +198,6 @@ public static byte[] getModifiedClassBytes(String className, List functi return classFile; } - //Get modified test class bytes for function mock - public static byte[] getModifiedTestClassBytes(String className, List functionNames, TestSuite suite, - ClassLoader classLoader, Class testDocumentClass, - byte[] classFile) { - Class functionToMockClass; - try { - functionToMockClass = classLoader.loadClass(className); - } catch (Throwable e) { - throw createLauncherException("failed to load class: " + className); - } - - boolean readFromBytes; - if (classFile.length == 0) { - readFromBytes = false; - } else { - readFromBytes = true; - } - - for (Method method1 : functionToMockClass.getDeclaredMethods()) { - if (functionNames.contains(MOCK_FN_DELIMITER + method1.getName())) { - String desugaredMockFunctionName = MOCK_FUNC_NAME_PREFIX + method1.getName(); - String testClassName = TesterinaUtils.getQualifiedClassName(suite.getOrgName(), - suite.getTestPackageID(), suite.getVersion(), - suite.getPackageID().replace(DOT, FILE_NAME_PERIOD_SEPARATOR)); - Class testClass; - try { - testClass = classLoader.loadClass(testClassName); - } catch (Throwable e) { - throw createLauncherException("failed to load class :" + testClassName); - } - for (Method method2 : testClass.getDeclaredMethods()) { - if (method2.getName().equals(desugaredMockFunctionName)) { - if (!readFromBytes) { - classFile = replaceTestClzMethodCall(testDocumentClass, method2, method1); - readFromBytes = true; - } else { - classFile = replaceTestClzMethodCall(classFile, method2, method1); - } - } - } - } else if (functionNames.contains(MOCK_LEGACY_DELIMITER + method1.getName())) { - String key = className + MOCK_LEGACY_DELIMITER + method1.getName(); - String mockFunctionName = suite.getMockFunctionNamesMap().get(key); - if (mockFunctionName != null) { - String mockFunctionClassName = suite.getTestUtilityFunctions().get(mockFunctionName); - Class mockFunctionClass; - try { - mockFunctionClass = classLoader.loadClass(mockFunctionClassName); - } catch (ClassNotFoundException e) { - throw createLauncherException("failed to load class: " + mockFunctionClassName); - } - for (Method method2 : mockFunctionClass.getDeclaredMethods()) { - if (method2.getName().equals(mockFunctionName)) { - if (!readFromBytes) { - classFile = replaceTestClzMethodCall(testDocumentClass, method1, method2); - readFromBytes = true; - } else { - classFile = replaceTestClzMethodCall(classFile, method1, method2); - } - } - } - } else { - continue; - } - } - } - return classFile; - } - - private static byte[] replaceTestClzMethodCall(Class testDocumentClass, Method toFunc, Method fromFunc) { - Class clazz = testDocumentClass; - ClassReader cr; - try { - InputStream ins; - ins = clazz.getResourceAsStream(clazz.getSimpleName() + CLASS_EXTENSION); - cr = new ClassReader(requireNonNull(ins)); - } catch (IOException e) { - throw createLauncherException("failed to get the class reader object for the class " - + clazz.getSimpleName()); - } - ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); - ClassVisitor cv = new MethodCallReplaceVisitor(Opcodes.ASM7, cw, toFunc, fromFunc); - cr.accept(cv, ClassReader.EXPAND_FRAMES); - return cw.toByteArray(); - } - - private static byte[] replaceTestClzMethodCall(byte[] classFile, Method toFunc, Method fromFunc) { - ClassReader cr = new ClassReader(classFile); - ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); - ClassVisitor cv = new MethodCallReplaceVisitor(Opcodes.ASM7, cw, toFunc, fromFunc); - cr.accept(cv, ClassReader.EXPAND_FRAMES); - return cw.toByteArray(); - } - private static byte[] replaceMethodBody(Method method, Method mockMethod) { Class clazz = method.getDeclaringClass(); ClassReader cr; @@ -325,7 +225,7 @@ private static byte[] replaceMethodBody(byte[] classFile, Method method, Method return cw.toByteArray(); } - public static List getURLList(List jarFilePaths) { + private static List getURLList(List jarFilePaths) { List urlList = new ArrayList<>(); for (String jarFilePath : jarFilePaths) { @@ -408,7 +308,6 @@ public void execute(Project project) { JBallerinaBackend jBallerinaBackend = JBallerinaBackend.from(packageCompilation, JvmTarget.JAVA_11); JarResolver jarResolver = jBallerinaBackend.jarResolver(); TestProcessor testProcessor = new TestProcessor(jarResolver); - List moduleNamesList = new ArrayList<>(); List updatedSingleExecTests; // Only tests in packages are executed so default packages i.e. single bal files which has the package name // as "." are ignored. This is to be consistent with the "bal test" command which only executes tests @@ -448,11 +347,10 @@ public void execute(Project project) { module.isDefaultModule() ? moduleName.toString() : module.moduleName().moduleNamePart(); testSuiteMap.put(resolvedModuleName, suite); testSuiteMapEntries.add(testSuiteMap); - moduleNamesList.add(resolvedModuleName); } // If the function mocking does not exist, combine all test suite map entries - if (!isMockFunctionExist){ + if (!isMockFunctionExist) { HashMap testSuiteMap = testSuiteMapEntries.remove(0); while (testSuiteMapEntries.size() > 0) { testSuiteMap.putAll(testSuiteMapEntries.remove(0)); @@ -461,7 +359,7 @@ public void execute(Project project) { } //Execute each testsuite within list one by one - for (Map testSuiteMap : testSuiteMapEntries ) { + for (Map testSuiteMap : testSuiteMapEntries) { try { Path nativeConfigPath = target.getNativeConfigPath(); createReflectConfig(nativeConfigPath, project.currentPackage(), testSuiteMap); @@ -493,7 +391,6 @@ public void execute(Project project) { //Write the testsuite to the disk TestUtils.writeToTestSuiteJson(testSuiteMap, testsCachePath); - if (hasTests) { int testResult = 1; try { @@ -506,7 +403,8 @@ public void execute(Project project) { testsCachePath.resolve(moduleName).resolve(TesterinaConstants.STATUS_FILE)); if (!moduleName.equals(project.currentPackage().packageName().toString())) { - moduleName = ModuleName.from(project.currentPackage().packageName(), moduleName).toString(); + moduleName = ModuleName.from(project.currentPackage().packageName(), + moduleName).toString(); } testReport.addModuleStatus(moduleName, moduleStatus); } @@ -529,7 +427,7 @@ public void execute(Project project) { generateTesterinaReports(project, testReport, this.out, target); } catch (IOException e) { TestUtils.cleanTempCache(project, cachesRoot); - throw createLauncherException("error occurred while generating test report :", e); + throw createLauncherException("error occurred while generating test report:", e); } } @@ -635,7 +533,7 @@ private int runTestSuiteWithNativeImage(Package currentPackage, Target target, private String getClassPath(Map testSuiteMap) { List dependencies = new ArrayList<>(); - for ( Map.Entry testSuiteEntry : testSuiteMap.entrySet()) { + for (Map.Entry testSuiteEntry : testSuiteMap.entrySet()) { dependencies.addAll(testSuiteEntry.getValue().getTestExecutionDependencies()); } @@ -646,30 +544,6 @@ private String getClassPath(Map testSuiteMap) { return classPath.toString(); } - - private String getClassPath(JBallerinaBackend jBallerinaBackend, Package currentPackage) { - List dependencies = new ArrayList<>(); - JarResolver jarResolver = jBallerinaBackend.jarResolver(); - - for (ModuleId moduleId : currentPackage.moduleIds()) { - Module module = currentPackage.module(moduleId); - - // Skip getting file paths for execution if module doesnt contain a testable jar - if (!module.testDocumentIds().isEmpty() || module.project().kind() - .equals(ProjectKind.SINGLE_FILE_PROJECT)) { - for (JarLibrary jarLibs : jarResolver.getJarFilePathsRequiredForTestExecution(module.moduleName())) { - dependencies.add(jarLibs.path()); - } - } - } - - dependencies = dependencies.stream().distinct().collect(Collectors.toList()); - - StringJoiner classPath = new StringJoiner(File.pathSeparator); - dependencies.stream().map(Path::toString).forEach(classPath::add); - return classPath.toString(); - } - private void modifyJarForFunctionMock(TestSuite testSuite, Target target, String moduleName) throws IOException { String testJarName = testSuite.getOrgName() + HYPHEN + moduleName + HYPHEN + testSuite.getVersion() + HYPHEN + TESTABLE + JAR_EXTENSION; @@ -690,7 +564,6 @@ private void modifyJarForFunctionMock(TestSuite testSuite, Target target, String testJarPath = testExecutionDependency; classLoaderUrlList.add(testJarPath); } - } ClassLoader classLoader = null; @@ -705,7 +578,7 @@ private void modifyJarForFunctionMock(TestSuite testSuite, Target target, String for (Map.Entry> classVsMockFunctionsEntry : classVsMockFunctionsMap.entrySet()) { String className = classVsMockFunctionsEntry.getKey(); String[] classMetaData = className.split("\\."); - mainJarName = classMetaData[0] + HYPHEN + classMetaData[1].replace("$0046", ".") + + mainJarName = classMetaData[0] + HYPHEN + classMetaData[1].replace(DOT_REPLACER, DOT) + HYPHEN + classMetaData[2]; if (mainJarVsClassMapping.containsKey(mainJarName)) { @@ -759,8 +632,7 @@ private void modifyJarForFunctionMock(TestSuite testSuite, Target target, String private void dumpJar(Map modifiedClassDefs, Map unmodifiedFiles, String modifiedJarPath) throws IOException { List duplicatePaths = new ArrayList<>(); - JarOutputStream jarOutputStream = new JarOutputStream(new FileOutputStream(modifiedJarPath)); - try { + try (JarOutputStream jarOutputStream = new JarOutputStream(new FileOutputStream(modifiedJarPath))) { for (Map.Entry modifiedClassDef : modifiedClassDefs.entrySet()) { if (modifiedClassDef.getValue().length > 0) { String entry = modifiedClassDef.getKey(); @@ -779,10 +651,7 @@ private void dumpJar(Map modifiedClassDefs, Map jarOutputStream.closeEntry(); } } - } finally { - jarOutputStream.close(); } - } private Map loadUnmodifiedFilesWithinJar(String mainJarPath) diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/MethodCallReplaceVisitor.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/MethodCallReplaceVisitor.java deleted file mode 100644 index 653725e2afa3..000000000000 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/MethodCallReplaceVisitor.java +++ /dev/null @@ -1,67 +0,0 @@ -package io.ballerina.cli.utils; - -import org.objectweb.asm.ClassVisitor; -import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; -import org.objectweb.asm.commons.GeneratorAdapter; - -import java.lang.reflect.Method; - -/** - * Remove existing method call and replace it with a mock call. - * - * @since 2201.4.0 - */ -public class MethodCallReplaceVisitor extends ClassVisitor { - private final Method toFunc; - public final Method fromFunc; - - private final int api; - - public MethodCallReplaceVisitor(int api, ClassWriter cw, Method toFunc, Method fromFunc) { - super(api, cw); - this.toFunc = toFunc; - this.fromFunc = fromFunc; - this.api = api; - } - - @Override - public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { - return new MethodReplaceMethodVisitor(super.visitMethod(access, name, desc, signature, exceptions), - access, name, desc); - } - - private final class MethodReplaceMethodVisitor extends GeneratorAdapter { - - public MethodReplaceMethodVisitor( - MethodVisitor mv, int access, String name, String desc) { - super(MethodCallReplaceVisitor.this.api , mv, access, name, desc); - } - - @Override - public void visitMethodInsn( - int opcode, String owner, String name, String desc, boolean itf) { - - String fromFuncOwner = MethodCallReplaceVisitor.this - .fromFunc.getDeclaringClass().getName().replace(".", "/"); - String fromFuncName = MethodCallReplaceVisitor.this.fromFunc.getName(); - String fromFunDesc = Type.getMethodDescriptor(MethodCallReplaceVisitor.this.fromFunc); - - String toFuncOwner = MethodCallReplaceVisitor.this - .toFunc.getDeclaringClass().getName().replace(".", "/"); - String toFuncName = MethodCallReplaceVisitor.this.toFunc.getName(); - String toFunDesc = Type.getMethodDescriptor(MethodCallReplaceVisitor.this.toFunc); - - if (opcode == Opcodes.INVOKESTATIC && owner.equals(fromFuncOwner) - && name.equals(fromFuncName) && desc.equals(fromFunDesc)) { - super.visitMethodInsn(Opcodes.INVOKESTATIC, toFuncOwner, - toFuncName, toFunDesc, false); - } else { - super.visitMethodInsn(opcode, owner, name, desc, itf); - } - } - } - -} diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java index 7dda824492d9..61721d9a6915 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/NativeUtils.java @@ -55,6 +55,7 @@ public class NativeUtils { private static final String MODULE_INIT_CLASS_NAME = "$_init"; private static final String MODULE_CONFIGURATION_MAPPER = "$configurationMapper"; private static final String MODULE_EXECUTE_GENERATED = "tests.test_execute-generated_"; + private static final String TEST_EXEC_FUNCTION = "__execute__"; //Add dynamically loading classes and methods to reflection config public static void createReflectConfig(Path nativeConfigPath, Package currentPackage, @@ -107,10 +108,10 @@ public static void createReflectConfig(Path nativeConfigPath, Package currentPac ) ); ReflectConfigClass testTestExecuteGeneratedRefConfClz = new ReflectConfigClass( - testSuiteMap.get(moduleName).getTestUtilityFunctions().get("__execute__")); + testSuiteMap.get(moduleName).getTestUtilityFunctions().get(TEST_EXEC_FUNCTION)); testTestExecuteGeneratedRefConfClz.addReflectConfigClassMethod( new ReflectConfigClassMethod( - "__execute__", + TEST_EXEC_FUNCTION, new String[]{ "io.ballerina.runtime.internal.scheduling.Strand", "io.ballerina.runtime.api.values.BString", @@ -160,8 +161,8 @@ public static void createReflectConfig(Path nativeConfigPath, Package currentPac } String testFile = testFileMockedFunctionMappingEntry.getKey().split("-")[1]; String[] mockedFunctions = testFileMockedFunctionMappingEntry.getValue(); - originalTestFileRefConfClz = new ReflectConfigClass(getQualifiedClassName(org, moduleNameForTestClz, - version, testFile)); + originalTestFileRefConfClz = new ReflectConfigClass( + getQualifiedClassName(org, moduleNameForTestClz, version, testFile)); for (int i = 0; i < mockedFunctions.length; i++) { originalTestFileRefConfClz.addReflectConfigClassMethod( new ReflectConfigClassMethod(mockedFunctions[i])); @@ -194,7 +195,7 @@ public static void createReflectConfig(Path nativeConfigPath, Package currentPac //Add test suite class ReflectConfigClass runtimeEntityTestSuiteRefConfClz = new ReflectConfigClass( - "org.ballerinalang.test.runtime.entity" + ".TestSuite"); + "org.ballerinalang.test.runtime.entity.TestSuite"); runtimeEntityTestSuiteRefConfClz.setAllDeclaredFields(true); runtimeEntityTestSuiteRefConfClz.setUnsafeAllocated(true); @@ -220,17 +221,17 @@ private static void extractMockFunctionClassMapping(Map testS String functionToMock; if (key.indexOf(MOCK_LEGACY_DELIMITER) == -1) { functionToMockClassName = key.substring(0, key.indexOf(MOCK_FN_DELIMITER)); - functionToMock = key.substring(key.indexOf(MOCK_FN_DELIMITER)+1); + functionToMock = key.substring(key.indexOf(MOCK_FN_DELIMITER) + 1); } else if (key.indexOf(MOCK_FN_DELIMITER) == -1) { functionToMockClassName = key.substring(0, key.indexOf(MOCK_LEGACY_DELIMITER)); - functionToMock = key.substring(key.indexOf(MOCK_LEGACY_DELIMITER)+1); + functionToMock = key.substring(key.indexOf(MOCK_LEGACY_DELIMITER) + 1); } else { if (key.indexOf(MOCK_FN_DELIMITER) < key.indexOf(MOCK_LEGACY_DELIMITER)) { functionToMockClassName = key.substring(0, key.indexOf(MOCK_FN_DELIMITER)); - functionToMock = key.substring(key.indexOf(MOCK_FN_DELIMITER)+1); + functionToMock = key.substring(key.indexOf(MOCK_FN_DELIMITER) + 1); } else { functionToMockClassName = key.substring(0, key.indexOf(MOCK_LEGACY_DELIMITER)); - functionToMock = key.substring(key.indexOf(MOCK_LEGACY_DELIMITER)+1); + functionToMock = key.substring(key.indexOf(MOCK_LEGACY_DELIMITER) + 1); } } functionToMock = functionToMock.replaceAll("\\\\", ""); diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/OrigMockFunctionReplaceVisitor.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/OrigMockFunctionReplaceVisitor.java deleted file mode 100644 index 175ea9d5b45c..000000000000 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/utils/OrigMockFunctionReplaceVisitor.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package io.ballerina.cli.utils; - -import org.objectweb.asm.ClassVisitor; -import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; - -import java.lang.reflect.Method; - -import static org.ballerinalang.test.runtime.util.TesterinaConstants.ORIGINAL_FUNC_NAME_PREFIX; -import static org.objectweb.asm.Opcodes.ALOAD; -import static org.objectweb.asm.Opcodes.ARETURN; -import static org.objectweb.asm.Opcodes.DLOAD; -import static org.objectweb.asm.Opcodes.DRETURN; -import static org.objectweb.asm.Opcodes.FLOAD; -import static org.objectweb.asm.Opcodes.FRETURN; -import static org.objectweb.asm.Opcodes.ILOAD; -import static org.objectweb.asm.Opcodes.INVOKESTATIC; -import static org.objectweb.asm.Opcodes.LLOAD; -import static org.objectweb.asm.Opcodes.LRETURN; -import static org.objectweb.asm.Opcodes.RETURN; - -/** - * Remove existing method body and replace it with a method call. - * - * @since 2201.1.0 - */ -public class OrigMockFunctionReplaceVisitor extends ClassVisitor { - - private final Method origMethod; - - public OrigMockFunctionReplaceVisitor - (int api, ClassWriter cw, Method origMethod) { - super(api, cw); - this.origMethod = origMethod; - } - - @Override - public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { - MethodVisitor methodVisitor; - if (!name.equals(origMethod.getName()) || !desc.equals(Type.getMethodDescriptor(origMethod))) { - // reproduce the methods where no changes needed - methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); - } else { - // Rename function as $ORIG_ to restore the original function with a different name. - methodVisitor = super.visitMethod(access, ORIGINAL_FUNC_NAME_PREFIX + name, - desc, signature, exceptions); - - generateMethodWithOrigFunctionCall(access, name, desc, signature, exceptions); - } - - return methodVisitor; - } - private void generateMethodWithOrigFunctionCall(int access, String name, String desc, String signature, - String[] exceptions) { - MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); - - mv.visitCode(); - Class[] parameterTypes = origMethod.getParameterTypes(); - int paramOffset = 0; - for (Class parameterType : parameterTypes) { - generateLoadInstruction(mv, parameterType, paramOffset); - if (parameterType == Long.TYPE || parameterType == Double.TYPE) { - paramOffset += 2; - } else { - paramOffset++; - } - } - - String origFunctionClassName = origMethod.getDeclaringClass().getName().replace(".", "/"); - mv.visitMethodInsn(INVOKESTATIC, origFunctionClassName, ORIGINAL_FUNC_NAME_PREFIX + origMethod.getName(), - Type.getMethodDescriptor(origMethod), false); - - generateReturnInstruction(mv, origMethod.getReturnType()); - mv.visitMaxs(0, 0); - mv.visitEnd(); - } - - private void generateLoadInstruction(MethodVisitor mv, Class type, int index) { - if (type.isPrimitive()) { - if (type == Integer.TYPE || type == Boolean.TYPE) { - mv.visitVarInsn(ILOAD, index); - } else if (type == Long.TYPE) { - mv.visitVarInsn(LLOAD, index); - } else if (type == Float.TYPE) { - mv.visitVarInsn(FLOAD, index); - } else if (type == Double.TYPE) { - mv.visitVarInsn(DLOAD, index); - } - } else { - mv.visitVarInsn(ALOAD, index); - } - } - - private void generateReturnInstruction(MethodVisitor mv, Class returnType) { - if (returnType.isPrimitive()) { - if (returnType == Integer.TYPE || returnType == Boolean.TYPE || returnType == Byte.TYPE) { - mv.visitInsn(Opcodes.IRETURN); - } else if (returnType == Long.TYPE) { - mv.visitInsn(LRETURN); - } else if (returnType == Float.TYPE) { - mv.visitInsn(FRETURN); - } else if (returnType == Double.TYPE) { - mv.visitInsn(DRETURN); - } else if (returnType == Void.TYPE) { - mv.visitInsn(RETURN); - } - } else { - mv.visitInsn(ARETURN); - } - } -} diff --git a/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/TesterinaCompilerPluginUtils.java b/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/TesterinaCompilerPluginUtils.java index 62410808d24d..12a10122cab9 100644 --- a/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/TesterinaCompilerPluginUtils.java +++ b/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/TesterinaCompilerPluginUtils.java @@ -36,7 +36,7 @@ import io.ballerina.compiler.syntax.tree.SimpleNameReferenceNode; import io.ballerina.compiler.syntax.tree.StatementNode; import io.ballerina.compiler.syntax.tree.SyntaxKind; -import org.ballerinalang.testerina.compiler.exceptions.CacheGenException; +import io.ballerina.projects.ProjectException; import java.io.File; import java.io.FileOutputStream; @@ -295,7 +295,7 @@ public static void writeCacheMapAsJson(Map map, Path path, String fileName) { try { Files.createDirectories(path); } catch (IOException e) { - throw new CacheGenException("couldn't create cache directories : " + e.toString()); + throw new ProjectException("couldn't create cache directories : " + e.toString()); } } @@ -307,10 +307,10 @@ public static void writeCacheMapAsJson(Map map, Path path, String fileName) { String json = gson.toJson(map); writer.write(new String(json.getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8)); } catch (IOException e) { - throw new CacheGenException("couldn't write cache data to the file : " + e.toString()); + throw new ProjectException("couldn't write cache data to the file : " + e.toString()); } } catch (IOException e) { - throw new CacheGenException("couldn't write cache data to the file : " + e.toString()); + throw new ProjectException("couldn't write cache data to the file : " + e.toString()); } } } diff --git a/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/exceptions/CacheGenException.java b/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/exceptions/CacheGenException.java deleted file mode 100644 index be202e2b11e2..000000000000 --- a/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/exceptions/CacheGenException.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.ballerinalang.testerina.compiler.exceptions; -/** - * Exception class to throw exception when the test document - mock function map fails to generate. - * - * @since 2201.4.0 - */ -public class CacheGenException extends RuntimeException { - public CacheGenException(String msg) { - super(msg); - } -} diff --git a/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/TesterinaConstants.java b/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/TesterinaConstants.java index 4bd7e74e163e..412c78715d00 100644 --- a/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/TesterinaConstants.java +++ b/misc/testerina/modules/testerina-runtime/src/main/java/org/ballerinalang/test/runtime/util/TesterinaConstants.java @@ -25,6 +25,7 @@ */ public class TesterinaConstants { + public static final String DOT_REPLACER = "$0046"; public static final String BALLERINA_SOURCE_ROOT = "ballerina.source.root"; public static final String TESTERINA_TEMP_DIR = ".testerina"; public static final String TESTERINA_TEST_SUITE = "test_suit.json"; From cde0e8f3a153e92347debe831f799782aaf384ac Mon Sep 17 00:00:00 2001 From: sanjana Date: Wed, 21 Dec 2022 16:14:23 +0530 Subject: [PATCH 385/450] Update typedesc langlib example --- .../lang.typedesc/src/main/ballerina/typedesc_lib.bal | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal b/langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal index 9ed9973ede83..6cd9bc190749 100644 --- a/langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal +++ b/langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal @@ -46,11 +46,14 @@ public type TypeId readonly & record {| # # type SampleError distinct (Error & error); # -# typedesc:TypeId[] typeIds = SampleError.typeIds(); -# typeIds[typeIds.length() - 1]["localId"] ⇒ Error +# SampleError.typeIds() ⇒ [ +# {"moduleId":{"organization":"$anon","name":".","platformParts":["0"]},"localId":"SampleError"}, +# {"moduleId":{"organization":"$anon","name":".","platformParts":["0"]},"localId":"Error"} +# ] # -# typedesc:TypeId[] primaryTypeIds = SampleError.typeIds(true); -# primaryTypeIds[primaryTypeIds.length() - 1]["localId"] ⇒ SampleError +# SampleError.typeIds(true) ⇒ [ +# {"moduleId":{"organization":"$anon","name":".","platformParts":["0"]},"localId":"SampleError"} +# ] # ``` # # + t - the typedesc From a8730a406e961bb981d11f9eb86fc52e8b790446 Mon Sep 17 00:00:00 2001 From: Fathima Dilhasha Date: Wed, 21 Dec 2022 16:18:06 +0530 Subject: [PATCH 386/450] Clear old package from cache when updating modules --- .../src/main/java/io/ballerina/projects/Package.java | 3 +++ .../langserver/workspace/BallerinaWorkspaceManager.java | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Package.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Package.java index ea351526d3e6..66c85313b470 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Package.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Package.java @@ -697,6 +697,9 @@ private void updateModules() { oldModuleContext.isDefaultModule(), srcDocContextMap, testDocContextMap, oldModuleContext.moduleMdContext().orElse(null), oldModuleContext.moduleDescDependencies(), resourceMap, testResourceMap)); + // Clear compilation package cache + PackageCache.getInstance(project.projectEnvironmentContext().getService(CompilerContext.class)). + remove(oldModuleContext.descriptor().moduleCompilationId()); } updateModules(moduleContextSet); } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/workspace/BallerinaWorkspaceManager.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/workspace/BallerinaWorkspaceManager.java index 40a3d49dee55..9b4bb328cda9 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/workspace/BallerinaWorkspaceManager.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/workspace/BallerinaWorkspaceManager.java @@ -875,7 +875,6 @@ private void updateBallerinaToml(String content, ProjectPair projectPair, boolea } // Update toml BallerinaToml updatedToml = ballerinaToml.get().modify().withContent(content).apply(); - updatedToml.packageInstance().project().clearCaches(); // Update project instance projectPair.setProject(updatedToml.packageInstance().project()); } finally { From c170a7ef005b2357b02e4579afb0cfd01cd99107 Mon Sep 17 00:00:00 2001 From: suleka96 Date: Wed, 21 Dec 2022 15:16:42 +0530 Subject: [PATCH 387/450] Refactor code --- .../lang.regexp/src/main/ballerina/regexp.bal | 89 +++++++------------ .../lang.string/src/main/ballerina/string.bal | 6 +- 2 files changed, 32 insertions(+), 63 deletions(-) diff --git a/langlib/lang.regexp/src/main/ballerina/regexp.bal b/langlib/lang.regexp/src/main/ballerina/regexp.bal index 7b9beacc91ab..306f15f3ed27 100644 --- a/langlib/lang.regexp/src/main/ballerina/regexp.bal +++ b/langlib/lang.regexp/src/main/ballerina/regexp.bal @@ -51,37 +51,12 @@ type GroupsAsSpanArrayType SpanAsTupleType[]; type GroupsArrayType GroupsAsSpanArrayType[]; -# Splits a string into substrings separated by matches of a regular expression. -# This finds the the non-overlapping matches of a regular expression and -# returns a list of substrings of `str` that occur before the first match, -# between matches, or after the last match. If there are no matches, then -# `[str]` will be returned. -# -# ```ballerina -# regexp:RegExp r = re `,`; -# -# r.split("Not Valid") ⇒ ["Not Valid"] -# -# r.split("abc,cde,efg") ⇒ ["abc", "cde", "efg"] -# ``` -# -# + re - the regular expression that specifies the separator -# + str - the string to be split -# + return - a list of substrings of `str` separated by matches of `re` -public isolated function split(RegExp re, string str) returns string[] = @java:Method { - 'class: "org.ballerinalang.langlib.regexp.Split", - name: "split" -} external; - # Returns the first match of a regular expression within a string. # # ```ballerina -# regexp:RegExp r = re `World`; -# +# string:RegExp r = re `World`; # r.find("Not A Match") is () ⇒ true -# # r.find("Hello World") is regexp:Span ⇒ true -# # r.find("Hello World", 7) is regexp:Span ⇒ true # ``` # @@ -110,12 +85,9 @@ isolated function findAllImpl(RegExp reExp, string str, int startIndex = 0) retu # Returns the `Groups` for the first match of a regular expression within a string. # # ```ballerina -# regexp:RegExp r = re `([bB].tt[a-z]*)`; -# +# string:RegExp r = re `([bB].tt[a-z]*)`; # r.findGroups("Not A Match") is () ⇒ true -# # r.findGroups("Butter was bought by Betty but the butter was bitter.") is regexp:Groups ⇒ true -# # r.findGroups("Butter was bought by Betty but the butter was bitter.", 7) is regexp:Groups ⇒ true # ``` # @@ -140,12 +112,9 @@ isolated function findGroupsImpl(RegExp reExp, string str, int startIndex = 0) r # match ended, so the list of matches will be non-overlapping. # # ```ballerina -# regexp:RegExp r = re `[bB].tt[a-z]*`; -# +# string:RegExp r = re `[bB].tt[a-z]*`; # r.findAll("Not A Match").length() ⇒ 0 -# # r.findAll("Butter was bought by Betty but the butter was bitter.").length() ⇒ 4 -# # r.findAll("Butter was bought by Betty but the butter was bitter.", 7).length() ⇒ 3 # ``` # @@ -169,12 +138,9 @@ public isolated function findAll(RegExp re, string str, int startIndex = 0) retu # match ended, so the list of matches will be non-overlapping. # # ```ballerina -# regexp:RegExp r = re `([bB].tt[a-z]*)`; -# +# string:RegExp r = re `([bB].tt[a-z]*)`; # r.findAllGroups("Not A Match").length() ⇒ 0 -# # r.findAllGroups("Butter was bought by Betty but the butter was bitter.").length() ⇒ 4 -# # r.findAllGroups("Butter was bought by Betty but the butter was bitter.", 7) ⇒ 3 # ``` # @@ -217,10 +183,8 @@ isolated function findAllGroupsImpl(RegExp reExp, string str, int startIndex = 0 # Tests whether there is a match of a regular expression at a specific index in the string. # # ```ballerina -# regexp:RegExp r = re `World`; -# +# string:RegExp r = re `World`; # r.matchAt("Hello World") is () ⇒ true -# # r.matchAt("Hello World", 6) is regexp:Span ⇒ true # ``` # @@ -245,10 +209,8 @@ isolated function matchAtImpl(RegExp reExp, string str, int startIndex = 0) retu # Returns the `Groups` of the match of a regular expression at a specific index in the string. # # ```ballerina -# regexp:RegExp r = re `([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])?`; -# +# string:RegExp r = re `([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])?`; # r.matchGroupsAt("time: 14:35:59") is () ⇒ true -# # r.matchGroupsAt("time: 14:35:59", 6) is regexp:Groups ⇒ true # ``` # @@ -282,10 +244,8 @@ isolated function matchGroupsAtImpl(RegExp reExp, string str, int startIndex = 0 # starts at index 0 and ends at index `n`, where `n` is the length of the string. # # ```ballerina -# regexp:RegExp r = re `A|Th.*ch|^`; -# +# string:RegExp r = re `A|Th.*ch|^`; # r.isFullMatch("This is a Match") ⇒ true -# # r.isFullMatch("Not a complete Match") ⇒ false # ``` # @@ -306,10 +266,8 @@ isolated function isFullMatchImpl(RegExp reExp, string str) returns boolean = @j # starts at index 0 and ends at index `n`, where `n` is the length of the string. # # ```ballerina -# regexp:RegExp r = re `([0-9]+)×([0-9]+)`; -# +# string:RegExp r = re `([0-9]+)×([0-9]+)`; # r.fullMatchGroups("test: 1440×900") is () ⇒ true -# # r.fullMatchGroups("1440×900") is regexp:Groups ⇒ true # ``` # @@ -333,12 +291,9 @@ public type Replacement ReplacerFunction|string; # Replaces the first match of a regular expression. # # ```ballerina -# regexp:RegExp r = re `0+`; -# +# string:RegExp r = re `0+`; # r.replace("10010011", "*") ⇒ 1*10011 -# # r.replace("10010011", "*", 4) ⇒ 1001*11 -# # r.replace("122111", "*") ⇒ 122111 # ``` # @@ -369,12 +324,9 @@ public isolated function replace(RegExp re, string str, Replacement replacement, # match ended, so the matches will be non-overlapping. # # ```ballerina -# regexp:RegExp r = re `0+`; -# +# string:RegExp r = re `0+`; # r.replaceAll("10010011", "*") ⇒ 1*1*11 -# # r.replaceAll("10010011", "*", 4) ⇒ 1001*11 -# # r.replaceAll("122111", "*") ⇒ 122111 # ``` # @@ -428,12 +380,31 @@ isolated function getReplacementString(Groups groups, Replacement replacement) r return replacement(groups); } +# Splits a string into substrings separated by matches of a regular expression. +# This finds the the non-overlapping matches of a regular expression and +# returns a list of substrings of `str` that occur before the first match, +# between matches, or after the last match. If there are no matches, then +# `[str]` will be returned. +# +# ```ballerina +# string:RegExp r = re `,`; +# r.split("abc,cde,efg") ⇒ ["abc", "cde", "efg"] +# r.split("Not Valid") ⇒ ["Not Valid"] +# ``` +# +# + re - the regular expression that specifies the separator +# + str - the string to be split +# + return - a list of substrings of `str` separated by matches of `re` +public isolated function split(RegExp re, string str) returns string[] = @java:Method { + 'class: "org.ballerinalang.langlib.regexp.Split", + name: "split" +} external; + # Constructs a regular expression from a string. # The syntax of the regular expression is the same as accepted by the `re` tagged data template expression. # # ```ballerina # regexp:fromString("AB+C*D{1,4}") ⇒ re `AB+C*D{1,4}` -# # regexp:fromString("AB+^*") ⇒ error # ``` # diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index 56bbad3e714d..f7923eb1ec83 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -318,8 +318,7 @@ public type RegExp regexp:RegExp; # This is equivalent to `regex:isFullMatch(re, str)`. # # ```ballerina -# string s = "This is a Match"; -# s.matches(re `A|Th.*ch|^`) ⇒ true +# "This is a Match".matches(re `A|Th.*ch|^`) ⇒ true # ``` # # + str - the string @@ -333,8 +332,7 @@ public function matches(string str, RegExp re) returns boolean { # This is equivalent to `regexp:find(re, str, startIndex) != ()`. # # ```ballerina -# string s = "Will Match Somewhere"; -# s.includesMatch(re `A|Th.*ch|^`) ⇒ true +# "Will Match Somewhere".includesMatch(re `A|Th.*ch|^`) ⇒ true # ``` # # + str - the string to be matched From 5bf9267e238e2a75cb4f28e85262b9097933e0fe Mon Sep 17 00:00:00 2001 From: suleka96 Date: Wed, 21 Dec 2022 15:25:57 +0530 Subject: [PATCH 388/450] Re-add spaces --- .../lang.regexp/src/main/ballerina/regexp.bal | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/langlib/lang.regexp/src/main/ballerina/regexp.bal b/langlib/lang.regexp/src/main/ballerina/regexp.bal index 306f15f3ed27..09f8e7c03deb 100644 --- a/langlib/lang.regexp/src/main/ballerina/regexp.bal +++ b/langlib/lang.regexp/src/main/ballerina/regexp.bal @@ -55,8 +55,11 @@ type GroupsArrayType GroupsAsSpanArrayType[]; # # ```ballerina # string:RegExp r = re `World`; +# # r.find("Not A Match") is () ⇒ true +# # r.find("Hello World") is regexp:Span ⇒ true +# # r.find("Hello World", 7) is regexp:Span ⇒ true # ``` # @@ -86,8 +89,11 @@ isolated function findAllImpl(RegExp reExp, string str, int startIndex = 0) retu # # ```ballerina # string:RegExp r = re `([bB].tt[a-z]*)`; +# # r.findGroups("Not A Match") is () ⇒ true +# # r.findGroups("Butter was bought by Betty but the butter was bitter.") is regexp:Groups ⇒ true +# # r.findGroups("Butter was bought by Betty but the butter was bitter.", 7) is regexp:Groups ⇒ true # ``` # @@ -113,8 +119,11 @@ isolated function findGroupsImpl(RegExp reExp, string str, int startIndex = 0) r # # ```ballerina # string:RegExp r = re `[bB].tt[a-z]*`; +# # r.findAll("Not A Match").length() ⇒ 0 +# # r.findAll("Butter was bought by Betty but the butter was bitter.").length() ⇒ 4 +# # r.findAll("Butter was bought by Betty but the butter was bitter.", 7).length() ⇒ 3 # ``` # @@ -139,8 +148,11 @@ public isolated function findAll(RegExp re, string str, int startIndex = 0) retu # # ```ballerina # string:RegExp r = re `([bB].tt[a-z]*)`; +# # r.findAllGroups("Not A Match").length() ⇒ 0 +# # r.findAllGroups("Butter was bought by Betty but the butter was bitter.").length() ⇒ 4 +# # r.findAllGroups("Butter was bought by Betty but the butter was bitter.", 7) ⇒ 3 # ``` # @@ -184,7 +196,9 @@ isolated function findAllGroupsImpl(RegExp reExp, string str, int startIndex = 0 # # ```ballerina # string:RegExp r = re `World`; +# # r.matchAt("Hello World") is () ⇒ true +# # r.matchAt("Hello World", 6) is regexp:Span ⇒ true # ``` # @@ -210,7 +224,9 @@ isolated function matchAtImpl(RegExp reExp, string str, int startIndex = 0) retu # # ```ballerina # string:RegExp r = re `([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])?`; +# # r.matchGroupsAt("time: 14:35:59") is () ⇒ true +# # r.matchGroupsAt("time: 14:35:59", 6) is regexp:Groups ⇒ true # ``` # @@ -245,7 +261,9 @@ isolated function matchGroupsAtImpl(RegExp reExp, string str, int startIndex = 0 # # ```ballerina # string:RegExp r = re `A|Th.*ch|^`; +# # r.isFullMatch("This is a Match") ⇒ true +# # r.isFullMatch("Not a complete Match") ⇒ false # ``` # @@ -267,7 +285,9 @@ isolated function isFullMatchImpl(RegExp reExp, string str) returns boolean = @j # # ```ballerina # string:RegExp r = re `([0-9]+)×([0-9]+)`; +# # r.fullMatchGroups("test: 1440×900") is () ⇒ true +# # r.fullMatchGroups("1440×900") is regexp:Groups ⇒ true # ``` # @@ -292,8 +312,11 @@ public type Replacement ReplacerFunction|string; # # ```ballerina # string:RegExp r = re `0+`; +# # r.replace("10010011", "*") ⇒ 1*10011 +# # r.replace("10010011", "*", 4) ⇒ 1001*11 +# # r.replace("122111", "*") ⇒ 122111 # ``` # @@ -325,8 +348,11 @@ public isolated function replace(RegExp re, string str, Replacement replacement, # # ```ballerina # string:RegExp r = re `0+`; +# # r.replaceAll("10010011", "*") ⇒ 1*1*11 +# # r.replaceAll("10010011", "*", 4) ⇒ 1001*11 +# # r.replaceAll("122111", "*") ⇒ 122111 # ``` # @@ -388,7 +414,9 @@ isolated function getReplacementString(Groups groups, Replacement replacement) r # # ```ballerina # string:RegExp r = re `,`; +# # r.split("abc,cde,efg") ⇒ ["abc", "cde", "efg"] +# # r.split("Not Valid") ⇒ ["Not Valid"] # ``` # @@ -405,6 +433,7 @@ public isolated function split(RegExp re, string str) returns string[] = @java:M # # ```ballerina # regexp:fromString("AB+C*D{1,4}") ⇒ re `AB+C*D{1,4}` +# # regexp:fromString("AB+^*") ⇒ error # ``` # From 17b6885a7702ae6cf2337cce0d1e39daa85cc83d Mon Sep 17 00:00:00 2001 From: sanjana Date: Wed, 21 Dec 2022 18:28:04 +0530 Subject: [PATCH 389/450] Correct output of xml langlib example --- langlib/lang.xml/src/main/ballerina/xml.bal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/langlib/lang.xml/src/main/ballerina/xml.bal b/langlib/lang.xml/src/main/ballerina/xml.bal index 2c3f0a069a76..b0a309051daf 100644 --- a/langlib/lang.xml/src/main/ballerina/xml.bal +++ b/langlib/lang.xml/src/main/ballerina/xml.bal @@ -57,7 +57,7 @@ public type Text xml; # xml `BallerinaJava`.length() ⇒ 2 # # xml `John20 -# adminteacher`.length() ⇒ 3 +# adminteacher`.length() ⇒ 4 # ``` # # + x - xml item @@ -475,7 +475,7 @@ public isolated function elementChildren(xml x, string? nm = ()) returns xmlJavaBallerina`; -# books.'map(function (xml xmlContent) returns xml { +# books.map(function (xml xmlContent) returns xml { # return xml `${xmlContent.children()}`; # }) ⇒ JavaBallerina # ``` From f4ad8c6fe9bdff0b316bd3cef1b17b8804dd0a05 Mon Sep 17 00:00:00 2001 From: Fathima Dilhasha Date: Thu, 22 Dec 2022 08:18:48 +0530 Subject: [PATCH 390/450] Fix PR suggestions --- .../src/main/java/io/ballerina/projects/Package.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Package.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Package.java index 66c85313b470..0f19751a4e6e 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Package.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/Package.java @@ -697,7 +697,7 @@ private void updateModules() { oldModuleContext.isDefaultModule(), srcDocContextMap, testDocContextMap, oldModuleContext.moduleMdContext().orElse(null), oldModuleContext.moduleDescDependencies(), resourceMap, testResourceMap)); - // Clear compilation package cache + // Remove the module with old PackageID from the compilation cache PackageCache.getInstance(project.projectEnvironmentContext().getService(CompilerContext.class)). remove(oldModuleContext.descriptor().moduleCompilationId()); } From 4848613699fd680e076e09d81236932d756a7aa5 Mon Sep 17 00:00:00 2001 From: LakshanWeerasinghe Date: Thu, 22 Dec 2022 10:17:55 +0530 Subject: [PATCH 391/450] Add examples for value langlib --- .../lang.value/src/main/ballerina/value.bal | 137 +++++++++++++++++- 1 file changed, 136 insertions(+), 1 deletion(-) diff --git a/langlib/lang.value/src/main/ballerina/value.bal b/langlib/lang.value/src/main/ballerina/value.bal index 4dee181cc6bd..8866861e51c2 100644 --- a/langlib/lang.value/src/main/ballerina/value.bal +++ b/langlib/lang.value/src/main/ballerina/value.bal @@ -38,6 +38,13 @@ type AnydataType anydata; # It corresponds to the Clone(v) abstract operation, # defined in the Ballerina Language Specification. # +# ```ballerina +# int[] arr = [1, 2, 3, 4]; +# int[] clone = arr.clone(); +# clone ⇒ [1,2,3,4] +# arr === clone ⇒ false +# ``` +# # + v - source value # + return - clone of parameter `v` public isolated function clone(CloneableType v) returns CloneableType = @java:Method { @@ -50,6 +57,13 @@ public isolated function clone(CloneableType v) returns CloneableType = @java:Me # It corresponds to the ImmutableClone(v) abstract operation, # defined in the Ballerina Language Specification. # +# ```ballerina +# int[] arr = [1, 2, 3, 4]; +# int[] & readonly immutableClone = arr.cloneReadOnly(); +# immutableClone ⇒ [1,2,3,4] +# immutableClone is readonly ⇒ true +# ``` +# # + v - source value # + return - immutable clone of parameter `v` public isolated function cloneReadOnly(CloneableType v) returns CloneableType & readonly = @java:Method { @@ -80,6 +94,20 @@ public isolated function cloneReadOnly(CloneableType v) returns CloneableType & # - if a record type descriptor specifies default values, these will be used # to supply any missing members # +# ```ballerina +# anydata[] arr = [1, 2, 3, 4]; +# int[] intArray = check arr.cloneWithType(); +# intArray ⇒ [1,2,3,4] +# arr === intArray ⇒ false +# +# type Vowels string:Char[]; +# +# string[] vowels = ["a", "e", "i", "o", "u"]; +# vowels.cloneWithType(Vowels) ⇒ ["a","e","i","o","u"] +# +# vowels.cloneWithType(string) ⇒ error +# ``` +# # + v - the value to be cloned # + t - the type for the cloned to be constructed # + return - a new value that belongs to parameter `t`, or an error if this cannot be done @@ -94,6 +122,17 @@ public isolated function cloneWithType(anydata v, typedesc t = <>) retu # This casts a value to a type in the same way as a type cast expression, # but returns an error if the cast cannot be done, rather than panicking. # +# ```ballerina +# json student = {name: "Jo", subjects: ["CS1212", "CS2021"]}; +# json[] subjects = check student.subjects.ensureType(); +# subjects ⇒ ["CS1212","CS2021"] +# +# anydata vowel = "I"; +# vowel.ensureType(string:Char) ⇒ I; +# +# vowel.ensureType(int) ⇒ error +# ``` +# # + v - the value to be cast # + t - a typedesc for the type to which to cast it # + return - `v` cast to the type described by parameter `t`, or an error, if the cast cannot be done @@ -106,6 +145,14 @@ public isolated function ensureType(any|error v, typedesc t = <>) returns t # # Returns true if read-only, false otherwise. # +# ```ballerina +# int[] scores = [21, 12, 33, 45, 81]; +# scores.isReadOnly() ⇒ true +# +# string[] sports = ["cricket", "football", "rugby"]; +# sports.isReadOnly() ⇒ false +# ``` +# # + v - source value # + return - true if read-only, false otherwise # # Deprecated @@ -124,6 +171,14 @@ public isolated function isReadOnly(anydata v) returns boolean = @java:Method { # The details of the conversion are specified by the ToString abstract operation # defined in the Ballerina Language Specification, using the direct style. # +# ```ballerina +# decimal value = 12.12d; +# value.toString() ⇒ 12.12 +# +# anydata[] data = [1, "Sam", 12.3f, 12.12d, {value: 12}]; +# data.toString() ⇒ [1,"Sam",12.3,12.12,{"value":12}] +# ``` +# # + v - the value to be converted to a string # + return - a string resulting from the conversion public isolated function toString((any) v) returns string = @java:Method { @@ -141,6 +196,14 @@ public isolated function toString((any) v) returns string = @java:Method { # The details of the conversion are specified by the ToString abstract operation # defined in the Ballerina Language Specification, using the expression style. # +# ```ballerina +# decimal value = 12.12d; +# value.toBalString() ⇒ 12.12d +# +# anydata[] data = [1, "Sam", 12.3f, 12.12d, {value: 12}]; +# data.toBalString() ⇒ [1,"Sam",12.3,12.12d,{"value":12}] +# ``` +# # + v - the value to be converted to a string # + return - a string resulting from the conversion public isolated function toBalString(any v) returns string = @java:Method { @@ -153,6 +216,14 @@ public isolated function toBalString(any v) returns string = @java:Method { # The subset of Ballerina expression syntax supported is that produced # by toBalString when applied to an anydata value. # +# ```ballerina +# string a = "12.12d"; +# a.fromBalString() ⇒ 12.12 +# +# string b = "[1, 2, !]"; +# b.fromBalString() ⇒ error +# ``` +# # + s - the string to be parsed and evaluated # + return - the result of evaluating the parsed expression, or # an error if the string cannot be parsed @@ -177,6 +248,15 @@ public isolated function fromBalString(string s) returns anydata|error = @java:M # immutable values. # This panics if parameter `v` has cycles. # +# ```ballerina +# anydata student = {name: "Jo", age: 11}; +# student.toJson() ⇒ {"name":"Jo","age":11} +# +# anydata[] array = []; +# array.push(array); +# array.toJson() ⇒ panic +# ``` +# # + v - anydata value # + return - representation of `v` as value of type json public isolated function toJson(anydata v) returns json = @java:Method { @@ -188,6 +268,11 @@ public isolated function toJson(anydata v) returns json = @java:Method { # # parameter `v` is first converted to `json` as if by the function `toJson`. # +# ```ballerina +# anydata marks = {"Alice": 90, "Bob": 85, "Jo": 91}; +# marks.toJsonString() ⇒ {"Alice":90, "Bob":85, "Jo":91} +# ``` +# # + v - anydata value # + return - string representation of parameter `v` converted to `json` public isolated function toJsonString(anydata v) returns string = @java:Method { @@ -195,7 +280,7 @@ public isolated function toJsonString(anydata v) returns string = @java:Method { name: "toJsonString" } external; -# Parses a string in JSON format and returns the the value that it represents. +# Parses a string in JSON format and returns the value that it represents. # # Numbers in the JSON string are converted into Ballerina values of type # decimal except in the following two cases: @@ -208,6 +293,12 @@ public isolated function toJsonString(anydata v) returns string = @java:Method { # # Returns an error if the string cannot be parsed. # +# ```ballerina +# "{\"id\": 12, \"name\": \"John\"}".fromJsonString() ⇒ {"id":12,"name":"John"} +# +# "{12: 12}".fromJsonString() ⇒ error +# ``` +# # + str - string in JSON format # + return - `str` parsed to json or error public isolated function fromJsonString(string str) returns json|error = @java:Method { @@ -222,6 +313,12 @@ public type JsonFloat ()|boolean|string|float|JsonFloat[]|map; # # Returns an error if the string cannot be parsed. # +# ```ballerina +# "[12, true, 123.4, \"hello\"]".fromJsonFloatString() ⇒ [12.0,true,123.4,"hello"] +# +# "[12, true, 12.5, !]".fromJsonFloatString() ⇒ error +# ``` +# # + str - string in JSON format # + return - parameter `str` parsed to JsonFloat or error public isolated function fromJsonFloatString(string str) returns JsonFloat|error = @java:Method { @@ -236,6 +333,12 @@ public type JsonDecimal ()|boolean|string|decimal|JsonDecimal[]|map # # Returns an error if the string cannot be parsed. # +# ```ballerina +# "[12, true, 123.4, \"hello\"]".fromJsonDecimalString() ⇒ [12.0,true,123.4,"hello"] +# +# "[12, true, 12.5, !]".fromJsonDecimalString() ⇒ error +# ``` +# # + str - string in JSON format # + return - parameter `str` parsed to JsonDecimal or error public isolated function fromJsonDecimalString(string str) returns JsonDecimal|error = @java:Method { @@ -248,6 +351,19 @@ public isolated function fromJsonDecimalString(string str) returns JsonDecimal|e # This works the same as function `cloneWithType`, # except that it also does the inverse of the conversions done by `toJson`. # +# ```ballerina +# json arr = [1, 2, 3, 4]; +# int[] intArray = check arr.fromJsonWithType(); +# intArray ⇒ [1,2,3,4] +# +# type Vowels string:Char[]; +# +# json vowels = ["a", "e", "i", "o", "u"]; +# vowels.fromJsonWithType(Vowels) ⇒ ["a","e","i","o","u"] +# +# vowels.fromJsonWithType(string) ⇒ error +# ``` +# # + v - json value # + t - type to convert to # + return - value belonging to type parameter `t` or error if this cannot be done @@ -261,6 +377,14 @@ public isolated function fromJsonWithType(json v, typedesc t = <>) # # This is a combination of function `fromJsonString` followed by function `fromJsonWithType`. # +# ```ballerina +# int[] intArray = check "[1, 2, 3, 4]".fromJsonStringWithType(); +# intArray ⇒ [1,2,3,4] +# +# "2022".fromJsonStringWithType(int) ⇒ 2022 +# "2022".fromJsonStringWithType(boolean) ⇒ error +# ``` +# # + str - string in JSON format # + t - type to convert to # + return - value belonging to type parameter `t` or error if this cannot be done @@ -281,6 +405,17 @@ public isolated function fromJsonStringWithType(string str, typedesc t # - otherwise, the merge fails # If the merge fails, then parameter `j1` is unchanged. # +# ```ballerina +# json student = {name: "John", age: 23}; +# json location = {city: "Colombo", country: "Sri Lanka"}; +# student.mergeJson(location) ⇒ {"name":"John","age":23,"city":"Colombo","country":"Sri Lanka"} +# +# value:mergeJson(student, location) ⇒ {"name":"John","age":23,"city":"Colombo","country":"Sri Lanka"} +# +# json city = "Colombo"; +# student.mergeJson(city) ⇒ error +# ``` +# # + j1 - json value # + j2 - json value # + return - the merge of parameter `j1` with parameter `j2` or an error if the merge fails From 655311c7fc0b499f37cf943591a1adab7925f13a Mon Sep 17 00:00:00 2001 From: sanjana Date: Thu, 22 Dec 2022 10:45:25 +0530 Subject: [PATCH 392/450] Reformat typedesc langlib example output --- .../lang.typedesc/src/main/ballerina/typedesc_lib.bal | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal b/langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal index 6cd9bc190749..91547c7bb154 100644 --- a/langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal +++ b/langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal @@ -46,14 +46,9 @@ public type TypeId readonly & record {| # # type SampleError distinct (Error & error); # -# SampleError.typeIds() ⇒ [ -# {"moduleId":{"organization":"$anon","name":".","platformParts":["0"]},"localId":"SampleError"}, -# {"moduleId":{"organization":"$anon","name":".","platformParts":["0"]},"localId":"Error"} -# ] +# SampleError.typeIds() ⇒ [{"moduleId":{"organization":"$anon","name":".","platformParts":["0"]},"localId":"SampleError"},{"moduleId":{"organization":"$anon","name":".","platformParts":["0"]},"localId":"Error"}] # -# SampleError.typeIds(true) ⇒ [ -# {"moduleId":{"organization":"$anon","name":".","platformParts":["0"]},"localId":"SampleError"} -# ] +# SampleError.typeIds(true) ⇒ [{"moduleId":{"organization":"$anon","name":".","platformParts":["0"]},"localId":"SampleError"}] # ``` # # + t - the typedesc From 19dbf66af289f28d87944c8d557956bb449ea688 Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Thu, 22 Dec 2022 11:25:13 +0530 Subject: [PATCH 393/450] Change duplicate array item record naming format --- .../jsonmapper/util/ConverterUtils.java | 16 ++++----- .../assert/singleFileProject/sample_10.bal | 12 +++---- .../assert/singleFileProject/sample_11.bal | 4 +-- .../assert/singleFileProject/sample_4.bal | 4 +-- .../assert/singleFileProject/sample_8.bal | 34 +++++++++---------- .../ballerina/sample_10_without_conflict.bal | 8 ++--- 6 files changed, 38 insertions(+), 40 deletions(-) diff --git a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java index 2106b648f5e8..376787828697 100644 --- a/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java +++ b/misc/json-to-record-converter/src/main/java/io/ballerina/jsonmapper/util/ConverterUtils.java @@ -314,19 +314,17 @@ private static String getUpdatedFieldName(String fieldName, boolean isArrayField if (!existingFieldNames.contains(fieldName) && !updatedFieldNames.containsValue(fieldName)) { return fieldName; } else { - String extractedFieldName = isArrayField ? - fieldName.substring(0, fieldName.length() - ARRAY_RECORD_SUFFIX.length()) : fieldName; - String[] fieldNameSplit = extractedFieldName.split("_"); - String numericSuffix = fieldNameSplit[fieldNameSplit.length - 1]; // 01 + String[] fieldNameSplit = fieldName.split("_"); + String numericSuffix = fieldNameSplit[fieldNameSplit.length - 1]; + if (NumberUtils.isParsable(numericSuffix)) { return getUpdatedFieldName(String.join("_", Arrays.copyOfRange(fieldNameSplit, 0, fieldNameSplit.length - 1)) + "_" + - String.format("%02d", Integer.parseInt(numericSuffix) + 1) + - (isArrayField ? ARRAY_RECORD_SUFFIX : ""), - isArrayField, existingFieldNames, updatedFieldNames); + String.format("%02d", Integer.parseInt(numericSuffix) + 1), isArrayField, + existingFieldNames, updatedFieldNames); } else { - return getUpdatedFieldName(extractedFieldName + "_01" + (isArrayField ? ARRAY_RECORD_SUFFIX : ""), - isArrayField, existingFieldNames, updatedFieldNames); + return getUpdatedFieldName(fieldName + "_01", isArrayField, existingFieldNames, + updatedFieldNames); } } } diff --git a/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_10.bal b/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_10.bal index 363f54420f6a..89d6e46722aa 100644 --- a/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_10.bal +++ b/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_10.bal @@ -1,26 +1,26 @@ -type Batter_01Item record { +type BatterItem_01 record { string id; string 'type; }; type Batters_01 record { - Batter_01Item[] batter; + BatterItem_01[] batter; }; -type Topping_01Item record { +type ToppingItem_01 record { string id; string 'type; }; -type NewRecord_01Item record { +type NewRecordItem_01 record { string id; string 'type; string name; decimal ppu; Batters_01 batters; - Topping_01Item[] topping; + ToppingItem_01[] topping; }; type NewRecord_01 record { - NewRecord_01Item[] newRecord; + NewRecordItem_01[] newRecord; }; diff --git a/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_11.bal b/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_11.bal index bc0c04e15b43..b563adc883f4 100644 --- a/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_11.bal +++ b/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_11.bal @@ -3,7 +3,7 @@ type Special\ object_01 record { int age; }; -type Special\\array\-\?_01Item record { +type Special\\array\-\?Item_01 record { string date; int value; string 'type?; @@ -17,5 +17,5 @@ type NewRecord_01 record { int ϼ\ \+\-\+; boolean ōŊĖ; Special\ object_01 special\ object; - (Special\\array\-\?_01Item[]|Special\\array\-\?_01Item[][])[] special\\array\-\?; + (Special\\array\-\?Item_01[]|Special\\array\-\?Item_01[][])[] special\\array\-\?; }; diff --git a/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_4.bal b/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_4.bal index 38d15ee9f4e5..33fafa8f07f0 100644 --- a/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_4.bal +++ b/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_4.bal @@ -1,4 +1,4 @@ -type People_01Item record { +type PeopleItem_01 record { string firstName; string lastName; string gender; @@ -7,6 +7,6 @@ type People_01Item record { }; type NewRecord_01 record { - People_01Item[] people; + PeopleItem_01[] people; anydata[] addresses; }; diff --git a/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_8.bal b/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_8.bal index feb26a4422dd..49e4fe859373 100644 --- a/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_8.bal +++ b/misc/json-to-record-converter/src/test/resources/project/assert/singleFileProject/sample_8.bal @@ -3,18 +3,18 @@ type Text_01 record { string div; }; -type Identifier_01Item record { +type IdentifierItem_01 record { string system; string value; }; -type Coding_01Item record { +type CodingItem_01 record { string code; string system?; }; type Type_01 record { - Coding_01Item[] coding; + CodingItem_01[] coding; }; type Patient_01 record { @@ -30,7 +30,7 @@ type Provider_01 record { }; type Priority_01 record { - Coding_01Item[] coding; + CodingItem_01[] coding; }; type Prescription_01 record { @@ -41,16 +41,16 @@ type Payee_01 record { Type_01 'type; }; -type CareTeam_01Item record { +type CareTeamItem_01 record { int sequence; Provider_01 provider; }; type DiagnosisCodeableConcept_01 record { - Coding_01Item[] coding; + CodingItem_01[] coding; }; -type Diagnosis_01Item record { +type DiagnosisItem_01 record { int sequence; DiagnosisCodeableConcept_01 diagnosisCodeableConcept; }; @@ -59,14 +59,14 @@ type Coverage_01 record { string reference; }; -type Insurance_01Item record { +type InsuranceItem_01 record { int sequence; boolean focal; Coverage_01 coverage; }; type ProductOrService_01 record { - Coding_01Item[] coding; + CodingItem_01[] coding; }; type UnitPrice_01 record { @@ -83,7 +83,7 @@ type Quantity_01 record { int value; }; -type Detail_01Item record { +type DetailItem_01 record { int sequence; ProductOrService_01 productOrService; UnitPrice_01 unitPrice; @@ -92,21 +92,21 @@ type Detail_01Item record { decimal factor?; }; -type Item_01Item record { +type ItemItem_01 record { int sequence; int[] careTeamSequence; ProductOrService_01 productOrService; string servicedDate; UnitPrice_01 unitPrice; Net_01 net; - Detail_01Item[] detail; + DetailItem_01[] detail; }; type NewRecord_01 record { string resourceType; string id; Text_01 text; - Identifier_01Item[] identifier; + IdentifierItem_01[] identifier; string status; Type_01 'type; string use; @@ -117,8 +117,8 @@ type NewRecord_01 record { Priority_01 priority; Prescription_01 prescription; Payee_01 payee; - CareTeam_01Item[] careTeam; - Diagnosis_01Item[] diagnosis; - Insurance_01Item[] insurance; - Item_01Item[] item; + CareTeamItem_01[] careTeam; + DiagnosisItem_01[] diagnosis; + InsuranceItem_01[] insurance; + ItemItem_01[] item; }; diff --git a/misc/ls-extensions/modules/json-to-record-converter/src/test/resources/ballerina/sample_10_without_conflict.bal b/misc/ls-extensions/modules/json-to-record-converter/src/test/resources/ballerina/sample_10_without_conflict.bal index ace986727faf..ddd76b76ffb9 100644 --- a/misc/ls-extensions/modules/json-to-record-converter/src/test/resources/ballerina/sample_10_without_conflict.bal +++ b/misc/ls-extensions/modules/json-to-record-converter/src/test/resources/ballerina/sample_10_without_conflict.bal @@ -1,13 +1,13 @@ -type Batter_01Item record { +type BatterItem_01 record { string id; string 'type; }; type Batters_01 record { - Batter_01Item[] batter; + BatterItem_01[] batter; }; -type Topping_01Item record { +type ToppingItem_01 record { string id; string 'type; }; @@ -18,7 +18,7 @@ type NewRecordItem record { string name; decimal ppu; Batters_01 batters; - Topping_01Item[] topping; + ToppingItem_01[] topping; }; type NewRecord_01 record { From 961232b1a175db4042a4073e0593e06d297d1e75 Mon Sep 17 00:00:00 2001 From: suleka96 Date: Thu, 22 Dec 2022 03:26:53 +0530 Subject: [PATCH 394/450] Add missing cases and refactor --- .../lang.regexp/src/main/ballerina/regexp.bal | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/langlib/lang.regexp/src/main/ballerina/regexp.bal b/langlib/lang.regexp/src/main/ballerina/regexp.bal index 09f8e7c03deb..baf51759a263 100644 --- a/langlib/lang.regexp/src/main/ballerina/regexp.bal +++ b/langlib/lang.regexp/src/main/ballerina/regexp.bal @@ -147,13 +147,13 @@ public isolated function findAll(RegExp re, string str, int startIndex = 0) retu # match ended, so the list of matches will be non-overlapping. # # ```ballerina -# string:RegExp r = re `([bB].tt[a-z]*)`; +# string:RegExp r = re `(([a-z]u)(bble))`; # # r.findAllGroups("Not A Match").length() ⇒ 0 # -# r.findAllGroups("Butter was bought by Betty but the butter was bitter.").length() ⇒ 4 +# r.findAllGroups("rubble, trouble, bubble, hubble").length() ⇒ 3 # -# r.findAllGroups("Butter was bought by Betty but the butter was bitter.", 7) ⇒ 3 +# r.findAllGroups("rubble, trouble, bubble, hubble", 7) ⇒ 2 # ``` # # + re - the regular expression @@ -318,6 +318,14 @@ public type Replacement ReplacerFunction|string; # r.replace("10010011", "*", 4) ⇒ 1001*11 # # r.replace("122111", "*") ⇒ 122111 +# +# r.replace("10010011", replaceFunction) ⇒ 1*10011 +# +# r.replace("10010011", replaceFunction, 4) ⇒ 1001*11 +# +# isolated function replaceFunction(regexp:Groups groups) returns string { +# return "*"; +# } # ``` # # + re - the regular expression @@ -354,6 +362,14 @@ public isolated function replace(RegExp re, string str, Replacement replacement, # r.replaceAll("10010011", "*", 4) ⇒ 1001*11 # # r.replaceAll("122111", "*") ⇒ 122111 +# +# r.replaceAll("10010011", replaceFunction) ⇒ 1*1*11 +# +# r.replaceAll("10010011", replaceFunction, 4) ⇒ 1001*11 +# +# isolated function replaceFunction(regexp:Groups groups) returns string { +# return "*"; +# } # ``` # # + re - the regular expression @@ -415,7 +431,7 @@ isolated function getReplacementString(Groups groups, Replacement replacement) r # ```ballerina # string:RegExp r = re `,`; # -# r.split("abc,cde,efg") ⇒ ["abc", "cde", "efg"] +# r.split("abc,cde,efg") ⇒ ["abc","cde","efg"] # # r.split("Not Valid") ⇒ ["Not Valid"] # ``` From 9695f92af3f494afc4b7dded8c8af5d49008a533 Mon Sep 17 00:00:00 2001 From: suleka96 Date: Thu, 22 Dec 2022 10:15:56 +0530 Subject: [PATCH 395/450] Change test case --- langlib/lang.regexp/src/main/ballerina/regexp.bal | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/langlib/lang.regexp/src/main/ballerina/regexp.bal b/langlib/lang.regexp/src/main/ballerina/regexp.bal index baf51759a263..03bb9a766879 100644 --- a/langlib/lang.regexp/src/main/ballerina/regexp.bal +++ b/langlib/lang.regexp/src/main/ballerina/regexp.bal @@ -363,12 +363,12 @@ public isolated function replace(RegExp re, string str, Replacement replacement, # # r.replaceAll("122111", "*") ⇒ 122111 # -# r.replaceAll("10010011", replaceFunction) ⇒ 1*1*11 +# r.replaceAll("10010011", replaceFunction) ⇒ 121211 # -# r.replaceAll("10010011", replaceFunction, 4) ⇒ 1001*11 +# r.replaceAll("10010011", replaceFunction, 4) ⇒ 1001211 # # isolated function replaceFunction(regexp:Groups groups) returns string { -# return "*"; +# return groups[0].substring().length().toString(); # } # ``` # From 42c728cc80a2552ad975746f185dd41e5421ea9d Mon Sep 17 00:00:00 2001 From: gabilang Date: Thu, 22 Dec 2022 15:37:55 +0530 Subject: [PATCH 396/450] Rename test --- .../test/expressions/binaryoperations/AddOperationTest.java | 2 +- .../test-src/expressions/binaryoperations/add-operation.bal | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/binaryoperations/AddOperationTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/binaryoperations/AddOperationTest.java index 6c9074ff7ffa..908fa26dff79 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/binaryoperations/AddOperationTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/binaryoperations/AddOperationTest.java @@ -159,7 +159,7 @@ public Object[] dataToTestAdditionWithTypes() { "testStringXmlSubtypesAddition", "testStringSubtypesAddition", "testXmlSubtypesAddition", - "testNullableIntAdd" + "testNullableIntAddition" }; } diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/expressions/binaryoperations/add-operation.bal b/tests/jballerina-unit-test/src/test/resources/test-src/expressions/binaryoperations/add-operation.bal index 0f74013bff79..6f5097874e16 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/expressions/binaryoperations/add-operation.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/expressions/binaryoperations/add-operation.bal @@ -529,7 +529,7 @@ function bam() returns int { return 5; } -function testNullableIntAdd() { +function testNullableIntAddition() { int[] result = [1, 2]; int? val = baz() + result[0]; assertEquality(val, ()); From 9dc46b7c36c28b92b9ce360ed71621b3a6eff8c0 Mon Sep 17 00:00:00 2001 From: sanjana Date: Thu, 22 Dec 2022 16:50:55 +0530 Subject: [PATCH 397/450] Address review suggestion iteration in xml langlib examples --- langlib/lang.xml/src/main/ballerina/xml.bal | 33 ++++++++++----------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/langlib/lang.xml/src/main/ballerina/xml.bal b/langlib/lang.xml/src/main/ballerina/xml.bal index b0a309051daf..72a31faa1610 100644 --- a/langlib/lang.xml/src/main/ballerina/xml.bal +++ b/langlib/lang.xml/src/main/ballerina/xml.bal @@ -54,10 +54,7 @@ public type Text xml; # Returns number of xml items in an xml value. # # ```ballerina -# xml `BallerinaJava`.length() ⇒ 2 -# -# xml `John20 -# adminteacher`.length() ⇒ 4 +# xml `Sherlock Holmes`.length() ⇒ 2 # ``` # # + x - xml item @@ -179,8 +176,8 @@ public isolated function setName(Element elem, string xName) = @java:Method { # The keys in the map are the expanded names of the attributes. # # ```ballerina -# xml:Element a = xml `John`; -# a.getAttributes() ⇒ {"gender":"male","isEmployed":"yes"} +# xml:Element a = xml `John`; +# a.getAttributes() ⇒ {"id":"1012","employed":"yes"} # ``` # # + x - xml element @@ -276,8 +273,8 @@ public isolated function data(xml x) returns string = @java:Method { # Returns the target part of the processing instruction. # # ```ballerina -# xml:ProcessingInstruction p = xml ``; -# p.getTarget() ⇒ website +# xml:ProcessingInstruction p = xml ``; +# p.getTarget() ⇒ sort # ``` # # + x - xml processing instruction item @@ -290,11 +287,11 @@ public isolated function getTarget(ProcessingInstruction x) returns string = @ja # Returns the content of a processing instruction or comment item. # # ```ballerina -# xml:ProcessingInstruction p = xml ``; -# person.getContent() ⇒ ballerina.io +# xml:ProcessingInstruction p = xml ``; +# p.getContent() ⇒ ascending # -# xml:Comment comment = xml ``; -# comment.getContent() ⇒ Example comment +# xml:Comment comment = xml ``; +# comment.getContent() ⇒ Employees by department # ``` # # + x - xml item @@ -309,9 +306,9 @@ public isolated function getContent(ProcessingInstruction|Comment x) returns str # ```ballerina # xml:createElement( # "book", -# {title: "Ballerina", author: "Anjana"}, -# xml `2022` -# ) ⇒ 2022 +# {title: "Ballerina", year: "2022"}, +# xml `Anjana` +# ) ⇒ Anjana # ``` # # + name - the name of the new element @@ -476,8 +473,8 @@ public isolated function elementChildren(xml x, string? nm = ()) returns xmlJavaBallerina`; # books.map(function (xml xmlContent) returns xml { -# return xml `${xmlContent.children()}`; -# }) ⇒ JavaBallerina +# return xml `${xmlContent.children()}`; +# }) ⇒ JavaBallerina # ``` # # + x - the xml value @@ -550,7 +547,7 @@ public isolated function fromString(string s) returns xml|error = @java:Method { # Selects all the items in a sequence that are of type `xml:Text`. # # ```ballerina -# xml books = xml `BallerinaJava`; +# xml books = xml `BallerinaJava`; # books.text() ⇒ BallerinaJava # ``` # From e7a747e6ae0fc137a7b933ee1cd091826412881a Mon Sep 17 00:00:00 2001 From: dulajdilshan Date: Fri, 2 Dec 2022 11:07:42 +0530 Subject: [PATCH 398/450] Add examples for the map langlib --- langlib/lang.map/src/main/ballerina/map.bal | 88 +++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/langlib/lang.map/src/main/ballerina/map.bal b/langlib/lang.map/src/main/ballerina/map.bal index 87ab4ddbe5ea..cab73ef1e67f 100644 --- a/langlib/lang.map/src/main/ballerina/map.bal +++ b/langlib/lang.map/src/main/ballerina/map.bal @@ -30,6 +30,11 @@ type Type1 any|error; # Returns number of members of a map. # +# ```ballerina +# map vowels = {a: "A", e: "E", i: "I", o: "O", u: "U"}; +# int length = vowels.length(); +# ``` +# # + m - the map # + return - number of members in parameter `m` public isolated function length(map m) returns int =@java:Method { @@ -39,6 +44,20 @@ public isolated function length(map m) returns int =@java:Method { # Returns an iterator over a map. # +# ```ballerina +# map vowels = {a: "A", e: "E", i: "I", o: "O", u: "U"}; +# +# // iterator() returns an iterator object with the `next()` method. +# var vowelsIter = vowels.iterator(); +# +# // `next()` can be used to get the next element of the map. +# record {|string value;|}? nextVal = vowelsIter.next(); +# +# while nextVal != null { +# nextVal = vowelsIter.next(); +# } +# ``` +# # The iterator will iterate over the members of the map not the keys. # The function `entries` can be used to iterate over the keys and members together. # The function `keys` can be used to iterator over just the keys. @@ -56,6 +75,11 @@ public isolated function iterator(map m) returns object { # Returns the member of a map with given key. # +# ```ballerina +# map indices = {a: 1, b: 2, c: 3, d: 4}; +# int indexOfA = indices.get("a"); +# ``` +# # This for use in a case where it is known that the map has a specific key, # and accordingly panics if parameter `m` does not have a member with parameter `k` key. # @@ -69,6 +93,11 @@ public isolated function get(map m, string k) returns Type = @java:Method # Returns a map containing [key, member] pair as the value for each key. # +# ```ballerina +# map indices = {a: 1, b: 2, c: 3, d: 4}; +# map<[string, int]> indexEntries = indices.entries(); +# ``` +# # + m - the map # + return - a new map of [key, member] pairs public isolated function entries(map m) returns map<[string, Type]> = @java:Method { @@ -80,6 +109,13 @@ public isolated function entries(map m) returns map<[string, Type]> = @jav # Applies a function each member of a map and returns a map of the result. # +# ```ballerina +# map heights = {"Carl": 1.7, "Bob": 1.778, "Max": 1.81}; +# map heightsCm = heights.map(function(float h) returns float { +# return h * 10; +# }); +# ``` +# # The resulting map will have the same keys as the argument map. # # + m - the map @@ -92,6 +128,14 @@ public isolated function 'map(map m, @isolatedParam function(Type val) ret # Applies a function to each member of a map. # +# ```ballerina +# map heights = {"Carl": 1.7, "Bob": 1.778, "Max": 1.81}; +# float totalHeight = 0; +# heights.forEach(function (float height) { +# totalHeight += height; +# }); +# ``` +# # The parameter `func` is applied to each member of parameter `m`. # # + m - the map @@ -103,6 +147,13 @@ public isolated function forEach(map m, @isolatedParam function(Type val) # Selects the members from a map for which a function returns true. # +# ```ballerina +# map heights = {"Carl": 1.7, "Bob": 1.778, "Max": 1.81}; +# map selected = heights.filter(function (float height) returns boolean { +# return height > 1.75; +# }); +# ``` +# # + m - the map # + func - a predicate to apply to each element to test whether it should be included # + return - new map containing members for which parameter `func` evaluates to true @@ -113,6 +164,13 @@ public isolated function filter(map m, @isolatedParam function(Type val) r # Combines the members of a map using a combining function. # +# ```ballerina +# map marks = {"Carl": 85, "Bob": 50, "Max": 60}; +# int totalMarks = marks.reduce(function (int accumulator, int value) returns int { +# return accumulator + value; +# }, 0); +# ``` +# # The combining function takes the combined value so far and a member of the map, # and returns a new combined value. # @@ -128,6 +186,11 @@ public isolated function reduce(map m, @isolatedParam function(Type1 accum # Removes a member of a map. # +# ```ballerina +# map marks = {"Carl": 85, "Bob": 50, "Max": 60}; +# _ = marks.remove("Carl"); +# ``` +# # This removes the member of parameter `m` with key parameter `k` and returns it. # It panics if there is no such member. # @@ -141,6 +204,11 @@ public isolated function remove(map m, string k) returns Type = @java:Meth # Removes a member of a map with a given key, if the map has member with the key. # +# ```ballerina +# map marks = {"Carl": 85, "Bob": 50, "Max": 60}; +# int? removed = marks.removeIfHasKey("Carl"); +# ``` +# # If parameter `m` has a member with key parameter `k`, it removes and returns it; # otherwise it returns `()`. # @@ -154,6 +222,11 @@ public isolated function removeIfHasKey(map m, string k) returns Type? = @ # Removes all members of a map. # +# ```ballerina +# map marks = {"Carl": 85, "Bob": 50, "Max": 60}; +# marks.removeAll(); +# ``` +# # This panics if any member cannot be removed. # # + m - the map @@ -164,6 +237,11 @@ public isolated function removeAll(map m) returns () = @java:Method { # Tests whether a map value has a member with a given key. # +# ```ballerina +# map vowels = {a: "A", e: "E", i: "I", o: "O", u: "U"}; +# boolean hasKey = vowels.hasKey("e"); +# ``` +# # + m - the map # + k - the key # + return - true if parameter `m` has a member with key parameter `k` @@ -174,6 +252,11 @@ public isolated function hasKey(map m, string k) returns boolean = @java:M # Returns a list of all the keys of a map. # +# ```ballerina +# map vowels = {a: "A", e: "E", i: "I", o: "O", u: "U"}; +# string[] voWelKeys = vowels.keys(); +# ``` +# # + m - the map # + return - a new list of all keys public isolated function keys(map m) returns string[] = @java:Method { @@ -183,6 +266,11 @@ public isolated function keys(map m) returns string[] = @java:Method # Returns a list of all the members of a map. # +# ```ballerina +# map marks = {"Carl": 85, "Bob": 50, "Max": 60}; +# int[] marksArray = marks.toArray(); +# ``` +# # + m - the map # + return - an array whose members are the members of parameter `m` public isolated function toArray(map m) returns Type[] = @java:Method { From 836638df2f7a1d1b4194e7491377e6e4604222cf Mon Sep 17 00:00:00 2001 From: dulajdilshan Date: Thu, 8 Dec 2022 10:23:35 +0530 Subject: [PATCH 399/450] Address review comments and improve consistency --- langlib/lang.map/src/main/ballerina/map.bal | 154 ++++++++++++++------ 1 file changed, 113 insertions(+), 41 deletions(-) diff --git a/langlib/lang.map/src/main/ballerina/map.bal b/langlib/lang.map/src/main/ballerina/map.bal index cab73ef1e67f..25c8482e3bfa 100644 --- a/langlib/lang.map/src/main/ballerina/map.bal +++ b/langlib/lang.map/src/main/ballerina/map.bal @@ -31,8 +31,8 @@ type Type1 any|error; # Returns number of members of a map. # # ```ballerina -# map vowels = {a: "A", e: "E", i: "I", o: "O", u: "U"}; -# int length = vowels.length(); +# map marksMap = {"Carl": 85, "Bob": 50, "Max": 60}; +# int length = marksMap.length(); # ``` # # + m - the map @@ -45,17 +45,11 @@ public isolated function length(map m) returns int =@java:Method { # Returns an iterator over a map. # # ```ballerina -# map vowels = {a: "A", e: "E", i: "I", o: "O", u: "U"}; -# -# // iterator() returns an iterator object with the `next()` method. -# var vowelsIter = vowels.iterator(); -# -# // `next()` can be used to get the next element of the map. -# record {|string value;|}? nextVal = vowelsIter.next(); -# -# while nextVal != null { -# nextVal = vowelsIter.next(); -# } +# map marksMap = {"Carl": 85, "Bob": 50, "Max": 60}; +# object { +# public isolated function next() returns record {|int value;|}?; +# } iterator = marksMap.iterator(); +# record {|int value;|}? next = iterator.next(); # ``` # # The iterator will iterate over the members of the map not the keys. @@ -76,8 +70,20 @@ public isolated function iterator(map m) returns object { # Returns the member of a map with given key. # # ```ballerina -# map indices = {a: 1, b: 2, c: 3, d: 4}; -# int indexOfA = indices.get("a"); +# map employees = { +# "Jo": {firstName: "Jo", lastName: "David", id: 2121}, +# "Emma": {firstName: "Jo", lastName: "David", id: 2121}, +# "John": {firstName: "John", lastName: "Doe", id: 2123} +# }; +# +# string key = "Jo"; +# Employee employee = employees.get(key); +# +# type Employee record { +# string firstName; +# string lastName?; +# int id; +# }; # ``` # # This for use in a case where it is known that the map has a specific key, @@ -94,8 +100,8 @@ public isolated function get(map m, string k) returns Type = @java:Method # Returns a map containing [key, member] pair as the value for each key. # # ```ballerina -# map indices = {a: 1, b: 2, c: 3, d: 4}; -# map<[string, int]> indexEntries = indices.entries(); +# map marksMap = {"Carl": 85, "Bob": 50, "Max": 60}; +# map<[string, int]> entries = marksMap.entries(); # ``` # # + m - the map @@ -110,10 +116,31 @@ public isolated function entries(map m) returns map<[string, Type]> = @jav # Applies a function each member of a map and returns a map of the result. # # ```ballerina -# map heights = {"Carl": 1.7, "Bob": 1.778, "Max": 1.81}; -# map heightsCm = heights.map(function(float h) returns float { -# return h * 10; +# map marksMap = {"Carl": 85, "Bob": 50, "Max": 60}; +# map results = marksMap.'map((marks) => marks > 50); +# +# map employees = { +# "Jo": {firstName: "Jo", lastName: "David", id: 2121}, +# "Emma": {firstName: "Jo", lastName: "David", id: 2121}, +# "John": {firstName: "John", lastName: "Doe", id: 2123} +# }; +# +# map fullNames = +# employees.'map(isolated function(Employee employee) returns string { +# string? lastName = employee.lastName; +# +# if lastName is () { +# return employee.firstName; +# } +# +# return string `${employee.firstName} ${lastName}`; # }); +# +# type Employee record { +# string firstName; +# string lastName?; +# int id; +# }; # ``` # # The resulting map will have the same keys as the argument map. @@ -129,11 +156,23 @@ public isolated function 'map(map m, @isolatedParam function(Type val) ret # Applies a function to each member of a map. # # ```ballerina -# map heights = {"Carl": 1.7, "Bob": 1.778, "Max": 1.81}; -# float totalHeight = 0; -# heights.forEach(function (float height) { -# totalHeight += height; +# map employees = { +# "Jo": {name: "Jo", id: 2121, salary: 1200}, +# "Emma": {name: "Emma", id: 2122, salary: ()}, +# "John": {name: "John", id: 2123, salary: 1500} +# }; +# +# employees.forEach(isolated function (Employee employee) { +# if employee.salary == () { +# employee.salary = 1000; +# } # }); +# +# type Employee record {| +# string name; +# int id; +# decimal? salary; +# |}; # ``` # # The parameter `func` is applied to each member of parameter `m`. @@ -148,10 +187,25 @@ public isolated function forEach(map m, @isolatedParam function(Type val) # Selects the members from a map for which a function returns true. # # ```ballerina -# map heights = {"Carl": 1.7, "Bob": 1.778, "Max": 1.81}; -# map selected = heights.filter(function (float height) returns boolean { -# return height > 1.75; +# map marksMap = {"Carl": 85, "Bob": 50, "Max": 60}; +# map filteredMarks = marksMap.filter((marks) => marks >= 50); +# +# map employees = { +# "Jo": {name: "Jo", id: 2121, salary: 1200}, +# "Emma": {name: "Emma", id: 2122, salary: 900}, +# "John": {name: "John", id: 2123, salary: 1500} +# }; +# +# map filteredBySalary = employees.filter(isolated function (Employee employee) returns boolean { +# decimal salary = employee.salary; +# return salary > 1000d && salary < 1500d; # }); +# +# type Employee record {| +# string name; +# int id; +# decimal salary; +# |}; # ``` # # + m - the map @@ -165,10 +219,25 @@ public isolated function filter(map m, @isolatedParam function(Type val) r # Combines the members of a map using a combining function. # # ```ballerina -# map marks = {"Carl": 85, "Bob": 50, "Max": 60}; -# int totalMarks = marks.reduce(function (int accumulator, int value) returns int { -# return accumulator + value; -# }, 0); +# map marksMap = {"Carl": 85, "Bob": 50, "Max": 60}; +# int totalMarks = marksMap.reduce(isolated function (int accumulatedTotal, int marks) returns int => accumulatedTotal + marks, 0); +# +# map employees = { +# "Jo": {name: "Jo", id: 2121, salary: 1200}, +# "Emma": {name: "Emma", id: 2122, salary: 900}, +# "John": {name: "John", id: 2123, salary: 1500} +# }; +# +# decimal currentTotal = 10500; +# decimal totalSalary = employees.reduce(isolated function (decimal accumulatedTotal, Employee employee) returns decimal { +# return accumulatedTotal + employee.salary; +# }, currentTotal); +# +# type Employee record {| +# string name; +# int id; +# decimal salary; +# |}; # ``` # # The combining function takes the combined value so far and a member of the map, @@ -187,8 +256,9 @@ public isolated function reduce(map m, @isolatedParam function(Type1 accum # Removes a member of a map. # # ```ballerina -# map marks = {"Carl": 85, "Bob": 50, "Max": 60}; -# _ = marks.remove("Carl"); +# map marksMap = {"Carl": 85, "Bob": 50, "Max": 60}; +# string key = "Carl"; +# int removedMarks = marksMap.remove(key); # ``` # # This removes the member of parameter `m` with key parameter `k` and returns it. @@ -205,8 +275,9 @@ public isolated function remove(map m, string k) returns Type = @java:Meth # Removes a member of a map with a given key, if the map has member with the key. # # ```ballerina -# map marks = {"Carl": 85, "Bob": 50, "Max": 60}; -# int? removed = marks.removeIfHasKey("Carl"); +# map marksMap = {"Carl": 85, "Bob": 50, "Max": 60}; +# string key = "John"; +# int? removedMarks = marksMap.removeIfHasKey(key); # ``` # # If parameter `m` has a member with key parameter `k`, it removes and returns it; @@ -223,8 +294,8 @@ public isolated function removeIfHasKey(map m, string k) returns Type? = @ # Removes all members of a map. # # ```ballerina -# map marks = {"Carl": 85, "Bob": 50, "Max": 60}; -# marks.removeAll(); +# map marksMap = {"Carl": 85, "Bob": 50, "Max": 60}; +# marksMap.removeAll(); # ``` # # This panics if any member cannot be removed. @@ -238,8 +309,9 @@ public isolated function removeAll(map m) returns () = @java:Method { # Tests whether a map value has a member with a given key. # # ```ballerina -# map vowels = {a: "A", e: "E", i: "I", o: "O", u: "U"}; -# boolean hasKey = vowels.hasKey("e"); +# map marksMap = {"Carl": 85, "Bob": 50, "Max": 60}; +# string key = "Carl"; +# boolean hasMarks = marksMap.hasKey(key); # ``` # # + m - the map @@ -253,8 +325,8 @@ public isolated function hasKey(map m, string k) returns boolean = @java:M # Returns a list of all the keys of a map. # # ```ballerina -# map vowels = {a: "A", e: "E", i: "I", o: "O", u: "U"}; -# string[] voWelKeys = vowels.keys(); +# map marksMap = {"Carl": 85, "Bob": 50, "Max": 60}; +# string[] keys = marksMap.keys(); # ``` # # + m - the map From f04e6adf2aa210b90b3a49ba32ac1be6f06a85df Mon Sep 17 00:00:00 2001 From: dulajdilshan Date: Tue, 13 Dec 2022 11:12:24 +0530 Subject: [PATCH 400/450] Address a review comment --- langlib/lang.map/src/main/ballerina/map.bal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/langlib/lang.map/src/main/ballerina/map.bal b/langlib/lang.map/src/main/ballerina/map.bal index 25c8482e3bfa..36ad71dd4457 100644 --- a/langlib/lang.map/src/main/ballerina/map.bal +++ b/langlib/lang.map/src/main/ballerina/map.bal @@ -72,7 +72,7 @@ public isolated function iterator(map m) returns object { # ```ballerina # map employees = { # "Jo": {firstName: "Jo", lastName: "David", id: 2121}, -# "Emma": {firstName: "Jo", lastName: "David", id: 2121}, +# "Emma": {firstName: "Emma", lastName: "White", id: 2122}, # "John": {firstName: "John", lastName: "Doe", id: 2123} # }; # @@ -121,7 +121,7 @@ public isolated function entries(map m) returns map<[string, Type]> = @jav # # map employees = { # "Jo": {firstName: "Jo", lastName: "David", id: 2121}, -# "Emma": {firstName: "Jo", lastName: "David", id: 2121}, +# "Emma": {firstName: "Emma", lastName: "White", id: 2122}, # "John": {firstName: "John", lastName: "Doe", id: 2123} # }; # From a6fd7499175a29b81951c6b099cc36be7915f69f Mon Sep 17 00:00:00 2001 From: dulajdilshan Date: Thu, 15 Dec 2022 14:28:21 +0530 Subject: [PATCH 401/450] Change according to the new example pattern --- langlib/lang.map/src/main/ballerina/map.bal | 174 +++++--------------- 1 file changed, 44 insertions(+), 130 deletions(-) diff --git a/langlib/lang.map/src/main/ballerina/map.bal b/langlib/lang.map/src/main/ballerina/map.bal index 36ad71dd4457..2d0cd497bc28 100644 --- a/langlib/lang.map/src/main/ballerina/map.bal +++ b/langlib/lang.map/src/main/ballerina/map.bal @@ -30,9 +30,8 @@ type Type1 any|error; # Returns number of members of a map. # -# ```ballerina -# map marksMap = {"Carl": 85, "Bob": 50, "Max": 60}; -# int length = marksMap.length(); +# ``` +# {"Carl": 85, "Bob": 50, "Max": 60}.length() ⇒ 3 # ``` # # + m - the map @@ -44,11 +43,11 @@ public isolated function length(map m) returns int =@java:Method { # Returns an iterator over a map. # -# ```ballerina -# map marksMap = {"Carl": 85, "Bob": 50, "Max": 60}; +# ``` +# map marks = {"Carl": 85, "Bob": 50, "Max": 60}; # object { # public isolated function next() returns record {|int value;|}?; -# } iterator = marksMap.iterator(); +# } iterator = marks.iterator(); # record {|int value;|}? next = iterator.next(); # ``` # @@ -69,21 +68,8 @@ public isolated function iterator(map m) returns object { # Returns the member of a map with given key. # -# ```ballerina -# map employees = { -# "Jo": {firstName: "Jo", lastName: "David", id: 2121}, -# "Emma": {firstName: "Emma", lastName: "White", id: 2122}, -# "John": {firstName: "John", lastName: "Doe", id: 2123} -# }; -# -# string key = "Jo"; -# Employee employee = employees.get(key); -# -# type Employee record { -# string firstName; -# string lastName?; -# int id; -# }; +# ``` +# {"Carl": 85, "Bob": 50, "Max": 60}.get("Carl") ⇒ 85 # ``` # # This for use in a case where it is known that the map has a specific key, @@ -99,9 +85,9 @@ public isolated function get(map m, string k) returns Type = @java:Method # Returns a map containing [key, member] pair as the value for each key. # -# ```ballerina -# map marksMap = {"Carl": 85, "Bob": 50, "Max": 60}; -# map<[string, int]> entries = marksMap.entries(); +# ``` +# map marks = {"Carl": 85, "Bob": 50}; +# marks.entries() ⇒ {"Carl": ["Carl", 85], "Bob": ["Bob", 50]} # ``` # # + m - the map @@ -115,32 +101,9 @@ public isolated function entries(map m) returns map<[string, Type]> = @jav # Applies a function each member of a map and returns a map of the result. # -# ```ballerina -# map marksMap = {"Carl": 85, "Bob": 50, "Max": 60}; -# map results = marksMap.'map((marks) => marks > 50); -# -# map employees = { -# "Jo": {firstName: "Jo", lastName: "David", id: 2121}, -# "Emma": {firstName: "Emma", lastName: "White", id: 2122}, -# "John": {firstName: "John", lastName: "Doe", id: 2123} -# }; -# -# map fullNames = -# employees.'map(isolated function(Employee employee) returns string { -# string? lastName = employee.lastName; -# -# if lastName is () { -# return employee.firstName; -# } -# -# return string `${employee.firstName} ${lastName}`; -# }); -# -# type Employee record { -# string firstName; -# string lastName?; -# int id; -# }; +# ``` +# map marks = {"Carl": 85, "Bob": 50, "Max": 60}; +# marks.'map((marks) => marks > 50) ⇒ {"Carl": true, "Bob": false}; # ``` # # The resulting map will have the same keys as the argument map. @@ -155,24 +118,12 @@ public isolated function 'map(map m, @isolatedParam function(Type val) ret # Applies a function to each member of a map. # -# ```ballerina -# map employees = { -# "Jo": {name: "Jo", id: 2121, salary: 1200}, -# "Emma": {name: "Emma", id: 2122, salary: ()}, -# "John": {name: "John", id: 2123, salary: 1500} -# }; -# -# employees.forEach(isolated function (Employee employee) { -# if employee.salary == () { -# employee.salary = 1000; -# } +# ``` +# int total = 0; +# {"Carl": 85, "Bob": 50, "Max": 60}.forEach(function (int m) { +# total += m; # }); -# -# type Employee record {| -# string name; -# int id; -# decimal? salary; -# |}; +# total ⇒ 195 # ``` # # The parameter `func` is applied to each member of parameter `m`. @@ -186,26 +137,9 @@ public isolated function forEach(map m, @isolatedParam function(Type val) # Selects the members from a map for which a function returns true. # -# ```ballerina -# map marksMap = {"Carl": 85, "Bob": 50, "Max": 60}; -# map filteredMarks = marksMap.filter((marks) => marks >= 50); -# -# map employees = { -# "Jo": {name: "Jo", id: 2121, salary: 1200}, -# "Emma": {name: "Emma", id: 2122, salary: 900}, -# "John": {name: "John", id: 2123, salary: 1500} -# }; -# -# map filteredBySalary = employees.filter(isolated function (Employee employee) returns boolean { -# decimal salary = employee.salary; -# return salary > 1000d && salary < 1500d; -# }); -# -# type Employee record {| -# string name; -# int id; -# decimal salary; -# |}; +# ``` +# map marks = {"Carl": 85, "Bob": 50, "Max": 60}; +# marks.filter((m) => m >= 60) ⇒ {"Carl": 85, "Max": 60} # ``` # # + m - the map @@ -218,26 +152,9 @@ public isolated function filter(map m, @isolatedParam function(Type val) r # Combines the members of a map using a combining function. # -# ```ballerina -# map marksMap = {"Carl": 85, "Bob": 50, "Max": 60}; -# int totalMarks = marksMap.reduce(isolated function (int accumulatedTotal, int marks) returns int => accumulatedTotal + marks, 0); -# -# map employees = { -# "Jo": {name: "Jo", id: 2121, salary: 1200}, -# "Emma": {name: "Emma", id: 2122, salary: 900}, -# "John": {name: "John", id: 2123, salary: 1500} -# }; -# -# decimal currentTotal = 10500; -# decimal totalSalary = employees.reduce(isolated function (decimal accumulatedTotal, Employee employee) returns decimal { -# return accumulatedTotal + employee.salary; -# }, currentTotal); -# -# type Employee record {| -# string name; -# int id; -# decimal salary; -# |}; +# ``` +# map marks = {"Carl": 85, "Bob": 50, "Max": 60}; +# marks.reduce(isolated function (int accTot, int next) returns int => accTot + next, 0) ⇒ 195; # ``` # # The combining function takes the combined value so far and a member of the map, @@ -255,10 +172,10 @@ public isolated function reduce(map m, @isolatedParam function(Type1 accum # Removes a member of a map. # -# ```ballerina -# map marksMap = {"Carl": 85, "Bob": 50, "Max": 60}; -# string key = "Carl"; -# int removedMarks = marksMap.remove(key); +# ``` +# map marks = {"Carl": 85, "Bob": 50, "Max": 60}; +# marks.remove("Carl") ⇒ 85 +# marks ⇒ {"Bob": 50, "Max": 60} # ``` # # This removes the member of parameter `m` with key parameter `k` and returns it. @@ -274,15 +191,15 @@ public isolated function remove(map m, string k) returns Type = @java:Meth # Removes a member of a map with a given key, if the map has member with the key. # -# ```ballerina -# map marksMap = {"Carl": 85, "Bob": 50, "Max": 60}; -# string key = "John"; -# int? removedMarks = marksMap.removeIfHasKey(key); -# ``` -# # If parameter `m` has a member with key parameter `k`, it removes and returns it; # otherwise it returns `()`. # +# ``` +# map marks = {"Carl": 85, "Bob": 50, "Max": 60}; +# marks.removeIfHasKey("Carl") ⇒ 85 +# marks ⇒ {"Bob": 50, "Max": 60} +# ``` +# # + m - the map # + k - the key # + return - the member of parameter `m` that had key parameter `k`, or `()` if parameter `m` does not have a key parameter `k` @@ -293,9 +210,10 @@ public isolated function removeIfHasKey(map m, string k) returns Type? = @ # Removes all members of a map. # -# ```ballerina -# map marksMap = {"Carl": 85, "Bob": 50, "Max": 60}; -# marksMap.removeAll(); +# ``` +# map marks = {"Carl": 85, "Bob": 50, "Max": 60}; +# marks.removeAll(); +# marks ⇒ {} # ``` # # This panics if any member cannot be removed. @@ -308,10 +226,8 @@ public isolated function removeAll(map m) returns () = @java:Method { # Tests whether a map value has a member with a given key. # -# ```ballerina -# map marksMap = {"Carl": 85, "Bob": 50, "Max": 60}; -# string key = "Carl"; -# boolean hasMarks = marksMap.hasKey(key); +# ``` +# {"Carl": 85, "Bob": 50, "Max": 60}.hasKey("Carl") ⇒ true # ``` # # + m - the map @@ -324,9 +240,8 @@ public isolated function hasKey(map m, string k) returns boolean = @java:M # Returns a list of all the keys of a map. # -# ```ballerina -# map marksMap = {"Carl": 85, "Bob": 50, "Max": 60}; -# string[] keys = marksMap.keys(); +# ``` +# {"Carl": 85, "Bob": 50, "Max": 60}.keys() ⇒ ["Carl", "Bob", "Max"] # ``` # # + m - the map @@ -338,9 +253,8 @@ public isolated function keys(map m) returns string[] = @java:Method # Returns a list of all the members of a map. # -# ```ballerina -# map marks = {"Carl": 85, "Bob": 50, "Max": 60}; -# int[] marksArray = marks.toArray(); +# ``` +# {"Carl": 85, "Bob": 50, "Max": 60}.toArray() ⇒ [85, 50, 60] # ``` # # + m - the map From 5ed723ab46a473e07c5e327a3c2d6f009c128f9e Mon Sep 17 00:00:00 2001 From: dulajdilshan Date: Tue, 20 Dec 2022 10:26:10 +0530 Subject: [PATCH 402/450] Address a review iteration --- langlib/lang.map/src/main/ballerina/map.bal | 97 ++++++++++++--------- 1 file changed, 55 insertions(+), 42 deletions(-) diff --git a/langlib/lang.map/src/main/ballerina/map.bal b/langlib/lang.map/src/main/ballerina/map.bal index 2d0cd497bc28..960e4ca1fc38 100644 --- a/langlib/lang.map/src/main/ballerina/map.bal +++ b/langlib/lang.map/src/main/ballerina/map.bal @@ -30,7 +30,7 @@ type Type1 any|error; # Returns number of members of a map. # -# ``` +# ```ballerina # {"Carl": 85, "Bob": 50, "Max": 60}.length() ⇒ 3 # ``` # @@ -43,18 +43,18 @@ public isolated function length(map m) returns int =@java:Method { # Returns an iterator over a map. # -# ``` +# The iterator will iterate over the members of the map not the keys. +# The function `entries` can be used to iterate over the keys and members together. +# The function `keys` can be used to iterator over just the keys. +# +# ```ballerina # map marks = {"Carl": 85, "Bob": 50, "Max": 60}; # object { # public isolated function next() returns record {|int value;|}?; # } iterator = marks.iterator(); -# record {|int value;|}? next = iterator.next(); +# iterator.next() ⇒ {"value":85} # ``` # -# The iterator will iterate over the members of the map not the keys. -# The function `entries` can be used to iterate over the keys and members together. -# The function `keys` can be used to iterator over just the keys. -# # + m - the map # + return - a new iterator object that will iterate over the members of parameter `m` public isolated function iterator(map m) returns object { @@ -68,13 +68,15 @@ public isolated function iterator(map m) returns object { # Returns the member of a map with given key. # -# ``` -# {"Carl": 85, "Bob": 50, "Max": 60}.get("Carl") ⇒ 85 -# ``` -# # This for use in a case where it is known that the map has a specific key, # and accordingly panics if parameter `m` does not have a member with parameter `k` key. # +# ```ballerina +# {"Carl": 85, "Bob": 50, "Max": 60}.get("Carl") ⇒ 85 +# +# {"Carl": 85, "Bob": 50, "Max": 60}.get("John") ⇒ panic +# ``` +# # + m - the map # + k - the key # + return - member with parameter `k` key @@ -85,9 +87,9 @@ public isolated function get(map m, string k) returns Type = @java:Method # Returns a map containing [key, member] pair as the value for each key. # -# ``` +# ```ballerina # map marks = {"Carl": 85, "Bob": 50}; -# marks.entries() ⇒ {"Carl": ["Carl", 85], "Bob": ["Bob", 50]} +# marks.entries() ⇒ {"Carl":["Carl",85],"Bob":["Bob",50]} # ``` # # + m - the map @@ -101,13 +103,13 @@ public isolated function entries(map m) returns map<[string, Type]> = @jav # Applies a function each member of a map and returns a map of the result. # -# ``` +# The resulting map will have the same keys as the argument map. +# +# ```ballerina # map marks = {"Carl": 85, "Bob": 50, "Max": 60}; -# marks.'map((marks) => marks > 50) ⇒ {"Carl": true, "Bob": false}; +# marks.map((marks) => marks > 50) ⇒ {"Carl":true,"Bob":false}; # ``` # -# The resulting map will have the same keys as the argument map. -# # + m - the map # + func - a function to apply to each member # + return - new map containing result of applying parameter `func` to each member @@ -118,7 +120,9 @@ public isolated function 'map(map m, @isolatedParam function(Type val) ret # Applies a function to each member of a map. # -# ``` +# The parameter `func` is applied to each member of parameter `m`. +# +# ```ballerina # int total = 0; # {"Carl": 85, "Bob": 50, "Max": 60}.forEach(function (int m) { # total += m; @@ -126,8 +130,6 @@ public isolated function 'map(map m, @isolatedParam function(Type val) ret # total ⇒ 195 # ``` # -# The parameter `func` is applied to each member of parameter `m`. -# # + m - the map # + func - a function to apply to each member public isolated function forEach(map m, @isolatedParam function(Type val) returns () func) returns () = @java:Method { @@ -137,9 +139,9 @@ public isolated function forEach(map m, @isolatedParam function(Type val) # Selects the members from a map for which a function returns true. # -# ``` +# ```ballerina # map marks = {"Carl": 85, "Bob": 50, "Max": 60}; -# marks.filter((m) => m >= 60) ⇒ {"Carl": 85, "Max": 60} +# marks.filter(m => m >= 60) ⇒ {"Carl":85,"Max":60} # ``` # # + m - the map @@ -152,14 +154,14 @@ public isolated function filter(map m, @isolatedParam function(Type val) r # Combines the members of a map using a combining function. # -# ``` -# map marks = {"Carl": 85, "Bob": 50, "Max": 60}; -# marks.reduce(isolated function (int accTot, int next) returns int => accTot + next, 0) ⇒ 195; -# ``` -# # The combining function takes the combined value so far and a member of the map, # and returns a new combined value. # +# ```ballerina +# map marks = {"Carl": 85, "Bob": 50, "Max": 60}; +# marks.reduce(isolated function (int total, int next) returns int => total + next, 0) ⇒ 195; +# ``` +# # + m - the map # + func - combining function # + initial - initial value for the first argument of combining parameter `func` @@ -172,14 +174,17 @@ public isolated function reduce(map m, @isolatedParam function(Type1 accum # Removes a member of a map. # -# ``` +# This removes the member of parameter `m` with key parameter `k` and returns it. +# It panics if there is no such member. +# +# ```ballerina # map marks = {"Carl": 85, "Bob": 50, "Max": 60}; +# # marks.remove("Carl") ⇒ 85 -# marks ⇒ {"Bob": 50, "Max": 60} -# ``` +# marks ⇒ {"Bob":50,"Max":60} # -# This removes the member of parameter `m` with key parameter `k` and returns it. -# It panics if there is no such member. +# marks.remove("John") ⇒ panic +# ``` # # + m - the map # + k - the key @@ -194,10 +199,13 @@ public isolated function remove(map m, string k) returns Type = @java:Meth # If parameter `m` has a member with key parameter `k`, it removes and returns it; # otherwise it returns `()`. # -# ``` +# ```ballerina # map marks = {"Carl": 85, "Bob": 50, "Max": 60}; +# # marks.removeIfHasKey("Carl") ⇒ 85 -# marks ⇒ {"Bob": 50, "Max": 60} +# marks ⇒ {"Bob":50,"Max":60} +# +# marks.removeIfHasKey("John") is () ⇒ true # ``` # # + m - the map @@ -210,13 +218,16 @@ public isolated function removeIfHasKey(map m, string k) returns Type? = @ # Removes all members of a map. # -# ``` +# This panics if any member cannot be removed. +# +# ```ballerina # map marks = {"Carl": 85, "Bob": 50, "Max": 60}; # marks.removeAll(); # marks ⇒ {} -# ``` # -# This panics if any member cannot be removed. +# map values = {"x": 10, "y": 20}; +# values.removeAll() ⇒ panic; +# ``` # # + m - the map public isolated function removeAll(map m) returns () = @java:Method { @@ -226,8 +237,10 @@ public isolated function removeAll(map m) returns () = @java:Method { # Tests whether a map value has a member with a given key. # -# ``` +# ```ballerina # {"Carl": 85, "Bob": 50, "Max": 60}.hasKey("Carl") ⇒ true +# +# {"Carl": 85, "Bob": 50, "Max": 60}.hasKey("John") ⇒ false # ``` # # + m - the map @@ -240,8 +253,8 @@ public isolated function hasKey(map m, string k) returns boolean = @java:M # Returns a list of all the keys of a map. # -# ``` -# {"Carl": 85, "Bob": 50, "Max": 60}.keys() ⇒ ["Carl", "Bob", "Max"] +# ```ballerina +# {"Carl": 85, "Bob": 50, "Max": 60}.keys() ⇒ ["Carl","Bob","Max"] # ``` # # + m - the map @@ -253,8 +266,8 @@ public isolated function keys(map m) returns string[] = @java:Method # Returns a list of all the members of a map. # -# ``` -# {"Carl": 85, "Bob": 50, "Max": 60}.toArray() ⇒ [85, 50, 60] +# ```ballerina +# {"Carl": 85, "Bob": 50, "Max": 60}.toArray() ⇒ [85,50,60] # ``` # # + m - the map From 719da62ea2fa9fda196fcc1a79cb26c3b36e5ac2 Mon Sep 17 00:00:00 2001 From: dulajdilshan Date: Thu, 8 Dec 2022 12:30:52 +0530 Subject: [PATCH 403/450] Add examples for the `lang.transaction` langlib functions --- .../src/main/ballerina/transaction.bal | 102 ++++++++++++++++++ .../src/main/ballerina/transaction_errors.bal | 13 +++ 2 files changed, 115 insertions(+) diff --git a/langlib/lang.transaction/src/main/ballerina/transaction.bal b/langlib/lang.transaction/src/main/ballerina/transaction.bal index a692d3498b5d..aa8769e7fcc8 100644 --- a/langlib/lang.transaction/src/main/ballerina/transaction.bal +++ b/langlib/lang.transaction/src/main/ballerina/transaction.bal @@ -51,6 +51,16 @@ public type Timestamp readonly & object { # Returns information about the current transaction. # +# ```ballerina +# transaction { +# transaction:Info info = transaction:info(); +# check commit; +# } +# +# transactional function transFunc() returns error? { +# transaction:Info? info = transaction:info(); +# } +# ``` # + return - information about the current transaction public transactional isolated function info() returns Info = @java:Method { 'class: "org.ballerinalang.langlib.transaction.Info", @@ -59,6 +69,19 @@ public transactional isolated function info() returns Info = @java:Method { # Returns information about the transaction with the specified xid. # +# ```ballerina +# byte[] xid = [48,53,101,102,101,55]; +# +# transaction { +# transaction:Info? info = transaction:getInfo(xid); +# check commit; +# } +# +# transactional function transFunc() returns error? { +# transaction:Info? info = transaction:getInfo(xid); +# } +# ``` +# # + xid - transaction id # + return - information about the transaction public isolated function getInfo(byte[] xid) returns Info? = @java:Method { @@ -68,6 +91,19 @@ public isolated function getInfo(byte[] xid) returns Info? = @java:Method { # Prevents the global transaction from committing successfully. # +# ```ballerina +# transaction { +# transaction:setRollbackOnly(notFoundError); +# check commit; +# } +# +# transactional function transFunc() returns error? { +# transaction:setRollbackOnly(notFoundError); +# } +# +# error notFoundError = error("not found"); +# ``` +# # This ask the transaction manager that when it makes the decision # whether to commit or rollback, it should decide to rollback. # @@ -81,6 +117,17 @@ public transactional isolated function setRollbackOnly(error? e) { # Tells whether it is known that the transaction will be rolled back. # +# ```ballerina +# transaction { +# boolean willRollBack = transaction:getRollbackOnly(); +# check commit; +# } +# +# transactional function transFunc() returns error? { +# boolean willRollBack = transaction:getRollbackOnly(); +# } +# ``` +# # + return - true if it is known that the transaction manager will, # when it makes the decision whether to commit or rollback, decide # to rollback @@ -91,6 +138,19 @@ public transactional isolated function getRollbackOnly() returns boolean = @java # Associates some data with the current transaction branch. # +# ```ballerina +# readonly & any|error data = {"author": "John", "fruits": ["Apple", "Orange"]}; +# +# transaction { +# transaction:setData(data); +# check commit; +# } +# +# transactional function transFunc() returns error? { +# transaction:setData(data); +# } +# ``` +# # + data - Data to be set public transactional isolated function setData(readonly data) = @java:Method { 'class: "org.ballerinalang.langlib.transaction.SetData", @@ -99,6 +159,17 @@ public transactional isolated function setData(readonly data) = @java:Method { # Retrieves data associated with the current transaction branch. # +# ```ballerina +# transaction { +# readonly data = transaction:getData(); +# check commit; +# } +# +# transactional function transFunc() returns error? { +# readonly data = transaction:getData(); +# } +# ``` +# # The data is set using `setData`. # # + return - the data, or `()` if no data has been set. @@ -121,6 +192,22 @@ public type RollbackHandler isolated function(Info info, error? cause, boolean w # Adds a handler to be called if and when the global transaction commits. # +# ```ballerina +# transaction { +# transaction:onCommit(handleCommit); +# check commit; +# } +# +# transactional function transFunc() returns error? { +# transaction:onCommit(handleCommit); +# } +# +# isolated function handleCommit(transaction:Info info) { +# // This funtion will be called on commit +# } +# +# ``` +# # + handler - the function to be called on commit public transactional isolated function onCommit(CommitHandler handler) = @java:Method { 'class: "org.ballerinalang.langlib.transaction.OnCommit", @@ -129,6 +216,21 @@ public transactional isolated function onCommit(CommitHandler handler) = @java:M # Adds a handler to be called if and when the global transaction rolls back. # +# ```ballerina +# transaction { +# transaction:onRollback(handleRollBack); +# check commit; +# } +# +# transactional function transFunc() returns error? { +# transaction:onCommit(handleRollBack); +# } +# +# isolated function handleRollBack(transaction:Info info, error? cause, boolean willRetry) { +# // This funtion will be called on roll-back +# } +# ``` +# # + handler - the function to be called on rollback public transactional isolated function onRollback(RollbackHandler handler) = @java:Method { 'class: "org.ballerinalang.langlib.transaction.OnRollback", diff --git a/langlib/lang.transaction/src/main/ballerina/transaction_errors.bal b/langlib/lang.transaction/src/main/ballerina/transaction_errors.bal index 6fa753cf0a80..8ef537c056a5 100644 --- a/langlib/lang.transaction/src/main/ballerina/transaction_errors.bal +++ b/langlib/lang.transaction/src/main/ballerina/transaction_errors.bal @@ -19,6 +19,19 @@ public type Error distinct error; # Log and prepare `error` as a `Error`. # +# ```ballerina +# transaction { +# transaction:Error err = transaction:prepareError("Error!"); +# check commit; +# } +# +# transactional function transFunc() returns error? { +# transaction:Error err = transaction:prepareError("Error!", notFoundError); +# } +# +# error notFoundError = error("not found"); +# ``` +# # + message - Error message # + err - `error` instance # + return - Prepared `Error` instance From c68a87274870e315244db724d089a5d63e38007b Mon Sep 17 00:00:00 2001 From: dulajdilshan Date: Fri, 9 Dec 2022 00:25:28 +0530 Subject: [PATCH 404/450] Address a few review comments --- .../src/main/ballerina/transaction.bal | 48 ++++++++----------- .../src/main/ballerina/transaction_errors.bal | 13 ----- 2 files changed, 20 insertions(+), 41 deletions(-) diff --git a/langlib/lang.transaction/src/main/ballerina/transaction.bal b/langlib/lang.transaction/src/main/ballerina/transaction.bal index aa8769e7fcc8..4a2cbc274bcd 100644 --- a/langlib/lang.transaction/src/main/ballerina/transaction.bal +++ b/langlib/lang.transaction/src/main/ballerina/transaction.bal @@ -57,10 +57,11 @@ public type Timestamp readonly & object { # check commit; # } # -# transactional function transFunc() returns error? { -# transaction:Info? info = transaction:info(); +# transactional function updateDB() returns error? { +# transaction:Info info = transaction:info(); # } # ``` +# # + return - information about the current transaction public transactional isolated function info() returns Info = @java:Method { 'class: "org.ballerinalang.langlib.transaction.Info", @@ -70,16 +71,8 @@ public transactional isolated function info() returns Info = @java:Method { # Returns information about the transaction with the specified xid. # # ```ballerina -# byte[] xid = [48,53,101,102,101,55]; -# -# transaction { -# transaction:Info? info = transaction:getInfo(xid); -# check commit; -# } -# -# transactional function transFunc() returns error? { -# transaction:Info? info = transaction:getInfo(xid); -# } +# byte[] xid = [48, 53, 101, 102, 101, 55]; +# transaction:Info? info = transaction:getInfo(xid); # ``` # # + xid - transaction id @@ -91,22 +84,22 @@ public isolated function getInfo(byte[] xid) returns Info? = @java:Method { # Prevents the global transaction from committing successfully. # -# ```ballerina +# This ask the transaction manager that when it makes the decision +# whether to commit or rollback, it should decide to rollback. +# +# ```ballerina # transaction { # transaction:setRollbackOnly(notFoundError); # check commit; # } # -# transactional function transFunc() returns error? { +# transactional function updateDB() returns error? { # transaction:setRollbackOnly(notFoundError); # } # # error notFoundError = error("not found"); # ``` # -# This ask the transaction manager that when it makes the decision -# whether to commit or rollback, it should decide to rollback. -# # + e - the error that caused the rollback or `()`, if there is none public transactional isolated function setRollbackOnly(error? e) { if(e is error) { @@ -117,13 +110,13 @@ public transactional isolated function setRollbackOnly(error? e) { # Tells whether it is known that the transaction will be rolled back. # -# ```ballerina +# ```ballerina # transaction { # boolean willRollBack = transaction:getRollbackOnly(); # check commit; # } # -# transactional function transFunc() returns error? { +# transactional function updateDB() returns error? { # boolean willRollBack = transaction:getRollbackOnly(); # } # ``` @@ -146,7 +139,7 @@ public transactional isolated function getRollbackOnly() returns boolean = @java # check commit; # } # -# transactional function transFunc() returns error? { +# transactional function updateDB() returns error? { # transaction:setData(data); # } # ``` @@ -159,19 +152,19 @@ public transactional isolated function setData(readonly data) = @java:Method { # Retrieves data associated with the current transaction branch. # +# The data is set using `setData`. +# # ```ballerina # transaction { # readonly data = transaction:getData(); # check commit; # } # -# transactional function transFunc() returns error? { +# transactional function updateDB() returns error? { # readonly data = transaction:getData(); # } # ``` # -# The data is set using `setData`. -# # + return - the data, or `()` if no data has been set. public transactional isolated function getData() returns readonly = @java:Method { 'class: "org.ballerinalang.langlib.transaction.GetData", @@ -198,14 +191,13 @@ public type RollbackHandler isolated function(Info info, error? cause, boolean w # check commit; # } # -# transactional function transFunc() returns error? { +# transactional function updateDB() returns error? { # transaction:onCommit(handleCommit); # } # # isolated function handleCommit(transaction:Info info) { -# // This funtion will be called on commit +# // This function will be called on commit. # } -# # ``` # # + handler - the function to be called on commit @@ -222,12 +214,12 @@ public transactional isolated function onCommit(CommitHandler handler) = @java:M # check commit; # } # -# transactional function transFunc() returns error? { +# transactional function updateDB() returns error? { # transaction:onCommit(handleRollBack); # } # # isolated function handleRollBack(transaction:Info info, error? cause, boolean willRetry) { -# // This funtion will be called on roll-back +# // This function will be called on roll-back. # } # ``` # diff --git a/langlib/lang.transaction/src/main/ballerina/transaction_errors.bal b/langlib/lang.transaction/src/main/ballerina/transaction_errors.bal index 8ef537c056a5..6fa753cf0a80 100644 --- a/langlib/lang.transaction/src/main/ballerina/transaction_errors.bal +++ b/langlib/lang.transaction/src/main/ballerina/transaction_errors.bal @@ -19,19 +19,6 @@ public type Error distinct error; # Log and prepare `error` as a `Error`. # -# ```ballerina -# transaction { -# transaction:Error err = transaction:prepareError("Error!"); -# check commit; -# } -# -# transactional function transFunc() returns error? { -# transaction:Error err = transaction:prepareError("Error!", notFoundError); -# } -# -# error notFoundError = error("not found"); -# ``` -# # + message - Error message # + err - `error` instance # + return - Prepared `Error` instance From e99d282b81bc5e506a3fe0a6d82b572bc39a07d7 Mon Sep 17 00:00:00 2001 From: dulajdilshan Date: Tue, 13 Dec 2022 11:05:24 +0530 Subject: [PATCH 405/450] Wrap transaction segment in a function --- .../src/main/ballerina/transaction.bal | 57 ++++++++++++------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/langlib/lang.transaction/src/main/ballerina/transaction.bal b/langlib/lang.transaction/src/main/ballerina/transaction.bal index 4a2cbc274bcd..fa0724f7f92a 100644 --- a/langlib/lang.transaction/src/main/ballerina/transaction.bal +++ b/langlib/lang.transaction/src/main/ballerina/transaction.bal @@ -52,9 +52,11 @@ public type Timestamp readonly & object { # Returns information about the current transaction. # # ```ballerina -# transaction { -# transaction:Info info = transaction:info(); -# check commit; +# function createEntity() { +# transaction { +# transaction:Info info = transaction:info(); +# check commit; +# } # } # # transactional function updateDB() returns error? { @@ -88,9 +90,11 @@ public isolated function getInfo(byte[] xid) returns Info? = @java:Method { # whether to commit or rollback, it should decide to rollback. # # ```ballerina -# transaction { -# transaction:setRollbackOnly(notFoundError); -# check commit; +# function createEntity() { +# transaction { +# transaction:setRollbackOnly(notFoundError); +# check commit; +# } # } # # transactional function updateDB() returns error? { @@ -111,9 +115,11 @@ public transactional isolated function setRollbackOnly(error? e) { # Tells whether it is known that the transaction will be rolled back. # # ```ballerina -# transaction { -# boolean willRollBack = transaction:getRollbackOnly(); -# check commit; +# function createEntity() { +# transaction { +# boolean willRollBack = transaction:getRollbackOnly(); +# check commit; +# } # } # # transactional function updateDB() returns error? { @@ -134,9 +140,11 @@ public transactional isolated function getRollbackOnly() returns boolean = @java # ```ballerina # readonly & any|error data = {"author": "John", "fruits": ["Apple", "Orange"]}; # -# transaction { -# transaction:setData(data); -# check commit; +# function createEntity() { +# transaction { +# transaction:setData(data); +# check commit; +# } # } # # transactional function updateDB() returns error? { @@ -155,11 +163,12 @@ public transactional isolated function setData(readonly data) = @java:Method { # The data is set using `setData`. # # ```ballerina -# transaction { -# readonly data = transaction:getData(); -# check commit; +# function createEntity() { +# transaction { +# readonly data = transaction:getData(); +# check commit; +# } # } -# # transactional function updateDB() returns error? { # readonly data = transaction:getData(); # } @@ -186,9 +195,11 @@ public type RollbackHandler isolated function(Info info, error? cause, boolean w # Adds a handler to be called if and when the global transaction commits. # # ```ballerina -# transaction { -# transaction:onCommit(handleCommit); -# check commit; +# function createEntity() { +# transaction { +# transaction:onCommit(handleCommit); +# check commit; +# } # } # # transactional function updateDB() returns error? { @@ -209,9 +220,11 @@ public transactional isolated function onCommit(CommitHandler handler) = @java:M # Adds a handler to be called if and when the global transaction rolls back. # # ```ballerina -# transaction { -# transaction:onRollback(handleRollBack); -# check commit; +# function createEntity() { +# transaction { +# transaction:onRollback(handleRollBack); +# check commit; +# } # } # # transactional function updateDB() returns error? { From eaf4da21d6a98797c8241cb5c47de9e5b05330d4 Mon Sep 17 00:00:00 2001 From: dulajdilshan Date: Thu, 15 Dec 2022 20:44:46 +0530 Subject: [PATCH 406/450] Improve examples --- .../src/main/ballerina/transaction.bal | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/langlib/lang.transaction/src/main/ballerina/transaction.bal b/langlib/lang.transaction/src/main/ballerina/transaction.bal index fa0724f7f92a..8e87446533ac 100644 --- a/langlib/lang.transaction/src/main/ballerina/transaction.bal +++ b/langlib/lang.transaction/src/main/ballerina/transaction.bal @@ -51,7 +51,7 @@ public type Timestamp readonly & object { # Returns information about the current transaction. # -# ```ballerina +# ``` # function createEntity() { # transaction { # transaction:Info info = transaction:info(); @@ -72,7 +72,7 @@ public transactional isolated function info() returns Info = @java:Method { # Returns information about the transaction with the specified xid. # -# ```ballerina +# ``` # byte[] xid = [48, 53, 101, 102, 101, 55]; # transaction:Info? info = transaction:getInfo(xid); # ``` @@ -89,19 +89,17 @@ public isolated function getInfo(byte[] xid) returns Info? = @java:Method { # This ask the transaction manager that when it makes the decision # whether to commit or rollback, it should decide to rollback. # -# ```ballerina +# ``` # function createEntity() { # transaction { -# transaction:setRollbackOnly(notFoundError); +# transaction:setRollbackOnly(error("not found")); # check commit; # } # } # # transactional function updateDB() returns error? { -# transaction:setRollbackOnly(notFoundError); +# transaction:setRollbackOnly(error("not found")); # } -# -# error notFoundError = error("not found"); # ``` # # + e - the error that caused the rollback or `()`, if there is none @@ -114,7 +112,7 @@ public transactional isolated function setRollbackOnly(error? e) { # Tells whether it is known that the transaction will be rolled back. # -# ```ballerina +# ``` # function createEntity() { # transaction { # boolean willRollBack = transaction:getRollbackOnly(); @@ -137,7 +135,7 @@ public transactional isolated function getRollbackOnly() returns boolean = @java # Associates some data with the current transaction branch. # -# ```ballerina +# ``` # readonly & any|error data = {"author": "John", "fruits": ["Apple", "Orange"]}; # # function createEntity() { @@ -162,7 +160,7 @@ public transactional isolated function setData(readonly data) = @java:Method { # # The data is set using `setData`. # -# ```ballerina +# ``` # function createEntity() { # transaction { # readonly data = transaction:getData(); @@ -194,7 +192,7 @@ public type RollbackHandler isolated function(Info info, error? cause, boolean w # Adds a handler to be called if and when the global transaction commits. # -# ```ballerina +# ``` # function createEntity() { # transaction { # transaction:onCommit(handleCommit); @@ -219,7 +217,7 @@ public transactional isolated function onCommit(CommitHandler handler) = @java:M # Adds a handler to be called if and when the global transaction rolls back. # -# ```ballerina +# ``` # function createEntity() { # transaction { # transaction:onRollback(handleRollBack); From cfa82e521b271b219608bf88949d7a8bf2c3ccee Mon Sep 17 00:00:00 2001 From: dulajdilshan Date: Tue, 20 Dec 2022 17:23:49 +0530 Subject: [PATCH 407/450] Address a review iteration --- .../src/main/ballerina/transaction.bal | 66 ++++++++++--------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/langlib/lang.transaction/src/main/ballerina/transaction.bal b/langlib/lang.transaction/src/main/ballerina/transaction.bal index 8e87446533ac..079df6743006 100644 --- a/langlib/lang.transaction/src/main/ballerina/transaction.bal +++ b/langlib/lang.transaction/src/main/ballerina/transaction.bal @@ -51,8 +51,8 @@ public type Timestamp readonly & object { # Returns information about the current transaction. # -# ``` -# function createEntity() { +# ```ballerina +# function createEntity() returns error? { # transaction { # transaction:Info info = transaction:info(); # check commit; @@ -61,6 +61,7 @@ public type Timestamp readonly & object { # # transactional function updateDB() returns error? { # transaction:Info info = transaction:info(); +# info.xid ⇒ [100,102,53,51,97,57,57,51,45] # } # ``` # @@ -72,9 +73,9 @@ public transactional isolated function info() returns Info = @java:Method { # Returns information about the transaction with the specified xid. # -# ``` +# ```ballerina # byte[] xid = [48, 53, 101, 102, 101, 55]; -# transaction:Info? info = transaction:getInfo(xid); +# transaction:getInfo(xid) ⇒ {"xid":[48, 53, 101, 102, 101, 55],"retryNumber":0,"prevAttempt":null,"startTime":2022-12-20 16:03:37,228} # ``` # # + xid - transaction id @@ -89,8 +90,8 @@ public isolated function getInfo(byte[] xid) returns Info? = @java:Method { # This ask the transaction manager that when it makes the decision # whether to commit or rollback, it should decide to rollback. # -# ``` -# function createEntity() { +# ```ballerina +# function createEntity() returns error? { # transaction { # transaction:setRollbackOnly(error("not found")); # check commit; @@ -112,16 +113,17 @@ public transactional isolated function setRollbackOnly(error? e) { # Tells whether it is known that the transaction will be rolled back. # -# ``` -# function createEntity() { +# ```ballerina +# function createEntity() returns error? { # transaction { -# boolean willRollBack = transaction:getRollbackOnly(); +# transaction:setRollbackOnly(error("not found")); +# transaction:getRollbackOnly() ⇒ true # check commit; # } # } # # transactional function updateDB() returns error? { -# boolean willRollBack = transaction:getRollbackOnly(); +# transaction:getRollbackOnly() ⇒ false # } # ``` # @@ -135,18 +137,16 @@ public transactional isolated function getRollbackOnly() returns boolean = @java # Associates some data with the current transaction branch. # -# ``` -# readonly & any|error data = {"author": "John", "fruits": ["Apple", "Orange"]}; -# -# function createEntity() { +# ```ballerina +# function createEntity() returns error? { # transaction { -# transaction:setData(data); +# transaction:setData({"accessType": "RO"}); # check commit; # } # } # # transactional function updateDB() returns error? { -# transaction:setData(data); +# transaction:setData({"accessType": "RO"}); # } # ``` # @@ -160,15 +160,17 @@ public transactional isolated function setData(readonly data) = @java:Method { # # The data is set using `setData`. # -# ``` -# function createEntity() { +# ```ballerina +# function createEntity() returns error? { # transaction { -# readonly data = transaction:getData(); +# transaction:setData({"author": "John"}); +# transaction:getData() ⇒ {"author":"John"} # check commit; # } # } # transactional function updateDB() returns error? { -# readonly data = transaction:getData(); +# transaction:setData({"accessType": "RO"}); +# transaction:getData() ⇒ {"accessType":"RO"} # } # ``` # @@ -192,20 +194,20 @@ public type RollbackHandler isolated function(Info info, error? cause, boolean w # Adds a handler to be called if and when the global transaction commits. # -# ``` -# function createEntity() { +# ```ballerina +# function createEntity() returns error? { # transaction { -# transaction:onCommit(handleCommit); +# transaction:onCommit(onCommitHandle); # check commit; # } # } # # transactional function updateDB() returns error? { -# transaction:onCommit(handleCommit); +# transaction:onCommit(onCommitHandle); # } # -# isolated function handleCommit(transaction:Info info) { -# // This function will be called on commit. +# isolated function onCommitHandle(transaction:Info info) { +# // Include the code to be executed when the transaction commits. # } # ``` # @@ -217,20 +219,20 @@ public transactional isolated function onCommit(CommitHandler handler) = @java:M # Adds a handler to be called if and when the global transaction rolls back. # -# ``` -# function createEntity() { +# ```ballerina +# function createEntity() returns error? { # transaction { -# transaction:onRollback(handleRollBack); +# transaction:onRollback(onRollBackHandle); # check commit; # } # } # # transactional function updateDB() returns error? { -# transaction:onCommit(handleRollBack); +# transaction:onRollback(onRollBackHandle); # } # -# isolated function handleRollBack(transaction:Info info, error? cause, boolean willRetry) { -# // This function will be called on roll-back. +# isolated function onRollBackHandle(transaction:Info info, error? cause, boolean willRetry) { +# // Include the code to be executed when the transaction rollback. # } # ``` # From 9b6e217b8c80ca8d5061f9af139ab0890a919f1c Mon Sep 17 00:00:00 2001 From: dulajdilshan Date: Wed, 21 Dec 2022 09:32:17 +0530 Subject: [PATCH 408/450] Address a review iteration --- .../src/main/ballerina/transaction.bal | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/langlib/lang.transaction/src/main/ballerina/transaction.bal b/langlib/lang.transaction/src/main/ballerina/transaction.bal index 079df6743006..feb03ec8ffb4 100644 --- a/langlib/lang.transaction/src/main/ballerina/transaction.bal +++ b/langlib/lang.transaction/src/main/ballerina/transaction.bal @@ -60,8 +60,8 @@ public type Timestamp readonly & object { # } # # transactional function updateDB() returns error? { -# transaction:Info info = transaction:info(); -# info.xid ⇒ [100,102,53,51,97,57,57,51,45] +# transaction:Info info = transaction:info(); +# info.xid ⇒ [100,102,53,51,97,57,57,51,45] # } # ``` # @@ -99,7 +99,7 @@ public isolated function getInfo(byte[] xid) returns Info? = @java:Method { # } # # transactional function updateDB() returns error? { -# transaction:setRollbackOnly(error("not found")); +# transaction:setRollbackOnly(error("not found")); # } # ``` # @@ -123,7 +123,7 @@ public transactional isolated function setRollbackOnly(error? e) { # } # # transactional function updateDB() returns error? { -# transaction:getRollbackOnly() ⇒ false +# transaction:getRollbackOnly() ⇒ false # } # ``` # @@ -146,7 +146,7 @@ public transactional isolated function getRollbackOnly() returns boolean = @java # } # # transactional function updateDB() returns error? { -# transaction:setData({"accessType": "RO"}); +# transaction:setData({"accessType": "RO"}); # } # ``` # @@ -169,8 +169,8 @@ public transactional isolated function setData(readonly data) = @java:Method { # } # } # transactional function updateDB() returns error? { -# transaction:setData({"accessType": "RO"}); -# transaction:getData() ⇒ {"accessType":"RO"} +# transaction:setData({"accessType": "RO"}); +# transaction:getData() ⇒ {"accessType":"RO"} # } # ``` # @@ -203,7 +203,7 @@ public type RollbackHandler isolated function(Info info, error? cause, boolean w # } # # transactional function updateDB() returns error? { -# transaction:onCommit(onCommitHandle); +# transaction:onCommit(onCommitHandle); # } # # isolated function onCommitHandle(transaction:Info info) { @@ -228,7 +228,7 @@ public transactional isolated function onCommit(CommitHandler handler) = @java:M # } # # transactional function updateDB() returns error? { -# transaction:onRollback(onRollBackHandle); +# transaction:onRollback(onRollBackHandle); # } # # isolated function onRollBackHandle(transaction:Info info, error? cause, boolean willRetry) { From c37e8b0a80451e2399111d2ac8a8b68f9d707417 Mon Sep 17 00:00:00 2001 From: LakshanWeerasinghe Date: Wed, 21 Dec 2022 18:46:41 +0530 Subject: [PATCH 409/450] Add examples for table langlib --- .../lang.table/src/main/ballerina/table.bal | 180 ++++++++++++++++++ 1 file changed, 180 insertions(+) diff --git a/langlib/lang.table/src/main/ballerina/table.bal b/langlib/lang.table/src/main/ballerina/table.bal index d08fbdd0026c..32432f62c0bd 100644 --- a/langlib/lang.table/src/main/ballerina/table.bal +++ b/langlib/lang.table/src/main/ballerina/table.bal @@ -42,6 +42,13 @@ type KeyType anydata; # Returns number of members of a table. # +# ```ballerina +# table [ +# {name: "Jo"}, +# {name: "Smith"} +# ].length() ⇒ 2 +# ``` +# # + t - the table # + return - number of members in parameter `t` public isolated function length(table> t) returns int = @java:Method { @@ -55,6 +62,16 @@ public isolated function length(table> t) returns int = @java:Met # The `entries` function can be used to iterate over the keys and members together. # The `keys` function can be used to iterator over just the keys. # +# ```ballerina +# object { +# public isolated function next() returns record {|record {|string name;|} value;|}?; +# } iterator = table [ +# {name: "Jo"}, +# {name: "Smith"} +# ].iterator(); +# iterator.next() ⇒ {"value":{"name":"Jo"}} +# ``` +# # + t - the table # + return - a new iterator object that will iterate over the members of parameter `t` public isolated function iterator(table t) returns object { @@ -71,6 +88,16 @@ public isolated function iterator(table t) returns object { # This for use in a case where it is known that the table has a specific key, # and accordingly panics if parameter `t` does not have a member with key parameter `k`. # +# ```ballerina +# table key(index) students = table [ +# {index: "220001CS", name: "Jo"}, +# {index: "220002CS", name: "Sam"} +# ]; +# students.get("220002CS") ⇒ {"index":"220002CS","name":"Sam"} +# +# students.get("invalidKey") ⇒ panic +# ``` +# # + t - the table # + k - the key # + return - member with key parameter `k` @@ -86,6 +113,29 @@ public isolated function get(table key t, KeyType k) returns M # otherwise, it will be added as the last member. # It panics if parameter `val` is inconsistent with the inherent type of parameter `t`. # +# ```ballerina +# table key(id) students = table [ +# {id: 1, name: "Jo"}, +# {id: 2, name: "Sam"} +# ]; +# +# students.put({id: 3, name: "Pat"}); +# students ⇒ [{"id":1,"name":"Jo"},{"id":2,"name":"Sam"},{"id":3,"name":"Pat"}] +# +# students.put({id: 1, name: "Kane"}); +# students ⇒ [{"id":1,"name":"Kane"},{"id":2,"name":"Sam"},{"id":3,"name":"Pat"}] +# +# table tbl = table [ +# {id: 1, name: "Jo"}, +# {id: 2, name: "Sam"} +# ]; +# tbl.put({id: 1, name: "Pat"}); +# tbl ⇒ [{"id":1,"name":"Jo"},{"id":2,"name":"Sam"},{"id":1,"name":"Pat"}] +# +# table key(id) studentIds = students; +# studentIds.put({id: 7}) ⇒ panic +# ``` +# # + t - the table # + val - the member public isolated function put(table t, MapType val) = @java:Method { @@ -99,6 +149,28 @@ public isolated function put(table t, MapType val) = @java:Method { # It panics if parameter `val` has the same key as an existing member of parameter `t`, # or if parameter `val` is inconsistent with the inherent type of `t`. # +# ```ballerina +# table key(id) students = table [ +# {id: 1, name: "Jo"}, +# {id: 2, name: "Sam"} +# ]; +# +# students.add({id: 3, name: "Pat"}); +# students ⇒ [{"id":1,"name":"Jo"},{"id":2,"name":"Sam"},{"id":3,"name":"Pat"}] +# +# table tbl = table [ +# {id: 1, name: "Jo"}, +# {id: 2, name: "Sam"} +# ]; +# tbl.add({id: 1, name: "Pat"}); +# tbl ⇒ [{"id":1,"name":"Jo"},{"id":2,"name":"Sam"},{"id":1,"name":"Pat"}] +# +# students.add({id: 1, name: "James"}) ⇒ panic +# +# table key(id) studentIds = students; +# studentIds.add({id: 7}) ⇒ panic +# ``` +# # + t - the table # + val - the member public isolated function add(table t, MapType val) = @java:Method { @@ -110,6 +182,13 @@ public isolated function add(table t, MapType val) = @java:Method { # Applies a function to each member of a table and returns a table of the result. # +# ```ballerina +# table [ +# {id: 1, maths: 78, physics: 70}, +# {id: 2, maths: 83, physics: 80} +# ].map(student => {id: student.id, avg: (student.maths + student.physics) / 2}) ⇒ [{"id":1,"avg":74},{"id":2,"avg":81}] +# ``` +# # + t - the table # + func - a function to apply to each member # + return - new table containing result of applying parameter `func` to each member @@ -123,6 +202,18 @@ public isolated function 'map(table t, @isolatedParam function(MapType # # The parameter `func` is applied to each member of parameter `t`. # +# ```ballerina +# table employees = table [ +# {name: "Jo", salary: 1200}, +# {name: "Emma", salary: 800} +# ]; +# int total = 0; +# employees.forEach(function(record {|string name; int salary;|} emp) { +# total += emp.salary; +# }); +# total ⇒ 2000 +# ``` +# # + t - the table # + func - a function to apply to each member public isolated function forEach(table t, @isolatedParam function(MapType val) returns () func) returns () = @java:Method { @@ -134,6 +225,14 @@ public isolated function forEach(table t, @isolatedParam function(MapTy # # The resulting table will have the same keys as the argument table. # +# ```ballerina +# table [ +# {id: 1, salary: 1200}, +# {id: 2, salary: 1100}, +# {id: 3, salary: 800} +# ].filter(emp => emp.salary < 1000) ⇒ [{"id":3,"salary":800}] +# ``` +# # + t - the table # + func - a predicate to apply to each member to test whether it should be included # + return - new table containing members for which parameter `func` evaluates to true @@ -148,6 +247,14 @@ public isolated function filter(table key t, @isolatedParam fu # The combining function takes the combined value so far and a member of the table, # and returns a new combined value. # +# ```ballerina +# table [ +# {id: 1, salary: 1200}, +# {id: 2, salary: 1100}, +# {id: 3, salary: 800} +# ].reduce(isolated function (int total, record {int id; int salary;} next) returns int => total + next.salary, 0) ⇒ 3100 +# ``` +# # + t - the table # + func - combining function # + initial - initial value for the first argument of combining parameter `func` @@ -163,6 +270,17 @@ public isolated function reduce(table t, @isolatedParam function(Type a # This removed the member of parameter `t` with key parameter `k` and returns it. # It panics if there is no such member. # +# ```ballerina +# table key(id) students = table [ +# {id: 1, name: "Jo"}, +# {id: 2, name: "Sam"} +# ]; +# students.remove(1) ⇒ {"id":1,"name":"Jo"} +# students ⇒ [{"id":2,"name":"Sam"}] +# +# students.remove(5) ⇒ panic +# ``` +# # + t - the table # + k - the key # + return - the member of parameter `t` that had key parameter `k` @@ -176,6 +294,18 @@ public isolated function remove(table key t, KeyType k) return # If parameter `t` has a member with key parameter `k`, it removes and returns it; # otherwise it returns `()`. # +# ```ballerina +# table key(id) students = table [ +# {id: 1, name: "Jo"}, +# {id: 2, name: "Sam"} +# ]; +# +# students.removeIfHasKey(1) ⇒ {"id":1,"name":"Jo"} +# students ⇒ [{"id":2,"name":"Sam"}] +# +# students.removeIfHasKey(3) is () ⇒ true +# ``` +# # + t - the table # + k - the key # + return - the member of parameter `t` that had key parameter `k`, or `()` if parameter `t` does not have a key parameter `k` @@ -188,6 +318,20 @@ public isolated function removeIfHasKey(table key t, KeyType k # # This panics if any member cannot be removed. # +# ```ballerina +# table students = table [ +# {name: "Jo"}, +# {name: "Sam"} +# ]; +# students.removeAll() is () ⇒ true +# +# table scores = table [ +# {score: 30}, +# {score: 40} +# ]; +# scores.removeAll() is () ⇒ panic +# ``` +# # + t - the table public isolated function removeAll(table> t) returns () = @java:Method { 'class: "org.ballerinalang.langlib.table.RemoveAll", @@ -196,6 +340,16 @@ public isolated function removeAll(table> t) returns () = @java:M # Tests whether a table has a member with a particular key. # +# ```ballerina +# table key(id) students = table [ +# {id: 1, name: "Jo"}, +# {id: 2, name: "Sam"} +# ]; +# +# students.hasKey(1) ⇒ true +# students.hasKey(5) ⇒ false +# ``` +# # + t - the table # + k - the key # + return - true if parameter `t` has a member with key parameter `k` @@ -206,6 +360,15 @@ public isolated function hasKey(table key t, KeyType k) return # Returns a list of all the keys of a table. # +# ```ballerina +# table key(code) countries = table [ +# {code: "CAN", name: "Canada"}, +# {code: "DNK", name: "Denmark"}, +# {code: "NPL", name: "Nepal"} +# ]; +# countries.keys() ⇒ ["CAN","DNK","NPL"] +# ``` +# # + t - the table # + return - a new list of all keys public isolated function keys(table> key t) returns KeyType[] = @java:Method { @@ -215,6 +378,14 @@ public isolated function keys(table> key t) returns KeyT # Returns a list of all the members of a table. # +# ```ballerina +# table [ +# {code: "CAN", name: "Canada"}, +# {code: "DNK", name: "Denmark"}, +# {code: "NPL", name: "Nepal"} +# ].toArray() ⇒ [{"code":"CAN","name":"Canada"},{"code":"DNK","name":"Denmark"},{"code":"NPL","name":"Nepal"}] +# ``` +# # + t - the table # + return - an array whose members are the members of parameter `t` public isolated function toArray(table t) returns MapType[] = @java:Method { @@ -227,6 +398,15 @@ public isolated function toArray(table t) returns MapType[] = @java:Met # This is maximum used key value + 1, or 0 if no key used # XXX should it be 0, if the maximum used key value is < 0? # Provides similar functionality to auto-increment +# +# ```ballerina +# table key(id) users = table [ +# {id: 1, name: "Jo"}, +# {id: 2, name: "Sam"} +# ]; +# users.nextKey() ⇒ 3 +# ``` + # # + t - the table with a key of type int # + return - an integer not yet used as a key From ff193069c623af687338af9f5d3c4f4025828adb Mon Sep 17 00:00:00 2001 From: Chiran Fernando Date: Thu, 22 Dec 2022 09:22:29 +0530 Subject: [PATCH 410/450] Add `students` output after `removeAll()` --- langlib/lang.table/src/main/ballerina/table.bal | 1 + 1 file changed, 1 insertion(+) diff --git a/langlib/lang.table/src/main/ballerina/table.bal b/langlib/lang.table/src/main/ballerina/table.bal index 32432f62c0bd..24d6bcbe1d5b 100644 --- a/langlib/lang.table/src/main/ballerina/table.bal +++ b/langlib/lang.table/src/main/ballerina/table.bal @@ -324,6 +324,7 @@ public isolated function removeIfHasKey(table key t, KeyType k # {name: "Sam"} # ]; # students.removeAll() is () ⇒ true +# students ⇒ [] # # table scores = table [ # {score: 30}, From 500daf82168815e44828aad0ed637c9ce7fa8434 Mon Sep 17 00:00:00 2001 From: malinthar Date: Tue, 20 Dec 2022 12:21:28 +0530 Subject: [PATCH 411/450] Fix extract to local var code action --- .../ExtractToLocalVarCodeAction.java | 9 ++++- .../codeaction/ExtractToLocalVarTest.java | 3 +- ...tToVariableInvalidExpressionStatement.json | 35 +++++++++++++++++++ ...ctToVariableInvalidExpressionStatement.bal | 9 +++++ 4 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-local-variable/config/extractToVariableInvalidExpressionStatement.json create mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-local-variable/source/extractToVariableInvalidExpressionStatement.bal diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToLocalVarCodeAction.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToLocalVarCodeAction.java index 76ebfac822af..2412efd76c77 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToLocalVarCodeAction.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToLocalVarCodeAction.java @@ -124,8 +124,15 @@ public List getCodeActions(CodeActionContext context, if (statementNode == null) { return Collections.emptyList(); } - String paddingStr = StringUtils.repeat(" ", statementNode.lineRange().startLine().offset()); String typeDescriptor = FunctionGenerator.getReturnTypeAsString(context, typeSymbol.get().signature()); + if (statementNode.kind() == SyntaxKind.INVALID_EXPRESSION_STATEMENT) { + String variable = String.format("%s %s = %s", typeDescriptor, varName, value); + TextEdit edit = new TextEdit(new Range(PositionUtil.toPosition(replaceRange.startLine()), + PositionUtil.toPosition(replaceRange.endLine())), variable); + return Collections.singletonList(CodeActionUtil.createCodeAction(CommandConstants.EXTRACT_TO_VARIABLE, + List.of(edit), context.fileUri(), CodeActionKind.RefactorExtract)); + } + String paddingStr = StringUtils.repeat(" ", statementNode.lineRange().startLine().offset()); String varDeclStr = String.format("%s %s = %s;%n%s", typeDescriptor, varName, value, paddingStr); Position varDeclPos = new Position(statementNode.lineRange().startLine().line(), statementNode.lineRange().startLine().offset()); diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToLocalVarTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToLocalVarTest.java index 6fd0b249688e..ac73c52943be 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToLocalVarTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToLocalVarTest.java @@ -74,7 +74,8 @@ public Object[][] dataProvider() { {"extractToVariableInFieldAccessInReturnStmt.json"}, {"extractToVariableInFieldAccessInAssignmentStmt.json"}, {"extractToVariableInObjectField.json"}, - {"extractToVariableInXmlnsDecl.json"} + {"extractToVariableInXmlnsDecl.json"}, + {"extractToVariableInvalidExpressionStatement.json"} }; } diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-local-variable/config/extractToVariableInvalidExpressionStatement.json b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-local-variable/config/extractToVariableInvalidExpressionStatement.json new file mode 100644 index 000000000000..74f4693d900b --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-local-variable/config/extractToVariableInvalidExpressionStatement.json @@ -0,0 +1,35 @@ +{ + "range": { + "start": { + "line": 7, + "character": 4 + }, + "end": { + "line": 7, + "character": 12 + } + }, + "source": "extractToVariableInvalidExpressionStatement.bal", + "expected": [ + { + "title": "Extract to local variable", + "kind": "refactor.extract", + "edits": [ + { + "range": { + "start": { + "line": 7, + "character": 4 + }, + "end": { + "line": 7, + "character": 12 + } + }, + "newText": "string|int? var1 = myvar.id" + } + ], + "resolvable": false + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-local-variable/source/extractToVariableInvalidExpressionStatement.bal b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-local-variable/source/extractToVariableInvalidExpressionStatement.bal new file mode 100644 index 000000000000..211a07524ae9 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-local-variable/source/extractToVariableInvalidExpressionStatement.bal @@ -0,0 +1,9 @@ + +type Type1 record {| + string|int? id; +|}; + +public function main() { + Type1 myvar = {id: 10}; + myvar.id; +} From 923196011e9567f92f6bb8ab26ca37633f6ebe2e Mon Sep 17 00:00:00 2001 From: suleka96 Date: Tue, 3 Jan 2023 12:49:54 +0530 Subject: [PATCH 412/450] Add false case for string regex --- langlib/lang.regexp/src/main/ballerina/regexp.bal | 10 +++------- langlib/lang.string/src/main/ballerina/string.bal | 4 ++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/langlib/lang.regexp/src/main/ballerina/regexp.bal b/langlib/lang.regexp/src/main/ballerina/regexp.bal index 03bb9a766879..f6a3c3b2f605 100644 --- a/langlib/lang.regexp/src/main/ballerina/regexp.bal +++ b/langlib/lang.regexp/src/main/ballerina/regexp.bal @@ -323,9 +323,7 @@ public type Replacement ReplacerFunction|string; # # r.replace("10010011", replaceFunction, 4) ⇒ 1001*11 # -# isolated function replaceFunction(regexp:Groups groups) returns string { -# return "*"; -# } +# isolated function replaceFunction(regexp:Groups groups) returns string => "*"; # ``` # # + re - the regular expression @@ -367,9 +365,7 @@ public isolated function replace(RegExp re, string str, Replacement replacement, # # r.replaceAll("10010011", replaceFunction, 4) ⇒ 1001211 # -# isolated function replaceFunction(regexp:Groups groups) returns string { -# return groups[0].substring().length().toString(); -# } +# isolated function replaceFunction(regexp:Groups groups) returns string => groups[0].substring().length().toString(); # ``` # # + re - the regular expression @@ -433,7 +429,7 @@ isolated function getReplacementString(Groups groups, Replacement replacement) r # # r.split("abc,cde,efg") ⇒ ["abc","cde","efg"] # -# r.split("Not Valid") ⇒ ["Not Valid"] +# r.split("abc cde efg") ⇒ ["abc cde efg"] # ``` # # + re - the regular expression that specifies the separator diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index f7923eb1ec83..ed458c4a1ecd 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -319,6 +319,8 @@ public type RegExp regexp:RegExp; # # ```ballerina # "This is a Match".matches(re `A|Th.*ch|^`) ⇒ true +# +# "Not a Match".matches(re `A|Th.*ch|^`) ⇒ false # ``` # # + str - the string @@ -333,6 +335,8 @@ public function matches(string str, RegExp re) returns boolean { # # ```ballerina # "Will Match Somewhere".includesMatch(re `A|Th.*ch|^`) ⇒ true +# +# "Not a match".includesMatch(re `A|Th.*ch`) ⇒ false # ``` # # + str - the string to be matched From 2aa5e9c9e0aae8555d7bdb54cae904ae484cd60f Mon Sep 17 00:00:00 2001 From: Dulaj Dilshan Date: Tue, 3 Jan 2023 13:00:22 +0530 Subject: [PATCH 413/450] Apply suggestions from code review Co-authored-by: Chiran Fernando --- .../src/main/ballerina/transaction.bal | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/langlib/lang.transaction/src/main/ballerina/transaction.bal b/langlib/lang.transaction/src/main/ballerina/transaction.bal index feb03ec8ffb4..51d8e117768c 100644 --- a/langlib/lang.transaction/src/main/ballerina/transaction.bal +++ b/langlib/lang.transaction/src/main/ballerina/transaction.bal @@ -93,13 +93,13 @@ public isolated function getInfo(byte[] xid) returns Info? = @java:Method { # ```ballerina # function createEntity() returns error? { # transaction { -# transaction:setRollbackOnly(error("not found")); +# transaction:setRollbackOnly(error("marked as rollback only")); # check commit; # } # } # # transactional function updateDB() returns error? { -# transaction:setRollbackOnly(error("not found")); +# transaction:setRollbackOnly(error("marked as rollback only")); # } # ``` # @@ -116,7 +116,7 @@ public transactional isolated function setRollbackOnly(error? e) { # ```ballerina # function createEntity() returns error? { # transaction { -# transaction:setRollbackOnly(error("not found")); +# transaction:setRollbackOnly(error("marked as rollback only")); # transaction:getRollbackOnly() ⇒ true # check commit; # } @@ -140,13 +140,13 @@ public transactional isolated function getRollbackOnly() returns boolean = @java # ```ballerina # function createEntity() returns error? { # transaction { -# transaction:setData({"accessType": "RO"}); +# transaction:setData({accessType: "RO"}); # check commit; # } # } # # transactional function updateDB() returns error? { -# transaction:setData({"accessType": "RO"}); +# transaction:setData({accessType: "RO"}); # } # ``` # @@ -163,13 +163,13 @@ public transactional isolated function setData(readonly data) = @java:Method { # ```ballerina # function createEntity() returns error? { # transaction { -# transaction:setData({"author": "John"}); -# transaction:getData() ⇒ {"author":"John"} +# transaction:setData({accessType: "RO"}); +# transaction:getData() ⇒ {"accessType": "RO"} # check commit; # } # } # transactional function updateDB() returns error? { -# transaction:setData({"accessType": "RO"}); +# transaction:setData({accessType: "RO"}); # transaction:getData() ⇒ {"accessType":"RO"} # } # ``` From e7123816c63494ae91562bf2fe5af2baa87fc43c Mon Sep 17 00:00:00 2001 From: mindula Date: Fri, 9 Dec 2022 15:05:45 +0530 Subject: [PATCH 414/450] Fix extract to constant code action --- .../ExtractToConstantCodeAction.java | 2 +- .../codeaction/ExtractToConstantTest.java | 1 + .../config/extractToConstantWithImports.json | 6 +-- .../config/extractToConstantWithImports2.json | 41 +++++++++++++++++++ .../source/extractToConstantWithImports2.bal | 9 ++++ 5 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/config/extractToConstantWithImports2.json create mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/source/extractToConstantWithImports2.bal diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToConstantCodeAction.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToConstantCodeAction.java index 8f50b9b84d05..9713b6f89778 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToConstantCodeAction.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToConstantCodeAction.java @@ -179,7 +179,7 @@ private Position getPosition(CodeActionContext context) { return PositionUtil.toPosition(modulePartNode.lineRange().startLine()); } ImportDeclarationNode lastImport = importsList.get(importsList.size() - 1); - return new Position(lastImport.lineRange().endLine().line() + 2, 0); + return new Position(lastImport.lineRange().endLine().line() + 1, 0); } /** diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToConstantTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToConstantTest.java index 89949f5dfe0d..616ceb5cc740 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToConstantTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToConstantTest.java @@ -55,6 +55,7 @@ public Object[][] dataProvider() { {"extractExpressionToConstant.json"}, {"extractConstDeclToConstant1.json"}, {"extractToConstantWithImports.json"}, + {"extractToConstantWithImports2.json"}, {"extractUnaryNumericExprToConstant.json"}, {"extractUnaryNumericExprToConstant2.json"}, {"extractUnaryLogicalExprToConstant.json"}, diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/config/extractToConstantWithImports.json b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/config/extractToConstantWithImports.json index d878f305b1f1..a82eb1886f8c 100644 --- a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/config/extractToConstantWithImports.json +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/config/extractToConstantWithImports.json @@ -12,15 +12,15 @@ { "range": { "start": { - "line": 3, + "line": 2, "character": 0 }, "end": { - "line": 3, + "line": 2, "character": 0 } }, - "newText": "const string CONST \u003d \"Hello World\";\n" + "newText": "const string CONST = \"Hello World\";\n" }, { "range": { diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/config/extractToConstantWithImports2.json b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/config/extractToConstantWithImports2.json new file mode 100644 index 000000000000..0f06e4631489 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/config/extractToConstantWithImports2.json @@ -0,0 +1,41 @@ +{ + "position": { + "line": 7, + "character": 13 + }, + "source": "extractToConstantWithImports2.bal", + "expected": [ + { + "title": "Extract to constant", + "kind": "refactor.extract", + "edits": [ + { + "range": { + "start": { + "line": 1, + "character": 0 + }, + "end": { + "line": 1, + "character": 0 + } + }, + "newText": "const int CONST = 0;\n" + }, + { + "range": { + "start": { + "line": 7, + "character": 12 + }, + "end": { + "line": 7, + "character": 13 + } + }, + "newText": "CONST" + } + ] + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/source/extractToConstantWithImports2.bal b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/source/extractToConstantWithImports2.bal new file mode 100644 index 000000000000..6e931c3313d7 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/source/extractToConstantWithImports2.bal @@ -0,0 +1,9 @@ +import ballerina/module1; +type RecordType record { + string name; + int age; +}; + +function testFunction(RecordType rec) { + int x = 0; +} From 72e0855905e45d30c51a7388d388b4d9d9ce5314 Mon Sep 17 00:00:00 2001 From: mindula Date: Fri, 16 Dec 2022 15:03:12 +0530 Subject: [PATCH 415/450] Address review suggestions --- .../ExtractToConstantCodeAction.java | 90 ++++++++++++++----- .../config/extractToConstantWithImports.json | 2 +- .../config/extractToConstantWithImports2.json | 2 +- 3 files changed, 68 insertions(+), 26 deletions(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToConstantCodeAction.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToConstantCodeAction.java index 9713b6f89778..ae81e183910e 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToConstantCodeAction.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToConstantCodeAction.java @@ -20,6 +20,7 @@ import io.ballerina.compiler.api.symbols.TypeSymbol; import io.ballerina.compiler.syntax.tree.BasicLiteralNode; import io.ballerina.compiler.syntax.tree.BinaryExpressionNode; +import io.ballerina.compiler.syntax.tree.ConstantDeclarationNode; import io.ballerina.compiler.syntax.tree.ImportDeclarationNode; import io.ballerina.compiler.syntax.tree.ModuleMemberDeclarationNode; import io.ballerina.compiler.syntax.tree.ModulePartNode; @@ -76,8 +77,8 @@ public List getSyntaxKinds() { public boolean validate(CodeActionContext context, RangeBasedPositionDetails positionDetails) { Node node = positionDetails.matchedCodeActionNode(); SyntaxKind parentKind = node.parent().kind(); - return context.currentSyntaxTree().isPresent() && context.currentSemanticModel().isPresent() - && parentKind != SyntaxKind.CONST_DECLARATION + return context.currentSyntaxTree().isPresent() && context.currentSemanticModel().isPresent() + && parentKind != SyntaxKind.CONST_DECLARATION && parentKind != SyntaxKind.INVALID_EXPRESSION_STATEMENT && CodeActionNodeValidator.validate(context.nodeAtRange()); } @@ -87,48 +88,51 @@ public boolean validate(CodeActionContext context, RangeBasedPositionDetails pos */ @Override public List getCodeActions(CodeActionContext context, - RangeBasedPositionDetails posDetails) { - + RangeBasedPositionDetails posDetails) { + Node node = posDetails.matchedCodeActionNode(); BasicLiteralNodeValidator nodeValidator = new BasicLiteralNodeValidator(); node.accept(nodeValidator); if (nodeValidator.getInvalidNode()) { return Collections.emptyList(); } - + String constName = getConstantName(context); Optional typeSymbol = context.currentSemanticModel().get().typeOf(node); if (typeSymbol.isEmpty() || typeSymbol.get().typeKind() == TypeDescKind.COMPILATION_ERROR) { return Collections.emptyList(); } - Position constDeclPosition = getPosition(context); - + ConstantData constantData = getConstantData(context); + Position constDeclPosition = constantData.getPosition(); + boolean addNewLineAtStart = constantData.isAddNewLineAtStart(); + // Check if the selection is a range or a position, and whether quick picks are supported by the client LSClientCapabilities lsClientCapabilities = context.languageServercontext().get(LSClientCapabilities.class); if (isRange(context.range()) || !lsClientCapabilities.getInitializationOptions().isQuickPickSupported()) { - + // Selection is a range - List textEdits = getTextEdits(node, typeSymbol.get(), constName, constDeclPosition); + List textEdits = + getTextEdits(node, typeSymbol.get(), constName, constDeclPosition, addNewLineAtStart); return Collections.singletonList(CodeActionUtil.createCodeAction(CommandConstants.EXTRACT_TO_CONSTANT, textEdits, context.fileUri(), CodeActionKind.RefactorExtract)); } - + // Selection is a position List nodeList = getPossibleExpressionNodes(node, nodeValidator); LinkedHashMap> textEditMap = new LinkedHashMap<>(); - - nodeList.forEach(extractableNode -> textEditMap.put(extractableNode.toSourceCode().strip(), - getTextEdits(extractableNode, typeSymbol.get(), constName, constDeclPosition))); - + + nodeList.forEach(extractableNode -> textEditMap.put(extractableNode.toSourceCode().strip(), + getTextEdits(extractableNode, typeSymbol.get(), constName, constDeclPosition, addNewLineAtStart))); + return Collections.singletonList(CodeActionUtil.createCodeAction(CommandConstants.EXTRACT_TO_CONSTANT, - new Command(NAME, EXTRACT_COMMAND, List.of(NAME, context.filePath().toString(), - textEditMap)), CodeActionKind.RefactorExtract)); + new Command(NAME, EXTRACT_COMMAND, List.of(NAME, context.filePath().toString(), + textEditMap)), CodeActionKind.RefactorExtract)); } private List getPossibleExpressionNodes(Node node, BasicLiteralNodeValidator nodeValidator) { // Identify the sub-expressions to be extracted List nodeList = new ArrayList<>(); - while (node != null && !isExpressionNode(node) && node.kind() != SyntaxKind.OBJECT_FIELD + while (node != null && !isExpressionNode(node) && node.kind() != SyntaxKind.OBJECT_FIELD && !nodeValidator.getInvalidNode()) { nodeList.add(node); node = node.parent(); @@ -146,10 +150,16 @@ public String getName() { return NAME; } - private List getTextEdits(Node node, TypeSymbol typeSymbol, String constName, Position constDeclPos) { + private List getTextEdits(Node node, TypeSymbol typeSymbol, String constName, Position constDeclPos, + boolean newLineAtStart) { String value = node.toSourceCode().strip(); LineRange replaceRange = node.lineRange(); - String constDeclStr = String.format("const %s %s = %s;%n", typeSymbol.signature(), constName, value); + String constDeclStr; + if (newLineAtStart) { + constDeclStr = String.format("%n" + "const %s %s = %s;%n", typeSymbol.signature(), constName, value); + } else { + constDeclStr = String.format("const %s %s = %s;%n", typeSymbol.signature(), constName, value); + } TextEdit constDeclEdit = new TextEdit(new Range(constDeclPos, constDeclPos), constDeclStr); TextEdit replaceEdit = new TextEdit(new Range(PositionUtil.toPosition(replaceRange.startLine()), PositionUtil.toPosition(replaceRange.endLine())), constName); @@ -171,15 +181,29 @@ private String getConstantName(CodeActionContext context) { return NameUtil.generateTypeName(CONSTANT_NAME_PREFIX, allNames); } - private Position getPosition(CodeActionContext context) { + private ConstantData getConstantData(CodeActionContext context) { ModulePartNode modulePartNode = context.currentSyntaxTree().get().rootNode(); NodeList importsList = modulePartNode.imports(); - + + ConstantDeclarationNode declarationNode = null; + for (Node node : modulePartNode.children()) { + if (node.kind() == SyntaxKind.CONST_DECLARATION) { + declarationNode = (ConstantDeclarationNode) node; + break; + } + } + if (importsList.isEmpty()) { - return PositionUtil.toPosition(modulePartNode.lineRange().startLine()); + return new ConstantData( + PositionUtil.toPosition(modulePartNode.lineRange().startLine()), false); + } else if (declarationNode == null) { + ImportDeclarationNode lastImport = importsList.get(importsList.size() - 1); + return new ConstantData( + new Position(lastImport.lineRange().endLine().line() + 1, 0), true); + } else { + return new ConstantData(new Position(declarationNode.lineRange().startLine().line(), 0), + !declarationNode.toString().startsWith("\n")); } - ImportDeclarationNode lastImport = importsList.get(importsList.size() - 1); - return new Position(lastImport.lineRange().endLine().line() + 1, 0); } /** @@ -212,4 +236,22 @@ public Boolean getInvalidNode() { return invalidNode; } } + + private static class ConstantData { + Position position; + boolean addNewLineAtStart; + + public ConstantData(Position position, boolean addNewLineAtStart) { + this.position = position; + this.addNewLineAtStart = addNewLineAtStart; + } + + public Position getPosition() { + return position; + } + + public boolean isAddNewLineAtStart() { + return addNewLineAtStart; + } + } } diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/config/extractToConstantWithImports.json b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/config/extractToConstantWithImports.json index a82eb1886f8c..b3ca356b4d41 100644 --- a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/config/extractToConstantWithImports.json +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/config/extractToConstantWithImports.json @@ -20,7 +20,7 @@ "character": 0 } }, - "newText": "const string CONST = \"Hello World\";\n" + "newText": "\nconst string CONST = \"Hello World\";\n" }, { "range": { diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/config/extractToConstantWithImports2.json b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/config/extractToConstantWithImports2.json index 0f06e4631489..eeb3a34a8477 100644 --- a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/config/extractToConstantWithImports2.json +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/config/extractToConstantWithImports2.json @@ -20,7 +20,7 @@ "character": 0 } }, - "newText": "const int CONST = 0;\n" + "newText": "\nconst int CONST = 0;\n" }, { "range": { From a2e005829b5ff2190d0604d0c6203851859aa4b0 Mon Sep 17 00:00:00 2001 From: mindula Date: Tue, 20 Dec 2022 10:11:32 +0530 Subject: [PATCH 416/450] Add more tests --- .../ExtractToConstantCodeAction.java | 10 ++--- .../codeaction/ExtractToConstantTest.java | 1 + .../config/extractToConstantWithImports3.json | 41 +++++++++++++++++++ .../source/extractToConstantWithImports3.bal | 12 ++++++ 4 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/config/extractToConstantWithImports3.json create mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/source/extractToConstantWithImports3.bal diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToConstantCodeAction.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToConstantCodeAction.java index ae81e183910e..b4d6c2738f6d 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToConstantCodeAction.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/ExtractToConstantCodeAction.java @@ -154,12 +154,12 @@ private List getTextEdits(Node node, TypeSymbol typeSymbol, String con boolean newLineAtStart) { String value = node.toSourceCode().strip(); LineRange replaceRange = node.lineRange(); - String constDeclStr; + String constDeclStr = ""; if (newLineAtStart) { - constDeclStr = String.format("%n" + "const %s %s = %s;%n", typeSymbol.signature(), constName, value); - } else { - constDeclStr = String.format("const %s %s = %s;%n", typeSymbol.signature(), constName, value); + constDeclStr += String.format("%n"); } + constDeclStr = String.format(constDeclStr + "const %s %s = %s;%n", typeSymbol.signature(), constName, value); + TextEdit constDeclEdit = new TextEdit(new Range(constDeclPos, constDeclPos), constDeclStr); TextEdit replaceEdit = new TextEdit(new Range(PositionUtil.toPosition(replaceRange.startLine()), PositionUtil.toPosition(replaceRange.endLine())), constName); @@ -202,7 +202,7 @@ private ConstantData getConstantData(CodeActionContext context) { new Position(lastImport.lineRange().endLine().line() + 1, 0), true); } else { return new ConstantData(new Position(declarationNode.lineRange().startLine().line(), 0), - !declarationNode.toString().startsWith("\n")); + !declarationNode.toString().startsWith(System.lineSeparator())); } } diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToConstantTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToConstantTest.java index 616ceb5cc740..d7d635a1eedc 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToConstantTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/ExtractToConstantTest.java @@ -56,6 +56,7 @@ public Object[][] dataProvider() { {"extractConstDeclToConstant1.json"}, {"extractToConstantWithImports.json"}, {"extractToConstantWithImports2.json"}, + {"extractToConstantWithImports3.json"}, {"extractUnaryNumericExprToConstant.json"}, {"extractUnaryNumericExprToConstant2.json"}, {"extractUnaryLogicalExprToConstant.json"}, diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/config/extractToConstantWithImports3.json b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/config/extractToConstantWithImports3.json new file mode 100644 index 000000000000..93b56f454790 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/config/extractToConstantWithImports3.json @@ -0,0 +1,41 @@ +{ + "position": { + "line": 10, + "character": 13 + }, + "source": "extractToConstantWithImports3.bal", + "expected": [ + { + "title": "Extract to constant", + "kind": "refactor.extract", + "edits": [ + { + "range": { + "start": { + "line": 2, + "character": 0 + }, + "end": { + "line": 2, + "character": 0 + } + }, + "newText": "const int CONST1 = 0;\n" + }, + { + "range": { + "start": { + "line": 10, + "character": 12 + }, + "end": { + "line": 10, + "character": 13 + } + }, + "newText": "CONST1" + } + ] + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/source/extractToConstantWithImports3.bal b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/source/extractToConstantWithImports3.bal new file mode 100644 index 000000000000..3bf2f18076ce --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/extract-to-constant/source/extractToConstantWithImports3.bal @@ -0,0 +1,12 @@ +import ballerina/module1; + +const int CONST = 10; + +type RecordType record { + string name; + int age; +}; + +function testFunction(RecordType rec) { + int x = 0; +} From c612a6ac04ba03d91ef909867f778f7c9725f204 Mon Sep 17 00:00:00 2001 From: LakshanWeerasinghe Date: Tue, 3 Jan 2023 14:22:56 +0530 Subject: [PATCH 417/450] Improve table langlib examples --- .../lang.table/src/main/ballerina/table.bal | 59 ++++++++++--------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/langlib/lang.table/src/main/ballerina/table.bal b/langlib/lang.table/src/main/ballerina/table.bal index 24d6bcbe1d5b..62592ffe72df 100644 --- a/langlib/lang.table/src/main/ballerina/table.bal +++ b/langlib/lang.table/src/main/ballerina/table.bal @@ -43,10 +43,11 @@ type KeyType anydata; # Returns number of members of a table. # # ```ballerina -# table [ +# table students = table [ # {name: "Jo"}, # {name: "Smith"} -# ].length() ⇒ 2 +# ]; +# students.length() ⇒ 2 # ``` # # + t - the table @@ -95,7 +96,7 @@ public isolated function iterator(table t) returns object { # ]; # students.get("220002CS") ⇒ {"index":"220002CS","name":"Sam"} # -# students.get("invalidKey") ⇒ panic +# students.get("110002CS") ⇒ panic # ``` # # + t - the table @@ -114,6 +115,13 @@ public isolated function get(table key t, KeyType k) returns M # It panics if parameter `val` is inconsistent with the inherent type of parameter `t`. # # ```ballerina +# table employees = table [ +# {id: 1, name: "Jo"}, +# {id: 2, name: "Sam"} +# ]; +# employees.put({id: 1, name: "Pat"}); +# employees ⇒ [{"id":1,"name":"Jo"},{"id":2,"name":"Sam"},{"id":1,"name":"Pat"}] +# # table key(id) students = table [ # {id: 1, name: "Jo"}, # {id: 2, name: "Sam"} @@ -121,16 +129,9 @@ public isolated function get(table key t, KeyType k) returns M # # students.put({id: 3, name: "Pat"}); # students ⇒ [{"id":1,"name":"Jo"},{"id":2,"name":"Sam"},{"id":3,"name":"Pat"}] -# +# # students.put({id: 1, name: "Kane"}); # students ⇒ [{"id":1,"name":"Kane"},{"id":2,"name":"Sam"},{"id":3,"name":"Pat"}] -# -# table tbl = table [ -# {id: 1, name: "Jo"}, -# {id: 2, name: "Sam"} -# ]; -# tbl.put({id: 1, name: "Pat"}); -# tbl ⇒ [{"id":1,"name":"Jo"},{"id":2,"name":"Sam"},{"id":1,"name":"Pat"}] # # table key(id) studentIds = students; # studentIds.put({id: 7}) ⇒ panic @@ -150,20 +151,20 @@ public isolated function put(table t, MapType val) = @java:Method { # or if parameter `val` is inconsistent with the inherent type of `t`. # # ```ballerina -# table key(id) students = table [ +# table employees = table [ # {id: 1, name: "Jo"}, # {id: 2, name: "Sam"} # ]; -# -# students.add({id: 3, name: "Pat"}); -# students ⇒ [{"id":1,"name":"Jo"},{"id":2,"name":"Sam"},{"id":3,"name":"Pat"}] +# employees.add({id: 1, name: "Pat"}); +# employees ⇒ [{"id":1,"name":"Jo"},{"id":2,"name":"Sam"},{"id":1,"name":"Pat"}] # -# table tbl = table [ +# table key(id) students = table [ # {id: 1, name: "Jo"}, # {id: 2, name: "Sam"} # ]; -# tbl.add({id: 1, name: "Pat"}); -# tbl ⇒ [{"id":1,"name":"Jo"},{"id":2,"name":"Sam"},{"id":1,"name":"Pat"}] +# +# students.add({id: 3, name: "Pat"}); +# students ⇒ [{"id":1,"name":"Jo"},{"id":2,"name":"Sam"},{"id":3,"name":"Pat"}] # # students.add({id: 1, name: "James"}) ⇒ panic # @@ -183,10 +184,11 @@ public isolated function add(table t, MapType val) = @java:Method { # Applies a function to each member of a table and returns a table of the result. # # ```ballerina -# table [ -# {id: 1, maths: 78, physics: 70}, -# {id: 2, maths: 83, physics: 80} -# ].map(student => {id: student.id, avg: (student.maths + student.physics) / 2}) ⇒ [{"id":1,"avg":74},{"id":2,"avg":81}] +# table students = table [ +# {id: 1, math: 78, physics: 70}, +# {id: 2, math: 83, physics: 80} +# ]; +# students.map(student => {id: student.id, avg: (student.math + student.physics) / 2}) ⇒ [{"id":1,"avg":74},{"id":2,"avg":81}] # ``` # # + t - the table @@ -226,11 +228,12 @@ public isolated function forEach(table t, @isolatedParam function(MapTy # The resulting table will have the same keys as the argument table. # # ```ballerina -# table [ +# table employees = table [ # {id: 1, salary: 1200}, # {id: 2, salary: 1100}, # {id: 3, salary: 800} -# ].filter(emp => emp.salary < 1000) ⇒ [{"id":3,"salary":800}] +# ]; +# employees.filter(emp => emp.salary < 1000) ⇒ [{"id":3,"salary":800}] # ``` # # + t - the table @@ -248,11 +251,12 @@ public isolated function filter(table key t, @isolatedParam fu # and returns a new combined value. # # ```ballerina -# table [ +# table employees = table [ # {id: 1, salary: 1200}, # {id: 2, salary: 1100}, # {id: 3, salary: 800} -# ].reduce(isolated function (int total, record {int id; int salary;} next) returns int => total + next.salary, 0) ⇒ 3100 +# ]; +# employees.reduce(isolated function (int total, record {int id; int salary;} next) returns int => total + next.salary, 0) ⇒ 3100 # ``` # # + t - the table @@ -330,7 +334,7 @@ public isolated function removeIfHasKey(table key t, KeyType k # {score: 30}, # {score: 40} # ]; -# scores.removeAll() is () ⇒ panic +# scores.removeAll() ⇒ panic # ``` # # + t - the table @@ -407,7 +411,6 @@ public isolated function toArray(table t) returns MapType[] = @java:Met # ]; # users.nextKey() ⇒ 3 # ``` - # # + t - the table with a key of type int # + return - an integer not yet used as a key From 03c4bcb4d47b629daa63aead4bfa213720fb8057 Mon Sep 17 00:00:00 2001 From: suleka96 Date: Tue, 3 Jan 2023 15:54:28 +0530 Subject: [PATCH 418/450] Add start index case --- langlib/lang.string/src/main/ballerina/string.bal | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/langlib/lang.string/src/main/ballerina/string.bal b/langlib/lang.string/src/main/ballerina/string.bal index ec82ad4832c2..541185064562 100644 --- a/langlib/lang.string/src/main/ballerina/string.bal +++ b/langlib/lang.string/src/main/ballerina/string.bal @@ -464,9 +464,13 @@ public function matches(string str, RegExp re) returns boolean { # This is equivalent to `regexp:find(re, str, startIndex) != ()`. # # ```ballerina -# "Will Match Somewhere".includesMatch(re `A|Th.*ch|^`) ⇒ true +# "This will match".includesMatch(re `Th.*ch`) ⇒ true # -# "Not a match".includesMatch(re `A|Th.*ch`) ⇒ false +# "Will this match".includesMatch(re `th.*ch`, 5) ⇒ true +# +# "Not a match".includesMatch(re `Th.*ch`) ⇒ false +# +# "Will this match".includesMatch(re `Th.*ch`, 5) ⇒ false # ``` # # + str - the string to be matched From 9f0cc0ee0d5845c8997e16410ce2fc154c6bf887 Mon Sep 17 00:00:00 2001 From: sanjana Date: Wed, 4 Jan 2023 09:13:02 +0530 Subject: [PATCH 419/450] Address review suggestion iteration --- langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal | 2 ++ 1 file changed, 2 insertions(+) diff --git a/langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal b/langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal index 91547c7bb154..c6257dbc5e12 100644 --- a/langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal +++ b/langlib/lang.typedesc/src/main/ballerina/typedesc_lib.bal @@ -46,6 +46,8 @@ public type TypeId readonly & record {| # # type SampleError distinct (Error & error); # +# Error.typeIds() ⇒ [{"moduleId":{"organization":"$anon","name":".","platformParts":["0"]},"localId":"Error"}] +# # SampleError.typeIds() ⇒ [{"moduleId":{"organization":"$anon","name":".","platformParts":["0"]},"localId":"SampleError"},{"moduleId":{"organization":"$anon","name":".","platformParts":["0"]},"localId":"Error"}] # # SampleError.typeIds(true) ⇒ [{"moduleId":{"organization":"$anon","name":".","platformParts":["0"]},"localId":"SampleError"}] From 9f467b310e16afaf96675caa95bb5213c0010e77 Mon Sep 17 00:00:00 2001 From: dulajdilshan Date: Tue, 20 Dec 2022 17:41:02 +0530 Subject: [PATCH 420/450] Address a review iteration --- langlib/lang.map/src/main/ballerina/map.bal | 24 +++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/langlib/lang.map/src/main/ballerina/map.bal b/langlib/lang.map/src/main/ballerina/map.bal index 960e4ca1fc38..2b12c395e34b 100644 --- a/langlib/lang.map/src/main/ballerina/map.bal +++ b/langlib/lang.map/src/main/ballerina/map.bal @@ -48,10 +48,9 @@ public isolated function length(map m) returns int =@java:Method { # The function `keys` can be used to iterator over just the keys. # # ```ballerina -# map marks = {"Carl": 85, "Bob": 50, "Max": 60}; # object { # public isolated function next() returns record {|int value;|}?; -# } iterator = marks.iterator(); +# } iterator = {"Carl": 85, "Bob": 50, "Max": 60}.iterator(); # iterator.next() ⇒ {"value":85} # ``` # @@ -72,9 +71,11 @@ public isolated function iterator(map m) returns object { # and accordingly panics if parameter `m` does not have a member with parameter `k` key. # # ```ballerina -# {"Carl": 85, "Bob": 50, "Max": 60}.get("Carl") ⇒ 85 +# map marks = {"Carl": 85, "Bob": 50, "Max": 60}; +# +# marks.get("Carl") ⇒ 85 # -# {"Carl": 85, "Bob": 50, "Max": 60}.get("John") ⇒ panic +# marks.get("John") ⇒ panic # ``` # # + m - the map @@ -88,8 +89,7 @@ public isolated function get(map m, string k) returns Type = @java:Method # Returns a map containing [key, member] pair as the value for each key. # # ```ballerina -# map marks = {"Carl": 85, "Bob": 50}; -# marks.entries() ⇒ {"Carl":["Carl",85],"Bob":["Bob",50]} +# {"Carl": 85, "Bob": 50}.entries() ⇒ {"Carl":["Carl",85],"Bob":["Bob",50]} # ``` # # + m - the map @@ -107,7 +107,7 @@ public isolated function entries(map m) returns map<[string, Type]> = @jav # # ```ballerina # map marks = {"Carl": 85, "Bob": 50, "Max": 60}; -# marks.map((marks) => marks > 50) ⇒ {"Carl":true,"Bob":false}; +# marks.map(m => m > 50) ⇒ {"Carl":true,"Bob":false,"Max":true} # ``` # # + m - the map @@ -159,7 +159,7 @@ public isolated function filter(map m, @isolatedParam function(Type val) r # # ```ballerina # map marks = {"Carl": 85, "Bob": 50, "Max": 60}; -# marks.reduce(isolated function (int total, int next) returns int => total + next, 0) ⇒ 195; +# marks.reduce(isolated function (int total, int next) returns int => total + next, 0) ⇒ 195 # ``` # # + m - the map @@ -225,7 +225,7 @@ public isolated function removeIfHasKey(map m, string k) returns Type? = @ # marks.removeAll(); # marks ⇒ {} # -# map values = {"x": 10, "y": 20}; +# map values = {x: 10, y: 20}; # values.removeAll() ⇒ panic; # ``` # @@ -238,9 +238,11 @@ public isolated function removeAll(map m) returns () = @java:Method { # Tests whether a map value has a member with a given key. # # ```ballerina -# {"Carl": 85, "Bob": 50, "Max": 60}.hasKey("Carl") ⇒ true +# map marks = {"Carl": 85, "Bob": 50, "Max": 60}; +# +# marks.hasKey("Carl") ⇒ true # -# {"Carl": 85, "Bob": 50, "Max": 60}.hasKey("John") ⇒ false +# marks.hasKey("John") ⇒ false # ``` # # + m - the map From abc4613a3882a674c186244194978f2a57ee8a2e Mon Sep 17 00:00:00 2001 From: dulajdilshan Date: Wed, 4 Jan 2023 09:26:07 +0530 Subject: [PATCH 421/450] Refactor code --- .../src/main/ballerina/transaction.bal | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/langlib/lang.transaction/src/main/ballerina/transaction.bal b/langlib/lang.transaction/src/main/ballerina/transaction.bal index 51d8e117768c..1e5076123b24 100644 --- a/langlib/lang.transaction/src/main/ballerina/transaction.bal +++ b/langlib/lang.transaction/src/main/ballerina/transaction.bal @@ -59,7 +59,7 @@ public type Timestamp readonly & object { # } # } # -# transactional function updateDB() returns error? { +# transactional function updateDB() { # transaction:Info info = transaction:info(); # info.xid ⇒ [100,102,53,51,97,57,57,51,45] # } @@ -98,7 +98,7 @@ public isolated function getInfo(byte[] xid) returns Info? = @java:Method { # } # } # -# transactional function updateDB() returns error? { +# transactional function updateDB() { # transaction:setRollbackOnly(error("marked as rollback only")); # } # ``` @@ -122,7 +122,7 @@ public transactional isolated function setRollbackOnly(error? e) { # } # } # -# transactional function updateDB() returns error? { +# transactional function updateDB() { # transaction:getRollbackOnly() ⇒ false # } # ``` @@ -145,7 +145,7 @@ public transactional isolated function getRollbackOnly() returns boolean = @java # } # } # -# transactional function updateDB() returns error? { +# transactional function updateDB() { # transaction:setData({accessType: "RO"}); # } # ``` @@ -164,11 +164,11 @@ public transactional isolated function setData(readonly data) = @java:Method { # function createEntity() returns error? { # transaction { # transaction:setData({accessType: "RO"}); -# transaction:getData() ⇒ {"accessType": "RO"} +# transaction:getData() ⇒ {"accessType":"RO"} # check commit; # } # } -# transactional function updateDB() returns error? { +# transactional function updateDB() { # transaction:setData({accessType: "RO"}); # transaction:getData() ⇒ {"accessType":"RO"} # } @@ -202,7 +202,7 @@ public type RollbackHandler isolated function(Info info, error? cause, boolean w # } # } # -# transactional function updateDB() returns error? { +# transactional function updateDB() { # transaction:onCommit(onCommitHandle); # } # @@ -227,7 +227,7 @@ public transactional isolated function onCommit(CommitHandler handler) = @java:M # } # } # -# transactional function updateDB() returns error? { +# transactional function updateDB() { # transaction:onRollback(onRollBackHandle); # } # From b8aa0b8c7b4bf88aa1cf829201c461ae20f753a1 Mon Sep 17 00:00:00 2001 From: dulajdilshan Date: Wed, 4 Jan 2023 09:52:47 +0530 Subject: [PATCH 422/450] Refactor code --- langlib/lang.transaction/src/main/ballerina/transaction.bal | 1 + 1 file changed, 1 insertion(+) diff --git a/langlib/lang.transaction/src/main/ballerina/transaction.bal b/langlib/lang.transaction/src/main/ballerina/transaction.bal index 1e5076123b24..0e8bd367b713 100644 --- a/langlib/lang.transaction/src/main/ballerina/transaction.bal +++ b/langlib/lang.transaction/src/main/ballerina/transaction.bal @@ -168,6 +168,7 @@ public transactional isolated function setData(readonly data) = @java:Method { # check commit; # } # } +# # transactional function updateDB() { # transaction:setData({accessType: "RO"}); # transaction:getData() ⇒ {"accessType":"RO"} From 748ab266475d51db8f993ce05fca56be34858b08 Mon Sep 17 00:00:00 2001 From: sanjana Date: Tue, 3 Jan 2023 22:54:26 +0530 Subject: [PATCH 423/450] Address review sugesstion iteration --- langlib/lang.xml/src/main/ballerina/xml.bal | 74 ++++++++++----------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/langlib/lang.xml/src/main/ballerina/xml.bal b/langlib/lang.xml/src/main/ballerina/xml.bal index 72a31faa1610..cd642cbe0a5d 100644 --- a/langlib/lang.xml/src/main/ballerina/xml.bal +++ b/langlib/lang.xml/src/main/ballerina/xml.bal @@ -83,8 +83,8 @@ type XmlType xml; # ```ballerina # object { # public isolated function next() returns record {|xml value;|}?; -# } iterator = xml `BallerinaJava`.iterator(); -# iterator.next() ⇒ {"value":`Ballerina`} +# } iterator = xml `Learning BallerinaJava Guide`.iterator(); +# iterator.next() ⇒ {"value":`Learning Ballerina`} # ``` # # + x - xml sequence to iterate over @@ -102,8 +102,8 @@ public isolated function iterator(xml x) returns object { # parameter `x` does not have an item with index parameter `i`. # # ```ballerina -# xml books = xml `BallerinaJava`; -# books.get(1) ⇒ Java +# xml books = xml `MacbethHamlet`; +# books.get(1) ⇒ Hamlet # # books.get(15) ⇒ panic # ``` @@ -119,13 +119,13 @@ public isolated function get(xml x, int i) returns ItemType = @java:Me # Concatenates xml and string values. # # ```ballerina -# xml bookA = xml `Ballerina`; -# xml bookB = xml `Java`; -# xml:concat(bookA, bookB, xml `Python`) ⇒ BallerinaJavaPython +# xml bookA = xml `Sherlock Holmes`; +# xml bookB = xml `Hamlet`; +# xml:concat(bookA, bookB, xml `Macbeth`) ⇒ Sherlock HolmesHamletMacbeth # -# bookA.concat(bookB) ⇒ BallerinaJava +# bookA.concat(bookB) ⇒ Sherlock HolmesHamlet # -# bookB.concat("Coding") ⇒ JavaCoding +# bookB.concat("Novel") ⇒ HamletNovel # # xml:concat("Hello", "World") ⇒ HelloWorld # @@ -190,8 +190,8 @@ public isolated function getAttributes(Element x) returns map = @java:Me # Returns the children of an xml element. # # ```ballerina -# xml:Element books = xml `BallerinaJava`; -# books.getChildren() ⇒ BallerinaJava +# xml:Element books = xml `HamletMacbeth`; +# books.getChildren() ⇒ HamletMacbeth # ``` # # + elem - xml element @@ -207,10 +207,10 @@ public isolated function getChildren(Element elem) returns xml = @java:Method { # becoming cyclic. # # ```ballerina -# xml:Element books = xml `BallerinaJava`; -# xml js = xml `HTMLJavascript`; +# xml:Element books = xml `Ballerina GuideJava Tutorial`; +# xml js = xml `Learning HTMLJavascript Guide`; # books.setChildren(js); -# books ⇒ HTMLJavascript +# books ⇒ Learning HTMLJavascript Guide # # xml:Element x = xml `John`; # x.setChildren("Jane"); @@ -259,8 +259,8 @@ public isolated function getDescendants(Element elem) returns xml = @java:Method # concatenation of the character data of x1 and the character data of x2. # # ```ballerina -# xml book = xml `Ballerina`; -# book.data() ⇒ Ballerina +# xml book = xml `Jane Eyre`; +# book.data() ⇒ Jane Eyre # ``` # # + x - the xml value @@ -306,9 +306,9 @@ public isolated function getContent(ProcessingInstruction|Comment x) returns str # ```ballerina # xml:createElement( # "book", -# {title: "Ballerina", year: "2022"}, +# {title: "Ballerina Guide", year: "2022"}, # xml `Anjana` -# ) ⇒ Anjana +# ) ⇒ Anjana # ``` # # + name - the name of the new element @@ -372,8 +372,8 @@ public isolated function createText(string data) returns Text = @java:Method { # Returns a subsequence of an xml value. # # ```ballerina -# xml books = xml `HTMLBallerinaPythonCSS`; -# books.slice(1, 3) ⇒ BallerinaPython +# xml books = xml `HTMLInvisible ManDavid CopperfieldJane Eyre`; +# books.slice(1, 3) ⇒ Invisible ManDavid Copperfield # ``` # # + x - the xml value @@ -412,11 +412,11 @@ public isolated function strip(xml x) returns xml = @java:Method { # otherwise, selects only elements whose expanded name is parameter `nm`. # # ```ballerina -# xml books = xml `Ballerina -# Python`; -# books.elements() ⇒ BallerinaPython +# xml books = xml `Ballerina Guide +# Learning Python`; +# books.elements() ⇒ Ballerina GuideLearning Python # -# books.elements("code") ⇒ BallerinaPython +# books.elements("code") ⇒ Ballerina GuideLearning Python # ``` # # + x - the xml value @@ -434,8 +434,8 @@ public isolated function elements(xml x, string? nm = ()) returns xml = # This is equivalent to `elements(x).map(getChildren)`. # # ```ballerina -# xml books = xml `JavaBallerina`; -# books.children() ⇒ JavaBallerina +# xml books = xml `HamletMacbeth`; +# books.children() ⇒ HamletMacbeth # ``` # # + x - xml value @@ -450,8 +450,8 @@ public isolated function children(xml x) returns xml = @java:Method { # This is equivalent to `children(x).elements(nm)`. # # ```ballerina -# xml books = xml `JavaBallerina`; -# books.elementChildren("title") ⇒ JavaBallerina +# xml books = xml `HamletMacbeth`; +# books.elementChildren("title") ⇒ HamletMacbeth # ``` # # + x - the xml value @@ -471,10 +471,10 @@ public isolated function elementChildren(xml x, string? nm = ()) returns xmlJavaBallerina`; +# xml books = xml `HamletMacbeth`; # books.map(function (xml xmlContent) returns xml { # return xml `${xmlContent.children()}`; -# }) ⇒ JavaBallerina +# }) ⇒ HamletMacbeth # ``` # # + x - the xml value @@ -491,14 +491,14 @@ public isolated function 'map(xml x, @isolatedParam function(ItemType # Each item is represented as a singleton value. # # ```ballerina -# xml books = xml `JavaBallerina`; +# xml books = xml `Java TutorialBallerina Guide`; # xml titles = xml ``; # # books.forEach(function (xml xmlItem) { # titles += xml `${xmlItem.data()}`; # }); # -# titles ⇒ JavaBallerina +# titles ⇒ Java TutorialBallerina Guide # ``` # # + x - the xml value @@ -513,8 +513,8 @@ public isolated function forEach(xml x, @isolatedParam function(ItemTy # Each item is represented as a singleton value. # # ```ballerina -# xml books = xml `BallerinaPython`; -# books.filter(x => x is xml:Element && x.getName() == "code") ⇒ BallerinaPython +# xml programmingLanguages = xml `BallerinaPython`; +# programmingLanguages.filter(x => x is xml:Element && x.getName() == "code") ⇒ BallerinaPython # ``` # # + x - xml value @@ -532,7 +532,7 @@ public isolated function filter(xml x, @isolatedParam function(ItemTyp # XML 1.0 Recommendation. # # ```ballerina -# xml:fromString("BallerinaJava") ⇒ BallerinaJava +# xml:fromString("HamletSherlock Holmes") ⇒ HamletSherlock Holmes # # xml:fromString("b") ⇒ error # ``` @@ -547,8 +547,8 @@ public isolated function fromString(string s) returns xml|error = @java:Method { # Selects all the items in a sequence that are of type `xml:Text`. # # ```ballerina -# xml books = xml `BallerinaJava`; -# books.text() ⇒ BallerinaJava +# xml books = xml `HamletPlay`; +# books.text() ⇒ HamletPlay # ``` # # + x - the xml value From 75acd3dceebcec35b0b72f4fdda46a010d9334f2 Mon Sep 17 00:00:00 2001 From: Charuka Tharindu Date: Wed, 4 Jan 2023 10:43:02 +0530 Subject: [PATCH 424/450] Update branches for nightly build --- .github/workflows/nightly_publish_timestamped_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly_publish_timestamped_release.yml b/.github/workflows/nightly_publish_timestamped_release.yml index ae4e23b68e60..19e38274639c 100644 --- a/.github/workflows/nightly_publish_timestamped_release.yml +++ b/.github/workflows/nightly_publish_timestamped_release.yml @@ -12,7 +12,7 @@ jobs: fail-fast: false max-parallel: 4 matrix: - branch: ['master', '2201.0.x', '2201.1.x', '2201.2.x'] + branch: ['master', '2201.2.x', '2201.3.x'] timeout-minutes: 240 if: github.repository_owner == 'ballerina-platform' steps: From f029f579e85fa1839ec63cdd15736535a9c79b6d Mon Sep 17 00:00:00 2001 From: Thevakumar-Luheerathan Date: Wed, 4 Jan 2023 10:53:37 +0530 Subject: [PATCH 425/450] Address the review --- .../compiler/TestExecutionGenerationTask.java | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/TestExecutionGenerationTask.java b/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/TestExecutionGenerationTask.java index 86ba2b20a293..465d55b1ba58 100644 --- a/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/TestExecutionGenerationTask.java +++ b/misc/testerina/modules/testerina-compiler-plugin/src/main/java/org/ballerinalang/testerina/compiler/TestExecutionGenerationTask.java @@ -60,6 +60,8 @@ */ public class TestExecutionGenerationTask implements GeneratorTask { + public static final String BAL_EXTENSION = ".bal"; + @Override public void generate(SourceGeneratorContext generatorContext) { generateClassMockedFunctionMapping(generatorContext.currentPackage(), generatorContext); @@ -175,7 +177,7 @@ private static void generateClassMockedFunctionMapping(Package pack, SourceGener String moduleName = module.moduleName().toString(); for (DocumentId documentId : module.testDocumentIds()) { Document document = module.document(documentId); - String documentName = moduleName + "-" + document.name().replace(".bal", "") + String documentName = moduleName + "-" + document.name().replace(BAL_EXTENSION, "") .replace("/", "."); List mockedFunctionList = new ArrayList<>(); Node rootNode = document.syntaxTree().rootNode(); @@ -186,24 +188,25 @@ private static void generateClassMockedFunctionMapping(Package pack, SourceGener NodeList statements = ((FunctionBodyBlockNode) functionBodyNode).statements(); for (int i = 0; i < statements.size(); i++) { StatementNode statementNode = (StatementNode) statements.get(i); - if (statementNode instanceof ExpressionStatementNode) { - ExpressionNode expressionStatement = ((ExpressionStatementNode) statementNode).expression(); - if (expressionStatement instanceof MethodCallExpressionNode) { - ExpressionNode methodCallExpression = ((MethodCallExpressionNode) - expressionStatement).expression(); - if (methodCallExpression instanceof FunctionCallExpressionNode) { - gatherMockedFunctions(mockedFunctionList, expressionStatement, - methodCallExpression); - - } else if (methodCallExpression instanceof MethodCallExpressionNode) { - methodCallExpression = ((MethodCallExpressionNode) - methodCallExpression).expression(); - if (methodCallExpression instanceof FunctionCallExpressionNode) { - gatherMockedFunctions(mockedFunctionList, expressionStatement, - methodCallExpression); - } - } - } + + if (statementNode.kind() != SyntaxKind.CALL_STATEMENT) { + continue; + } + ExpressionNode expressionStatement = ((ExpressionStatementNode) statementNode).expression(); + + if (expressionStatement.kind() != SyntaxKind.METHOD_CALL) { + continue; + } + ExpressionNode methodCallExpression = ((MethodCallExpressionNode) expressionStatement) + .expression(); + + if (methodCallExpression.kind() == SyntaxKind.METHOD_CALL) { + methodCallExpression = ((MethodCallExpressionNode) methodCallExpression).expression(); + } + + if (methodCallExpression.kind() == SyntaxKind.FUNCTION_CALL) { + gatherMockedFunctions(mockedFunctionList, expressionStatement, methodCallExpression); + } } } @@ -221,7 +224,7 @@ private static void gatherMockedFunctions(List mockedFunctionList, Expre MethodCallExpressionNode methodCallExpressionNode = (MethodCallExpressionNode) expressionStatement; FunctionCallExpressionNode functionCallExpressionNode = (FunctionCallExpressionNode) methodCallExpression; NameReferenceNode functionName = functionCallExpressionNode.functionName(); - if (functionName instanceof QualifiedNameReferenceNode) { + if (functionName.kind() == SyntaxKind.QUALIFIED_NAME_REFERENCE) { String modulePrefix = ((QualifiedNameReferenceNode) functionName). modulePrefix().text(); String identifier = ((QualifiedNameReferenceNode) functionName). From 37cf6741fba821e69983fd8b38cb65c757da6278 Mon Sep 17 00:00:00 2001 From: sanjana Date: Wed, 4 Jan 2023 11:18:41 +0530 Subject: [PATCH 426/450] Address review suggestions of xml langlib examples --- langlib/lang.xml/src/main/ballerina/xml.bal | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/langlib/lang.xml/src/main/ballerina/xml.bal b/langlib/lang.xml/src/main/ballerina/xml.bal index cd642cbe0a5d..ed556ecda7ff 100644 --- a/langlib/lang.xml/src/main/ballerina/xml.bal +++ b/langlib/lang.xml/src/main/ballerina/xml.bal @@ -309,6 +309,10 @@ public isolated function getContent(ProcessingInstruction|Comment x) returns str # {title: "Ballerina Guide", year: "2022"}, # xml `Anjana` # ) ⇒ Anjana +# +# xml:createElement("student") ⇒ +# +# xml:createElement("person", children = xml `John`) ⇒ John # ``` # # + name - the name of the new element @@ -374,6 +378,8 @@ public isolated function createText(string data) returns Text = @java:Method { # ```ballerina # xml books = xml `HTMLInvisible ManDavid CopperfieldJane Eyre`; # books.slice(1, 3) ⇒ Invisible ManDavid Copperfield +# +# books.slice(2) ⇒ David CopperfieldJane Eyre # ``` # # + x - the xml value @@ -450,8 +456,10 @@ public isolated function children(xml x) returns xml = @java:Method { # This is equivalent to `children(x).elements(nm)`. # # ```ballerina -# xml books = xml `HamletMacbeth`; -# books.elementChildren("title") ⇒ HamletMacbeth +# xml books = xml `HamletMacbeth`; +# books.elementChildren("novel") ⇒ Macbeth +# +# books.elementChildren() ⇒ HamletMacbeth # ``` # # + x - the xml value @@ -472,9 +480,9 @@ public isolated function elementChildren(xml x, string? nm = ()) returns xmlHamletMacbeth`; -# books.map(function (xml xmlContent) returns xml { -# return xml `${xmlContent.children()}`; -# }) ⇒ HamletMacbeth +# books.map(function (xml xmlContent) returns xml => +# xml `${xmlContent.children()}` +# ) ⇒ HamletMacbeth # ``` # # + x - the xml value From 7ab0e52d6429f674307b3173b290ce0ca9f37b47 Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Wed, 4 Jan 2023 11:34:45 +0530 Subject: [PATCH 427/450] Remove architecture-model-generator related modules --- .../zip/jballerina-tools/build.gradle | 3 - .../architecture-model-generator/build.gradle | 56 --- .../ComponentModel.java | 96 ---- .../ComponentModelBuilder.java | 69 --- .../ProjectComponentRequest.java | 40 -- .../ProjectComponentResponse.java | 63 --- .../ProjectDesignConstants.java | 103 ----- .../diagnostics/ComponentModelException.java | 35 -- .../ComponentModelingDiagnostics.java | 84 ---- .../diagnostics/DiagnosticMessage.java | 64 --- .../diagnostics/DiagnosticUtils.java | 43 -- .../generators/GeneratorUtils.java | 171 -------- .../generators/ModelGenerator.java | 58 --- .../entity/EntityModelGenerator.java | 332 -------------- .../service/ServiceModelGenerator.java | 58 --- .../nodevisitors/ActionNodeVisitor.java | 248 ----------- .../ServiceDeclarationNodeVisitor.java | 174 -------- .../ServiceMemberFunctionNodeVisitor.java | 414 ------------------ .../model/ElementLocation.java | 83 ---- .../model/ModelElement.java | 37 -- .../model/entity/Association.java | 75 ---- .../model/entity/Attribute.java | 75 ---- .../model/entity/Entity.java | 63 --- .../model/service/Dependency.java | 46 -- .../model/service/FunctionParameter.java | 55 --- .../model/service/Interaction.java | 47 -- .../model/service/RemoteFunction.java | 63 --- .../model/service/Resource.java | 68 --- .../model/service/ResourceId.java | 50 --- .../model/service/ResourceParameter.java | 63 --- .../model/service/Service.java | 81 ---- .../model/service/ServiceAnnotation.java | 57 --- .../src/main/java/module-info.java | 27 -- .../build.gradle | 40 -- .../CompilationAnalysisTask.java | 87 ---- .../ModelGeneratorCodeAnalyzer.java | 33 -- .../ModelGeneratorCompilerPlugin.java | 32 -- .../PluginConstants.java | 27 -- .../diagnostic/DiagnosticMessage.java | 52 --- .../src/main/java/module-info.java | 27 -- ....ballerina.projects.plugins.CompilerPlugin | 1 - .../project-design-service/build.gradle | 68 --- .../ProjectDesignClientCapabilities.java | 45 -- .../ProjectDesignClientCapabilitySetter.java | 43 -- .../ProjectDesignServerCapabilities.java | 44 -- .../ProjectDesignServerCapabilitySetter.java | 53 --- .../projectdesign/ProjectDesignService.java | 116 ----- .../io/ballerina/projectdesign/Utils.java | 44 -- .../src/main/java/module-info.java | 28 -- ...gistration.BallerinaClientCapabilitySetter | 1 - ...gistration.BallerinaServerCapabilitySetter | 1 - ....service.spi.ExtendedLanguageServerService | 1 - settings.gradle | 6 - 53 files changed, 3750 deletions(-) delete mode 100644 misc/architecture-model-generator/build.gradle delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ComponentModel.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ComponentModelBuilder.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectComponentRequest.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectComponentResponse.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectDesignConstants.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/ComponentModelException.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/ComponentModelingDiagnostics.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/DiagnosticMessage.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/DiagnosticUtils.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/GeneratorUtils.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/ModelGenerator.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/entity/EntityModelGenerator.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/ServiceModelGenerator.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ActionNodeVisitor.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/ElementLocation.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/ModelElement.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Association.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Attribute.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Entity.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Dependency.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/FunctionParameter.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Interaction.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/RemoteFunction.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Resource.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ResourceId.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ResourceParameter.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Service.java delete mode 100644 misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ServiceAnnotation.java delete mode 100644 misc/architecture-model-generator/src/main/java/module-info.java delete mode 100644 misc/compiler-plugins/modules/architecture-model-generator-plugin/build.gradle delete mode 100644 misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/CompilationAnalysisTask.java delete mode 100644 misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCodeAnalyzer.java delete mode 100644 misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCompilerPlugin.java delete mode 100644 misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/PluginConstants.java delete mode 100644 misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/diagnostic/DiagnosticMessage.java delete mode 100644 misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/module-info.java delete mode 100644 misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/resources/META-INF/services/io.ballerina.projects.plugins.CompilerPlugin delete mode 100644 misc/ls-extensions/modules/project-design-service/build.gradle delete mode 100644 misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignClientCapabilities.java delete mode 100644 misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignClientCapabilitySetter.java delete mode 100644 misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignServerCapabilities.java delete mode 100644 misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignServerCapabilitySetter.java delete mode 100644 misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignService.java delete mode 100644 misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/Utils.java delete mode 100644 misc/ls-extensions/modules/project-design-service/src/main/java/module-info.java delete mode 100644 misc/ls-extensions/modules/project-design-service/src/main/resources/META-INF/services/org.ballerinalang.langserver.commons.registration.BallerinaClientCapabilitySetter delete mode 100644 misc/ls-extensions/modules/project-design-service/src/main/resources/META-INF/services/org.ballerinalang.langserver.commons.registration.BallerinaServerCapabilitySetter delete mode 100644 misc/ls-extensions/modules/project-design-service/src/main/resources/META-INF/services/org.ballerinalang.langserver.commons.service.spi.ExtendedLanguageServerService diff --git a/distribution/zip/jballerina-tools/build.gradle b/distribution/zip/jballerina-tools/build.gradle index 802db0d1a87a..e2e26170a8ed 100644 --- a/distribution/zip/jballerina-tools/build.gradle +++ b/distribution/zip/jballerina-tools/build.gradle @@ -96,7 +96,6 @@ dependencies { dist "com.atomikos:atomikos-util:${project.atomikosUtilVersion}" dist "com.atomikos:transactions:${project.atomikosTransactionsVersion}" - dist project(':architecture-model-generator') dist project(':ballerina-tools-api') dist project(':ballerina-parser') dist project(':ballerina-tools-api') @@ -124,7 +123,6 @@ dependencies { dist project(':ballerina-shell:shell-cli') dist project(':compiler-plugins:package-semantic-analyzer') dist project(':compiler-plugins:configurable-schema-generator') - dist project(':compiler-plugins:architecture-model-generator-plugin') dist project(':identifier-util') datamapperLib project(':ballerinalang-data-mapper') @@ -138,7 +136,6 @@ dependencies { langserverLib project(':ls-extensions:partial-parser') langserverLib project(':ls-extensions:trigger-service') langserverLib project(':ls-extensions:bal-shell-service') - langserverLib project(':ls-extensions:project-design-service') debugAdapterLib project(path: ':debug-adapter:debug-adapter-core', configuration: 'libs') debugAdapterLib project(':debug-adapter:debug-adapter-cli') diff --git a/misc/architecture-model-generator/build.gradle b/misc/architecture-model-generator/build.gradle deleted file mode 100644 index ef93d96b342b..000000000000 --- a/misc/architecture-model-generator/build.gradle +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -apply from: "$rootDir/gradle/javaProject.gradle" -apply from: "$rootDir/gradle/ballerinaLangLibLoad.gradle" - -configurations { - compile.transitive = false - compileClasspath.extendsFrom(compileOnly) -} - -dependencies { - compileOnly project(':ballerina-parser') - compileOnly project(':ballerina-lang') - - implementation project(':ballerina-tools-api') - implementation "com.google.code.gson:gson:${project.gsonVersion}" - - testCompile 'org.testng:testng' - -} - -test { - useTestNG() { - suites 'src/test/resources/testng.xml' - } -} - -description = 'Model generator core for project design diagram generation' - -ext.moduleName = 'io.ballerina.architecturemodelgenerator' - -compileJava { - inputs.property("moduleName", moduleName) - doFirst { - options.compilerArgs = [ - '--module-path', classpath.asPath, - ] - classpath = files() - } -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ComponentModel.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ComponentModel.java deleted file mode 100644 index 39cf3b3311bd..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ComponentModel.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator; - -import io.ballerina.architecturemodelgenerator.model.entity.Entity; -import io.ballerina.architecturemodelgenerator.model.service.Service; -import io.ballerina.projects.Package; - -import java.util.Map; - -/** - * Represents intermediate model to represent multi-service projects. - * - * @since 2201.2.2 - */ -public class ComponentModel { - - private final PackageId packageId; - private final boolean hasCompilationErrors; - private final Map services; - private final Map entities; - - public ComponentModel(PackageId packageId, Map services, Map entities, - boolean hasCompilationErrors) { - - this.packageId = packageId; - this.services = services; - this.entities = entities; - this.hasCompilationErrors = hasCompilationErrors; - } - - public PackageId getPackageId() { - - return packageId; - } - - public Map getServices() { - - return services; - } - - public Map getEntities() { - - return entities; - } - - public boolean hasCompilationErrors() { - return hasCompilationErrors; - } - - /** - * Represent current package information. - */ - public static class PackageId { - - private final String name; - private final String org; - private final String version; - - public PackageId(Package currentPackage) { - - this.name = currentPackage.packageName().value(); - this.org = currentPackage.packageOrg().value(); - this.version = currentPackage.packageVersion().value().toString(); - } - - public String getName() { - return name; - } - - public String getOrg() { - return org; - } - - public String getVersion() { - return version; - } - - } -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ComponentModelBuilder.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ComponentModelBuilder.java deleted file mode 100644 index 9acd436fd4ca..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ComponentModelBuilder.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator; - -import io.ballerina.architecturemodelgenerator.ComponentModel.PackageId; -import io.ballerina.architecturemodelgenerator.generators.entity.EntityModelGenerator; -import io.ballerina.architecturemodelgenerator.generators.service.ServiceModelGenerator; -import io.ballerina.architecturemodelgenerator.model.entity.Entity; -import io.ballerina.architecturemodelgenerator.model.service.Service; -import io.ballerina.compiler.api.SemanticModel; -import io.ballerina.projects.Package; -import io.ballerina.projects.PackageCompilation; - -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.atomic.AtomicBoolean; - -/** - * Construct component model fpr project with multiple service. - * - * @since 2201.2.2 - */ -public class ComponentModelBuilder { - - public ComponentModel constructComponentModel(Package currentPackage) { - return constructComponentModel(currentPackage, null); - } - - public ComponentModel constructComponentModel(Package currentPackage, PackageCompilation packageCompilation) { - Map services = new HashMap<>(); - // todo: Change to TypeDefinition - Map entities = new HashMap<>(); - PackageId packageId = new PackageId(currentPackage); - AtomicBoolean hasDiagnosticErrors = new AtomicBoolean(false); - - currentPackage.modules().forEach(module -> { - PackageCompilation currentPackageCompilation = packageCompilation == null ? - currentPackage.getCompilation() : packageCompilation; - SemanticModel currentSemanticModel = currentPackageCompilation.getSemanticModel(module.moduleId()); - if (currentPackageCompilation.diagnosticResult().hasErrors() && !hasDiagnosticErrors.get()) { - hasDiagnosticErrors.set(true); - } - // todo : Check project diagnostics - ServiceModelGenerator serviceModelGenerator = new ServiceModelGenerator(currentSemanticModel, module); - services.putAll(serviceModelGenerator.generate()); - - EntityModelGenerator entityModelGenerator = new EntityModelGenerator(currentSemanticModel, module); - entities.putAll(entityModelGenerator.generate()); - }); - - return new ComponentModel(packageId, services, entities, hasDiagnosticErrors.get()); - } -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectComponentRequest.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectComponentRequest.java deleted file mode 100644 index 75eb6095bbde..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectComponentRequest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator; - -import java.util.ArrayList; -import java.util.List; - -/** - * Request for Solution Architecture model generation. - * - * @since 2201.2.2 - */ -public class ProjectComponentRequest { - - private List documentUris = new ArrayList<>(); - - public List getDocumentUris() { - return documentUris; - } - - public void setDocumentUris(List documentUris) { - this.documentUris = documentUris; - } -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectComponentResponse.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectComponentResponse.java deleted file mode 100644 index 043bdbac8821..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectComponentResponse.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator; - -import com.google.gson.JsonObject; -import io.ballerina.architecturemodelgenerator.diagnostics.ComponentModelingDiagnostics; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Response format for component model request. - * - * @since 2201.2.2 - */ -public class ProjectComponentResponse { - - private Map componentModels = new HashMap<>(); - - private List diagnostics = new ArrayList<>(); - - public Map getComponentModels() { - return componentModels; - } - - public void setComponentModels(Map componentModels) { - this.componentModels = componentModels; - } - - public List getDiagnostics() { - return diagnostics; - } - - public void setDiagnostics(List diagnostics) { - this.diagnostics = diagnostics; - } - - public void addcomponentModel(String key, JsonObject jsonObject) { - componentModels.put(key, jsonObject); - } - - public void addDiagnostics(List componentModelingDiagnostics) { - this.diagnostics.addAll(componentModelingDiagnostics); - } -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectDesignConstants.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectDesignConstants.java deleted file mode 100644 index 51fb52bab040..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/ProjectDesignConstants.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator; - -import io.ballerina.compiler.syntax.tree.SyntaxKind; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -/** - * Constants use for Solution Architecture model generation. - * - * @since 2201.2.2 - */ -public class ProjectDesignConstants { - - /** - * Enum to select the type of the parameter. - */ - public enum ParameterIn { - BODY("body"), - QUERY("query"), - HEADER("header"), - PATH("path"); - - private final String parameterIn; - - ParameterIn(String parameterIn) { - this.parameterIn = parameterIn; - } - - public String getValue() { - return this.parameterIn; - } - } - - public static final String CAPABILITY_NAME = "multiServiceModelingService"; - public static final String COLON = ":"; - public static final String FORWARD_SLASH = "/"; - public static final String SERVICE_ANNOTATION = "choreo:Service"; - public static final String DISPLAY_ANNOTATION = "display"; - public static final String CLIENT_ANNOTATION = "choreo:Client"; - public static final String ID = "id"; - public static final String LABEL = "label"; - public static final String SERVICE_ID = "serviceId"; - public static final String ARRAY = "[]"; - public static final String LISTENER = ":Listener"; - public static final String CLIENT = ":Client"; - - /** - * Enum for cardinality types. - */ - public enum CardinalityValue { - ZERO("0"), - ZERO_OR_ONE("0-1"), - ZERO_OR_MANY("0-m"), - ONE("1"), - ONE_AND_ONLY_ONE("1-1"), - ONE_OR_MANY("1-m"), - MANY("m"); - - private final String cardinalityValue; - - CardinalityValue(String cardinalityValue) { - this.cardinalityValue = cardinalityValue; - } - - public String getValue() { - return this.cardinalityValue; - } - } - - public static final Map TYPE_MAP; - - // todo: for hex literals ? - static { - Map typeMap = new HashMap<>(); - typeMap.put(SyntaxKind.STRING_LITERAL, "string"); - typeMap.put(SyntaxKind.BOOLEAN_LITERAL, "boolean"); - typeMap.put(SyntaxKind.DECIMAL_FLOATING_POINT_LITERAL_TOKEN, "float"); - typeMap.put(SyntaxKind.NUMERIC_LITERAL, "decimal"); - typeMap.put(SyntaxKind.DECIMAL_INTEGER_LITERAL_TOKEN, "float"); - TYPE_MAP = Collections.unmodifiableMap(typeMap); - } - -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/ComponentModelException.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/ComponentModelException.java deleted file mode 100644 index 29fc1c8dbeb2..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/ComponentModelException.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator.diagnostics; - -/** - * Exception for component model generation. - * - * @since 2201.2.2 - */ -public class ComponentModelException extends Exception { - - public ComponentModelException(String message, Throwable e) { - super(message, e); - } - - public ComponentModelException(String message) { - super(message); - } -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/ComponentModelingDiagnostics.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/ComponentModelingDiagnostics.java deleted file mode 100644 index 4d162d5a3ce9..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/ComponentModelingDiagnostics.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator.diagnostics; - -import io.ballerina.tools.diagnostics.Diagnostic; -import io.ballerina.tools.diagnostics.DiagnosticInfo; -import io.ballerina.tools.diagnostics.DiagnosticProperty; -import io.ballerina.tools.diagnostics.DiagnosticSeverity; -import io.ballerina.tools.diagnostics.Location; - -import java.text.MessageFormat; -import java.util.Collections; -import java.util.List; - -/** - * Diagnostic class for the ProjectDesignService. - * - * @since 2201.2.2 - */ -public class ComponentModelingDiagnostics extends Diagnostic { - - private final DiagnosticInfo diagnosticInfo; - private final Location location; - private final List> properties; - private final String message; - private final String severity; - - public ComponentModelingDiagnostics(String code, String message, DiagnosticSeverity severity, - Location location, Object[] args) { - - this.diagnosticInfo = new DiagnosticInfo(code, message, severity); - this.location = location; - this.properties = Collections.emptyList(); - this.message = MessageFormat.format(message, args); - this.severity = severity.name(); - } - - @Override - public Location location() { - return this.location; - } - - @Override - public DiagnosticInfo diagnosticInfo() { - return this.diagnosticInfo; - } - - @Override - public String message() { - return this.message; - } - - @Override - public List> properties() { - return this.properties; - } - - public String getSeverity() { - return this.severity; - } - - @Override - public String toString() { - - String severity = this.diagnosticInfo().severity().toString(); - return "[" + severity + "] " + this.message(); - } -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/DiagnosticMessage.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/DiagnosticMessage.java deleted file mode 100644 index ab7bd766e560..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/DiagnosticMessage.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator.diagnostics; - -import io.ballerina.tools.diagnostics.DiagnosticSeverity; - -/** - * Diagnostic message format for component model generation errors. - * - * @since 2201.2.2 - */ -public class DiagnosticMessage { - - private final String code; - private final String description; - private final DiagnosticSeverity severity; - - private DiagnosticMessage(String code, String description, DiagnosticSeverity severity) { - - this.code = code; - this.description = description; - this.severity = severity; - } - - public String getCode() { - return code; - } - - public String getDescription() { - return description; - } - - public DiagnosticSeverity getSeverity() { - return severity; - } - - public static DiagnosticMessage componentModellingService001(String projectPath) { - return new DiagnosticMessage("001", String.format("Ballerina project not found in the path : %s", - projectPath), DiagnosticSeverity.ERROR); - } - - public static DiagnosticMessage componentModellingService002(String projectPath, String message, - String stacktrace) { - return new DiagnosticMessage("002", String.format("Unexpected error occurred while resolving Ballerina " + - "package for the path: %s. %nMessage : %s %nStackTrace : %s", projectPath, message, stacktrace), - DiagnosticSeverity.ERROR); - } -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/DiagnosticUtils.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/DiagnosticUtils.java deleted file mode 100644 index 01e57cfa53ca..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/diagnostics/DiagnosticUtils.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator.diagnostics; - -import io.ballerina.architecturemodelgenerator.ProjectComponentResponse; - -import java.util.List; - -/** - * Provides util functions for diagnostics. - * - * @since 2201.2.2 - */ -public class DiagnosticUtils { - - public static List getDiagnosticResponse(List diagnosticMessages, - ProjectComponentResponse response) { - - List diagnostics = response.getDiagnostics(); - for (DiagnosticMessage message : diagnosticMessages) { - ComponentModelingDiagnostics diagnostic = new ComponentModelingDiagnostics( - message.getCode(), message.getDescription(), message.getSeverity(), null, null); - diagnostics.add(diagnostic); - } - return diagnostics; - } -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/GeneratorUtils.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/GeneratorUtils.java deleted file mode 100644 index ab574af2bf28..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/GeneratorUtils.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator.generators; - -import io.ballerina.architecturemodelgenerator.model.ElementLocation; -import io.ballerina.architecturemodelgenerator.model.service.ServiceAnnotation; -import io.ballerina.compiler.api.SemanticModel; -import io.ballerina.compiler.api.symbols.Annotatable; -import io.ballerina.compiler.api.symbols.AnnotationAttachmentSymbol; -import io.ballerina.compiler.api.symbols.AnnotationSymbol; -import io.ballerina.compiler.api.symbols.TypeSymbol; -import io.ballerina.compiler.api.values.ConstantValue; -import io.ballerina.compiler.syntax.tree.AnnotationNode; -import io.ballerina.compiler.syntax.tree.ExpressionNode; -import io.ballerina.compiler.syntax.tree.MappingFieldNode; -import io.ballerina.compiler.syntax.tree.ModulePartNode; -import io.ballerina.compiler.syntax.tree.Node; -import io.ballerina.compiler.syntax.tree.NodeList; -import io.ballerina.compiler.syntax.tree.NonTerminalNode; -import io.ballerina.compiler.syntax.tree.SeparatedNodeList; -import io.ballerina.compiler.syntax.tree.SpecificFieldNode; -import io.ballerina.compiler.syntax.tree.SyntaxKind; -import io.ballerina.compiler.syntax.tree.SyntaxTree; -import io.ballerina.tools.text.LineRange; -import io.ballerina.tools.text.TextDocument; -import io.ballerina.tools.text.TextRange; - -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Optional; -import java.util.UUID; - -import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.CLIENT; -import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.DISPLAY_ANNOTATION; -import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.ID; -import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.LABEL; - -/** - * Provide utils functions for component model generating. - * - * @since 2201.3.1 - */ -public class GeneratorUtils { - - public static ElementLocation getElementLocation(String filePath, LineRange lineRange) { - - ElementLocation.LinePosition startPosition = ElementLocation.LinePosition.from( - lineRange.startLine().line(), lineRange.startLine().offset()); - ElementLocation.LinePosition endLinePosition = ElementLocation.LinePosition.from( - lineRange.endLine().line(), lineRange.endLine().offset() - ); - return ElementLocation.from(filePath, startPosition, endLinePosition); - - } - - public static ServiceAnnotation getServiceAnnotation(NodeList annotationNodes, String filePath) { - - String id = UUID.randomUUID().toString(); - String label = ""; - ElementLocation elementLocation = null; - for (AnnotationNode annotationNode : annotationNodes) { - String annotationName = annotationNode.annotReference().toString().trim(); - if (!(annotationName.equals(DISPLAY_ANNOTATION) && annotationNode.annotValue().isPresent())) { - continue; - } - SeparatedNodeList fields = annotationNode.annotValue().get().fields(); - elementLocation = getElementLocation(filePath, annotationNode.lineRange()); - for (MappingFieldNode mappingFieldNode : fields) { - if (mappingFieldNode.kind() != SyntaxKind.SPECIFIC_FIELD) { - continue; - } - SpecificFieldNode specificFieldNode = (SpecificFieldNode) mappingFieldNode; - String name = specificFieldNode.fieldName().toString().trim(); - if (specificFieldNode.valueExpr().isEmpty()) { - continue; - } - ExpressionNode expressionNode = specificFieldNode.valueExpr().get(); - String expressionNodeStr = expressionNode.toString().trim(); - String annotation = expressionNodeStr.replace("\"", ""); - if (name.equals(ID)) { - id = annotation; - } else if (name.equals(LABEL)) { - label = annotation; - } - } - break; - } - - return new ServiceAnnotation(id, label, elementLocation); - } - - public static ServiceAnnotation getServiceAnnotation(Annotatable annotableSymbol, String filePath) { - - String id = null; - String label = ""; - ElementLocation elementLocation = null; - - List annotSymbols = annotableSymbol.annotations(); - List annotAttachmentSymbols = annotableSymbol.annotAttachments(); - if (annotSymbols.size() == annotAttachmentSymbols.size()) { - for (int i = 0; i < annotSymbols.size(); i++) { - AnnotationSymbol annotSymbol = annotSymbols.get(i); - AnnotationAttachmentSymbol annotAttachmentSymbol = annotAttachmentSymbols.get(i); - String annotName = annotSymbol.getName().orElse(""); - elementLocation = annotSymbol.getLocation().isPresent() ? - getElementLocation(filePath, annotSymbol.getLocation().get().lineRange()) : null; - if (!annotName.equals(DISPLAY_ANNOTATION) || annotAttachmentSymbol.attachmentValue().isEmpty() || - !(annotAttachmentSymbol.attachmentValue().get().value() instanceof LinkedHashMap) || - !annotAttachmentSymbol.isConstAnnotation()) { - continue; - } - LinkedHashMap attachmentValue = (LinkedHashMap) annotAttachmentSymbol.attachmentValue().get().value(); - if (attachmentValue.containsKey(ID)) { - id = ((ConstantValue) attachmentValue.get(ID)).value().toString(); - } - if (attachmentValue.containsKey(LABEL)) { - label = ((ConstantValue) attachmentValue.get(LABEL)).value().toString(); - } - break; - } - } - - return new ServiceAnnotation(id, label, elementLocation); - } - - public static String getClientModuleName(Node clientNode, SemanticModel semanticModel) { - - String clientModuleName = null; - Optional clientTypeSymbol = semanticModel.typeOf(clientNode); - if (clientTypeSymbol.isPresent()) { - clientModuleName = clientTypeSymbol.get().signature().trim().replace(CLIENT, ""); - } - - return clientModuleName; - } - - public static String getClientModuleName(TypeSymbol typeSymbol) { - String clientModuleName = typeSymbol.signature().trim().replace(CLIENT, ""); - if (typeSymbol.getModule().isPresent()) { - clientModuleName = typeSymbol.getModule().get().id().toString();; - } - return clientModuleName; - } - - public static NonTerminalNode findNode(SyntaxTree syntaxTree, LineRange lineRange) { - if (lineRange == null) { - return null; - } - - TextDocument textDocument = syntaxTree.textDocument(); - int start = textDocument.textPositionFrom(lineRange.startLine()); - int end = textDocument.textPositionFrom(lineRange.endLine()); - return ((ModulePartNode) syntaxTree.rootNode()).findNode(TextRange.from(start, end - start), true); - } -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/ModelGenerator.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/ModelGenerator.java deleted file mode 100644 index bb6b6fb6ad3f..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/ModelGenerator.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator.generators; - -import io.ballerina.compiler.api.SemanticModel; -import io.ballerina.projects.Module; - -import java.nio.file.Path; - -/** - * Model Generator Abstract Class. - * - * @since 2201.4.0 - */ -public abstract class ModelGenerator { - private final SemanticModel semanticModel; - private final Module module; - private final Path moduleRootPath; - - public ModelGenerator(SemanticModel semanticModel, Module module) { - - this.semanticModel = semanticModel; - this.module = module; - Path moduleRootPath = module.project().sourceRoot().toAbsolutePath(); - if (module.moduleName().moduleNamePart() != null) { - moduleRootPath = moduleRootPath.resolve(module.moduleName().moduleNamePart()); - } - this.moduleRootPath = moduleRootPath; - } - - public SemanticModel getSemanticModel() { - return this.semanticModel; - } - - public Module getModule() { - return this.module; - } - - public Path getModuleRootPath() { - return moduleRootPath; - } -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/entity/EntityModelGenerator.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/entity/EntityModelGenerator.java deleted file mode 100644 index b3a2e413986e..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/entity/EntityModelGenerator.java +++ /dev/null @@ -1,332 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator.generators.entity; - -import io.ballerina.architecturemodelgenerator.ComponentModel.PackageId; -import io.ballerina.architecturemodelgenerator.ProjectDesignConstants.CardinalityValue; -import io.ballerina.architecturemodelgenerator.generators.GeneratorUtils; -import io.ballerina.architecturemodelgenerator.generators.ModelGenerator; -import io.ballerina.architecturemodelgenerator.model.ElementLocation; -import io.ballerina.architecturemodelgenerator.model.entity.Association; -import io.ballerina.architecturemodelgenerator.model.entity.Attribute; -import io.ballerina.architecturemodelgenerator.model.entity.Entity; -import io.ballerina.compiler.api.SemanticModel; -import io.ballerina.compiler.api.symbols.ArrayTypeSymbol; -import io.ballerina.compiler.api.symbols.NilTypeSymbol; -import io.ballerina.compiler.api.symbols.RecordFieldSymbol; -import io.ballerina.compiler.api.symbols.RecordTypeSymbol; -import io.ballerina.compiler.api.symbols.Symbol; -import io.ballerina.compiler.api.symbols.SymbolKind; -import io.ballerina.compiler.api.symbols.TypeDefinitionSymbol; -import io.ballerina.compiler.api.symbols.TypeDescKind; -import io.ballerina.compiler.api.symbols.TypeReferenceTypeSymbol; -import io.ballerina.compiler.api.symbols.TypeSymbol; -import io.ballerina.compiler.api.symbols.UnionTypeSymbol; -import io.ballerina.projects.Module; -import io.ballerina.tools.text.LineRange; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.stream.Collectors; - -import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.ARRAY; -import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.COLON; -import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.FORWARD_SLASH; - -/** - * Build entity model to represent relationship between records. - * - * @since 2201.2.2 - */ -public class EntityModelGenerator extends ModelGenerator { - - private final Map types = new HashMap<>(); - - public EntityModelGenerator(SemanticModel semanticModel, Module module) { - super(semanticModel, module); - } - - public Map generate() { - List symbols = getSemanticModel().moduleSymbols(); - for (Symbol symbol : symbols) { - if (symbol.kind().equals(SymbolKind.TYPE_DEFINITION)) { - TypeDefinitionSymbol typeDefinitionSymbol = (TypeDefinitionSymbol) symbol; - if (typeDefinitionSymbol.typeDescriptor() instanceof RecordTypeSymbol) { - String entityName = getEntityName(typeDefinitionSymbol.moduleQualifiedName()); - RecordTypeSymbol recordTypeSymbol = (RecordTypeSymbol) typeDefinitionSymbol.typeDescriptor(); - this.types.put(entityName, getType(recordTypeSymbol, entityName, - getElementLocation(typeDefinitionSymbol), false)); - } - } - } - return types; - } - - private Entity getType(RecordTypeSymbol recordTypeSymbol, String entityName, ElementLocation elementLocation, - boolean isAnonymous) { - List attributeList = new ArrayList<>(); - List inclusionList = new ArrayList<>(); - Map recordFieldSymbolMap = - getOriginalFieldMap(recordTypeSymbol, inclusionList, entityName); - for (RecordFieldSymbol recordFieldSymbol : recordFieldSymbolMap.values()) { - attributeList.add(getAttribute(recordFieldSymbol, entityName)); - } - return new Entity(attributeList, inclusionList, elementLocation, isAnonymous); - } - - private Attribute getAttribute(RecordFieldSymbol recordFieldSymbol, String entityName) { - TypeDescKind fieldTypeDescKind = recordFieldSymbol.typeDescriptor().typeKind(); - TypeSymbol fieldTypeSymbol = recordFieldSymbol.typeDescriptor(); - - String fieldName = recordFieldSymbol.getName().get(); // need to handle - String fieldType = recordFieldSymbol.typeDescriptor().signature(); - List associations; - boolean optional = recordFieldSymbol.isOptional(); - String defaultValue = ""; //need to address - boolean nillable = isNillable(recordFieldSymbol.typeDescriptor()); - String inlineRecordName = entityName + fieldName.substring(0, 1).toUpperCase(Locale.ROOT) + - fieldName.substring(1); - - if (fieldTypeDescKind.equals(TypeDescKind.RECORD)) { - RecordTypeSymbol inlineRecordTypeSymbol = (RecordTypeSymbol) fieldTypeSymbol; - fieldType = TypeDescKind.RECORD.getName(); - this.types.put(inlineRecordName, getType(inlineRecordTypeSymbol, inlineRecordName, - getElementLocation(recordFieldSymbol), true)); - String associateCardinality = optional ? CardinalityValue.ZERO_OR_ONE.getValue() : - CardinalityValue.ONE_AND_ONLY_ONE.getValue(); - Association association = new Association(inlineRecordName, new Association.Cardinality( - CardinalityValue.ONE_AND_ONLY_ONE.getValue(), associateCardinality)); - associations = new LinkedList<>(List.of(association)); - } else if (fieldTypeDescKind.equals(TypeDescKind.ARRAY) && - ((ArrayTypeSymbol) fieldTypeSymbol).memberTypeDescriptor().typeKind().equals(TypeDescKind.RECORD)) { - RecordTypeSymbol inlineRecordTypeSymbol = (RecordTypeSymbol) ((ArrayTypeSymbol) - fieldTypeSymbol).memberTypeDescriptor(); - fieldType = TypeDescKind.RECORD.getName() + ARRAY; - String associateCardinality = optional ? CardinalityValue.ZERO_OR_MANY.getValue() : - CardinalityValue.ONE_OR_MANY.getValue(); - Association association = new Association(inlineRecordName, new Association.Cardinality( - CardinalityValue.ONE_AND_ONLY_ONE.getValue(), associateCardinality)); - associations = new LinkedList<>(List.of(association)); - this.types.put(inlineRecordName, getType(inlineRecordTypeSymbol, inlineRecordName, - getElementLocation(recordFieldSymbol), true)); - - } else { - associations = - getAssociations(recordFieldSymbol.typeDescriptor(), entityName, optional, nillable); - - } - // todo: address when union types has anonymous records - return new Attribute(fieldName, fieldType, optional, nillable, defaultValue, associations, - getElementLocation(recordFieldSymbol)); - } - - private Map getOriginalFieldMap( - RecordTypeSymbol recordTypeSymbol, List inclusionList, String entityName) { - - Map childRecordFieldSymbolMap = recordTypeSymbol.fieldDescriptors(); - if (!recordTypeSymbol.typeInclusions().isEmpty()) { - List typeInclusions = recordTypeSymbol.typeInclusions(); - for (TypeSymbol includedType : typeInclusions) { - if (includedType instanceof TypeReferenceTypeSymbol) { - TypeReferenceTypeSymbol typeReferenceTypeSymbol = (TypeReferenceTypeSymbol) includedType; - inclusionList.add(getAssociateEntityName(typeReferenceTypeSymbol, entityName)); - RecordTypeSymbol parentRecordTypeSymbol = (RecordTypeSymbol) - typeReferenceTypeSymbol.typeDescriptor(); - Map parentRecordFieldSymbolMap = - parentRecordTypeSymbol.fieldDescriptors(); - // is it enough to check only based on the key ? - childRecordFieldSymbolMap = childRecordFieldSymbolMap.entrySet().stream() - .filter(entry -> !parentRecordFieldSymbolMap.containsKey(entry.getKey())) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - } - } - } - return childRecordFieldSymbolMap; - } - - private boolean isNillable(TypeSymbol fieldTypeDescriptor) { - - boolean isNillable = false; - if (fieldTypeDescriptor instanceof UnionTypeSymbol) { - UnionTypeSymbol unionTypeSymbol = (UnionTypeSymbol) fieldTypeDescriptor; - List memberTypeDescriptors = unionTypeSymbol.memberTypeDescriptors(); - isNillable = memberTypeDescriptors.stream().anyMatch(m -> m instanceof NilTypeSymbol); - } - return isNillable; - } - - private String getSelfCardinality(TypeSymbol typeSymbol, String entityName) { - - String selfCardinality = CardinalityValue.ONE_AND_ONLY_ONE.getValue(); - if (typeSymbol instanceof TypeReferenceTypeSymbol && - ((TypeReferenceTypeSymbol) typeSymbol).typeDescriptor() instanceof RecordTypeSymbol) { - RecordTypeSymbol recordTypeSymbol = (RecordTypeSymbol) - (((TypeReferenceTypeSymbol) typeSymbol).typeDescriptor()); - Map recordFieldSymbolMap = recordTypeSymbol.fieldDescriptors(); - for (Map.Entry fieldEntry : recordFieldSymbolMap.entrySet()) { - TypeSymbol fieldTypeDescriptor = fieldEntry.getValue().typeDescriptor(); - if (fieldTypeDescriptor instanceof TypeReferenceTypeSymbol) { - if (entityName.equals(getAssociateEntityName( - (TypeReferenceTypeSymbol) fieldTypeDescriptor, entityName))) { - selfCardinality = CardinalityValue.ONE_AND_ONLY_ONE.getValue(); - } - } else if (fieldTypeDescriptor instanceof UnionTypeSymbol) { - boolean isFound = false; - boolean isNull = false; - UnionTypeSymbol unionTypeSymbol = (UnionTypeSymbol) fieldTypeDescriptor; - List memberTypeDescriptors = unionTypeSymbol.memberTypeDescriptors(); - for (TypeSymbol memberTypeSymbol : memberTypeDescriptors) { - if (memberTypeSymbol instanceof TypeReferenceTypeSymbol && - entityName.equals(getAssociateEntityName( - (TypeReferenceTypeSymbol) memberTypeSymbol, entityName))) { - isFound = true; - } else if (memberTypeSymbol instanceof NilTypeSymbol) { - isNull = true; - } - } - if (isFound && isNull) { - selfCardinality = CardinalityValue.ZERO_OR_ONE.getValue(); - } - } else if (fieldTypeDescriptor instanceof ArrayTypeSymbol) { - TypeSymbol memberTypeDescriptor = ((ArrayTypeSymbol) fieldTypeDescriptor).memberTypeDescriptor(); - if (memberTypeDescriptor instanceof TypeReferenceTypeSymbol && - getAssociateEntityName((TypeReferenceTypeSymbol) memberTypeDescriptor, entityName). - replace(ARRAY, "").equals(entityName)) { - selfCardinality = CardinalityValue.ZERO_OR_MANY.getValue(); - } - } - } - } - return selfCardinality; - } - - private String getAssociateCardinality(boolean isArray, boolean isOptional, boolean isNillable) { - // todo: double check - if (isArray && !isOptional && !isNillable) { - return CardinalityValue.ONE_OR_MANY.getValue(); - } else if (isArray) { - return CardinalityValue.ZERO_OR_MANY.getValue(); - } else if (isOptional || isNillable) { - return CardinalityValue.ZERO_OR_ONE.getValue(); - } else { - return CardinalityValue.ONE_AND_ONLY_ONE.getValue(); - } - } - - /** - * Build the FQN of the entity Ex: ballerina/reservation_api:0.1.0:Flight. - * - * @param moduleQualifiedName - * @return - */ - private String getEntityName(String moduleQualifiedName) { - // moduleQualifiedName is not correct when there is a dot in package name - PackageId packageId = new PackageId(getModule().packageInstance()); - String entityName; - String[] nameSpits = moduleQualifiedName.split(COLON); - if (packageId.getName().equals(nameSpits[0])) { // check whether the referenced type is from the same module - entityName = packageId.getOrg() + FORWARD_SLASH + packageId.getName() + COLON + packageId.getVersion() + - COLON + nameSpits[1]; - } else { - entityName = packageId.getOrg() + FORWARD_SLASH + packageId.getName() + COLON + nameSpits[0] + COLON + - packageId.getVersion() + COLON + nameSpits[1]; - } - return entityName; - } - - private List getAssociationsInUnionTypes(UnionTypeSymbol unionTypeSymbol, String entityName, - boolean isRequired) { - - List unionTypeAssociations = new ArrayList<>(); - List memberTypeDescriptors = unionTypeSymbol.memberTypeDescriptors(); - boolean isNullableAssociate = memberTypeDescriptors.stream().anyMatch(m -> m instanceof NilTypeSymbol); - for (TypeSymbol typeSymbol : memberTypeDescriptors) { - if (!(typeSymbol instanceof NilTypeSymbol)) { - List associations = getAssociations(typeSymbol, entityName, - isRequired, isNullableAssociate); - unionTypeAssociations.addAll(associations); - } - } - return unionTypeAssociations; - } - - private String getAssociateEntityName(TypeReferenceTypeSymbol typeReferenceTypeSymbol, - String referencedPackageName) { - - String referenceType = typeReferenceTypeSymbol.signature(); - if (typeReferenceTypeSymbol.getModule().isPresent() && - !referenceType.split(":")[0].equals(referencedPackageName.split(":")[0])) { - String orgName = typeReferenceTypeSymbol.getModule().get().id().orgName(); - String packageName = typeReferenceTypeSymbol.getModule().get().id().packageName(); - String modulePrefix = typeReferenceTypeSymbol.getModule().get().id().modulePrefix(); - String recordName = typeReferenceTypeSymbol.getName().get(); - String version = typeReferenceTypeSymbol.getModule().get().id().version(); - // module name check - if (packageName.equals(modulePrefix)) { - referenceType = String.format("%s/%s:%s:%s", orgName, packageName, version, recordName); - } else { - referenceType = String.format( - "%s/%s:%s:%s:%s", orgName, packageName, modulePrefix, version, recordName); - } - } - return referenceType; - } - - private List getAssociations(TypeSymbol fieldTypeDescriptor, String entityName, boolean optional, - boolean isNillable) { - - List associations = new ArrayList<>(); - if (fieldTypeDescriptor instanceof TypeReferenceTypeSymbol) { - String associate = getAssociateEntityName((TypeReferenceTypeSymbol) fieldTypeDescriptor, entityName); - Association.Cardinality cardinality = new Association.Cardinality( - getSelfCardinality(fieldTypeDescriptor, entityName), - getAssociateCardinality(false, optional, isNillable)); - - associations.add(new Association(associate, cardinality)); - } else if (fieldTypeDescriptor instanceof UnionTypeSymbol) { - UnionTypeSymbol unionTypeSymbol = (UnionTypeSymbol) fieldTypeDescriptor; - associations.addAll(getAssociationsInUnionTypes(unionTypeSymbol, entityName, optional)); - } else if (fieldTypeDescriptor instanceof ArrayTypeSymbol) { - ArrayTypeSymbol arrayTypeSymbol = (ArrayTypeSymbol) fieldTypeDescriptor; - if (arrayTypeSymbol.memberTypeDescriptor() instanceof TypeReferenceTypeSymbol) { - String associate = getAssociateEntityName((TypeReferenceTypeSymbol) - arrayTypeSymbol.memberTypeDescriptor(), entityName).replace(ARRAY, ""); - Association.Cardinality cardinality = new Association.Cardinality( - getSelfCardinality(arrayTypeSymbol, entityName), - getAssociateCardinality(true, optional, isNillable)); - associations.add(new Association(associate, cardinality)); - } - } - return associations; - } - - private ElementLocation getElementLocation(Symbol symbol) { - ElementLocation elementLocation = null; - if (symbol.getLocation().isPresent()) { - LineRange typeLineRange = symbol.getLocation().get().lineRange(); - String filePath = getModuleRootPath().resolve(typeLineRange.filePath()).toAbsolutePath().toString(); - elementLocation = GeneratorUtils.getElementLocation(filePath, typeLineRange); - } - return elementLocation; - } -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/ServiceModelGenerator.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/ServiceModelGenerator.java deleted file mode 100644 index a4ee4bbe5d09..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/ServiceModelGenerator.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator.generators.service; - -import io.ballerina.architecturemodelgenerator.generators.ModelGenerator; -import io.ballerina.architecturemodelgenerator.generators.service.nodevisitors.ServiceDeclarationNodeVisitor; -import io.ballerina.architecturemodelgenerator.model.service.Service; -import io.ballerina.compiler.api.SemanticModel; -import io.ballerina.compiler.syntax.tree.SyntaxTree; -import io.ballerina.projects.DocumentId; -import io.ballerina.projects.Module; - -import java.nio.file.Path; -import java.util.HashMap; -import java.util.Map; - -/** - * Build service model based on a given Ballerina service. - * - * @since 2201.2.2 - */ -public class ServiceModelGenerator extends ModelGenerator { - - public ServiceModelGenerator(SemanticModel semanticModel, Module module) { - super(semanticModel, module); - } - - public Map generate() { - Map services = new HashMap<>(); - for (DocumentId documentId :getModule().documentIds()) { - SyntaxTree syntaxTree = getModule().document(documentId).syntaxTree(); - Path filePath = getModuleRootPath().resolve(syntaxTree.filePath()); - ServiceDeclarationNodeVisitor serviceNodeVisitor = new ServiceDeclarationNodeVisitor(getSemanticModel(), - syntaxTree, getModule().packageInstance(), filePath); - syntaxTree.rootNode().accept(serviceNodeVisitor); - serviceNodeVisitor.getServices().forEach(service -> { - services.put(service.getServiceId(), service); - }); - } - return services; - } -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ActionNodeVisitor.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ActionNodeVisitor.java deleted file mode 100644 index c18952d88261..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ActionNodeVisitor.java +++ /dev/null @@ -1,248 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator.generators.service.nodevisitors; - -import io.ballerina.architecturemodelgenerator.model.service.Interaction; -import io.ballerina.architecturemodelgenerator.model.service.ResourceId; -import io.ballerina.compiler.api.ModuleID; -import io.ballerina.compiler.api.SemanticModel; -import io.ballerina.compiler.api.symbols.Annotatable; -import io.ballerina.compiler.api.symbols.ModuleSymbol; -import io.ballerina.compiler.api.symbols.Symbol; -import io.ballerina.compiler.syntax.tree.BasicLiteralNode; -import io.ballerina.compiler.syntax.tree.ClientResourceAccessActionNode; -import io.ballerina.compiler.syntax.tree.ComputedResourceAccessSegmentNode; -import io.ballerina.compiler.syntax.tree.ExpressionNode; -import io.ballerina.compiler.syntax.tree.FieldAccessExpressionNode; -import io.ballerina.compiler.syntax.tree.FunctionCallExpressionNode; -import io.ballerina.compiler.syntax.tree.FunctionDefinitionNode; -import io.ballerina.compiler.syntax.tree.IdentifierToken; -import io.ballerina.compiler.syntax.tree.MethodCallExpressionNode; -import io.ballerina.compiler.syntax.tree.MethodDeclarationNode; -import io.ballerina.compiler.syntax.tree.ModulePartNode; -import io.ballerina.compiler.syntax.tree.NameReferenceNode; -import io.ballerina.compiler.syntax.tree.Node; -import io.ballerina.compiler.syntax.tree.NodeVisitor; -import io.ballerina.compiler.syntax.tree.NonTerminalNode; -import io.ballerina.compiler.syntax.tree.RemoteMethodCallActionNode; -import io.ballerina.compiler.syntax.tree.SeparatedNodeList; -import io.ballerina.compiler.syntax.tree.SimpleNameReferenceNode; -import io.ballerina.compiler.syntax.tree.SyntaxKind; -import io.ballerina.compiler.syntax.tree.SyntaxTree; -import io.ballerina.projects.DocumentId; -import io.ballerina.projects.Package; -import io.ballerina.tools.diagnostics.Location; - -import java.util.Collection; -import java.util.LinkedList; -import java.util.List; -import java.util.Objects; -import java.util.Optional; - -import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.FORWARD_SLASH; -import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.TYPE_MAP; -import static io.ballerina.architecturemodelgenerator.generators.GeneratorUtils.getClientModuleName; -import static io.ballerina.architecturemodelgenerator.generators.GeneratorUtils.getElementLocation; -import static io.ballerina.architecturemodelgenerator.generators.GeneratorUtils.getServiceAnnotation; - -/** - * Visitor class for RemoteMethodCallAction nodes. - * - * @since 2201.2.2 - */ -public class ActionNodeVisitor extends NodeVisitor { - - private final SemanticModel semanticModel; - private final Package currentPackage; - private final List interactionList = new LinkedList<>(); - private final String filePath; - - public ActionNodeVisitor(SemanticModel semanticModel, Package currentPackage, String filePath) { - - this.semanticModel = semanticModel; - this.currentPackage = currentPackage; - this.filePath = filePath; - } - - public List getInteractionList() { - return interactionList; - } - - @Override - public void visit(ClientResourceAccessActionNode clientResourceAccessActionNode) { - ExpressionNode clientNode = clientResourceAccessActionNode.expression(); - String resourceMethod = String.valueOf(clientResourceAccessActionNode.methodName().get().name().text()); - String resourcePath = getResourcePath(clientResourceAccessActionNode.resourceAccessPath()); - - String serviceId = null; - Optional clientSymbol = semanticModel.symbol(clientNode); - if (clientSymbol.isPresent()) { - Annotatable annotatableSymbol = (Annotatable) clientSymbol.get(); - serviceId = getServiceAnnotation(annotatableSymbol, filePath).getId(); - } - - Interaction interaction = new Interaction( - new ResourceId(serviceId, resourceMethod, resourcePath), - getClientModuleName(clientNode, semanticModel), getElementLocation(filePath, - clientResourceAccessActionNode.lineRange())); - interactionList.add(interaction); - } - - @Override - public void visit(RemoteMethodCallActionNode remoteMethodCallActionNode) { - SimpleNameReferenceNode clientNode = null; - if (remoteMethodCallActionNode.expression() instanceof FieldAccessExpressionNode) { - NameReferenceNode fieldName = ((FieldAccessExpressionNode) - remoteMethodCallActionNode.expression()).fieldName(); - if (fieldName instanceof SimpleNameReferenceNode) { - clientNode = (SimpleNameReferenceNode) fieldName; - } - // todo : Other combinations - } else if (remoteMethodCallActionNode.expression() instanceof SimpleNameReferenceNode) { - clientNode = (SimpleNameReferenceNode) remoteMethodCallActionNode.expression(); - } - // todo : Other combinations - - if (clientNode != null) { - String resourceMethod = remoteMethodCallActionNode.methodName().name().text(); - - String serviceId = null; - Optional clientSymbol = semanticModel.symbol(clientNode); - if (clientSymbol.isPresent()) { - Annotatable annotatableSymbol = (Annotatable) clientSymbol.get(); - serviceId = getServiceAnnotation(annotatableSymbol, filePath).getId(); - } - - Interaction interaction = new Interaction(new ResourceId(serviceId, - resourceMethod, null), getClientModuleName(clientNode, semanticModel), - getElementLocation(filePath, remoteMethodCallActionNode.lineRange())); - interactionList.add(interaction); - } - } - - @Override - public void visit(FunctionCallExpressionNode functionCallExpressionNode) { - - if (functionCallExpressionNode.functionName() instanceof SimpleNameReferenceNode) { - String methodName = ((SimpleNameReferenceNode) functionCallExpressionNode.functionName()).name().text(); - Optional symbol = semanticModel.symbol(functionCallExpressionNode.functionName()); - symbol.ifPresent(value -> findInteractions(methodName, value)); - if (!functionCallExpressionNode.arguments().isEmpty()) { - functionCallExpressionNode.arguments().forEach(arg -> { - arg.accept(this); - }); - } - } - // todo : Other combinations - } - - @Override - public void visit(MethodCallExpressionNode methodCallExpressionNode) { - - if (methodCallExpressionNode.methodName() instanceof SimpleNameReferenceNode) { - String methodName = ((SimpleNameReferenceNode) methodCallExpressionNode.methodName()).name().text(); - Optional symbol = semanticModel.symbol(methodCallExpressionNode.methodName()); - symbol.ifPresent(value -> findInteractions(methodName, value)); - if (!methodCallExpressionNode.arguments().isEmpty()) { - methodCallExpressionNode.arguments().forEach(arg -> { - arg.accept(this); - }); - } - } - // todo : Other combinations - } - - private void findInteractions(String methodName, Symbol methodSymbol) { - - Optional location = methodSymbol.getLocation(); - Optional optionalModuleSymbol = methodSymbol.getModule(); - if (optionalModuleSymbol.isPresent()) { - ModuleID moduleID = optionalModuleSymbol.get().id(); - currentPackage.modules().forEach(module -> { - if (Objects.equals(moduleID.moduleName(), module.moduleName().toString())) { - Collection documentIds = module.documentIds(); - for (DocumentId documentId : documentIds) { - SyntaxTree syntaxTree = module.document(documentId).syntaxTree(); - // todo : Improve the logic - NonTerminalNode node = ((ModulePartNode) syntaxTree.rootNode()) - .findNode(location.get().textRange()); - if (!node.isMissing()) { - if (node instanceof FunctionDefinitionNode) { - FunctionDefinitionNode functionDefinitionNode = (FunctionDefinitionNode) node; - String referencedFunctionName = functionDefinitionNode.functionName().text(); - if (methodName.equals(referencedFunctionName)) { - ActionNodeVisitor actionNodeVisitor = new ActionNodeVisitor(semanticModel, - currentPackage, this.filePath); - functionDefinitionNode.accept(actionNodeVisitor); - interactionList.addAll(actionNodeVisitor.getInteractionList()); - } - } else if (node instanceof MethodDeclarationNode) { - MethodDeclarationNode methodDeclarationNode = (MethodDeclarationNode) node; - String referencedFunctionName = methodDeclarationNode.methodName().text(); - if (methodName.equals(referencedFunctionName)) { - ActionNodeVisitor actionNodeVisitor = new ActionNodeVisitor(semanticModel, - currentPackage, this.filePath); - methodDeclarationNode.accept(actionNodeVisitor); - interactionList.addAll(actionNodeVisitor.getInteractionList()); - } - } - } - } - } - }); - } - } - - private String getResourcePath(SeparatedNodeList accessPathNodes) { - - StringBuilder resourcePathBuilder = new StringBuilder(); - for (Node accessPathNode : accessPathNodes) { - if (resourcePathBuilder.length() > 0) { - resourcePathBuilder.append(FORWARD_SLASH); - } - if (accessPathNode.kind() == SyntaxKind.IDENTIFIER_TOKEN) { - resourcePathBuilder.append(((IdentifierToken) accessPathNode).text()); - } else if (accessPathNode.kind() == SyntaxKind.COMPUTED_RESOURCE_ACCESS_SEGMENT) { - ComputedResourceAccessSegmentNode accessSegmentNode = - (ComputedResourceAccessSegmentNode) accessPathNode; - ExpressionNode expressionNode = accessSegmentNode.expression(); - if (expressionNode.kind() == SyntaxKind.STRING_LITERAL) { - resourcePathBuilder.append(String.format("[%s]", TYPE_MAP.get(SyntaxKind.STRING_LITERAL))); - } else if (expressionNode.kind().equals(SyntaxKind.NUMERIC_LITERAL)) { - SyntaxKind numericKind = ((BasicLiteralNode) expressionNode).literalToken().kind(); - if (numericKind.equals(SyntaxKind.DECIMAL_FLOATING_POINT_LITERAL_TOKEN)) { - resourcePathBuilder.append(String.format("[%s]", TYPE_MAP.get( - SyntaxKind.DECIMAL_FLOATING_POINT_LITERAL_TOKEN))); - } else if (numericKind.equals(SyntaxKind.DECIMAL_INTEGER_LITERAL_TOKEN)) { - resourcePathBuilder.append(String.format("[%s]", SyntaxKind.DECIMAL_INTEGER_LITERAL_TOKEN)); - } else { - resourcePathBuilder.append(String.format("[%s]", SyntaxKind.NUMERIC_LITERAL)); - } - } else if (expressionNode.kind().equals(SyntaxKind.BOOLEAN_LITERAL)) { - resourcePathBuilder.append(String.format("[%s]", SyntaxKind.BOOLEAN_LITERAL)); - } else if (expressionNode.kind() == SyntaxKind.SIMPLE_NAME_REFERENCE || - expressionNode.kind() == SyntaxKind.FIELD_ACCESS) { - String varType = semanticModel.typeOf(expressionNode).get().signature(); - resourcePathBuilder.append("[").append(varType.trim()).append("]"); - } - } - } - return resourcePathBuilder.toString(); - } -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java deleted file mode 100644 index 295682e871ca..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceDeclarationNodeVisitor.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator.generators.service.nodevisitors; - -import io.ballerina.architecturemodelgenerator.generators.GeneratorUtils; -import io.ballerina.architecturemodelgenerator.model.service.Service; -import io.ballerina.architecturemodelgenerator.model.service.ServiceAnnotation; -import io.ballerina.compiler.api.SemanticModel; -import io.ballerina.compiler.api.symbols.Symbol; -import io.ballerina.compiler.api.symbols.TypeDescKind; -import io.ballerina.compiler.api.symbols.TypeReferenceTypeSymbol; -import io.ballerina.compiler.api.symbols.TypeSymbol; -import io.ballerina.compiler.syntax.tree.AnnotationNode; -import io.ballerina.compiler.syntax.tree.ClassDefinitionNode; -import io.ballerina.compiler.syntax.tree.EnumDeclarationNode; -import io.ballerina.compiler.syntax.tree.ExplicitNewExpressionNode; -import io.ballerina.compiler.syntax.tree.ExpressionNode; -import io.ballerina.compiler.syntax.tree.FunctionDefinitionNode; -import io.ballerina.compiler.syntax.tree.ImportDeclarationNode; -import io.ballerina.compiler.syntax.tree.MetadataNode; -import io.ballerina.compiler.syntax.tree.Node; -import io.ballerina.compiler.syntax.tree.NodeList; -import io.ballerina.compiler.syntax.tree.NodeVisitor; -import io.ballerina.compiler.syntax.tree.QualifiedNameReferenceNode; -import io.ballerina.compiler.syntax.tree.SeparatedNodeList; -import io.ballerina.compiler.syntax.tree.ServiceDeclarationNode; -import io.ballerina.compiler.syntax.tree.SimpleNameReferenceNode; -import io.ballerina.compiler.syntax.tree.SyntaxTree; -import io.ballerina.compiler.syntax.tree.TypeDefinitionNode; -import io.ballerina.compiler.syntax.tree.TypeDescriptorNode; -import io.ballerina.compiler.syntax.tree.VariableDeclarationNode; -import io.ballerina.projects.Package; - -import java.nio.file.Path; -import java.util.LinkedList; -import java.util.List; -import java.util.Optional; -import java.util.UUID; - -import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.FORWARD_SLASH; -import static io.ballerina.architecturemodelgenerator.ProjectDesignConstants.LISTENER; - -/** - * Visitor class for ServiceDeclaration nodes. - * - * @since 2201.2.2 - */ -public class ServiceDeclarationNodeVisitor extends NodeVisitor { - - private final SemanticModel semanticModel; - private final SyntaxTree syntaxTree; - private final Package currentPackage; - private final List services = new LinkedList<>(); - private final Path filePath; - - public ServiceDeclarationNodeVisitor(SemanticModel semanticModel, SyntaxTree syntaxTree, Package currentPackage, - Path filePath) { - this.semanticModel = semanticModel; - this.syntaxTree = syntaxTree; - this.currentPackage = currentPackage; - this.filePath = filePath; - } - - public List getServices() { - return services; - } - - @Override - public void visit(ServiceDeclarationNode serviceDeclarationNode) { - - StringBuilder serviceNameBuilder = new StringBuilder(); - ServiceAnnotation serviceAnnotation; - NodeList serviceNameNodes = serviceDeclarationNode.absoluteResourcePath(); - for (Node serviceNameNode : serviceNameNodes) { - serviceNameBuilder.append(serviceNameNode.toString().replace("\"", "")); - } - - Optional metadataNode = serviceDeclarationNode.metadata(); - if (metadataNode.isPresent()) { - NodeList annotationNodes = metadataNode.get().annotations(); - serviceAnnotation = GeneratorUtils.getServiceAnnotation(annotationNodes, this.filePath.toString()); - } else { - serviceAnnotation = new ServiceAnnotation(UUID.randomUUID().toString(), "", null); - } - - String serviceName = serviceNameBuilder.toString().startsWith(FORWARD_SLASH) ? - serviceNameBuilder.substring(1) : serviceNameBuilder.toString(); - - ServiceMemberFunctionNodeVisitor serviceMemberFunctionNodeVisitor = - new ServiceMemberFunctionNodeVisitor(serviceAnnotation.getId(), - semanticModel, syntaxTree, currentPackage, filePath.toString()); - serviceDeclarationNode.accept(serviceMemberFunctionNodeVisitor); - services.add(new Service(serviceName.trim(), serviceAnnotation.getId(), - getServiceType(serviceDeclarationNode), serviceMemberFunctionNodeVisitor.getResources(), - serviceAnnotation, serviceMemberFunctionNodeVisitor.getRemoteFunctions(), - serviceMemberFunctionNodeVisitor.getDependencies(), - GeneratorUtils.getElementLocation(filePath.toString(), serviceDeclarationNode.lineRange()))); - } - - private String getServiceType(ServiceDeclarationNode serviceDeclarationNode) { - - String serviceType = null; - SeparatedNodeList expressionNodes = serviceDeclarationNode.expressions(); - for (ExpressionNode expressionNode : expressionNodes) { - if (expressionNode instanceof ExplicitNewExpressionNode) { - ExplicitNewExpressionNode explicitNewExpressionNode = (ExplicitNewExpressionNode) expressionNode; - //todo: Implement using semantic model - returns null - TypeDescriptorNode typeDescriptorNode = explicitNewExpressionNode.typeDescriptor(); - if (typeDescriptorNode instanceof QualifiedNameReferenceNode) { - QualifiedNameReferenceNode listenerNode = (QualifiedNameReferenceNode) typeDescriptorNode; - Optional listenerSymbol = semanticModel.symbol(listenerNode); - if (listenerSymbol.isPresent() && (listenerSymbol.get() instanceof TypeReferenceTypeSymbol)) { - serviceType = ((TypeReferenceTypeSymbol) - listenerSymbol.get()).signature().replace(LISTENER, ""); - } else { - serviceType = listenerNode.modulePrefix().text().trim(); - } - } - } else if (expressionNode instanceof SimpleNameReferenceNode) { // support when use listener from a var - Optional typeSymbol = semanticModel.typeOf(expressionNode); - if (typeSymbol.isPresent() && typeSymbol.get().typeKind().equals(TypeDescKind.TYPE_REFERENCE)) { - serviceType = typeSymbol.get().signature().replace(LISTENER, ""); - } - } - } - return serviceType; - } - - @Override - public void visit(ImportDeclarationNode importDeclarationNode) { - - } - - @Override - public void visit(EnumDeclarationNode enumDeclarationNode) { - - } - - @Override - public void visit(FunctionDefinitionNode functionDefinitionNode) { - - } - - @Override - public void visit(TypeDefinitionNode typeDefinitionNode) { - - } - - @Override - public void visit(VariableDeclarationNode variableDeclarationNode) { - - } - - @Override - public void visit(ClassDefinitionNode classDefinitionNode) { - - } -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java deleted file mode 100644 index 556b4f11a372..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/generators/service/nodevisitors/ServiceMemberFunctionNodeVisitor.java +++ /dev/null @@ -1,414 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator.generators.service.nodevisitors; - -import io.ballerina.architecturemodelgenerator.ComponentModel.PackageId; -import io.ballerina.architecturemodelgenerator.ProjectDesignConstants.ParameterIn; -import io.ballerina.architecturemodelgenerator.model.ElementLocation; -import io.ballerina.architecturemodelgenerator.model.service.Dependency; -import io.ballerina.architecturemodelgenerator.model.service.FunctionParameter; -import io.ballerina.architecturemodelgenerator.model.service.RemoteFunction; -import io.ballerina.architecturemodelgenerator.model.service.Resource; -import io.ballerina.architecturemodelgenerator.model.service.ResourceId; -import io.ballerina.architecturemodelgenerator.model.service.ResourceParameter; -import io.ballerina.compiler.api.SemanticModel; -import io.ballerina.compiler.api.symbols.ArrayTypeSymbol; -import io.ballerina.compiler.api.symbols.ClassSymbol; -import io.ballerina.compiler.api.symbols.MethodSymbol; -import io.ballerina.compiler.api.symbols.ParameterSymbol; -import io.ballerina.compiler.api.symbols.PathParameterSymbol; -import io.ballerina.compiler.api.symbols.Qualifier; -import io.ballerina.compiler.api.symbols.Symbol; -import io.ballerina.compiler.api.symbols.SymbolKind; -import io.ballerina.compiler.api.symbols.TypeDescKind; -import io.ballerina.compiler.api.symbols.TypeReferenceTypeSymbol; -import io.ballerina.compiler.api.symbols.TypeSymbol; -import io.ballerina.compiler.api.symbols.UnionTypeSymbol; -import io.ballerina.compiler.syntax.tree.AnnotationNode; -import io.ballerina.compiler.syntax.tree.ConstantDeclarationNode; -import io.ballerina.compiler.syntax.tree.DefaultableParameterNode; -import io.ballerina.compiler.syntax.tree.FunctionDefinitionNode; -import io.ballerina.compiler.syntax.tree.FunctionSignatureNode; -import io.ballerina.compiler.syntax.tree.Node; -import io.ballerina.compiler.syntax.tree.NodeList; -import io.ballerina.compiler.syntax.tree.NodeVisitor; -import io.ballerina.compiler.syntax.tree.ObjectFieldNode; -import io.ballerina.compiler.syntax.tree.ParameterNode; -import io.ballerina.compiler.syntax.tree.ParenthesisedTypeDescriptorNode; -import io.ballerina.compiler.syntax.tree.RequiredParameterNode; -import io.ballerina.compiler.syntax.tree.ResourcePathParameterNode; -import io.ballerina.compiler.syntax.tree.ReturnTypeDescriptorNode; -import io.ballerina.compiler.syntax.tree.SeparatedNodeList; -import io.ballerina.compiler.syntax.tree.SyntaxKind; -import io.ballerina.compiler.syntax.tree.SyntaxTree; -import io.ballerina.compiler.syntax.tree.UnionTypeDescriptorNode; -import io.ballerina.projects.Package; -import io.ballerina.tools.diagnostics.Location; -import io.ballerina.tools.text.LineRange; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Optional; -import java.util.UUID; -import java.util.stream.Collectors; - -import static io.ballerina.architecturemodelgenerator.generators.GeneratorUtils.findNode; -import static io.ballerina.architecturemodelgenerator.generators.GeneratorUtils.getClientModuleName; -import static io.ballerina.architecturemodelgenerator.generators.GeneratorUtils.getElementLocation; -import static io.ballerina.architecturemodelgenerator.generators.GeneratorUtils.getServiceAnnotation; - -/** - * Visitor class for FunctionDefinition node. - * - * @since 2201.2.2 - */ -public class ServiceMemberFunctionNodeVisitor extends NodeVisitor { - - private final String serviceId; - private final SemanticModel semanticModel; - private final SyntaxTree syntaxTree; - private final Package currentPackage; - private List resources = new LinkedList<>(); - private List remoteFunctions = new LinkedList<>(); - private final List dependencies = new LinkedList<>(); - private final String filePath; - - public ServiceMemberFunctionNodeVisitor(String serviceId, SemanticModel semanticModel, SyntaxTree syntaxTree, - Package currentPackage, String filePath) { - this.serviceId = serviceId; - this.semanticModel = semanticModel; - this.syntaxTree = syntaxTree; - this.currentPackage = currentPackage; - this.filePath = filePath; - } - - public List getResources() { - return resources; - } - - public List getRemoteFunctions() { - return remoteFunctions; - } - - public List getDependencies() { - return dependencies; - } - - @Override - public void visit(FunctionDefinitionNode functionDefinitionNode) { - ElementLocation elementLocation = getElementLocation(filePath, - functionDefinitionNode.lineRange()); - SyntaxKind kind = functionDefinitionNode.kind(); - switch (kind) { - case RESOURCE_ACCESSOR_DEFINITION: { - StringBuilder identifierBuilder = new StringBuilder(); - StringBuilder resourcePathBuilder = new StringBuilder(); - List resourceParameterList = new ArrayList<>(); - NodeList relativeResourcePaths = functionDefinitionNode.relativeResourcePath(); - for (Node path : relativeResourcePaths) { - if (path instanceof ResourcePathParameterNode) { - ResourcePathParameterNode pathParam = (ResourcePathParameterNode) path; - resourceParameterList.add(getPathParameter(pathParam)); - identifierBuilder.append(String.format("[%s]", - pathParam.typeDescriptor().toSourceCode().trim())); - } else { - identifierBuilder.append(path); - } - resourcePathBuilder.append(path); - } - - String resourcePath = resourcePathBuilder.toString().trim(); - String method = functionDefinitionNode.functionName().text().trim(); - - getParameters(functionDefinitionNode.functionSignature(), true, - resourceParameterList, null); - List returnTypes = getReturnTypes(functionDefinitionNode); - - ActionNodeVisitor actionNodeVisitor = - new ActionNodeVisitor(semanticModel, currentPackage, filePath); - functionDefinitionNode.accept(actionNodeVisitor); - - ResourceId resourceId = new ResourceId(this.serviceId, method, resourcePath); - Resource resource = new Resource(identifierBuilder.toString().trim(), - resourceId, resourceParameterList, returnTypes, - actionNodeVisitor.getInteractionList(), elementLocation); - resources.add(resource); - - break; - } - case OBJECT_METHOD_DEFINITION: { - boolean isRemote = functionDefinitionNode.qualifierList().stream(). - anyMatch(item -> item.kind().equals(SyntaxKind.REMOTE_KEYWORD)); - if (isRemote) { - String name = functionDefinitionNode.functionName().text().trim(); - List parameterList = new ArrayList<>(); - getParameters(functionDefinitionNode.functionSignature(), - false, null, parameterList); - List returnTypes = getReturnTypes(functionDefinitionNode); - - ActionNodeVisitor actionNodeVisitor = new ActionNodeVisitor( - semanticModel, currentPackage, filePath); - functionDefinitionNode.accept(actionNodeVisitor); - - RemoteFunction remoteFunction = new RemoteFunction(name, parameterList, returnTypes, - actionNodeVisitor.getInteractionList(), elementLocation); - remoteFunctions.add(remoteFunction); - } - break; - } - } - } - - private ResourceParameter getPathParameter(ResourcePathParameterNode resourcePathParameterNode) { - ElementLocation elementLocation = getElementLocation(this.filePath, - resourcePathParameterNode.lineRange()); - String name = resourcePathParameterNode.paramName().get().text(); - List paramTypes = new LinkedList<>(); - Optional symbol = semanticModel.symbol(resourcePathParameterNode); - if (symbol.isPresent()) { - PathParameterSymbol parameterSymbol = ((PathParameterSymbol) symbol.get()); - paramTypes = getReferencedType(parameterSymbol.typeDescriptor()); - } // todo : implement else - return new ResourceParameter(paramTypes, name, ParameterIn.PATH.getValue(), true, elementLocation); - } - - private void getParameters(FunctionSignatureNode functionSignatureNode, boolean isResource, - List resourceParams, List remoteFunctionParams) { - - SeparatedNodeList parameterNodes = functionSignatureNode.parameters(); - for (ParameterNode parameterNode : parameterNodes) { - ElementLocation elementLocation = getElementLocation(this.filePath, - parameterNode.lineRange()); - Optional symbol = semanticModel.symbol(parameterNode); - if (symbol.isPresent() && symbol.get().kind().equals(SymbolKind.PARAMETER)) { - String paramIn = ""; - String paramName = ""; - boolean isRequired = false; - ParameterSymbol parameterSymbol = ((ParameterSymbol) symbol.get()); - TypeSymbol typeSymbol = parameterSymbol.typeDescriptor(); - List paramTypes = getReferencedType(typeSymbol); - switch (parameterNode.kind()) { - case REQUIRED_PARAM: - RequiredParameterNode requiredParameterNode = (RequiredParameterNode) parameterNode; - paramIn = getParameterIn(requiredParameterNode.annotations()); - paramName = requiredParameterNode.paramName().isPresent() ? - requiredParameterNode.paramName().get().toString() : ""; - isRequired = true; - break; - case DEFAULTABLE_PARAM: - DefaultableParameterNode defaultableParameterNode = (DefaultableParameterNode) parameterNode; - paramIn = getParameterIn(defaultableParameterNode.annotations()); - paramName = defaultableParameterNode.paramName().isPresent() ? - defaultableParameterNode.paramName().get().toString() : ""; - break; - case INCLUDED_RECORD_PARAM: - break; - // res params - - } - if (isResource) { - // todo : param kind - resourceParams.add(new ResourceParameter( - paramTypes, paramName.trim(), paramIn, isRequired, elementLocation)); - } else { - remoteFunctionParams.add(new FunctionParameter(paramTypes, paramName, isRequired, elementLocation)); - } - } - } - } - - private String getReferenceEntityName(TypeReferenceTypeSymbol typeReferenceTypeSymbol) { - PackageId packageId = new PackageId(currentPackage); - String currentPackageName = String.format - ("%s/%s:%s", packageId.getOrg(), packageId.getName(), packageId.getVersion()); - String referenceType = typeReferenceTypeSymbol.signature(); - if (typeReferenceTypeSymbol.getModule().isPresent() && - !referenceType.split(":")[0].equals(currentPackageName.split(":")[0])) { - String orgName = typeReferenceTypeSymbol.getModule().get().id().orgName(); - String packageName = typeReferenceTypeSymbol.getModule().get().id().packageName(); - String modulePrefix = typeReferenceTypeSymbol.getModule().get().id().modulePrefix(); - String recordName = typeReferenceTypeSymbol.getName().get(); - String version = typeReferenceTypeSymbol.getModule().get().id().version(); - referenceType = String.format("%s/%s:%s:%s:%s", orgName, packageName, modulePrefix, version, recordName); - } - return referenceType; - } - - private List getReferencedType(TypeSymbol typeSymbol) { - List paramTypes = new LinkedList<>(); - TypeDescKind typeDescKind = typeSymbol.typeKind(); - switch (typeDescKind) { - case TYPE_REFERENCE: - TypeReferenceTypeSymbol typeReferenceTypeSymbol = (TypeReferenceTypeSymbol) typeSymbol; - paramTypes.add(getReferenceEntityName(typeReferenceTypeSymbol).trim()); - break; - case UNION: - UnionTypeSymbol unionTypeSymbol = (UnionTypeSymbol) typeSymbol; - List memberTypeDescriptors = unionTypeSymbol.memberTypeDescriptors(); - for (TypeSymbol memberTypeDescriptor : memberTypeDescriptors) { - paramTypes.addAll(getReferencedType(memberTypeDescriptor)); - } - break; - case ARRAY: - ArrayTypeSymbol arrayTypeSymbol = (ArrayTypeSymbol) typeSymbol; - if (arrayTypeSymbol.memberTypeDescriptor().typeKind().equals(TypeDescKind.TYPE_REFERENCE)) { - paramTypes.add(getReferenceEntityName( - (TypeReferenceTypeSymbol) arrayTypeSymbol.memberTypeDescriptor()).trim()); - } else { - paramTypes.add(arrayTypeSymbol.signature().trim()); - } - break; - case NIL: - paramTypes.add("null"); - break; - default: - paramTypes.add(typeDescKind.getName()); - } - return paramTypes; - } - - private String getParameterIn(NodeList annotationNodes) { - - String in = ""; - Optional payloadAnnotation = annotationNodes.stream().filter(annot -> - annot.toString().trim().equals("@http:Payload")).findAny(); - Optional headerAnnotation = annotationNodes.stream().filter(annot -> - annot.toString().trim().equals("@http:Header")).findAny(); - // do we need to handle http:Request - - if (payloadAnnotation.isPresent()) { - in = ParameterIn.BODY.getValue(); - } else if (headerAnnotation.isPresent()) { - in = ParameterIn.HEADER.getValue(); - } else { - in = ParameterIn.QUERY.getValue(); - } - return in; - } - - private List getReturnTypes(FunctionDefinitionNode functionDefinitionNode) { - - List returnTypes = new ArrayList<>(); - FunctionSignatureNode functionSignature = functionDefinitionNode.functionSignature(); - Optional returnTypeDescriptor = functionSignature.returnTypeDesc(); - if (returnTypeDescriptor.isPresent()) { - Optional symbol = semanticModel.symbol(functionDefinitionNode); - if (symbol.isPresent() && symbol.get().kind().equals(SymbolKind.METHOD) || - symbol.get().kind().equals(SymbolKind.RESOURCE_METHOD)) { - MethodSymbol resourceMethodSymbol = (MethodSymbol) symbol.get(); - Optional returnTypeSymbol = resourceMethodSymbol.typeDescriptor().returnTypeDescriptor(); - returnTypeSymbol.ifPresent(typeSymbol -> returnTypes.addAll(getReferencedType(typeSymbol))); - } - // need to split by pipe sign - } - return returnTypes; - } - - @Override - public void visit(ObjectFieldNode objectFieldNode) { - if (hasInvocationReferences(objectFieldNode)) { - return; - } - Node fieldTypeName = getReferredNode(objectFieldNode.typeName()); - if (fieldTypeName != null) { - Optional fieldTypeNameSymbol = semanticModel.symbol(fieldTypeName); - if (fieldTypeNameSymbol.isPresent()) { - ClassSymbol referredClassSymbol = getReferredClassSymbol((TypeSymbol) fieldTypeNameSymbol.get()); - if (referredClassSymbol != null) { - boolean isClientClass = referredClassSymbol.qualifiers().stream() - .anyMatch(qualifier -> qualifier.equals(Qualifier.CLIENT)); - if (isClientClass) { - String serviceId = objectFieldNode.metadata().isPresent() ? - getServiceAnnotation(objectFieldNode.metadata().get().annotations(), filePath).getId() : - UUID.randomUUID().toString(); - Dependency dependency = new Dependency(serviceId, - getClientModuleName(referredClassSymbol), - getElementLocation(filePath, objectFieldNode.lineRange())); - dependencies.add(dependency); - } - } - } - } - } - - @Override - public void visit(ConstantDeclarationNode constantDeclarationNode) { - - } - - private Node getReferredNode(Node typeName) { - Node qualifiedNameRefNode = null; - if (typeName.kind().equals(SyntaxKind.QUALIFIED_NAME_REFERENCE) || - typeName.kind().equals(SyntaxKind.SIMPLE_NAME_REFERENCE)) { - qualifiedNameRefNode = typeName; - } else if (typeName.kind().equals(SyntaxKind.UNION_TYPE_DESC)) { - Node leftTypeDescNode = getReferredNode(((UnionTypeDescriptorNode) typeName).leftTypeDesc()); - Node rightTypeDescNode = getReferredNode(((UnionTypeDescriptorNode) typeName).rightTypeDesc()); - if (leftTypeDescNode != null && (leftTypeDescNode.kind().equals(SyntaxKind.QUALIFIED_NAME_REFERENCE) || - leftTypeDescNode.kind().equals(SyntaxKind.SIMPLE_NAME_REFERENCE))) { - qualifiedNameRefNode = leftTypeDescNode; - } - if (rightTypeDescNode != null && (rightTypeDescNode.kind().equals(SyntaxKind.QUALIFIED_NAME_REFERENCE) || - rightTypeDescNode.kind().equals(SyntaxKind.SIMPLE_NAME_REFERENCE))) { - qualifiedNameRefNode = rightTypeDescNode; - } - } else if (typeName.kind().equals(SyntaxKind.PARENTHESISED_TYPE_DESC)) { - Node typeDescNode = getReferredNode(((ParenthesisedTypeDescriptorNode) typeName).typedesc()); - if (typeDescNode != null && (typeDescNode.kind().equals(SyntaxKind.QUALIFIED_NAME_REFERENCE) || - typeDescNode.kind().equals(SyntaxKind.SIMPLE_NAME_REFERENCE))) { - qualifiedNameRefNode = typeDescNode; - } - } - return qualifiedNameRefNode; - } - - private ClassSymbol getReferredClassSymbol(TypeSymbol symbol) { - ClassSymbol classSymbol = null; - if (symbol.kind().equals(SymbolKind.CLASS)) { - classSymbol = (ClassSymbol) symbol; - } else if (symbol.typeKind().equals(TypeDescKind.TYPE_REFERENCE)) { - TypeReferenceTypeSymbol typeRefTypeSymbol = (TypeReferenceTypeSymbol) symbol; - TypeSymbol typeDescTypeSymbol = typeRefTypeSymbol.typeDescriptor(); - classSymbol = getReferredClassSymbol(typeDescTypeSymbol); - } - return classSymbol; - } - - private boolean hasInvocationReferences(ObjectFieldNode clientDeclarationNode) { - Optional objFieldNodeSymbol = semanticModel.symbol(clientDeclarationNode); - if (objFieldNodeSymbol.isEmpty()) { - return false; - } - List objFieldNodeRefs = semanticModel.references(objFieldNodeSymbol.get()) - .stream().map(Location::lineRange).collect(Collectors.toList()); - for (LineRange lineRange : objFieldNodeRefs) { - Node referredNode = findNode(syntaxTree, lineRange); - while (!referredNode.kind().equals(SyntaxKind.SERVICE_DECLARATION) && - !referredNode.kind().equals(SyntaxKind.MODULE_PART)) { - if (referredNode.kind().equals(SyntaxKind.REMOTE_METHOD_CALL_ACTION) || - referredNode.kind().equals(SyntaxKind.CLIENT_RESOURCE_ACCESS_ACTION)) { - return true; - } - referredNode = referredNode.parent(); - } - } - return false; - } -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/ElementLocation.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/ElementLocation.java deleted file mode 100644 index 1314cf753161..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/ElementLocation.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator.model; - -/** - * Represent the location of a component model element. - * - * @since 2201.3.1 - */ -public class ElementLocation { - - private final String filePath; - private final LinePosition startPosition; - private final LinePosition endPosition; - - private ElementLocation(String filePath, LinePosition startPosition, LinePosition endPosition) { - this.filePath = filePath; - this.startPosition = startPosition; - this.endPosition = endPosition; - } - - public static ElementLocation from(String filePath, LinePosition startLine, LinePosition endLine) { - return new ElementLocation(filePath, startLine, endLine); - } - - public String getFilePath() { - return filePath; - } - - public LinePosition getStartPosition() { - return startPosition; - } - - public LinePosition getEndPosition() { - return endPosition; - } - - /** - * Represent the line position of a component model element. - * - * @since 2201.3.1 - */ - public static class LinePosition { - - private final int line; - private final int offset; - - private LinePosition(int line, int offset) { - this.line = line; - this.offset = offset; - } - - public static LinePosition from(int line, int offset) { - return new LinePosition(line, offset); - } - - public int getLine() { - return line; - } - - public int getOffset() { - return offset; - } - } -} - - diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/ModelElement.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/ModelElement.java deleted file mode 100644 index a58f3929a909..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/ModelElement.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator.model; - -/** - * Represents the abstract model for a component model item. - * - * @since 2201.3.1 - */ -public abstract class ModelElement { - - private final ElementLocation elementLocation; - - public ModelElement(ElementLocation elementLocation) { - this.elementLocation = elementLocation; - } - - public ElementLocation getElementLocation() { - return elementLocation; - } -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Association.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Association.java deleted file mode 100644 index 1d10b08234cb..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Association.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator.model.entity; - -/** - * Represent the relationship between records. - * - * @since 2201.2.2 - */ -public class Association { - - private String associate; - private Cardinality cardinality; - - public Association(String associate, Cardinality cardinality) { - - this.associate = associate; - this.cardinality = cardinality; - } - - public String getAssociate() { - return associate; - } - - public Cardinality getCardinality() { - return cardinality; - } - - public void setAssociate(String associate) { - this.associate = associate; - } - - public void setCardinality(Cardinality cardinality) { - this.cardinality = cardinality; - } - - /** - * Represents the cardinality of the relationship. - */ - public static class Cardinality { - - private final String self; - private final String associate; - - public Cardinality(String self, String associate) { - - this.self = self; - this.associate = associate; - } - - public String getSelf() { - return self; - } - - public String getAssociate() { - return associate; - } - } -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Attribute.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Attribute.java deleted file mode 100644 index b0b03039f833..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Attribute.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator.model.entity; - -import io.ballerina.architecturemodelgenerator.model.ElementLocation; -import io.ballerina.architecturemodelgenerator.model.ModelElement; - -import java.util.List; - -/** - * Represents field of a record. - * - * @since 2201.2.2 - */ -public class Attribute extends ModelElement { - - private final String name; - private final String type; - private final boolean optional; - private final boolean nillable; - private final String defaultValue; - private final List associations; // can have multiple association when union is found - - public Attribute(String name, String type, boolean optional, boolean nillable, String defaultValue, - List associations, ElementLocation elementLocation) { - super(elementLocation); - this.name = name; - this.type = type; - this.optional = optional; - this.nillable = nillable; - this.defaultValue = defaultValue; - this.associations = associations; - } - - public String getName() { - return name; - } - - public String getType() { - return type; - } - - public boolean isOptional() { - return optional; - } - - public boolean isNillable() { - return nillable; - } - - public String getDefaultValue() { - return defaultValue; - } - - public List getAssociations() { - return associations; - } - -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Entity.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Entity.java deleted file mode 100644 index 5c3c8e3d135e..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/entity/Entity.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator.model.entity; - -import io.ballerina.architecturemodelgenerator.model.ElementLocation; -import io.ballerina.architecturemodelgenerator.model.ModelElement; - -import java.util.List; - -/** - * Represent a Ballerina record. - * - * @since 2201.2.2 - */ -public class Entity extends ModelElement { - - private List attributes; - private final List inclusions; - private final boolean isAnonymous; - - // todo : send the location - - public Entity(List attributes, List inclusions, ElementLocation elementLocation, - boolean isAnonymous) { - super(elementLocation); - this.attributes = attributes; - this.inclusions = inclusions; - this.isAnonymous = isAnonymous; - } - - public List getAttributes() { - return attributes; - } - - public void setAttributes(List attributes) { - this.attributes = attributes; - } - - public List getInclusions() { - return inclusions; - } - - public boolean isAnonymous() { - return isAnonymous; - } -} - diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Dependency.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Dependency.java deleted file mode 100644 index bf018ed906b0..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Dependency.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator.model.service; - -import io.ballerina.architecturemodelgenerator.model.ElementLocation; -import io.ballerina.architecturemodelgenerator.model.ModelElement; - -/** - * Represent the dependency of another service. - * - * @since 2201.4.0 - */ -public class Dependency extends ModelElement { - private final String serviceId; - private final String connectorType; - - public Dependency(String serviceId, String connectorType, ElementLocation elementLocation) { - super(elementLocation); - this.serviceId = serviceId; - this.connectorType = connectorType; - } - - public String getServiceId() { - return serviceId; - } - - public String getConnectorType() { - return connectorType; - } -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/FunctionParameter.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/FunctionParameter.java deleted file mode 100644 index 2a3bbafd6c96..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/FunctionParameter.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator.model.service; - -import io.ballerina.architecturemodelgenerator.model.ElementLocation; -import io.ballerina.architecturemodelgenerator.model.ModelElement; - -import java.util.List; - -/** - * Represent a parameter of a Ballerina Object Method. - * - * @since 2201.2.2 - */ -public class FunctionParameter extends ModelElement { - - private final List type; - private final String name; - private final boolean isRequired; - - public FunctionParameter(List type, String name, boolean isRequired, ElementLocation elementLocation) { - super(elementLocation); - this.type = type; - this.name = name; - this.isRequired = isRequired; - } - - public List getType() { - return type; - } - - public String getName() { - return name; - } - - public boolean isRequired() { - return isRequired; - } -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Interaction.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Interaction.java deleted file mode 100644 index be4d59bab049..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Interaction.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator.model.service; - -import io.ballerina.architecturemodelgenerator.model.ElementLocation; -import io.ballerina.architecturemodelgenerator.model.ModelElement; - -/** - * Represent interaction with another service. - * - * @since 2201.2.2 - */ -public class Interaction extends ModelElement { - - private final ResourceId resourceId; - private final String connectorType; - - public Interaction(ResourceId resourceId, String connectorType, ElementLocation elementLocation) { - super(elementLocation); - this.resourceId = resourceId; - this.connectorType = connectorType; - } - - public ResourceId getResourceId() { - return resourceId; - } - - public String getConnectorType() { - return connectorType; - } -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/RemoteFunction.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/RemoteFunction.java deleted file mode 100644 index d6e10bbcf14a..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/RemoteFunction.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator.model.service; - -import io.ballerina.architecturemodelgenerator.model.ElementLocation; -import io.ballerina.architecturemodelgenerator.model.ModelElement; - -import java.util.List; - -/** - * Represents a Ballerina remote function. - * - * @since 2201.2.2 - */ -public class RemoteFunction extends ModelElement { - - private final String name; - private final List parameters; - private final List returns; - - private final List interactions; - - public RemoteFunction(String name, List parameters, List returns, - List interactions, ElementLocation elementLocation) { - super(elementLocation); - this.name = name; - this.parameters = parameters; - this.returns = returns; - this.interactions = interactions; - } - - public String getName() { - return name; - } - - public List getParameters() { - return parameters; - } - - public List getReturns() { - return returns; - } - - public List getInteractions() { - return interactions; - } -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Resource.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Resource.java deleted file mode 100644 index 9fb03acdec8c..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Resource.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator.model.service; - -import io.ballerina.architecturemodelgenerator.model.ElementLocation; -import io.ballerina.architecturemodelgenerator.model.ModelElement; - -import java.util.List; - -/** - * Represents resource details. - * - * @since 2201.2.2 - */ -public class Resource extends ModelElement { - - private final String identifier; - private final ResourceId resourceId; - private final List parameters; - private final List returns; - private final List interactions; - - public Resource(String identifier, ResourceId resourceId, List parameters, List returns, - List interactions, ElementLocation elementLocation) { - super(elementLocation); - this.identifier = identifier; - this.resourceId = resourceId; - this.parameters = parameters; - this.returns = returns; - this.interactions = interactions; - } - - public String getIdentifier() { - return identifier; - } - - public ResourceId getResourceId() { - return resourceId; - } - - public List getParameters() { - return parameters; - } - - public List getReturns() { - return returns; - } - - public List getInteractions() { - return interactions; - } -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ResourceId.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ResourceId.java deleted file mode 100644 index 69136d21dc60..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ResourceId.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator.model.service; - -/** - * Provide resource information. - * - * @since 2201.2.2 - */ -public class ResourceId { - - private final String serviceId; - private final String path; - private final String action; - - public ResourceId(String serviceId, String action, String path) { - - this.serviceId = serviceId; - this.action = action; - this.path = path; - } - - public String getServiceId() { - return serviceId; - } - - public String getPath() { - return path; - } - - public String getAction() { - return action; - } -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ResourceParameter.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ResourceParameter.java deleted file mode 100644 index a28acec9530b..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ResourceParameter.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator.model.service; - -import io.ballerina.architecturemodelgenerator.model.ElementLocation; -import io.ballerina.architecturemodelgenerator.model.ModelElement; - -import java.util.List; - -/** - * Represents resource funstion parameter information. - * - * @since 2201.2.2 - */ -public class ResourceParameter extends ModelElement { - - private final List type; - private final String name; - private final String in; - private final boolean isRequired; - - public ResourceParameter(List type, String name, String in, boolean isRequired, - ElementLocation elementLocation) { - super(elementLocation); - this.type = type; - this.name = name; - this.in = in; - this.isRequired = isRequired; - - } - - public List getType() { - return type; - } - - public String getName() { - return name; - } - - public String getIn() { - return in; - } - - public boolean isRequired() { - return isRequired; - } -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Service.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Service.java deleted file mode 100644 index 6415903d382f..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/Service.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator.model.service; - -import io.ballerina.architecturemodelgenerator.model.ElementLocation; -import io.ballerina.architecturemodelgenerator.model.ModelElement; - -import java.util.List; - -/** - * Provides service related information. - * - * @since 2201.2.2 - */ -public class Service extends ModelElement { - - private final String path; - private final String serviceId; - private final String serviceType; - private final List resources; - private final ServiceAnnotation annotation; - private final List remoteFunctions; - private final List dependencies; - - public Service(String path, String serviceId, String serviceType, List resources, - ServiceAnnotation annotation, List remoteFunctions, List dependencies, - ElementLocation elementLocation) { - super(elementLocation); - this.path = path; - this.serviceId = serviceId; - this.serviceType = serviceType; - this.resources = resources; - this.annotation = annotation; - this.remoteFunctions = remoteFunctions; - this.dependencies = dependencies; - } - - public String getPath() { - return path; - } - - public String getServiceId() { - return serviceId; - } - - public String getServiceType() { - return serviceType; - } - - public List getResources() { - return resources; - } - - public ServiceAnnotation getAnnotation() { - return annotation; - } - - public List getRemoteFunctions() { - return remoteFunctions; - } - - public List getDependencies() { - return dependencies; - } -} diff --git a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ServiceAnnotation.java b/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ServiceAnnotation.java deleted file mode 100644 index ab1f7111c9a7..000000000000 --- a/misc/architecture-model-generator/src/main/java/io/ballerina/architecturemodelgenerator/model/service/ServiceAnnotation.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.architecturemodelgenerator.model.service; - -import io.ballerina.architecturemodelgenerator.model.ElementLocation; - -/** - * Represents display annotation. - * - * @since 2201.2.2 - */ -public class ServiceAnnotation { - - private final String id; - private final String label; - private final ElementLocation elementLocation; - - public ServiceAnnotation() { - this.id = ""; - this.label = ""; - elementLocation = null; - } - - public ServiceAnnotation(String id, String label, ElementLocation elementLocation) { - this.id = id; - this.label = label; - this.elementLocation = elementLocation; - } - - public String getId() { - return id; - } - - public String getLabel() { - return label; - } - - public ElementLocation getElementLocation() { - return elementLocation; - } -} diff --git a/misc/architecture-model-generator/src/main/java/module-info.java b/misc/architecture-model-generator/src/main/java/module-info.java deleted file mode 100644 index 83356dfebb95..000000000000 --- a/misc/architecture-model-generator/src/main/java/module-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -module io.ballerina.architecturemodelgenerator { - requires com.google.gson; - requires io.ballerina.lang; - requires io.ballerina.parser; - requires io.ballerina.tools.api; - - exports io.ballerina.architecturemodelgenerator; - exports io.ballerina.architecturemodelgenerator.diagnostics; -} diff --git a/misc/compiler-plugins/modules/architecture-model-generator-plugin/build.gradle b/misc/compiler-plugins/modules/architecture-model-generator-plugin/build.gradle deleted file mode 100644 index 252d1adc5be1..000000000000 --- a/misc/compiler-plugins/modules/architecture-model-generator-plugin/build.gradle +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://wso2.com) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -apply from: "$rootDir/gradle/javaProject.gradle" -apply from: "$rootDir/gradle/ballerinaLangLibLoad.gradle" - -description = 'Ballerina Component Model Generator' - -dependencies { - implementation project(':ballerina-lang') - implementation project(':ballerina-parser') - implementation project(':ballerina-tools-api') - - implementation project(':architecture-model-generator') - implementation "com.google.code.gson:gson:${project.gsonVersion}" -} - -ext.moduleName = 'io.ballerina.modelgenerator.plugin' - -compileJava { - doFirst { - options.compilerArgs = [ - '--module-path', classpath.asPath, - ] - classpath = files() - } -} diff --git a/misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/CompilationAnalysisTask.java b/misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/CompilationAnalysisTask.java deleted file mode 100644 index dff9de53890e..000000000000 --- a/misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/CompilationAnalysisTask.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://wso2.com) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.ballerina.architecturemodelgeneratorplugin; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import io.ballerina.architecturemodelgenerator.ComponentModel; -import io.ballerina.architecturemodelgenerator.ComponentModelBuilder; -import io.ballerina.architecturemodelgeneratorplugin.diagnostic.DiagnosticMessage; -import io.ballerina.projects.BuildOptions; -import io.ballerina.projects.Project; -import io.ballerina.projects.plugins.AnalysisTask; -import io.ballerina.projects.plugins.CompilationAnalysisContext; -import io.ballerina.tools.diagnostics.Diagnostic; -import io.ballerina.tools.diagnostics.DiagnosticFactory; -import io.ballerina.tools.diagnostics.DiagnosticInfo; - -import java.io.FileWriter; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.InvalidPathException; -import java.nio.file.Path; - -import static io.ballerina.architecturemodelgeneratorplugin.PluginConstants.MODEL_DIR_NAME; -import static io.ballerina.architecturemodelgeneratorplugin.PluginConstants.MODEL_JSON_NAME; - -/** - * Compilation analyzer to generate component model. - * - * @since 2201.4.0 - */ -public class CompilationAnalysisTask implements AnalysisTask { - @Override - public void perform(CompilationAnalysisContext compilationAnalysisContext) { - Project project = compilationAnalysisContext.currentPackage().project(); - - //Used build option exportComponentModel() to enable plugin at the build time. - BuildOptions buildOptions = project.buildOptions(); - if (buildOptions.exportComponentModel()) { - Path outPath = project.targetDir(); - ComponentModelBuilder componentModelBuilder = new ComponentModelBuilder(); - ComponentModel projectModel = componentModelBuilder - .constructComponentModel(compilationAnalysisContext.currentPackage(), - compilationAnalysisContext.compilation()); - Gson gson = new GsonBuilder().setPrettyPrinting().serializeNulls().create(); - String componentModelJson = gson.toJson(projectModel) + System.lineSeparator(); - writeComponentModelJson(outPath, componentModelJson, compilationAnalysisContext); - } - } - - private void writeComponentModelJson(Path outPath, String componentModelJson, CompilationAnalysisContext context) { - try { - // Create ComponentModel directory if not exists in the path. If exists do not throw an error - Path componentModelExportDir = outPath.resolve(MODEL_DIR_NAME); - Files.createDirectories(componentModelExportDir); - Path writePath = componentModelExportDir.resolve(MODEL_JSON_NAME); - writeFile(writePath, componentModelJson); - } catch (InvalidPathException | SecurityException | IOException e) { - DiagnosticMessage diagnosticMessage = DiagnosticMessage.ERROR_100; - DiagnosticInfo diagnosticInfo = new DiagnosticInfo(diagnosticMessage.getCode(), - diagnosticMessage.getMessageFormat(), diagnosticMessage.getSeverity()); - Diagnostic diagnostic = DiagnosticFactory.createDiagnostic(diagnosticInfo, null, e.getMessage()); - context.reportDiagnostic(diagnostic); - } - } - - private void writeFile(Path filePath, String content) throws IOException { - try (FileWriter writer = new FileWriter(filePath.toString(), StandardCharsets.UTF_8)) { - writer.write(content); - } - } -} diff --git a/misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCodeAnalyzer.java b/misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCodeAnalyzer.java deleted file mode 100644 index eb4d62a1be87..000000000000 --- a/misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCodeAnalyzer.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://wso2.com) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package io.ballerina.architecturemodelgeneratorplugin; - -import io.ballerina.projects.plugins.CodeAnalysisContext; -import io.ballerina.projects.plugins.CodeAnalyzer; - -/** - * CodeAnalyzer for Component model generator compiler plugin. - * - * @since 2201.4.0 - */ -public class ModelGeneratorCodeAnalyzer extends CodeAnalyzer { - @Override - public void init(CodeAnalysisContext analysisContext) { - analysisContext.addCompilationAnalysisTask(new CompilationAnalysisTask()); - } -} diff --git a/misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCompilerPlugin.java b/misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCompilerPlugin.java deleted file mode 100644 index 0526a04d3d18..000000000000 --- a/misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/ModelGeneratorCompilerPlugin.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://wso2.com) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.ballerina.architecturemodelgeneratorplugin; - -import io.ballerina.projects.plugins.CompilerPlugin; -import io.ballerina.projects.plugins.CompilerPluginContext; - -/** - * Compiler Plugin to generate Component Models. - * - * @since 2201.4.0 - */ -public class ModelGeneratorCompilerPlugin extends CompilerPlugin { - @Override - public void init(CompilerPluginContext pluginContext) { - pluginContext.addCodeAnalyzer(new ModelGeneratorCodeAnalyzer()); - } -} diff --git a/misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/PluginConstants.java b/misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/PluginConstants.java deleted file mode 100644 index 30b339bb21b4..000000000000 --- a/misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/PluginConstants.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://wso2.com) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.ballerina.architecturemodelgeneratorplugin; - -/** - * Plugin Constants. - * - * @since 2201.4.0 - */ -public class PluginConstants { - public static final String MODEL_DIR_NAME = "component-model"; - public static final String MODEL_JSON_NAME = "component-model.json"; -} diff --git a/misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/diagnostic/DiagnosticMessage.java b/misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/diagnostic/DiagnosticMessage.java deleted file mode 100644 index c361d3533876..000000000000 --- a/misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/io/ballerina/architecturemodelgeneratorplugin/diagnostic/DiagnosticMessage.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://wso2.com) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.ballerina.architecturemodelgeneratorplugin.diagnostic; - -import io.ballerina.tools.diagnostics.DiagnosticSeverity; - -/** - * Model Generator compiler plugin diagnostic messages. - * - * @since 2201.4.0 - */ -public enum DiagnosticMessage { - ERROR_100("MODEL_GENERATOR_PLUGIN_ERROR_100", - "Failed to write the generated Component Model JSON to the target directory: {0}.", - DiagnosticSeverity.ERROR); - - private final String code; - private final String messageFormat; - private final DiagnosticSeverity severity; - - DiagnosticMessage(String code, String messageFormat, DiagnosticSeverity severity) { - this.code = code; - this.messageFormat = messageFormat; - this.severity = severity; - } - - public String getCode() { - return this.code; - } - - public String getMessageFormat() { - return this.messageFormat; - } - - public DiagnosticSeverity getSeverity() { - return this.severity; - } -} diff --git a/misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/module-info.java b/misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/module-info.java deleted file mode 100644 index 3f9fc5362750..000000000000 --- a/misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/java/module-info.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -module io.ballerina.modelgenerator.plugin { - requires com.google.gson; - requires io.ballerina.lang; - requires io.ballerina.parser; - requires io.ballerina.tools.api; - requires io.ballerina.architecturemodelgenerator; - - exports io.ballerina.architecturemodelgeneratorplugin; -} diff --git a/misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/resources/META-INF/services/io.ballerina.projects.plugins.CompilerPlugin b/misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/resources/META-INF/services/io.ballerina.projects.plugins.CompilerPlugin deleted file mode 100644 index 8901ab6d2807..000000000000 --- a/misc/compiler-plugins/modules/architecture-model-generator-plugin/src/main/resources/META-INF/services/io.ballerina.projects.plugins.CompilerPlugin +++ /dev/null @@ -1 +0,0 @@ -io.ballerina.architecturemodelgeneratorplugin.ModelGeneratorCompilerPlugin diff --git a/misc/ls-extensions/modules/project-design-service/build.gradle b/misc/ls-extensions/modules/project-design-service/build.gradle deleted file mode 100644 index 526a5ac6b0ea..000000000000 --- a/misc/ls-extensions/modules/project-design-service/build.gradle +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -apply from: "$rootDir/gradle/javaProject.gradle" -apply from: "$rootDir/gradle/ballerinaLangLibLoad.gradle" - -configurations { - compile.transitive = false - compileClasspath.extendsFrom(compileOnly) -} - -dependencies { - compileOnly project(':ballerina-lang') - compileOnly project(':ballerina-tools-api') - compileOnly project(':language-server:language-server-commons') - compileOnly project(':language-server:language-server-core') - - compileOnly(group: 'org.eclipse.lsp4j', name: 'org.eclipse.lsp4j', version: "${project.eclipseLsp4jVersion}") - - implementation project(":architecture-model-generator") - - testCompile 'org.testng:testng' - -} - -test { - useTestNG() { - suites 'src/test/resources/testng.xml' - } -} - -description = 'LS extension for project design diagram generation' - -ext.moduleName = 'project-design-service' - -compileJava { - inputs.property("moduleName", moduleName) - doFirst { - options.compilerArgs = [ - '--module-path', classpath.asPath, - ] - classpath = files() - } -} - -jar { - manifest { - attributes "Main-Class": "io.ballerina.componentmodel.ProjectDesignService" - } - from { - configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } - } -} diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignClientCapabilities.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignClientCapabilities.java deleted file mode 100644 index e24f7fda6402..000000000000 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignClientCapabilities.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.projectdesign; - -import io.ballerina.architecturemodelgenerator.ProjectDesignConstants; -import org.ballerinalang.langserver.commons.registration.BallerinaClientCapability; - -/** - * Client capabilities for the solution architecture modeling service. - * - * @since 2201.2.2 - */ -public class ProjectDesignClientCapabilities extends BallerinaClientCapability { - - private boolean getMultiServiceModel; - - public ProjectDesignClientCapabilities() { - - super(ProjectDesignConstants.CAPABILITY_NAME); - } - - public boolean isGetMultiServiceModel() { - return getMultiServiceModel; - } - - public void setGetMultiServiceModel(boolean getMultiServiceModel) { - this.getMultiServiceModel = getMultiServiceModel; - } -} diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignClientCapabilitySetter.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignClientCapabilitySetter.java deleted file mode 100644 index bd0f33236c6a..000000000000 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignClientCapabilitySetter.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.projectdesign; - -import io.ballerina.architecturemodelgenerator.ProjectDesignConstants; -import org.ballerinalang.annotation.JavaSPIService; -import org.ballerinalang.langserver.commons.registration.BallerinaClientCapabilitySetter; - -/** - * Client Capability setter for the {@link ProjectDesignService}. - * - * @since 2201.2.2 - */ -@JavaSPIService("org.ballerinalang.langserver.commons.registration.BallerinaClientCapabilitySetter") -public class ProjectDesignClientCapabilitySetter extends - BallerinaClientCapabilitySetter { - - @Override - public String getCapabilityName() { - return ProjectDesignConstants.CAPABILITY_NAME; - } - - @Override - public Class getCapability() { - return ProjectDesignClientCapabilities.class; - } -} diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignServerCapabilities.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignServerCapabilities.java deleted file mode 100644 index a91877d9acd2..000000000000 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignServerCapabilities.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.projectdesign; - -import io.ballerina.architecturemodelgenerator.ProjectDesignConstants; -import org.ballerinalang.langserver.commons.registration.BallerinaServerCapability; - -/** - * Server capabilities for the solution architecture modeling service. - * - * @since 2201.2.2 - */ -public class ProjectDesignServerCapabilities extends BallerinaServerCapability { - - private boolean getMultiServiceModel; - - public ProjectDesignServerCapabilities() { - super(ProjectDesignConstants.CAPABILITY_NAME); - } - - public boolean isGetMultiServiceModel() { - return getMultiServiceModel; - } - - public void setGetMultiServiceModel(boolean getMultiServiceModel) { - this.getMultiServiceModel = getMultiServiceModel; - } -} diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignServerCapabilitySetter.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignServerCapabilitySetter.java deleted file mode 100644 index a36002e9683a..000000000000 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignServerCapabilitySetter.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.projectdesign; - -import io.ballerina.architecturemodelgenerator.ProjectDesignConstants; -import org.ballerinalang.annotation.JavaSPIService; -import org.ballerinalang.langserver.commons.registration.BallerinaServerCapabilitySetter; - -import java.util.Optional; - -/** - * Capability setter for the {@link ProjectDesignService}. - * - * @since 2201.2.2 - */ -@JavaSPIService("org.ballerinalang.langserver.commons.registration.BallerinaServerCapabilitySetter") -public class ProjectDesignServerCapabilitySetter extends - BallerinaServerCapabilitySetter { - - @Override - public Optional build() { - - ProjectDesignServerCapabilities capabilities = new ProjectDesignServerCapabilities(); - capabilities.setGetMultiServiceModel(true); - return Optional.of(capabilities); - } - - @Override - public String getCapabilityName() { - return ProjectDesignConstants.CAPABILITY_NAME; - } - - @Override - public Class getCapability() { - return ProjectDesignServerCapabilities.class; - } -} diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignService.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignService.java deleted file mode 100644 index f60447d81eb4..000000000000 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/ProjectDesignService.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.projectdesign; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonObject; -import io.ballerina.architecturemodelgenerator.ComponentModel; -import io.ballerina.architecturemodelgenerator.ComponentModelBuilder; -import io.ballerina.architecturemodelgenerator.ProjectComponentRequest; -import io.ballerina.architecturemodelgenerator.ProjectComponentResponse; -import io.ballerina.architecturemodelgenerator.diagnostics.ComponentModelException; -import io.ballerina.architecturemodelgenerator.diagnostics.DiagnosticMessage; -import io.ballerina.architecturemodelgenerator.diagnostics.DiagnosticUtils; -import io.ballerina.projects.Project; -import org.ballerinalang.annotation.JavaSPIService; -import org.ballerinalang.langserver.commons.eventsync.exceptions.EventSyncException; -import org.ballerinalang.langserver.commons.service.spi.ExtendedLanguageServerService; -import org.ballerinalang.langserver.commons.workspace.WorkspaceDocumentException; -import org.ballerinalang.langserver.commons.workspace.WorkspaceManager; -import org.eclipse.lsp4j.jsonrpc.services.JsonRequest; -import org.eclipse.lsp4j.jsonrpc.services.JsonSegment; -import org.eclipse.lsp4j.services.LanguageServer; - -import java.nio.file.Path; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.concurrent.CompletableFuture; - -/** - * The extended service for generation solution architecture model. - * - * @since 2201.2.2 - */ -@JavaSPIService("org.ballerinalang.langserver.commons.service.spi.ExtendedLanguageServerService") -@JsonSegment("projectDesignService") -public class ProjectDesignService implements ExtendedLanguageServerService { - - private WorkspaceManager workspaceManager; - - @Override - public void init(LanguageServer langServer, WorkspaceManager workspaceManager) { - this.workspaceManager = workspaceManager; - } - - @Override - public Class getRemoteInterface() { - return getClass(); - } - - @JsonRequest - public CompletableFuture getProjectComponentModels - (ProjectComponentRequest request) { - - return CompletableFuture.supplyAsync(() -> { - ProjectComponentResponse response = new ProjectComponentResponse(); - Map componentModelMap = new HashMap<>(); - for (String documentUri : request.getDocumentUris()) { - Path path = Path.of(documentUri); - try { - Project project = getCurrentProject(path); - if (!Utils.modelAlreadyExists(componentModelMap, project.currentPackage())) { - ComponentModelBuilder componentModelBuilder = new ComponentModelBuilder(); - ComponentModel projectModel = componentModelBuilder - .constructComponentModel(project.currentPackage()); - Gson gson = new GsonBuilder().serializeNulls().create(); - JsonObject componentModelJson = (JsonObject) gson.toJsonTree(projectModel); - componentModelMap.put(Utils.getQualifiedPackageName( - projectModel.getPackageId()), componentModelJson); - } - } catch (ComponentModelException | WorkspaceDocumentException | EventSyncException e) { - // todo : Improve error messages - DiagnosticMessage message = DiagnosticMessage.componentModellingService001(documentUri); - response.addDiagnostics - (DiagnosticUtils.getDiagnosticResponse(List.of(message), response)); - } catch (Exception e) { - DiagnosticMessage message = DiagnosticMessage.componentModellingService002( - e.getMessage(), Arrays.toString(e.getStackTrace()), documentUri); - response.addDiagnostics - (DiagnosticUtils.getDiagnosticResponse(List.of(message), response)); - } - } - response.setComponentModels(componentModelMap); - return response; - }); - } - - private Project getCurrentProject(Path path) throws ComponentModelException, WorkspaceDocumentException, - EventSyncException { - - Optional project = workspaceManager.project(path); - if (project.isEmpty()) { - return workspaceManager.loadProject(path); - } - return project.get(); - } -} diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/Utils.java b/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/Utils.java deleted file mode 100644 index 46697533a3de..000000000000 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/io/ballerina/projectdesign/Utils.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package io.ballerina.projectdesign; - -import com.google.gson.JsonObject; -import io.ballerina.architecturemodelgenerator.ComponentModel; -import io.ballerina.projects.Package; - -import java.util.Map; - -/** - * Provide utils functions for component model building. - * - * @since 2201.2.2 - */ -public class Utils { - public static String getQualifiedPackageName(ComponentModel.PackageId packageId) { - - return String.format("%s/%s:%s", packageId.getOrg(), - packageId.getName(), packageId.getVersion()); - } - - public static boolean modelAlreadyExists(Map componentModelMap, Package currentPackage) { - - ComponentModel.PackageId packageId = new ComponentModel.PackageId(currentPackage); - return componentModelMap.containsKey(getQualifiedPackageName(packageId)); - } -} diff --git a/misc/ls-extensions/modules/project-design-service/src/main/java/module-info.java b/misc/ls-extensions/modules/project-design-service/src/main/java/module-info.java deleted file mode 100644 index 9cdff86a2c12..000000000000 --- a/misc/ls-extensions/modules/project-design-service/src/main/java/module-info.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -module io.ballerina.LSExtensions.ProjectDesignService { - requires io.ballerina.language.server.commons; - requires io.ballerina.lang; - requires org.eclipse.lsp4j.jsonrpc; - requires org.eclipse.lsp4j; - requires com.google.gson; - requires io.ballerina.tools.api; - requires io.ballerina.language.server.core; - requires io.ballerina.architecturemodelgenerator; -} diff --git a/misc/ls-extensions/modules/project-design-service/src/main/resources/META-INF/services/org.ballerinalang.langserver.commons.registration.BallerinaClientCapabilitySetter b/misc/ls-extensions/modules/project-design-service/src/main/resources/META-INF/services/org.ballerinalang.langserver.commons.registration.BallerinaClientCapabilitySetter deleted file mode 100644 index 5e075dfd846a..000000000000 --- a/misc/ls-extensions/modules/project-design-service/src/main/resources/META-INF/services/org.ballerinalang.langserver.commons.registration.BallerinaClientCapabilitySetter +++ /dev/null @@ -1 +0,0 @@ -io.ballerina.projectdesign.ProjectDesignClientCapabilitySetter \ No newline at end of file diff --git a/misc/ls-extensions/modules/project-design-service/src/main/resources/META-INF/services/org.ballerinalang.langserver.commons.registration.BallerinaServerCapabilitySetter b/misc/ls-extensions/modules/project-design-service/src/main/resources/META-INF/services/org.ballerinalang.langserver.commons.registration.BallerinaServerCapabilitySetter deleted file mode 100644 index 25e56131ab5d..000000000000 --- a/misc/ls-extensions/modules/project-design-service/src/main/resources/META-INF/services/org.ballerinalang.langserver.commons.registration.BallerinaServerCapabilitySetter +++ /dev/null @@ -1 +0,0 @@ -io.ballerina.projectdesign.ProjectDesignServerCapabilitySetter \ No newline at end of file diff --git a/misc/ls-extensions/modules/project-design-service/src/main/resources/META-INF/services/org.ballerinalang.langserver.commons.service.spi.ExtendedLanguageServerService b/misc/ls-extensions/modules/project-design-service/src/main/resources/META-INF/services/org.ballerinalang.langserver.commons.service.spi.ExtendedLanguageServerService deleted file mode 100644 index 2336d00b6550..000000000000 --- a/misc/ls-extensions/modules/project-design-service/src/main/resources/META-INF/services/org.ballerinalang.langserver.commons.service.spi.ExtendedLanguageServerService +++ /dev/null @@ -1 +0,0 @@ -io.ballerina.projectdesign.ProjectDesignService \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 513800bd2c9d..2901f32d13ec 100644 --- a/settings.gradle +++ b/settings.gradle @@ -98,7 +98,6 @@ include(':language-server-simulator') // TODO: enable at 'dependsOn' of tools-intergration-tests // and 'mustRunAfter' of vs-code-pluggin -include(':architecture-model-generator') include(':benchmarks') include(':build-config:checkstyle') include(':debug-adapter:debug-adapter-core') @@ -106,7 +105,6 @@ include(':debug-adapter:debug-adapter-cli') include(':debug-adapter:debug-adapter-runtime') include('semver-checker:semver-checker-cli') include('semver-checker:semver-checker-core') -include(':compiler-plugins:architecture-model-generator-plugin') include(':compiler-plugins:package-semantic-analyzer') include(':compiler-plugins:configurable-schema-generator') include(':formatter:formatter-core') @@ -116,7 +114,6 @@ include(':ls-extensions:performance-analyzer-services') include(':ls-extensions:partial-parser') include(':ls-extensions:trigger-service') include(':ls-extensions:bal-shell-service') -include(':ls-extensions:project-design-service') include(':project-api-test-artifact:event-logger-compiler-plugin') include(':project-api-test-artifact:compiler-plugin-with-one-dependency') include(':project-api-test-artifact:compiler-plugin-with-codeactions') @@ -183,7 +180,6 @@ project(':ballerina-runtime').projectDir = file('bvm/ballerina-runtime') project(':ballerina-rt').projectDir = file('bvm/ballerina-rt') project(':ballerina-treegen').projectDir = file('compiler/ballerina-treegen') project(':ballerina-test-utils').projectDir = file('tests/ballerina-test-utils') -project(':architecture-model-generator').projectDir = file('misc/architecture-model-generator') project(':ballerina-io-internal').projectDir = file('misc/io-internal') project(':json-mapper').projectDir = file('misc/json-to-record-converter') project(':lib-creator').projectDir = file('misc/lib-creator') @@ -246,7 +242,6 @@ project(':debug-adapter:debug-adapter-cli').projectDir = file('misc/debug-adapte project(':debug-adapter:debug-adapter-runtime').projectDir = file('misc/debug-adapter/modules/debug-adapter-runtime') project(':semver-checker:semver-checker-core').projectDir = file('misc/semver-checker/modules/semver-checker-core') project(':semver-checker:semver-checker-cli').projectDir = file('misc/semver-checker/modules/semver-checker-cli') -project(':compiler-plugins:architecture-model-generator-plugin').projectDir = file('misc/compiler-plugins/modules/architecture-model-generator-plugin') project(':compiler-plugins:package-semantic-analyzer').projectDir = file('misc/compiler-plugins/modules/package-semantic-analyzer') project(':compiler-plugins:configurable-schema-generator').projectDir = file('misc/compiler-plugins/modules/configurable-schema-generator') project(':formatter:formatter-core').projectDir = file('misc/formatter/modules/formatter-core') @@ -256,7 +251,6 @@ project(':ls-extensions:performance-analyzer-services').projectDir = file('misc/ project(':ls-extensions:partial-parser').projectDir = file('misc/ls-extensions/modules/partial-parser') project(':ls-extensions:trigger-service').projectDir = file('misc/ls-extensions/modules/trigger-service') project(':ls-extensions:bal-shell-service').projectDir = file('misc/ls-extensions/modules/bal-shell-service') -project(':ls-extensions:project-design-service').projectDir = file('misc/ls-extensions/modules/project-design-service') buildCache { remote(HttpBuildCache) { From 3ad8230a2545c4a3c9156080dbf1491986761d7c Mon Sep 17 00:00:00 2001 From: sanjana Date: Wed, 4 Jan 2023 12:36:06 +0530 Subject: [PATCH 428/450] Update xml langlib examples --- langlib/lang.xml/src/main/ballerina/xml.bal | 48 ++++++++++----------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/langlib/lang.xml/src/main/ballerina/xml.bal b/langlib/lang.xml/src/main/ballerina/xml.bal index ed556ecda7ff..dc1e218e6b10 100644 --- a/langlib/lang.xml/src/main/ballerina/xml.bal +++ b/langlib/lang.xml/src/main/ballerina/xml.bal @@ -83,8 +83,8 @@ type XmlType xml; # ```ballerina # object { # public isolated function next() returns record {|xml value;|}?; -# } iterator = xml `Learning BallerinaJava Guide`.iterator(); -# iterator.next() ⇒ {"value":`Learning Ballerina`} +# } iterator = xml `JohnPeter`.iterator(); +# iterator.next() ⇒ {"value":`John`} # ``` # # + x - xml sequence to iterate over @@ -207,10 +207,10 @@ public isolated function getChildren(Element elem) returns xml = @java:Method { # becoming cyclic. # # ```ballerina -# xml:Element books = xml `Ballerina GuideJava Tutorial`; -# xml js = xml `Learning HTMLJavascript Guide`; -# books.setChildren(js); -# books ⇒ Learning HTMLJavascript Guide +# xml:Element employees = xml `DavidPeter`; +# xml newEmployees = xml `AliceBob`; +# employees.setChildren(newEmployees); +# employees ⇒ AliceBob # # xml:Element x = xml `John`; # x.setChildren("Jane"); @@ -306,13 +306,13 @@ public isolated function getContent(ProcessingInstruction|Comment x) returns str # ```ballerina # xml:createElement( # "book", -# {title: "Ballerina Guide", year: "2022"}, -# xml `Anjana` -# ) ⇒ Anjana +# {title: "The Adventures of Sherlock Holmes", year: "1892"}, +# xml `Arthur Conan Doyle` +# ) ⇒ Arthur Conan Doyle # # xml:createElement("student") ⇒ # -# xml:createElement("person", children = xml `John`) ⇒ John +# xml:createElement("employee", children = xml `John`) ⇒ John # ``` # # + name - the name of the new element @@ -400,9 +400,9 @@ public isolated function slice(xml x, int startIndex, int endIndex = x # and a chunk is considered insignificant if the entire chunk is whitespace. # # ```ballerina -# xml books = xml ` -# Learning Ballerina`; -# books.strip() ⇒ Learning Ballerina +# xml books = xml ` +# Othello`; +# books.strip() ⇒ Othello # ``` # # + x - the xml value @@ -418,11 +418,11 @@ public isolated function strip(xml x) returns xml = @java:Method { # otherwise, selects only elements whose expanded name is parameter `nm`. # # ```ballerina -# xml books = xml `Ballerina Guide -# Learning Python`; -# books.elements() ⇒ Ballerina GuideLearning Python +# xml books = xml `Sherlock HolmesHamlet +# Jane EyreMacbeth`; +# books.elements() ⇒ Sherlock HolmesHamletJane EyreMacbeth # -# books.elements("code") ⇒ Ballerina GuideLearning Python +# books.elements("novel") ⇒ Sherlock HolmesJane Eyre # ``` # # + x - the xml value @@ -481,8 +481,8 @@ public isolated function elementChildren(xml x, string? nm = ()) returns xmlHamletMacbeth`; # books.map(function (xml xmlContent) returns xml => -# xml `${xmlContent.children()}` -# ) ⇒ HamletMacbeth +# xml `${xmlContent.children()}` +# ) ⇒ HamletMacbeth # ``` # # + x - the xml value @@ -499,14 +499,14 @@ public isolated function 'map(xml x, @isolatedParam function(ItemType # Each item is represented as a singleton value. # # ```ballerina -# xml books = xml `Java TutorialBallerina Guide`; +# xml books = xml `Sherlock HolmesInvisible Man`; # xml titles = xml ``; # # books.forEach(function (xml xmlItem) { -# titles += xml `${xmlItem.data()}`; +# titles += xml `${xmlItem.data()}`; # }); # -# titles ⇒ Java TutorialBallerina Guide +# titles ⇒ Sherlock HolmesInvisible Man # ``` # # + x - the xml value @@ -521,8 +521,8 @@ public isolated function forEach(xml x, @isolatedParam function(ItemTy # Each item is represented as a singleton value. # # ```ballerina -# xml programmingLanguages = xml `BallerinaPython`; -# programmingLanguages.filter(x => x is xml:Element && x.getName() == "code") ⇒ BallerinaPython +# xml books = xml `Sherlock HolemesHamletInvisible ManRomeo and Juliet`; +# books.filter(x => x is xml:Element && x.getName() == "play") ⇒ HamletRomeo and Juliet # ``` # # + x - xml value From 507766c951243ee02d1016afe94bc6af85168b7a Mon Sep 17 00:00:00 2001 From: sanjana Date: Wed, 4 Jan 2023 14:04:40 +0530 Subject: [PATCH 429/450] Add more examples in xml langlibs --- langlib/lang.xml/src/main/ballerina/xml.bal | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/langlib/lang.xml/src/main/ballerina/xml.bal b/langlib/lang.xml/src/main/ballerina/xml.bal index dc1e218e6b10..706c9b664e69 100644 --- a/langlib/lang.xml/src/main/ballerina/xml.bal +++ b/langlib/lang.xml/src/main/ballerina/xml.bal @@ -208,13 +208,13 @@ public isolated function getChildren(Element elem) returns xml = @java:Method { # # ```ballerina # xml:Element employees = xml `DavidPeter`; -# xml newEmployees = xml `AliceBob`; +# xml newEmployees = xml `AliceBob`; # employees.setChildren(newEmployees); -# employees ⇒ AliceBob +# employees ⇒ AliceBob # -# xml:Element x = xml `John`; +# xml:Element x = xml `John`; # x.setChildren("Jane"); -# x ⇒ Jane +# x ⇒ Jane # ``` # # + elem - xml element @@ -306,11 +306,13 @@ public isolated function getContent(ProcessingInstruction|Comment x) returns str # ```ballerina # xml:createElement( # "book", -# {title: "The Adventures of Sherlock Holmes", year: "1892"}, -# xml `Arthur Conan Doyle` -# ) ⇒ Arthur Conan Doyle +# {genre: "Mystery", year: "1892"}, +# xml `Sherlock HolmesArthur Conan Doyle` +# ) ⇒ Sherlock HolmesArthur Conan Doyle # -# xml:createElement("student") ⇒ +# xml:createElement("person") ⇒ +# +# xml:createElement("student", {id: "1209"}) ⇒ # # xml:createElement("employee", children = xml `John`) ⇒ John # ``` From 01c546268681d37e358d88c1d7eaae581a037d8f Mon Sep 17 00:00:00 2001 From: Fathima Dilhasha Date: Thu, 22 Dec 2022 08:09:26 +0530 Subject: [PATCH 430/450] Fix issue in new generated module with only default module --- .../projects/internal/ProjectFiles.java | 10 ++++-- .../TestBuildProjectWithGeneratedSources.java | 31 +++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ProjectFiles.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ProjectFiles.java index 614a8280d9fd..710cd77b8ebb 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ProjectFiles.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ProjectFiles.java @@ -32,7 +32,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.PathMatcher; -import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Optional; @@ -68,7 +67,12 @@ public static PackageData loadSingleFileProjectPackageData(Path filePath) { public static PackageData loadBuildProjectPackageData(Path packageDirPath) { ModuleData defaultModule = loadModule(packageDirPath); List otherModules = loadOtherModules(packageDirPath); - otherModules.addAll(loadNewGeneratedModules(packageDirPath)); + List newModules = loadNewGeneratedModules(packageDirPath); + if (otherModules.isEmpty()) { + otherModules = newModules; + } else { + otherModules.addAll(newModules); + } DocumentData ballerinaToml = loadDocument(packageDirPath.resolve(ProjectConstants.BALLERINA_TOML)); DocumentData dependenciesToml = loadDocument(packageDirPath.resolve(ProjectConstants.DEPENDENCIES_TOML)); DocumentData cloudToml = loadDocument(packageDirPath.resolve(ProjectConstants.CLOUD_TOML)); @@ -79,7 +83,7 @@ public static PackageData loadBuildProjectPackageData(Path packageDirPath) { ballerinaToml, dependenciesToml, cloudToml, compilerPluginToml, packageMd); } - private static Collection loadNewGeneratedModules(Path packageDirPath) { + private static List loadNewGeneratedModules(Path packageDirPath) { Path generatedSourceRoot = packageDirPath.resolve(ProjectConstants.GENERATED_MODULES_ROOT); if (Files.isDirectory(generatedSourceRoot)) { try (Stream pathStream = Files.walk(generatedSourceRoot, 1)) { diff --git a/project-api/project-api-test/src/test/java/io/ballerina/projects/test/TestBuildProjectWithGeneratedSources.java b/project-api/project-api-test/src/test/java/io/ballerina/projects/test/TestBuildProjectWithGeneratedSources.java index 3227a52703a7..15d4b40ec32e 100644 --- a/project-api/project-api-test/src/test/java/io/ballerina/projects/test/TestBuildProjectWithGeneratedSources.java +++ b/project-api/project-api-test/src/test/java/io/ballerina/projects/test/TestBuildProjectWithGeneratedSources.java @@ -105,6 +105,37 @@ public void testBuildProjectWithNoReadPermission() { resetPermissions(generatedDirPath); } + @Test (description = "tests loading a valid build project with a new generated module") + public void testProjectWithNewGeneratedModule() { + Path projectPath = RESOURCE_DIRECTORY.resolve("new_generated_mod"); + + // 1) Initialize the project instance + BuildProject project = loadBuildProject(projectPath); + // 2) Load the package + Package currentPackage = project.currentPackage(); + // 3) Load the default module + Module defaultModule = currentPackage.getDefaultModule(); + Assert.assertEquals(defaultModule.documentIds().size(), 1); + + // 4) Get Ballerina.toml file + Optional ballerinaTomlOptional = currentPackage.ballerinaToml(); + Assert.assertTrue(ballerinaTomlOptional.isPresent()); + + int noOfSrcDocuments = 0; + int noOfTestDocuments = 0; + final Collection moduleIds = currentPackage.moduleIds(); + Assert.assertEquals(moduleIds.size(), 2); + for (ModuleId moduleId : moduleIds) { + Module module = currentPackage.module(moduleId); + noOfSrcDocuments += module.documentIds().size(); + noOfTestDocuments += module.testDocumentIds().size(); + for (DocumentId docId : module.documentIds()) { + Assert.assertNotNull(module.document(docId).syntaxTree()); + } + } + Assert.assertEquals(noOfSrcDocuments, 2); + Assert.assertEquals(noOfTestDocuments, 0); + } @AfterClass (alwaysRun = true) public void reset() { Path projectPath = RESOURCE_DIRECTORY.resolve("project_no_permission"); From ca1ddcc44ecbe93e9d99518bac287ed07f820466 Mon Sep 17 00:00:00 2001 From: Fathima Dilhasha Date: Thu, 22 Dec 2022 10:12:48 +0530 Subject: [PATCH 431/450] Add test package for generated sources with new module --- .../new_generated_mod/Ballerina.toml | 7 +++++++ .../new_generated_mod/generated/foo/foo.bal | 3 +++ .../generated-sources-tests/new_generated_mod/main.bal | 5 +++++ 3 files changed, 15 insertions(+) create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/new_generated_mod/Ballerina.toml create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/new_generated_mod/generated/foo/foo.bal create mode 100644 project-api/project-api-test/src/test/resources/generated-sources-tests/new_generated_mod/main.bal diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/new_generated_mod/Ballerina.toml b/project-api/project-api-test/src/test/resources/generated-sources-tests/new_generated_mod/Ballerina.toml new file mode 100644 index 000000000000..405b92855ff8 --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/new_generated_mod/Ballerina.toml @@ -0,0 +1,7 @@ +[package] +org = "dilhashanazeer" +name = "new_generated_mod" +version = "0.1.0" + +[build-options] +observabilityIncluded = true diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/new_generated_mod/generated/foo/foo.bal b/project-api/project-api-test/src/test/resources/generated-sources-tests/new_generated_mod/generated/foo/foo.bal new file mode 100644 index 000000000000..7392b442f6d4 --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/new_generated_mod/generated/foo/foo.bal @@ -0,0 +1,3 @@ +function func1() { + +} diff --git a/project-api/project-api-test/src/test/resources/generated-sources-tests/new_generated_mod/main.bal b/project-api/project-api-test/src/test/resources/generated-sources-tests/new_generated_mod/main.bal new file mode 100644 index 000000000000..31e8785bf98f --- /dev/null +++ b/project-api/project-api-test/src/test/resources/generated-sources-tests/new_generated_mod/main.bal @@ -0,0 +1,5 @@ +import ballerina/io; + +public function main() { + io:println("Hello, World!"); +} From 0c55af040bb99165436b4648775828e9db94c1b1 Mon Sep 17 00:00:00 2001 From: kavindu Date: Wed, 4 Jan 2023 15:02:25 +0530 Subject: [PATCH 432/450] Fix issue in table iteration --- .../runtime/internal/TableUtils.java | 2 + .../internal/values/TableValueImpl.java | 23 ++--- .../langlib/test/LangLibTableTest.java | 8 ++ .../test/resources/test-src/tablelib_test.bal | 85 +++++++++++++++++++ 4 files changed, 107 insertions(+), 11 deletions(-) diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TableUtils.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TableUtils.java index bf39f68cdb9c..f3ea52e39b94 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TableUtils.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/TableUtils.java @@ -96,6 +96,8 @@ public static Long hash(Object obj, Node parent) { } else { return (long) obj.hashCode(); } + } else if (obj instanceof Long) { + return (long) obj; } else { return (long) obj.hashCode(); } diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TableValueImpl.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TableValueImpl.java index abab4b211b19..3f9fafbdb6f0 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TableValueImpl.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/TableValueImpl.java @@ -94,7 +94,7 @@ public class TableValueImpl implements TableValue { //These are required to achieve the iterator behavior private LinkedHashMap indexToKeyMap; - private LinkedHashMap keyToIndexMap; + private LinkedHashMap keyToIndexMap; private LinkedHashMap keyValues; private long noOfAddedEntries = 0; @@ -537,9 +537,10 @@ public V putData(V data) { List> entryList = new ArrayList<>(); entryList.add(entry); UUID uuid = UUID.randomUUID(); - entries.put((long) uuid.hashCode(), entryList); - updateIndexKeyMappings((K) data); - values.put((long) uuid.hashCode(), newData); + Long hash = (long) uuid.hashCode(); + entries.put(hash, entryList); + updateIndexKeyMappings((K) data, hash); + values.put(hash, newData); keyValues.put((K) data, data); return data; } @@ -595,7 +596,7 @@ public void addData(V data) { List extValues = values.get(hash); extValues.add(data); keyValues.put(key, data); - updateIndexKeyMappings(key); + updateIndexKeyMappings(key, hash); return; } @@ -641,7 +642,7 @@ private V putData(K key, V value, List data, Map.Entry entry, Long hash entryList.add(entry); entries.put(hash, entryList); keys.put(hash, key); - updateIndexKeyMappings(key); + updateIndexKeyMappings(key, hash); values.put(hash, data); keyValues.put(key, value); return data.get(0); @@ -670,7 +671,7 @@ public V remove(K key) { List valueList = values.get(hash); valueList.remove(entry.getValue()); entryList.remove(entry); - Long index = keyToIndexMap.remove(key); + Long index = keyToIndexMap.remove(hash); indexToKeyMap.remove(index); if (index != null && index == noOfAddedEntries - 1) { noOfAddedEntries--; @@ -681,7 +682,7 @@ public V remove(K key) { } entries.remove(hash); keys.remove(hash); - Long index = keyToIndexMap.remove(key); + Long index = keyToIndexMap.remove(hash); indexToKeyMap.remove(index); if (index != null && index == noOfAddedEntries - 1) { noOfAddedEntries--; @@ -754,9 +755,9 @@ public K wrapKey(MapValue data) { } // This method updates the indexes and the order required by the iterators - private void updateIndexKeyMappings(K key) { - if (!keyToIndexMap.containsKey(key)) { - keyToIndexMap.put(key, noOfAddedEntries); + private void updateIndexKeyMappings(K key, Long hash) { + if (!keyToIndexMap.containsKey(hash)) { + keyToIndexMap.put(hash, noOfAddedEntries); indexToKeyMap.put(noOfAddedEntries, key); noOfAddedEntries++; } diff --git a/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/LangLibTableTest.java b/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/LangLibTableTest.java index e758f82c547f..5c9f1a52c74b 100644 --- a/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/LangLibTableTest.java +++ b/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/LangLibTableTest.java @@ -584,4 +584,12 @@ public Object[] functionsToTestEmptyKeyedKeylessTbl() { "testLengthWithEmptyKeyedKeyLessTbl" }; } + + @Test + public void testTableIterationAfterPut() { + BRunUtil.invoke(compileResult, "testTableIterationAfterPut1"); + BRunUtil.invoke(compileResult, "testTableIterationAfterPut2"); + BRunUtil.invoke(compileResult, "testTableIterationAfterPut3"); + BRunUtil.invoke(compileResult, "testTableIterationAfterPut4"); + } } diff --git a/langlib/langlib-test/src/test/resources/test-src/tablelib_test.bal b/langlib/langlib-test/src/test/resources/test-src/tablelib_test.bal index f6cdb7005e6d..e15085dbdd53 100644 --- a/langlib/langlib-test/src/test/resources/test-src/tablelib_test.bal +++ b/langlib/langlib-test/src/test/resources/test-src/tablelib_test.bal @@ -1243,6 +1243,91 @@ function testLengthWithEmptyKeyedKeyLessTbl() { assertEquals(4, personTable.length()); } +type Coordinate1 record {| + readonly int x; + int y?; +|}; + +function testTableIterationAfterPut1() { + table key(x) positions = table []; + positions.put({x: 0}); + positions.put({x: 1}); + positions.put({x: -1}); + assertEquals(positions.toString(), "[{\"x\":0},{\"x\":1},{\"x\":-1}]"); + int sum = -2; + foreach var position in positions { + sum = sum + position.x; + } + assertEquals(sum, -2); +} + +type Coordinate2 record {| + readonly float x; + int y?; +|}; + +function testTableIterationAfterPut2() { + table key(x) positions = table []; + positions.put({x: 0}); + positions.put({x: 1}); + positions.put({x: -1}); + assertEquals(positions.toString(), "[{\"x\":0.0},{\"x\":1.0},{\"x\":-1.0}]"); + float sum = -2; + foreach var position in positions { + sum = sum + position.x; + } + assertEquals(sum, -2.0); +} + +type Coordinate3 record {| + readonly decimal x; + int y?; +|}; + +function testTableIterationAfterPut3() { + table key(x) positions = table []; + positions.put({x: 0}); + positions.put({x: 1}); + positions.put({x: -1}); + assertEquals(positions.toString(), "[{\"x\":0},{\"x\":1},{\"x\":-1}]"); + decimal sum = -2; + foreach var position in positions { + sum = sum + position.x; + } + assertEquals(sum, -2d); +} + +type Position record {| + readonly int x; + readonly int y; +|}; + +Position 'start = {x: 0, y: 0}; +Position end = {x: 5, y: 5}; + +function testTableIterationAfterPut4() { + int iterations = 0; + int length = 0; + table key(x,y) possible = table []; + possible.add('start); + while !possible.hasKey([end.x, end.y]) { + iterations = iterations + 1; + table key(x,y) next = table []; + foreach var p in possible { + next.put({x: p.x, y: p.y}); + next.put({x: p.x + 1, y: p.y}); + next.put({x: p.x - 1, y: p.y}); + next.put({x: p.x, y: p.y + 1}); + next.put({x: p.x, y: p.y - 1}); + } + var _ = next.removeIfHasKey(['start.x, 'start.y - 1]); + possible = next; + length = possible.length(); + } + assertEquals(iterations, 10); + assertEquals(length, 218); +} + const ASSERTION_ERROR_REASON = "AssertionError"; function assertTrue(boolean actual) { From 2e3f08d34017179decc7b450aaa73d8b388d0d5f Mon Sep 17 00:00:00 2001 From: sanjana Date: Wed, 4 Jan 2023 17:16:30 +0530 Subject: [PATCH 433/450] Update xml langlib examples --- langlib/lang.xml/src/main/ballerina/xml.bal | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/langlib/lang.xml/src/main/ballerina/xml.bal b/langlib/lang.xml/src/main/ballerina/xml.bal index 706c9b664e69..96868fad267a 100644 --- a/langlib/lang.xml/src/main/ballerina/xml.bal +++ b/langlib/lang.xml/src/main/ballerina/xml.bal @@ -334,7 +334,7 @@ public isolated function createElement(string name, map attributes = {}, # Creates a new xml processing instruction item. # # ```ballerina -# xml:createProcessingInstruction("url", "ballerina.io") ⇒ +# xml:createProcessingInstruction("sort", "descending") ⇒ # ``` # # + target - the target part of the processing instruction to be constructed @@ -379,9 +379,9 @@ public isolated function createText(string data) returns Text = @java:Method { # # ```ballerina # xml books = xml `HTMLInvisible ManDavid CopperfieldJane Eyre`; -# books.slice(1, 3) ⇒ Invisible ManDavid Copperfield -# # books.slice(2) ⇒ David CopperfieldJane Eyre +# +# books.slice(1, 3) ⇒ Invisible ManDavid Copperfield # ``` # # + x - the xml value @@ -459,9 +459,9 @@ public isolated function children(xml x) returns xml = @java:Method { # # ```ballerina # xml books = xml `HamletMacbeth`; -# books.elementChildren("novel") ⇒ Macbeth -# # books.elementChildren() ⇒ HamletMacbeth +# +# books.elementChildren("novel") ⇒ Macbeth # ``` # # + x - the xml value @@ -557,7 +557,7 @@ public isolated function fromString(string s) returns xml|error = @java:Method { # Selects all the items in a sequence that are of type `xml:Text`. # # ```ballerina -# xml books = xml `HamletPlay`; +# xml books = xml `HamletNovelPlay`; # books.text() ⇒ HamletPlay # ``` # From dc51b987c881da441ac86b0dcdd3a05cd5586759 Mon Sep 17 00:00:00 2001 From: Thevakumar-Luheerathan Date: Wed, 4 Jan 2023 17:18:34 +0530 Subject: [PATCH 434/450] Fix ballerina native test for project with no tests --- .../main/java/io/ballerina/cli/task/RunNativeImageTestTask.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java index f482b445d772..50b49f56f704 100644 --- a/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java +++ b/cli/ballerina-cli/src/main/java/io/ballerina/cli/task/RunNativeImageTestTask.java @@ -350,7 +350,7 @@ public void execute(Project project) { } // If the function mocking does not exist, combine all test suite map entries - if (!isMockFunctionExist) { + if (!isMockFunctionExist && testSuiteMapEntries.size() != 0) { HashMap testSuiteMap = testSuiteMapEntries.remove(0); while (testSuiteMapEntries.size() > 0) { testSuiteMap.putAll(testSuiteMapEntries.remove(0)); From 75fb05529fd77b99c02753abfe6149352338d506 Mon Sep 17 00:00:00 2001 From: Imesha Sudasingha Date: Mon, 12 Dec 2022 16:24:10 +0530 Subject: [PATCH 435/450] Update fix return type code in main() function to add "returns error?" when there's a check expression inside with no matching error return type. --- .../changetype/FixReturnTypeCodeAction.java | 14 ++++++---- .../codeaction/FixReturnTypeTest.java | 16 ++++++++++- .../config/fixReturnTypeInMain1.json | 28 +++++++++++++++++++ .../negativeFixReturnTypeWithMain1.json | 12 ++++++++ .../source/fixReturnTypeInMain1.bal | 7 +++++ .../source/negativeFixReturnTypeWithMain1.bal | 4 +++ 6 files changed, 75 insertions(+), 6 deletions(-) create mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/fix-return-type/config/fixReturnTypeInMain1.json create mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/fix-return-type/config/negativeFixReturnTypeWithMain1.json create mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/fix-return-type/source/fixReturnTypeInMain1.bal create mode 100644 language-server/modules/langserver-core/src/test/resources/codeaction/fix-return-type/source/negativeFixReturnTypeWithMain1.bal diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/changetype/FixReturnTypeCodeAction.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/changetype/FixReturnTypeCodeAction.java index 7f4050e32f15..37cf178ef4c3 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/changetype/FixReturnTypeCodeAction.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/changetype/FixReturnTypeCodeAction.java @@ -71,10 +71,10 @@ public boolean validate(Diagnostic diagnostic, DiagBasedPositionDetails position //Suggest the code action only if the immediate parent of the matched node is either of return statement, //check expression, check action. - NonTerminalNode parentNode = positionDetails.matchedNode().parent(); - if (parentNode != null && parentNode.kind() != SyntaxKind.RETURN_STATEMENT && - positionDetails.matchedNode().kind() != SyntaxKind.CHECK_EXPRESSION && - positionDetails.matchedNode().kind() != SyntaxKind.CHECK_ACTION) { + NonTerminalNode matchedNode = positionDetails.matchedNode(); + if (matchedNode.parent() != null && matchedNode.parent().kind() != SyntaxKind.RETURN_STATEMENT && + matchedNode.kind() != SyntaxKind.CHECK_EXPRESSION && + matchedNode.kind() != SyntaxKind.CHECK_ACTION) { return false; } @@ -104,7 +104,7 @@ public List getCodeActions(Diagnostic diagnostic, } Optional funcDef = CodeActionUtil.getEnclosedFunction(positionDetails.matchedNode()); - if (funcDef.isEmpty() || RuntimeConstants.MAIN_FUNCTION_NAME.equals(funcDef.get().functionName().text())) { + if (funcDef.isEmpty()) { return Collections.emptyList(); } @@ -122,6 +122,10 @@ public List getCodeActions(Diagnostic diagnostic, types.add(Collections.singleton("error?")); } } else { + // Not going to provide code action to change return type of the main() function + if (RuntimeConstants.MAIN_FUNCTION_NAME.equals(funcDef.get().functionName().text())) { + return Collections.emptyList(); + } List> combinedTypes = new ArrayList<>(); ReturnStatementFinder returnStatementFinder = new ReturnStatementFinder(); returnStatementFinder.visit(funcDef.get()); diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/FixReturnTypeTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/FixReturnTypeTest.java index e2a080ff506c..14ed7d9c3410 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/FixReturnTypeTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/codeaction/FixReturnTypeTest.java @@ -63,7 +63,21 @@ public Object[][] dataProvider() { {"fixReturnTypeInUnionContext2.json"}, {"fixReturnTypeInUnionContext3.json"}, {"fixReturnTypeInUnionContext4.json"}, - {"fixReturnTypeInCommitAction.json"} + {"fixReturnTypeInCommitAction.json"}, + {"fixReturnTypeInMain1.json"} + }; + } + + @Test(dataProvider = "negativeDataProvider") + @Override + public void negativeTest(String config) throws IOException, WorkspaceDocumentException { + super.negativeTest(config); + } + + @DataProvider + public Object[][] negativeDataProvider() { + return new Object[][] { + {"negativeFixReturnTypeWithMain1.json"} }; } } diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/fix-return-type/config/fixReturnTypeInMain1.json b/language-server/modules/langserver-core/src/test/resources/codeaction/fix-return-type/config/fixReturnTypeInMain1.json new file mode 100644 index 000000000000..955e1d99c934 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/fix-return-type/config/fixReturnTypeInMain1.json @@ -0,0 +1,28 @@ +{ + "position": { + "line": 1, + "character": 25 + }, + "source": "fixReturnTypeInMain1.bal", + "expected": [ + { + "title": "Change return type to 'error?'", + "kind": "quickfix", + "edits": [ + { + "range": { + "start": { + "line": 0, + "character": 22 + }, + "end": { + "line": 0, + "character": 22 + } + }, + "newText": " returns error?" + } + ] + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/fix-return-type/config/negativeFixReturnTypeWithMain1.json b/language-server/modules/langserver-core/src/test/resources/codeaction/fix-return-type/config/negativeFixReturnTypeWithMain1.json new file mode 100644 index 000000000000..c87c9ea40562 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/fix-return-type/config/negativeFixReturnTypeWithMain1.json @@ -0,0 +1,12 @@ +{ + "position": { + "line": 2, + "character": 12 + }, + "source": "negativeFixReturnTypeWithMain1.bal", + "expected": [ + { + "title": "Change return type to 'error?'" + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/fix-return-type/source/fixReturnTypeInMain1.bal b/language-server/modules/langserver-core/src/test/resources/codeaction/fix-return-type/source/fixReturnTypeInMain1.bal new file mode 100644 index 000000000000..e58864357125 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/fix-return-type/source/fixReturnTypeInMain1.bal @@ -0,0 +1,7 @@ +public function main() { + int data = check getData(); +} + +function getData() returns int|error { + return 1; +} diff --git a/language-server/modules/langserver-core/src/test/resources/codeaction/fix-return-type/source/negativeFixReturnTypeWithMain1.bal b/language-server/modules/langserver-core/src/test/resources/codeaction/fix-return-type/source/negativeFixReturnTypeWithMain1.bal new file mode 100644 index 000000000000..ee14b2024904 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/codeaction/fix-return-type/source/negativeFixReturnTypeWithMain1.bal @@ -0,0 +1,4 @@ +public function main() { + int val = 10 / 2; + return val; +} From 89e206d60f31aa92b9de5f9bcb39baa08981a943 Mon Sep 17 00:00:00 2001 From: Imesha Sudasingha Date: Wed, 14 Dec 2022 18:21:46 +0530 Subject: [PATCH 436/450] Fix expr context completions for remote method calls --- .../RemoteMethodCallActionNodeContext.java | 13 + .../config/remote_action_config8.json | 695 ++++++++++++++++++ .../source/remote_action_source8.bal | 38 + 3 files changed, 746 insertions(+) create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/remote_action_config8.json create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/action_node_context/source/remote_action_source8.bal diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/RemoteMethodCallActionNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/RemoteMethodCallActionNodeContext.java index 51c626a7af2c..9c12e12d3306 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/RemoteMethodCallActionNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/RemoteMethodCallActionNodeContext.java @@ -53,6 +53,14 @@ public RemoteMethodCallActionNodeContext() { public List getCompletions(BallerinaCompletionContext context, RemoteMethodCallActionNode node) throws LSCompletionException { List completionItems = new ArrayList<>(); + if (onSuggestClients(node, context)) { + // Covers following: + // 1. cl->func() + completionItems.addAll(this.expressionCompletions(context)); + this.sort(context, node, completionItems); + return completionItems; + } + ContextTypeResolver resolver = new ContextTypeResolver(context); Optional expressionType = node.expression().apply(resolver); @@ -110,6 +118,11 @@ private boolean onSuggestClientActions(RemoteMethodCallActionNode node, Ballerin (node.openParenToken().isMissing() || cursor <= node.openParenToken().textRange().startOffset()); } + private boolean onSuggestClients(RemoteMethodCallActionNode node, BallerinaCompletionContext context) { + int cursor = context.getCursorPositionInTree(); + return cursor <= node.rightArrowToken().textRange().startOffset(); + } + @Override public void sort(BallerinaCompletionContext context, RemoteMethodCallActionNode node, diff --git a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/remote_action_config8.json b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/remote_action_config8.json new file mode 100644 index 000000000000..d1a14498b405 --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/remote_action_config8.json @@ -0,0 +1,695 @@ +{ + "position": { + "line": 36, + "character": 17 + }, + "source": "action_node_context/source/remote_action_source8.bal", + "items": [ + { + "label": "test/project2", + "kind": "Module", + "detail": "Module", + "sortText": "CR", + "filterText": "project2", + "insertText": "project2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/project2;\n" + } + ] + }, + { + "label": "test/project1", + "kind": "Module", + "detail": "Module", + "sortText": "CR", + "filterText": "project1", + "insertText": "project1", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/project1;\n" + } + ] + }, + { + "label": "ballerina/lang.runtime", + "kind": "Module", + "detail": "Module", + "sortText": "CR", + "filterText": "runtime", + "insertText": "runtime", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.runtime;\n" + } + ] + }, + { + "label": "ballerina/lang.regexp", + "kind": "Module", + "detail": "Module", + "sortText": "CR", + "filterText": "regexp", + "insertText": "regexp", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.regexp;\n" + } + ] + }, + { + "label": "ballerina/module1", + "kind": "Module", + "detail": "Module", + "sortText": "CR", + "filterText": "module1", + "insertText": "module1", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/module1;\n" + } + ] + }, + { + "label": "ballerina/lang.test", + "kind": "Module", + "detail": "Module", + "sortText": "CR", + "filterText": "test", + "insertText": "test", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.test;\n" + } + ] + }, + { + "label": "test/local_project2", + "kind": "Module", + "detail": "Module", + "sortText": "CR", + "filterText": "local_project2", + "insertText": "local_project2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/local_project2;\n" + } + ] + }, + { + "label": "test/local_project1", + "kind": "Module", + "detail": "Module", + "sortText": "CR", + "filterText": "local_project1", + "insertText": "local_project1", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/local_project1;\n" + } + ] + }, + { + "label": "ballerina/lang.value", + "kind": "Module", + "detail": "Module", + "sortText": "CR", + "filterText": "value", + "insertText": "value", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.value;\n" + } + ] + }, + { + "label": "ballerina/jballerina.java", + "kind": "Module", + "detail": "Module", + "sortText": "CR", + "filterText": "java", + "insertText": "java", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/jballerina.java;\n" + } + ] + }, + { + "label": "ballerina/lang.array", + "kind": "Module", + "detail": "Module", + "sortText": "CR", + "filterText": "array", + "insertText": "array", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.array;\n" + } + ] + }, + { + "label": "decimal", + "kind": "Unit", + "detail": "type", + "sortText": "CR", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Unit", + "detail": "type", + "sortText": "CR", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "object", + "kind": "Unit", + "detail": "type", + "sortText": "CR", + "insertText": "object", + "insertTextFormat": "Snippet" + }, + { + "label": "transaction", + "kind": "Unit", + "detail": "type", + "sortText": "CR", + "insertText": "transaction", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "Unit", + "detail": "type", + "sortText": "CR", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "table", + "kind": "Unit", + "detail": "type", + "sortText": "CR", + "insertText": "table", + "insertTextFormat": "Snippet" + }, + { + "label": "map", + "kind": "Unit", + "detail": "type", + "sortText": "CR", + "insertText": "map", + "insertTextFormat": "Snippet" + }, + { + "label": "stream", + "kind": "Unit", + "detail": "type", + "sortText": "CR", + "insertText": "stream", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "Unit", + "detail": "type", + "sortText": "CR", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "Unit", + "detail": "type", + "sortText": "CR", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "Unit", + "detail": "type", + "sortText": "CR", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "Unit", + "detail": "type", + "sortText": "CR", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "Unit", + "detail": "type", + "sortText": "CR", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "Unit", + "detail": "type", + "sortText": "CR", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "Unit", + "detail": "type", + "sortText": "CR", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "CQ", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "new", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "CQ", + "filterText": "new", + "insertText": "new ", + "insertTextFormat": "Snippet" + }, + { + "label": "isolated", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "CQ", + "filterText": "isolated", + "insertText": "isolated ", + "insertTextFormat": "Snippet" + }, + { + "label": "transactional", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "CQ", + "filterText": "transactional", + "insertText": "transactional", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "CQ", + "filterText": "function", + "insertText": "function ", + "insertTextFormat": "Snippet" + }, + { + "label": "let", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "CQ", + "filterText": "let", + "insertText": "let", + "insertTextFormat": "Snippet" + }, + { + "label": "typeof", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "CQ", + "filterText": "typeof", + "insertText": "typeof ", + "insertTextFormat": "Snippet" + }, + { + "label": "trap", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "CQ", + "filterText": "trap", + "insertText": "trap", + "insertTextFormat": "Snippet" + }, + { + "label": "client", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "CQ", + "filterText": "client", + "insertText": "client ", + "insertTextFormat": "Snippet" + }, + { + "label": "true", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "CQ", + "filterText": "true", + "insertText": "true", + "insertTextFormat": "Snippet" + }, + { + "label": "false", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "CQ", + "filterText": "false", + "insertText": "false", + "insertTextFormat": "Snippet" + }, + { + "label": "null", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "CQ", + "filterText": "null", + "insertText": "null", + "insertTextFormat": "Snippet" + }, + { + "label": "check", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "CQ", + "filterText": "check", + "insertText": "check ", + "insertTextFormat": "Snippet" + }, + { + "label": "checkpanic", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "CQ", + "filterText": "checkpanic", + "insertText": "checkpanic ", + "insertTextFormat": "Snippet" + }, + { + "label": "is", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "CQ", + "filterText": "is", + "insertText": "is", + "insertTextFormat": "Snippet" + }, + { + "label": "error constructor", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "CP", + "filterText": "error", + "insertText": "error(\"${1}\")", + "insertTextFormat": "Snippet" + }, + { + "label": "object constructor", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "CP", + "filterText": "object", + "insertText": "object {${1}}", + "insertTextFormat": "Snippet" + }, + { + "label": "base16", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "CP", + "filterText": "base16", + "insertText": "base16 `${1}`", + "insertTextFormat": "Snippet" + }, + { + "label": "base64", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "CP", + "filterText": "base64", + "insertText": "base64 `${1}`", + "insertTextFormat": "Snippet" + }, + { + "label": "from", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "CQ", + "filterText": "from", + "insertText": "from ", + "insertTextFormat": "Snippet" + }, + { + "label": "StrandData", + "kind": "Struct", + "detail": "Record", + "documentation": { + "left": "Describes Strand execution details for the runtime.\n" + }, + "sortText": "CM", + "insertText": "StrandData", + "insertTextFormat": "Snippet" + }, + { + "label": "ProductClient", + "kind": "Interface", + "detail": "Class", + "sortText": "CK", + "insertText": "ProductClient", + "insertTextFormat": "Snippet" + }, + { + "label": "main()", + "kind": "Function", + "detail": "error?", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _._ \n \n \n \n \n**Return** `error?` \n \n" + } + }, + "sortText": "CZ", + "filterText": "main", + "insertText": "main()", + "insertTextFormat": "Snippet" + }, + { + "label": "Thread", + "kind": "TypeParameter", + "detail": "Union", + "sortText": "CN", + "insertText": "Thread", + "insertTextFormat": "Snippet" + }, + { + "label": "Product", + "kind": "Struct", + "detail": "Record", + "sortText": "CM", + "insertText": "Product", + "insertTextFormat": "Snippet" + }, + { + "label": "prodClient", + "kind": "Variable", + "detail": "ProductClient", + "sortText": "CB", + "insertText": "prodClient", + "insertTextFormat": "Snippet" + }, + { + "label": "v", + "kind": "Variable", + "detail": "string", + "sortText": "AB", + "insertText": "v", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "Unit", + "detail": "type", + "sortText": "CR", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "Unit", + "detail": "type", + "sortText": "CR", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "Unit", + "detail": "type", + "sortText": "CR", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "Unit", + "detail": "type", + "sortText": "CR", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "Unit", + "detail": "type", + "sortText": "CR", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "Unit", + "detail": "type", + "sortText": "CR", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "Unit", + "detail": "type", + "sortText": "CR", + "insertText": "byte", + "insertTextFormat": "Snippet" + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/source/remote_action_source8.bal b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/source/remote_action_source8.bal new file mode 100644 index 000000000000..80d086ea4c1a --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/source/remote_action_source8.bal @@ -0,0 +1,38 @@ +public type Product record { + string id?; + string name; + string description?; +}; + +client class ProductClient { + + private string url; + + public function init(string url) returns error? { + self.url = url; + } + + remote function findByName(string name) returns Product { + return { + id: "123", + name: "Test" + }; + } + + remote function listAll() returns Product[] { + return []; + } + + remote function countByName(string name) returns int { + return 1; + } + + remote function getVersion() returns string { + return "v1.0.0"; + } +} + +public function main() returns error? { + ProductClient prodClient = check new("http://example,com"); + string v = pr->listAll(); +} From 1d0698e9a3e36721d46f9224e23576fe8db42580 Mon Sep 17 00:00:00 2001 From: Imesha Sudasingha Date: Wed, 14 Dec 2022 18:40:32 +0530 Subject: [PATCH 437/450] Add additional check for packages list length in PathUtil.getFilePathForLanglibSymbol() method --- .../langserver/common/utils/PathUtil.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/PathUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/PathUtil.java index 137e7b9f035d..619c9c77b15c 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/PathUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/PathUtil.java @@ -42,6 +42,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.Collection; +import java.util.List; import java.util.Optional; /** @@ -195,8 +196,14 @@ private static Optional getFilePathForLanglibSymbol(Project project, Symbo } String orgName = symbol.getModule().get().id().orgName(); String moduleName = symbol.getModule().get().id().moduleName(); - Package langLibPackage = project.projectEnvironmentContext().environment().getService(PackageCache.class) - .getPackages(PackageOrg.from(orgName), PackageName.from(moduleName)).get(0); + List langLibPackages = project.projectEnvironmentContext().environment().getService(PackageCache.class) + .getPackages(PackageOrg.from(orgName), PackageName.from(moduleName)); + // Ideally this list cannot be empty. But due to concurrent issues, it can be. + // Checking if it's empty for safety. + if (langLibPackages.isEmpty()) { + return Optional.empty(); + } + Package langLibPackage = langLibPackages.get(0); String sourceFile = symbol.getLocation().get().lineRange().filePath(); Optional filepath = Optional.empty(); From 8941bd51bb9e48a62e83acb2ac74d5ec1c6e9abb Mon Sep 17 00:00:00 2001 From: Imesha Sudasingha Date: Fri, 16 Dec 2022 16:37:42 +0530 Subject: [PATCH 438/450] Fix sorting in expr of remote method call actions --- .../RemoteMethodCallActionNodeContext.java | 16 + .../config/remote_action_config8.json | 393 ++++++++++-------- .../source/remote_action_source8.bal | 8 +- 3 files changed, 237 insertions(+), 180 deletions(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/RemoteMethodCallActionNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/RemoteMethodCallActionNodeContext.java index 9c12e12d3306..fbbfe35b6f67 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/RemoteMethodCallActionNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/RemoteMethodCallActionNodeContext.java @@ -132,6 +132,22 @@ public void sort(BallerinaCompletionContext context, return; } + // At expression of the remote method call action, suggest clients first + if (onSuggestClients(node, context)) { + completionItems.forEach(completionItem -> { + Optional typeSymbol = SortingUtil.getSymbolFromCompletionItem(completionItem); + String sortText; + if (typeSymbol.isPresent() && SymbolUtil.isClient(typeSymbol.get())) { + sortText = SortingUtil.genSortText(1); + } else { + sortText = SortingUtil.genSortText(2); + } + sortText += SortingUtil.genSortText(SortingUtil.toRank(context, completionItem)); + completionItem.getCompletionItem().setSortText(sortText); + }); + return; + } + for (LSCompletionItem item : completionItems) { sortByAssignability(context, item, SortingUtil.toRank(context, item)); } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/remote_action_config8.json b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/remote_action_config8.json index d1a14498b405..790fb5df3f51 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/remote_action_config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/remote_action_config8.json @@ -1,7 +1,7 @@ { "position": { - "line": 36, - "character": 17 + "line": 40, + "character": 18 }, "source": "action_node_context/source/remote_action_source8.bal", "items": [ @@ -9,7 +9,7 @@ "label": "test/project2", "kind": "Module", "detail": "Module", - "sortText": "CR", + "sortText": "BR", "filterText": "project2", "insertText": "project2", "insertTextFormat": "Snippet", @@ -33,7 +33,7 @@ "label": "test/project1", "kind": "Module", "detail": "Module", - "sortText": "CR", + "sortText": "BR", "filterText": "project1", "insertText": "project1", "insertTextFormat": "Snippet", @@ -57,7 +57,7 @@ "label": "ballerina/lang.runtime", "kind": "Module", "detail": "Module", - "sortText": "CR", + "sortText": "BR", "filterText": "runtime", "insertText": "runtime", "insertTextFormat": "Snippet", @@ -81,7 +81,7 @@ "label": "ballerina/lang.regexp", "kind": "Module", "detail": "Module", - "sortText": "CR", + "sortText": "BR", "filterText": "regexp", "insertText": "regexp", "insertTextFormat": "Snippet", @@ -102,34 +102,19 @@ ] }, { - "label": "ballerina/module1", + "label": "module1", "kind": "Module", "detail": "Module", - "sortText": "CR", + "sortText": "BO", "filterText": "module1", "insertText": "module1", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "newText": "import ballerina/module1;\n" - } - ] + "insertTextFormat": "Snippet" }, { "label": "ballerina/lang.test", "kind": "Module", "detail": "Module", - "sortText": "CR", + "sortText": "BR", "filterText": "test", "insertText": "test", "insertTextFormat": "Snippet", @@ -153,7 +138,7 @@ "label": "test/local_project2", "kind": "Module", "detail": "Module", - "sortText": "CR", + "sortText": "BR", "filterText": "local_project2", "insertText": "local_project2", "insertTextFormat": "Snippet", @@ -177,7 +162,7 @@ "label": "test/local_project1", "kind": "Module", "detail": "Module", - "sortText": "CR", + "sortText": "BR", "filterText": "local_project1", "insertText": "local_project1", "insertTextFormat": "Snippet", @@ -201,7 +186,7 @@ "label": "ballerina/lang.value", "kind": "Module", "detail": "Module", - "sortText": "CR", + "sortText": "BR", "filterText": "value", "insertText": "value", "insertTextFormat": "Snippet", @@ -225,7 +210,7 @@ "label": "ballerina/jballerina.java", "kind": "Module", "detail": "Module", - "sortText": "CR", + "sortText": "BR", "filterText": "java", "insertText": "java", "insertTextFormat": "Snippet", @@ -249,7 +234,7 @@ "label": "ballerina/lang.array", "kind": "Module", "detail": "Module", - "sortText": "CR", + "sortText": "BR", "filterText": "array", "insertText": "array", "insertTextFormat": "Snippet", @@ -269,27 +254,11 @@ } ] }, - { - "label": "decimal", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "decimal", - "insertTextFormat": "Snippet" - }, - { - "label": "error", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "error", - "insertTextFormat": "Snippet" - }, { "label": "object", "kind": "Unit", "detail": "type", - "sortText": "CR", + "sortText": "BR", "insertText": "object", "insertTextFormat": "Snippet" }, @@ -297,23 +266,15 @@ "label": "transaction", "kind": "Unit", "detail": "type", - "sortText": "CR", + "sortText": "BR", "insertText": "transaction", "insertTextFormat": "Snippet" }, - { - "label": "xml", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "xml", - "insertTextFormat": "Snippet" - }, { "label": "table", "kind": "Unit", "detail": "type", - "sortText": "CR", + "sortText": "BR", "insertText": "table", "insertTextFormat": "Snippet" }, @@ -321,7 +282,7 @@ "label": "map", "kind": "Unit", "detail": "type", - "sortText": "CR", + "sortText": "BR", "insertText": "map", "insertTextFormat": "Snippet" }, @@ -329,71 +290,15 @@ "label": "stream", "kind": "Unit", "detail": "type", - "sortText": "CR", + "sortText": "BR", "insertText": "stream", "insertTextFormat": "Snippet" }, - { - "label": "boolean", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "boolean", - "insertTextFormat": "Snippet" - }, - { - "label": "future", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "future", - "insertTextFormat": "Snippet" - }, - { - "label": "int", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "int", - "insertTextFormat": "Snippet" - }, - { - "label": "float", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "float", - "insertTextFormat": "Snippet" - }, - { - "label": "function", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "function", - "insertTextFormat": "Snippet" - }, - { - "label": "string", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "string", - "insertTextFormat": "Snippet" - }, - { - "label": "typedesc", - "kind": "Unit", - "detail": "type", - "sortText": "CR", - "insertText": "typedesc", - "insertTextFormat": "Snippet" - }, { "label": "service", "kind": "Keyword", "detail": "Keyword", - "sortText": "CQ", + "sortText": "BQ", "filterText": "service", "insertText": "service", "insertTextFormat": "Snippet" @@ -402,7 +307,7 @@ "label": "new", "kind": "Keyword", "detail": "Keyword", - "sortText": "CQ", + "sortText": "BQ", "filterText": "new", "insertText": "new ", "insertTextFormat": "Snippet" @@ -411,7 +316,7 @@ "label": "isolated", "kind": "Keyword", "detail": "Keyword", - "sortText": "CQ", + "sortText": "BQ", "filterText": "isolated", "insertText": "isolated ", "insertTextFormat": "Snippet" @@ -420,7 +325,7 @@ "label": "transactional", "kind": "Keyword", "detail": "Keyword", - "sortText": "CQ", + "sortText": "BQ", "filterText": "transactional", "insertText": "transactional", "insertTextFormat": "Snippet" @@ -429,7 +334,7 @@ "label": "function", "kind": "Keyword", "detail": "Keyword", - "sortText": "CQ", + "sortText": "BQ", "filterText": "function", "insertText": "function ", "insertTextFormat": "Snippet" @@ -438,7 +343,7 @@ "label": "let", "kind": "Keyword", "detail": "Keyword", - "sortText": "CQ", + "sortText": "BQ", "filterText": "let", "insertText": "let", "insertTextFormat": "Snippet" @@ -447,7 +352,7 @@ "label": "typeof", "kind": "Keyword", "detail": "Keyword", - "sortText": "CQ", + "sortText": "BQ", "filterText": "typeof", "insertText": "typeof ", "insertTextFormat": "Snippet" @@ -456,7 +361,7 @@ "label": "trap", "kind": "Keyword", "detail": "Keyword", - "sortText": "CQ", + "sortText": "BQ", "filterText": "trap", "insertText": "trap", "insertTextFormat": "Snippet" @@ -465,7 +370,7 @@ "label": "client", "kind": "Keyword", "detail": "Keyword", - "sortText": "CQ", + "sortText": "BQ", "filterText": "client", "insertText": "client ", "insertTextFormat": "Snippet" @@ -474,7 +379,7 @@ "label": "true", "kind": "Keyword", "detail": "Keyword", - "sortText": "CQ", + "sortText": "BQ", "filterText": "true", "insertText": "true", "insertTextFormat": "Snippet" @@ -483,7 +388,7 @@ "label": "false", "kind": "Keyword", "detail": "Keyword", - "sortText": "CQ", + "sortText": "BQ", "filterText": "false", "insertText": "false", "insertTextFormat": "Snippet" @@ -492,7 +397,7 @@ "label": "null", "kind": "Keyword", "detail": "Keyword", - "sortText": "CQ", + "sortText": "BQ", "filterText": "null", "insertText": "null", "insertTextFormat": "Snippet" @@ -501,7 +406,7 @@ "label": "check", "kind": "Keyword", "detail": "Keyword", - "sortText": "CQ", + "sortText": "BQ", "filterText": "check", "insertText": "check ", "insertTextFormat": "Snippet" @@ -510,7 +415,7 @@ "label": "checkpanic", "kind": "Keyword", "detail": "Keyword", - "sortText": "CQ", + "sortText": "BQ", "filterText": "checkpanic", "insertText": "checkpanic ", "insertTextFormat": "Snippet" @@ -519,7 +424,7 @@ "label": "is", "kind": "Keyword", "detail": "Keyword", - "sortText": "CQ", + "sortText": "BQ", "filterText": "is", "insertText": "is", "insertTextFormat": "Snippet" @@ -528,7 +433,7 @@ "label": "error constructor", "kind": "Snippet", "detail": "Snippet", - "sortText": "CP", + "sortText": "BP", "filterText": "error", "insertText": "error(\"${1}\")", "insertTextFormat": "Snippet" @@ -537,7 +442,7 @@ "label": "object constructor", "kind": "Snippet", "detail": "Snippet", - "sortText": "CP", + "sortText": "BP", "filterText": "object", "insertText": "object {${1}}", "insertTextFormat": "Snippet" @@ -546,7 +451,7 @@ "label": "base16", "kind": "Snippet", "detail": "Snippet", - "sortText": "CP", + "sortText": "BP", "filterText": "base16", "insertText": "base16 `${1}`", "insertTextFormat": "Snippet" @@ -555,7 +460,7 @@ "label": "base64", "kind": "Snippet", "detail": "Snippet", - "sortText": "CP", + "sortText": "BP", "filterText": "base64", "insertText": "base64 `${1}`", "insertTextFormat": "Snippet" @@ -564,7 +469,7 @@ "label": "from", "kind": "Keyword", "detail": "Keyword", - "sortText": "CQ", + "sortText": "BQ", "filterText": "from", "insertText": "from ", "insertTextFormat": "Snippet" @@ -576,7 +481,7 @@ "documentation": { "left": "Describes Strand execution details for the runtime.\n" }, - "sortText": "CM", + "sortText": "BM", "insertText": "StrandData", "insertTextFormat": "Snippet" }, @@ -584,30 +489,15 @@ "label": "ProductClient", "kind": "Interface", "detail": "Class", - "sortText": "CK", + "sortText": "AK", "insertText": "ProductClient", "insertTextFormat": "Snippet" }, - { - "label": "main()", - "kind": "Function", - "detail": "error?", - "documentation": { - "right": { - "kind": "markdown", - "value": "**Package:** _._ \n \n \n \n \n**Return** `error?` \n \n" - } - }, - "sortText": "CZ", - "filterText": "main", - "insertText": "main()", - "insertTextFormat": "Snippet" - }, { "label": "Thread", "kind": "TypeParameter", "detail": "Union", - "sortText": "CN", + "sortText": "BN", "insertText": "Thread", "insertTextFormat": "Snippet" }, @@ -615,7 +505,7 @@ "label": "Product", "kind": "Struct", "detail": "Record", - "sortText": "CM", + "sortText": "BM", "insertText": "Product", "insertTextFormat": "Snippet" }, @@ -623,71 +513,218 @@ "label": "prodClient", "kind": "Variable", "detail": "ProductClient", - "sortText": "CB", + "sortText": "AB", "insertText": "prodClient", "insertTextFormat": "Snippet" }, { - "label": "v", + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "name", "kind": "Variable", "detail": "string", + "sortText": "BB", + "insertText": "name", + "insertTextFormat": "Snippet" + }, + { + "label": "pageSize", + "kind": "Variable", + "detail": "int", + "sortText": "BB", + "insertText": "pageSize", + "insertTextFormat": "Snippet" + }, + { + "label": "count", + "kind": "Variable", + "detail": "int", + "sortText": "BB", + "insertText": "count", + "insertTextFormat": "Snippet" + }, + { + "label": "modClient", + "kind": "Variable", + "detail": "module1:Client", "sortText": "AB", - "insertText": "v", + "insertText": "modClient", + "insertTextFormat": "Snippet" + }, + { + "label": "getData(string firstName, string lastName, int page, int pageSize)", + "kind": "Function", + "detail": "error?", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _._ \n \n \n**Params** \n- `string` firstName \n- `string` lastName \n- `int` page \n- `int` pageSize \n \n**Return** `error?` \n \n" + } + }, + "sortText": "BC", + "filterText": "getData", + "insertText": "getData(${1})", + "insertTextFormat": "Snippet", + "command": { + "title": "editor.action.triggerParameterHints", + "command": "editor.action.triggerParameterHints" + } + }, + { + "label": "lastName", + "kind": "Variable", + "detail": "string", + "sortText": "BB", + "insertText": "lastName", + "insertTextFormat": "Snippet" + }, + { + "label": "page", + "kind": "Variable", + "detail": "int", + "sortText": "BB", + "insertText": "page", + "insertTextFormat": "Snippet" + }, + { + "label": "firstName", + "kind": "Variable", + "detail": "string", + "sortText": "BB", + "insertText": "firstName", "insertTextFormat": "Snippet" }, { "label": "readonly", - "kind": "Unit", - "detail": "type", - "sortText": "CR", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", "insertText": "readonly", "insertTextFormat": "Snippet" }, { "label": "handle", - "kind": "Unit", - "detail": "type", - "sortText": "CR", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", "insertText": "handle", "insertTextFormat": "Snippet" }, { "label": "never", - "kind": "Unit", - "detail": "type", - "sortText": "CR", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", "insertText": "never", "insertTextFormat": "Snippet" }, { "label": "json", - "kind": "Unit", - "detail": "type", - "sortText": "CR", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", "insertText": "json", "insertTextFormat": "Snippet" }, { "label": "anydata", - "kind": "Unit", - "detail": "type", - "sortText": "CR", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", "insertText": "anydata", "insertTextFormat": "Snippet" }, { "label": "any", - "kind": "Unit", - "detail": "type", - "sortText": "CR", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", "insertText": "any", "insertTextFormat": "Snippet" }, { "label": "byte", - "kind": "Unit", - "detail": "type", - "sortText": "CR", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", "insertText": "byte", "insertTextFormat": "Snippet" } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/source/remote_action_source8.bal b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/source/remote_action_source8.bal index 80d086ea4c1a..9df4db36dff6 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/source/remote_action_source8.bal +++ b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/source/remote_action_source8.bal @@ -1,3 +1,5 @@ +import ballerina/module1; + public type Product record { string id?; string name; @@ -32,7 +34,9 @@ client class ProductClient { } } -public function main() returns error? { +public function getData(string firstName, string lastName, int page, int pageSize) returns error? { + module1:Client modClient = new("http://example2.com"); + string name = firstName.concat(lastName); ProductClient prodClient = check new("http://example,com"); - string v = pr->listAll(); + int count = pr->countByName(name); } From 801742201a8db44db588396bc1358fd26cacf0f8 Mon Sep 17 00:00:00 2001 From: Imesha Sudasingha Date: Fri, 16 Dec 2022 17:12:31 +0530 Subject: [PATCH 439/450] Fix sorting in expr of client resource access actions --- ...ClientResourceAccessActionNodeContext.java | 40 +- .../langserver/completion/CompletionTest.java | 1 + ...lient_resource_access_action_config20.json | 723 ++++++++++++++++++ ...client_resource_access_action_source20.bal | 45 ++ 4 files changed, 808 insertions(+), 1 deletion(-) create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_resource_access_action_config20.json create mode 100644 language-server/modules/langserver-core/src/test/resources/completion/action_node_context/source/client_resource_access_action_source20.bal diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ClientResourceAccessActionNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ClientResourceAccessActionNodeContext.java index 59c0b09bf6f6..d4bcb41938c8 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ClientResourceAccessActionNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ClientResourceAccessActionNodeContext.java @@ -25,6 +25,7 @@ import io.ballerina.compiler.api.symbols.ResourceMethodSymbol; import io.ballerina.compiler.api.symbols.Symbol; import io.ballerina.compiler.api.symbols.SymbolKind; +import io.ballerina.compiler.api.symbols.TypeDescKind; import io.ballerina.compiler.api.symbols.TypeSymbol; import io.ballerina.compiler.api.symbols.resourcepath.PathRestParam; import io.ballerina.compiler.api.symbols.resourcepath.PathSegmentList; @@ -37,6 +38,7 @@ import io.ballerina.compiler.syntax.tree.Node; import io.ballerina.compiler.syntax.tree.ParenthesizedArgList; import io.ballerina.compiler.syntax.tree.QualifiedNameReferenceNode; +import io.ballerina.compiler.syntax.tree.RemoteMethodCallActionNode; import io.ballerina.compiler.syntax.tree.SyntaxKind; import org.apache.commons.lang3.tuple.Pair; import org.ballerinalang.annotation.JavaSPIService; @@ -49,6 +51,7 @@ import org.ballerinalang.langserver.completions.builder.ResourcePathCompletionUtil; import org.ballerinalang.langserver.completions.util.ContextTypeResolver; import org.ballerinalang.langserver.completions.util.QNameRefCompletionUtil; +import org.ballerinalang.langserver.completions.util.SortingUtil; import org.eclipse.lsp4j.CompletionItem; import java.util.ArrayList; @@ -75,9 +78,16 @@ public List getCompletions(BallerinaCompletionContext context, ClientResourceAccessActionNode node) throws LSCompletionException { List completionItems = new ArrayList<>(); + if (onSuggestClients(node, context)) { + // Covers following: + // 1. cl->/path1/path2 + completionItems.addAll(this.expressionCompletions(context)); + this.sort(context, node, completionItems); + return completionItems; + } + ContextTypeResolver resolver = new ContextTypeResolver(context); Optional expressionType = node.expression().apply(resolver); - if (expressionType.isEmpty() || !SymbolUtil.isClient(expressionType.get())) { return Collections.emptyList(); } @@ -133,6 +143,29 @@ public List getCompletions(BallerinaCompletionContext context, return completionItems; } + @Override + public void sort(BallerinaCompletionContext context, ClientResourceAccessActionNode node, + List completionItems) { + // At expression of the remote method call action, suggest clients first + if (onSuggestClients(node, context)) { + completionItems.forEach(completionItem -> { + Optional typeSymbol = SortingUtil.getSymbolFromCompletionItem(completionItem); + String sortText; + // Prioritize clients + if (typeSymbol.isPresent() && SymbolUtil.isClient(typeSymbol.get())) { + sortText = SortingUtil.genSortText(1); + } else { + sortText = SortingUtil.genSortText(2); + } + sortText += SortingUtil.genSortText(SortingUtil.toRank(context, completionItem)); + completionItem.getCompletionItem().setSortText(sortText); + }); + return; + } + + super.sort(context, node, completionItems); + } + private List getPathSegmentCompletionItems(ClientResourceAccessActionNode node, BallerinaCompletionContext context, List resourceMethods, @@ -264,6 +297,11 @@ private Pair, Boolean> completableSegmentList(ResourceMethodSy return Pair.of(completableSegments, true); } + private boolean onSuggestClients(ClientResourceAccessActionNode node, BallerinaCompletionContext context) { + int cursor = context.getCursorPositionInTree(); + return cursor <= node.rightArrowToken().textRange().startOffset(); + } + private boolean isInResourceMethodParameterContext(ClientResourceAccessActionNode node, BallerinaCompletionContext context) { Optional arguments = node.arguments(); diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/completion/CompletionTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/completion/CompletionTest.java index 4eeb8335fb9d..1b383e4bc22b 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/completion/CompletionTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/completion/CompletionTest.java @@ -150,6 +150,7 @@ private void updateConfig(Path configJsonPath, TestConfig testConfig, List results = new ArrayList<>(); List copyOfResultList = new ArrayList<>(responseItemList); diff --git a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_resource_access_action_config20.json b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_resource_access_action_config20.json new file mode 100644 index 000000000000..63560c5c290f --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_resource_access_action_config20.json @@ -0,0 +1,723 @@ +{ + "position": { + "line": 39, + "character": 24 + }, + "source": "action_node_context/source/client_resource_access_action_source20.bal", + "description": "Test completions at expression of a completed client resource access action", + "items": [ + { + "label": "test/project2", + "kind": "Module", + "detail": "Module", + "sortText": "BR", + "filterText": "project2", + "insertText": "project2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/project2;\n" + } + ] + }, + { + "label": "test/project1", + "kind": "Module", + "detail": "Module", + "sortText": "BR", + "filterText": "project1", + "insertText": "project1", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/project1;\n" + } + ] + }, + { + "label": "ballerina/lang.runtime", + "kind": "Module", + "detail": "Module", + "sortText": "BR", + "filterText": "runtime", + "insertText": "runtime", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.runtime;\n" + } + ] + }, + { + "label": "ballerina/lang.regexp", + "kind": "Module", + "detail": "Module", + "sortText": "BR", + "filterText": "regexp", + "insertText": "regexp", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.regexp;\n" + } + ] + }, + { + "label": "ballerina/module1", + "kind": "Module", + "detail": "Module", + "sortText": "BR", + "filterText": "module1", + "insertText": "module1", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/module1;\n" + } + ] + }, + { + "label": "ballerina/lang.test", + "kind": "Module", + "detail": "Module", + "sortText": "BR", + "filterText": "test", + "insertText": "test", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.test;\n" + } + ] + }, + { + "label": "test/local_project2", + "kind": "Module", + "detail": "Module", + "sortText": "BR", + "filterText": "local_project2", + "insertText": "local_project2", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/local_project2;\n" + } + ] + }, + { + "label": "test/local_project1", + "kind": "Module", + "detail": "Module", + "sortText": "BR", + "filterText": "local_project1", + "insertText": "local_project1", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import test/local_project1;\n" + } + ] + }, + { + "label": "ballerina/lang.value", + "kind": "Module", + "detail": "Module", + "sortText": "BR", + "filterText": "value", + "insertText": "value", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.value;\n" + } + ] + }, + { + "label": "ballerina/jballerina.java", + "kind": "Module", + "detail": "Module", + "sortText": "BR", + "filterText": "java", + "insertText": "java", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/jballerina.java;\n" + } + ] + }, + { + "label": "ballerina/lang.array", + "kind": "Module", + "detail": "Module", + "sortText": "BR", + "filterText": "array", + "insertText": "array", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "newText": "import ballerina/lang.array;\n" + } + ] + }, + { + "label": "decimal", + "kind": "TypeParameter", + "detail": "Decimal", + "sortText": "BN", + "insertText": "decimal", + "insertTextFormat": "Snippet" + }, + { + "label": "error", + "kind": "Event", + "detail": "Error", + "sortText": "BL", + "insertText": "error", + "insertTextFormat": "Snippet" + }, + { + "label": "object", + "kind": "Unit", + "detail": "type", + "sortText": "BR", + "insertText": "object", + "insertTextFormat": "Snippet" + }, + { + "label": "transaction", + "kind": "Unit", + "detail": "type", + "sortText": "BR", + "insertText": "transaction", + "insertTextFormat": "Snippet" + }, + { + "label": "xml", + "kind": "TypeParameter", + "detail": "Xml", + "sortText": "BN", + "insertText": "xml", + "insertTextFormat": "Snippet" + }, + { + "label": "table", + "kind": "Unit", + "detail": "type", + "sortText": "BR", + "insertText": "table", + "insertTextFormat": "Snippet" + }, + { + "label": "map", + "kind": "Unit", + "detail": "type", + "sortText": "BR", + "insertText": "map", + "insertTextFormat": "Snippet" + }, + { + "label": "stream", + "kind": "Unit", + "detail": "type", + "sortText": "BR", + "insertText": "stream", + "insertTextFormat": "Snippet" + }, + { + "label": "boolean", + "kind": "TypeParameter", + "detail": "Boolean", + "sortText": "BN", + "insertText": "boolean", + "insertTextFormat": "Snippet" + }, + { + "label": "future", + "kind": "TypeParameter", + "detail": "Future", + "sortText": "BN", + "insertText": "future", + "insertTextFormat": "Snippet" + }, + { + "label": "int", + "kind": "TypeParameter", + "detail": "Int", + "sortText": "BN", + "insertText": "int", + "insertTextFormat": "Snippet" + }, + { + "label": "float", + "kind": "TypeParameter", + "detail": "Float", + "sortText": "BN", + "insertText": "float", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "TypeParameter", + "detail": "Function", + "sortText": "BN", + "insertText": "function", + "insertTextFormat": "Snippet" + }, + { + "label": "string", + "kind": "TypeParameter", + "detail": "String", + "sortText": "BN", + "insertText": "string", + "insertTextFormat": "Snippet" + }, + { + "label": "typedesc", + "kind": "TypeParameter", + "detail": "Typedesc", + "sortText": "BN", + "insertText": "typedesc", + "insertTextFormat": "Snippet" + }, + { + "label": "service", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "BQ", + "filterText": "service", + "insertText": "service", + "insertTextFormat": "Snippet" + }, + { + "label": "new", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "BQ", + "filterText": "new", + "insertText": "new ", + "insertTextFormat": "Snippet" + }, + { + "label": "isolated", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "BQ", + "filterText": "isolated", + "insertText": "isolated ", + "insertTextFormat": "Snippet" + }, + { + "label": "transactional", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "BQ", + "filterText": "transactional", + "insertText": "transactional", + "insertTextFormat": "Snippet" + }, + { + "label": "function", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "BQ", + "filterText": "function", + "insertText": "function ", + "insertTextFormat": "Snippet" + }, + { + "label": "let", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "BQ", + "filterText": "let", + "insertText": "let", + "insertTextFormat": "Snippet" + }, + { + "label": "typeof", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "BQ", + "filterText": "typeof", + "insertText": "typeof ", + "insertTextFormat": "Snippet" + }, + { + "label": "trap", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "BQ", + "filterText": "trap", + "insertText": "trap", + "insertTextFormat": "Snippet" + }, + { + "label": "client", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "BQ", + "filterText": "client", + "insertText": "client ", + "insertTextFormat": "Snippet" + }, + { + "label": "true", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "BQ", + "filterText": "true", + "insertText": "true", + "insertTextFormat": "Snippet" + }, + { + "label": "false", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "BQ", + "filterText": "false", + "insertText": "false", + "insertTextFormat": "Snippet" + }, + { + "label": "null", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "BQ", + "filterText": "null", + "insertText": "null", + "insertTextFormat": "Snippet" + }, + { + "label": "check", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "BQ", + "filterText": "check", + "insertText": "check ", + "insertTextFormat": "Snippet" + }, + { + "label": "checkpanic", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "BQ", + "filterText": "checkpanic", + "insertText": "checkpanic ", + "insertTextFormat": "Snippet" + }, + { + "label": "is", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "BQ", + "filterText": "is", + "insertText": "is", + "insertTextFormat": "Snippet" + }, + { + "label": "error constructor", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "BP", + "filterText": "error", + "insertText": "error(\"${1}\")", + "insertTextFormat": "Snippet" + }, + { + "label": "object constructor", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "BP", + "filterText": "object", + "insertText": "object {${1}}", + "insertTextFormat": "Snippet" + }, + { + "label": "base16", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "BP", + "filterText": "base16", + "insertText": "base16 `${1}`", + "insertTextFormat": "Snippet" + }, + { + "label": "base64", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "BP", + "filterText": "base64", + "insertText": "base64 `${1}`", + "insertTextFormat": "Snippet" + }, + { + "label": "from", + "kind": "Keyword", + "detail": "Keyword", + "sortText": "BQ", + "filterText": "from", + "insertText": "from ", + "insertTextFormat": "Snippet" + }, + { + "label": "testClient(string param1, int count)", + "kind": "Function", + "detail": "error?", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _._ \n \n \n**Params** \n- `string` param1 \n- `int` count \n \n**Return** `error?` \n \n" + } + }, + "sortText": "BC", + "filterText": "testClient", + "insertText": "testClient(${1})", + "insertTextFormat": "Snippet", + "command": { + "title": "editor.action.triggerParameterHints", + "command": "editor.action.triggerParameterHints" + } + }, + { + "label": "param1", + "kind": "Variable", + "detail": "string", + "sortText": "BB", + "insertText": "param1", + "insertTextFormat": "Snippet" + }, + { + "label": "response", + "kind": "Variable", + "detail": "string", + "sortText": "BB", + "insertText": "response", + "insertTextFormat": "Snippet" + }, + { + "label": "count", + "kind": "Variable", + "detail": "int", + "sortText": "BB", + "insertText": "count", + "insertTextFormat": "Snippet" + }, + { + "label": "Thread", + "kind": "TypeParameter", + "detail": "Union", + "sortText": "BN", + "insertText": "Thread", + "insertTextFormat": "Snippet" + }, + { + "label": "StrandData", + "kind": "Struct", + "detail": "Record", + "documentation": { + "left": "Describes Strand execution details for the runtime.\n" + }, + "sortText": "BM", + "insertText": "StrandData", + "insertTextFormat": "Snippet" + }, + { + "label": "MyClient", + "kind": "Interface", + "detail": "Class", + "sortText": "AK", + "insertText": "MyClient", + "insertTextFormat": "Snippet" + }, + { + "label": "myClient", + "kind": "Variable", + "detail": "MyClient", + "sortText": "AB", + "insertText": "myClient", + "insertTextFormat": "Snippet" + }, + { + "label": "readonly", + "kind": "TypeParameter", + "detail": "Readonly", + "sortText": "BN", + "insertText": "readonly", + "insertTextFormat": "Snippet" + }, + { + "label": "handle", + "kind": "TypeParameter", + "detail": "Handle", + "sortText": "BN", + "insertText": "handle", + "insertTextFormat": "Snippet" + }, + { + "label": "never", + "kind": "TypeParameter", + "detail": "Never", + "sortText": "BN", + "insertText": "never", + "insertTextFormat": "Snippet" + }, + { + "label": "json", + "kind": "TypeParameter", + "detail": "Json", + "sortText": "BN", + "insertText": "json", + "insertTextFormat": "Snippet" + }, + { + "label": "anydata", + "kind": "TypeParameter", + "detail": "Anydata", + "sortText": "BN", + "insertText": "anydata", + "insertTextFormat": "Snippet" + }, + { + "label": "any", + "kind": "TypeParameter", + "detail": "Any", + "sortText": "BN", + "insertText": "any", + "insertTextFormat": "Snippet" + }, + { + "label": "byte", + "kind": "TypeParameter", + "detail": "Byte", + "sortText": "BN", + "insertText": "byte", + "insertTextFormat": "Snippet" + }, + { + "label": "getClient()", + "kind": "Function", + "detail": "MyClient", + "documentation": { + "right": { + "kind": "markdown", + "value": "**Package:** _._ \n \n \n \n \n**Return** `MyClient` \n \n" + } + }, + "sortText": "AC", + "filterText": "getClient", + "insertText": "getClient()", + "insertTextFormat": "Snippet" + } + ] +} diff --git a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/source/client_resource_access_action_source20.bal b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/source/client_resource_access_action_source20.bal new file mode 100644 index 000000000000..e302ea96180f --- /dev/null +++ b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/source/client_resource_access_action_source20.bal @@ -0,0 +1,45 @@ +client class MyClient { + + resource function get user/[int id]() returns json { + return {}; + } + + resource function post user/[int id](string referrer) { + + } + + resource function get user/[int id]/[string... params]() { + } + + resource function post user/[int id]/[string... params]() { + } + + resource function get [string... params](string id) returns string { + return ""; + } + + resource function post [string... params]() { + + } + + resource function post user/[string... params](string id, string age, string name) { + + } + + resource function put [string... params]() { + + } + + resource function patch [int... params]() { + + } +} + +public function testClient(string param1, int count) returns error? { + MyClient myClient = new (); + string response = my->/user/[1]/path1/path2/["path3"]; +} + +function getClient() returns MyClient { + return new MyClient(); +} \ No newline at end of file From 3348f3ff0702734b8839e3104ce321cfabf9b11d Mon Sep 17 00:00:00 2001 From: Imesha Sudasingha Date: Tue, 20 Dec 2022 10:28:10 +0530 Subject: [PATCH 440/450] Fix checkstyle failure --- .../context/ClientResourceAccessActionNodeContext.java | 2 -- .../source/client_resource_access_action_source20.bal | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ClientResourceAccessActionNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ClientResourceAccessActionNodeContext.java index d4bcb41938c8..e1189415d6b7 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ClientResourceAccessActionNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ClientResourceAccessActionNodeContext.java @@ -25,7 +25,6 @@ import io.ballerina.compiler.api.symbols.ResourceMethodSymbol; import io.ballerina.compiler.api.symbols.Symbol; import io.ballerina.compiler.api.symbols.SymbolKind; -import io.ballerina.compiler.api.symbols.TypeDescKind; import io.ballerina.compiler.api.symbols.TypeSymbol; import io.ballerina.compiler.api.symbols.resourcepath.PathRestParam; import io.ballerina.compiler.api.symbols.resourcepath.PathSegmentList; @@ -38,7 +37,6 @@ import io.ballerina.compiler.syntax.tree.Node; import io.ballerina.compiler.syntax.tree.ParenthesizedArgList; import io.ballerina.compiler.syntax.tree.QualifiedNameReferenceNode; -import io.ballerina.compiler.syntax.tree.RemoteMethodCallActionNode; import io.ballerina.compiler.syntax.tree.SyntaxKind; import org.apache.commons.lang3.tuple.Pair; import org.ballerinalang.annotation.JavaSPIService; diff --git a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/source/client_resource_access_action_source20.bal b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/source/client_resource_access_action_source20.bal index e302ea96180f..97e2afca25d6 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/source/client_resource_access_action_source20.bal +++ b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/source/client_resource_access_action_source20.bal @@ -42,4 +42,4 @@ public function testClient(string param1, int count) returns error? { function getClient() returns MyClient { return new MyClient(); -} \ No newline at end of file +} From f952af60ea7a9db44dbb1433277a0e35e8d1db7f Mon Sep 17 00:00:00 2001 From: Imesha Sudasingha Date: Wed, 4 Jan 2023 14:54:47 +0530 Subject: [PATCH 441/450] Fix failing action node context tests --- .../config/client_resource_access_action_config20.json | 9 +++++++++ .../config/remote_action_config8.json | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_resource_access_action_config20.json b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_resource_access_action_config20.json index 63560c5c290f..429ba44c7a8a 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_resource_access_action_config20.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/client_resource_access_action_config20.json @@ -718,6 +718,15 @@ "filterText": "getClient", "insertText": "getClient()", "insertTextFormat": "Snippet" + }, + { + "label": "re ``", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "BP", + "filterText": "re ``", + "insertText": "re `${1}`", + "insertTextFormat": "Snippet" } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/remote_action_config8.json b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/remote_action_config8.json index 790fb5df3f51..90ebf7b929c5 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/remote_action_config8.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/action_node_context/config/remote_action_config8.json @@ -727,6 +727,15 @@ "sortText": "BN", "insertText": "byte", "insertTextFormat": "Snippet" + }, + { + "label": "re ``", + "kind": "Snippet", + "detail": "Snippet", + "sortText": "BP", + "filterText": "re ``", + "insertText": "re `${1}`", + "insertTextFormat": "Snippet" } ] } From fbf169a707d1c433d4994910029435440ebd4fd5 Mon Sep 17 00:00:00 2001 From: sanjana Date: Wed, 4 Jan 2023 23:56:34 +0530 Subject: [PATCH 442/450] Modify xml langlib examples --- langlib/lang.xml/src/main/ballerina/xml.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langlib/lang.xml/src/main/ballerina/xml.bal b/langlib/lang.xml/src/main/ballerina/xml.bal index 96868fad267a..a334a7be4f65 100644 --- a/langlib/lang.xml/src/main/ballerina/xml.bal +++ b/langlib/lang.xml/src/main/ballerina/xml.bal @@ -557,7 +557,7 @@ public isolated function fromString(string s) returns xml|error = @java:Method { # Selects all the items in a sequence that are of type `xml:Text`. # # ```ballerina -# xml books = xml `HamletNovelPlay`; +# xml books = xml `HamletMacbethPlay`; # books.text() ⇒ HamletPlay # ``` # From 1a486737dd1d90aa1850aed0d8cc1aec729e802c Mon Sep 17 00:00:00 2001 From: Sivanandan Anjana Date: Thu, 5 Jan 2023 10:11:42 +0530 Subject: [PATCH 443/450] Update langlib/lang.xml/src/main/ballerina/xml.bal Co-authored-by: Maryam Ziyad --- langlib/lang.xml/src/main/ballerina/xml.bal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/langlib/lang.xml/src/main/ballerina/xml.bal b/langlib/lang.xml/src/main/ballerina/xml.bal index a334a7be4f65..9a3f16b8e941 100644 --- a/langlib/lang.xml/src/main/ballerina/xml.bal +++ b/langlib/lang.xml/src/main/ballerina/xml.bal @@ -557,8 +557,8 @@ public isolated function fromString(string s) returns xml|error = @java:Method { # Selects all the items in a sequence that are of type `xml:Text`. # # ```ballerina -# xml books = xml `HamletMacbethPlay`; -# books.text() ⇒ HamletPlay +# xml details = xml `JohnAlex Doe`; +# details.text() ⇒ John Doe # ``` # # + x - the xml value From bf39c7852d115470ae3546633701e9d970a83df8 Mon Sep 17 00:00:00 2001 From: Sivanandan Anjana Date: Thu, 5 Jan 2023 11:54:18 +0530 Subject: [PATCH 444/450] Update langlib/lang.xml/src/main/ballerina/xml.bal Co-authored-by: Maryam Ziyad --- langlib/lang.xml/src/main/ballerina/xml.bal | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/langlib/lang.xml/src/main/ballerina/xml.bal b/langlib/lang.xml/src/main/ballerina/xml.bal index 9a3f16b8e941..338340cba40b 100644 --- a/langlib/lang.xml/src/main/ballerina/xml.bal +++ b/langlib/lang.xml/src/main/ballerina/xml.bal @@ -208,8 +208,7 @@ public isolated function getChildren(Element elem) returns xml = @java:Method { # # ```ballerina # xml:Element employees = xml `DavidPeter`; -# xml newEmployees = xml `AliceBob`; -# employees.setChildren(newEmployees); +# employees.setChildren(xml `AliceBob`); # employees ⇒ AliceBob # # xml:Element x = xml `John`; From b569d6fd6eb0e328b82594953ca56c1f0fbc9d0d Mon Sep 17 00:00:00 2001 From: Sivanandan Anjana Date: Thu, 5 Jan 2023 11:58:08 +0530 Subject: [PATCH 445/450] Update langlib/lang.xml/src/main/ballerina/xml.bal as per review suggestion Co-authored-by: Maryam Ziyad --- langlib/lang.xml/src/main/ballerina/xml.bal | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/langlib/lang.xml/src/main/ballerina/xml.bal b/langlib/lang.xml/src/main/ballerina/xml.bal index 338340cba40b..f329d1ee54b0 100644 --- a/langlib/lang.xml/src/main/ballerina/xml.bal +++ b/langlib/lang.xml/src/main/ballerina/xml.bal @@ -211,9 +211,9 @@ public isolated function getChildren(Element elem) returns xml = @java:Method { # employees.setChildren(xml `AliceBob`); # employees ⇒ AliceBob # -# xml:Element x = xml `John`; -# x.setChildren("Jane"); -# x ⇒ Jane +# xml:Element student = xml `John`; +# student.setChildren("Jane"); +# student ⇒ Jane # ``` # # + elem - xml element From b45256178712bd9bf29209c619d009a1701dc3a2 Mon Sep 17 00:00:00 2001 From: sanjana Date: Thu, 5 Jan 2023 12:10:23 +0530 Subject: [PATCH 446/450] Reformat xml langlib examples --- langlib/lang.xml/src/main/ballerina/xml.bal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/langlib/lang.xml/src/main/ballerina/xml.bal b/langlib/lang.xml/src/main/ballerina/xml.bal index f329d1ee54b0..15d1f49b1ba7 100644 --- a/langlib/lang.xml/src/main/ballerina/xml.bal +++ b/langlib/lang.xml/src/main/ballerina/xml.bal @@ -176,8 +176,8 @@ public isolated function setName(Element elem, string xName) = @java:Method { # The keys in the map are the expanded names of the attributes. # # ```ballerina -# xml:Element a = xml `John`; -# a.getAttributes() ⇒ {"id":"1012","employed":"yes"} +# xml:Element x = xml `John`; +# x.getAttributes() ⇒ {"id":"1012","employed":"yes"} # ``` # # + x - xml element From 503e179a741f518021380c7714f358de1a1ea5ef Mon Sep 17 00:00:00 2001 From: sanjana Date: Thu, 5 Jan 2023 12:29:41 +0530 Subject: [PATCH 447/450] Reformat code as per review suggestions --- langlib/lang.xml/src/main/ballerina/xml.bal | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/langlib/lang.xml/src/main/ballerina/xml.bal b/langlib/lang.xml/src/main/ballerina/xml.bal index 15d1f49b1ba7..8dbec6c5c190 100644 --- a/langlib/lang.xml/src/main/ballerina/xml.bal +++ b/langlib/lang.xml/src/main/ballerina/xml.bal @@ -144,8 +144,8 @@ public isolated function concat((xml|string)... xs) returns xml = @java:Method { # Returns a string giving the expanded name of an xml element. # # ```ballerina -# xml:Element p = xml `John`; -# p.getName() ⇒ person +# xml:Element e = xml `John`; +# e.getName() ⇒ person # ``` # # + elem - xml element @@ -158,9 +158,9 @@ public isolated function getName(Element elem) returns string = @java:Method { # Changes the name of an XML element. # # ```ballerina -# xml:Element s = xml `John`; -# s.setName("student"); -# s ⇒ John +# xml:Element e = xml `John`; +# e.setName("student"); +# e ⇒ John # ``` # # + elem - xml element @@ -272,8 +272,8 @@ public isolated function data(xml x) returns string = @java:Method { # Returns the target part of the processing instruction. # # ```ballerina -# xml:ProcessingInstruction p = xml ``; -# p.getTarget() ⇒ sort +# xml:ProcessingInstruction x = xml ``; +# x.getTarget() ⇒ sort # ``` # # + x - xml processing instruction item @@ -286,8 +286,8 @@ public isolated function getTarget(ProcessingInstruction x) returns string = @ja # Returns the content of a processing instruction or comment item. # # ```ballerina -# xml:ProcessingInstruction p = xml ``; -# p.getContent() ⇒ ascending +# xml:ProcessingInstruction x = xml ``; +# x.getContent() ⇒ ascending # # xml:Comment comment = xml ``; # comment.getContent() ⇒ Employees by department From 9e3825cfc14eb9a436ff047ae61260fdd92d4fcb Mon Sep 17 00:00:00 2001 From: Sivanandan Anjana Date: Thu, 5 Jan 2023 12:52:37 +0530 Subject: [PATCH 448/450] Update langlib/lang.xml/src/main/ballerina/xml.bal Co-authored-by: Maryam Ziyad --- langlib/lang.xml/src/main/ballerina/xml.bal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/langlib/lang.xml/src/main/ballerina/xml.bal b/langlib/lang.xml/src/main/ballerina/xml.bal index 8dbec6c5c190..b4fb1a7bd23d 100644 --- a/langlib/lang.xml/src/main/ballerina/xml.bal +++ b/langlib/lang.xml/src/main/ballerina/xml.bal @@ -176,8 +176,8 @@ public isolated function setName(Element elem, string xName) = @java:Method { # The keys in the map are the expanded names of the attributes. # # ```ballerina -# xml:Element x = xml `John`; -# x.getAttributes() ⇒ {"id":"1012","employed":"yes"} +# xml:Element e = xml `John`; +# e.getAttributes() ⇒ {"id":"1012","employed":"yes"} # ``` # # + x - xml element From 8aebebcf2d4d399a9fce4f08f8d65e33725738f6 Mon Sep 17 00:00:00 2001 From: Sivanandan Anjana Date: Thu, 5 Jan 2023 12:57:40 +0530 Subject: [PATCH 449/450] Address review suggestion iteration --- langlib/lang.xml/src/main/ballerina/xml.bal | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/langlib/lang.xml/src/main/ballerina/xml.bal b/langlib/lang.xml/src/main/ballerina/xml.bal index b4fb1a7bd23d..179fac359c35 100644 --- a/langlib/lang.xml/src/main/ballerina/xml.bal +++ b/langlib/lang.xml/src/main/ballerina/xml.bal @@ -272,8 +272,8 @@ public isolated function data(xml x) returns string = @java:Method { # Returns the target part of the processing instruction. # # ```ballerina -# xml:ProcessingInstruction x = xml ``; -# x.getTarget() ⇒ sort +# xml:ProcessingInstruction p = xml ``; +# p.getTarget() ⇒ sort # ``` # # + x - xml processing instruction item @@ -286,8 +286,8 @@ public isolated function getTarget(ProcessingInstruction x) returns string = @ja # Returns the content of a processing instruction or comment item. # # ```ballerina -# xml:ProcessingInstruction x = xml ``; -# x.getContent() ⇒ ascending +# xml:ProcessingInstruction p = xml ``; +# p.getContent() ⇒ ascending # # xml:Comment comment = xml ``; # comment.getContent() ⇒ Employees by department From ecca94231c1ac6fec461a8b51fe43092aa5ca3ee Mon Sep 17 00:00:00 2001 From: sanjana Date: Thu, 5 Jan 2023 14:28:43 +0530 Subject: [PATCH 450/450] Update xml langlib example var names --- langlib/lang.xml/src/main/ballerina/xml.bal | 60 ++++++++++----------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/langlib/lang.xml/src/main/ballerina/xml.bal b/langlib/lang.xml/src/main/ballerina/xml.bal index 179fac359c35..b898e86fa967 100644 --- a/langlib/lang.xml/src/main/ballerina/xml.bal +++ b/langlib/lang.xml/src/main/ballerina/xml.bal @@ -102,10 +102,10 @@ public isolated function iterator(xml x) returns object { # parameter `x` does not have an item with index parameter `i`. # # ```ballerina -# xml books = xml `MacbethHamlet`; -# books.get(1) ⇒ Hamlet +# xml x = xml `MacbethHamlet`; +# x.get(1) ⇒ Hamlet # -# books.get(15) ⇒ panic +# x.get(15) ⇒ panic # ``` # # + x - the xml sequence @@ -190,8 +190,8 @@ public isolated function getAttributes(Element x) returns map = @java:Me # Returns the children of an xml element. # # ```ballerina -# xml:Element books = xml `HamletMacbeth`; -# books.getChildren() ⇒ HamletMacbeth +# xml:Element e = xml `HamletMacbeth`; +# e.getChildren() ⇒ HamletMacbeth # ``` # # + elem - xml element @@ -234,8 +234,8 @@ public isolated function setChildren(Element elem, xml|string children) = @java: # of the item would occur in the representation of the element in XML syntax. # # ```ballerina -# xml:Element person = xml `John Doe30`; -# person.getDescendants() ⇒ John DoeJohn Doe3030 +# xml:Element e = xml `John Doe30`; +# e.getDescendants() ⇒ John DoeJohn Doe3030 # ``` # # + elem - xml element @@ -258,8 +258,8 @@ public isolated function getDescendants(Element elem) returns xml = @java:Method # concatenation of the character data of x1 and the character data of x2. # # ```ballerina -# xml book = xml `Jane Eyre`; -# book.data() ⇒ Jane Eyre +# xml x = xml `Jane Eyre`; +# x.data() ⇒ Jane Eyre # ``` # # + x - the xml value @@ -286,8 +286,8 @@ public isolated function getTarget(ProcessingInstruction x) returns string = @ja # Returns the content of a processing instruction or comment item. # # ```ballerina -# xml:ProcessingInstruction p = xml ``; -# p.getContent() ⇒ ascending +# xml:ProcessingInstruction procInstruction = xml ``; +# procInstruction.getContent() ⇒ ascending # # xml:Comment comment = xml ``; # comment.getContent() ⇒ Employees by department @@ -377,10 +377,10 @@ public isolated function createText(string data) returns Text = @java:Method { # Returns a subsequence of an xml value. # # ```ballerina -# xml books = xml `HTMLInvisible ManDavid CopperfieldJane Eyre`; -# books.slice(2) ⇒ David CopperfieldJane Eyre +# xml x = xml `HTMLInvisible ManDavid CopperfieldJane Eyre`; +# x.slice(2) ⇒ David CopperfieldJane Eyre # -# books.slice(1, 3) ⇒ Invisible ManDavid Copperfield +# x.slice(1, 3) ⇒ Invisible ManDavid Copperfield # ``` # # + x - the xml value @@ -401,9 +401,9 @@ public isolated function slice(xml x, int startIndex, int endIndex = x # and a chunk is considered insignificant if the entire chunk is whitespace. # # ```ballerina -# xml books = xml ` +# xml x = xml ` # Othello`; -# books.strip() ⇒ Othello +# x.strip() ⇒ Othello # ``` # # + x - the xml value @@ -419,11 +419,11 @@ public isolated function strip(xml x) returns xml = @java:Method { # otherwise, selects only elements whose expanded name is parameter `nm`. # # ```ballerina -# xml books = xml `Sherlock HolmesHamlet +# xml x = xml `Sherlock HolmesHamlet # Jane EyreMacbeth`; -# books.elements() ⇒ Sherlock HolmesHamletJane EyreMacbeth +# x.elements() ⇒ Sherlock HolmesHamletJane EyreMacbeth # -# books.elements("novel") ⇒ Sherlock HolmesJane Eyre +# x.elements("novel") ⇒ Sherlock HolmesJane Eyre # ``` # # + x - the xml value @@ -441,8 +441,8 @@ public isolated function elements(xml x, string? nm = ()) returns xml = # This is equivalent to `elements(x).map(getChildren)`. # # ```ballerina -# xml books = xml `HamletMacbeth`; -# books.children() ⇒ HamletMacbeth +# xml x = xml `HamletMacbeth`; +# x.children() ⇒ HamletMacbeth # ``` # # + x - xml value @@ -457,10 +457,10 @@ public isolated function children(xml x) returns xml = @java:Method { # This is equivalent to `children(x).elements(nm)`. # # ```ballerina -# xml books = xml `HamletMacbeth`; -# books.elementChildren() ⇒ HamletMacbeth +# xml x = xml `HamletMacbeth`; +# x.elementChildren() ⇒ HamletMacbeth # -# books.elementChildren("novel") ⇒ Macbeth +# x.elementChildren("novel") ⇒ Macbeth # ``` # # + x - the xml value @@ -480,8 +480,8 @@ public isolated function elementChildren(xml x, string? nm = ()) returns xmlHamletMacbeth`; -# books.map(function (xml xmlContent) returns xml => +# xml x = xml `HamletMacbeth`; +# x.map(function (xml xmlContent) returns xml => # xml `${xmlContent.children()}` # ) ⇒ HamletMacbeth # ``` @@ -522,8 +522,8 @@ public isolated function forEach(xml x, @isolatedParam function(ItemTy # Each item is represented as a singleton value. # # ```ballerina -# xml books = xml `Sherlock HolemesHamletInvisible ManRomeo and Juliet`; -# books.filter(x => x is xml:Element && x.getName() == "play") ⇒ HamletRomeo and Juliet +# xml x = xml `Sherlock HolemesHamletInvisible ManRomeo and Juliet`; +# x.filter(x => x is xml:Element && x.getName() == "play") ⇒ HamletRomeo and Juliet # ``` # # + x - xml value @@ -556,8 +556,8 @@ public isolated function fromString(string s) returns xml|error = @java:Method { # Selects all the items in a sequence that are of type `xml:Text`. # # ```ballerina -# xml details = xml `JohnAlex Doe`; -# details.text() ⇒ John Doe +# xml x = xml `JohnAlex Doe`; +# x.text() ⇒ John Doe # ``` # # + x - the xml value